@perses-dev/plugin-system 0.46.0-rc1 → 0.47.0-rc0

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 (185) hide show
  1. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +70 -99
  2. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +2 -1
  3. package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +1 -1
  4. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +49 -19
  5. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +1 -0
  6. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +10 -71
  7. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +408 -376
  8. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +2 -2
  9. package/dist/cjs/components/Variables/variable-model.js +24 -22
  10. package/dist/cjs/context/ProjectStoreProvider.js +7 -4
  11. package/dist/cjs/context/ValidationProvider.js +69 -0
  12. package/dist/cjs/context/index.js +1 -0
  13. package/dist/cjs/index.js +0 -1
  14. package/dist/cjs/runtime/QueryCountProvider.js +83 -0
  15. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +100 -0
  16. package/dist/cjs/runtime/TimeRangeProvider/index.js +2 -1
  17. package/dist/cjs/runtime/builtin-variables.js +1 -1
  18. package/dist/cjs/runtime/datasources.js +22 -13
  19. package/dist/cjs/runtime/index.js +3 -2
  20. package/dist/cjs/runtime/plugin-registry.js +33 -22
  21. package/dist/cjs/runtime/time-series-queries.js +3 -3
  22. package/dist/cjs/runtime/trace-queries.js +5 -1
  23. package/dist/cjs/runtime/{template-variables.js → variables.js} +19 -19
  24. package/dist/cjs/stories/shared-utils/decorators/{WithPluginSystemTemplateVariables.js → WithPluginSystemVariables.js} +8 -8
  25. package/dist/cjs/stories/shared-utils/decorators/index.js +2 -2
  26. package/dist/cjs/test/mock-data.js +25 -4
  27. package/dist/cjs/test/render.js +1 -9
  28. package/dist/cjs/test/test-plugins/bert/index.js +20 -19
  29. package/dist/cjs/utils/variables.js +23 -23
  30. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +2 -2
  31. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  32. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +71 -100
  33. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  34. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -3
  35. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  36. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +1 -1
  37. package/dist/components/MultiQueryEditor/MultiQueryEditor.js +1 -1
  38. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
  39. package/dist/components/MultiQueryEditor/QueryEditorContainer.js +1 -1
  40. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
  41. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +3 -1
  42. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  43. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +50 -20
  44. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  45. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
  46. package/dist/components/PluginKindSelect/PluginKindSelect.js +1 -0
  47. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  48. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +2 -2
  49. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  50. package/dist/components/TimeRangeControls/TimeRangeControls.js +12 -70
  51. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  52. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  53. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +411 -379
  54. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  55. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +2 -2
  56. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  57. package/dist/components/Variables/variable-model.d.ts.map +1 -1
  58. package/dist/components/Variables/variable-model.js +25 -23
  59. package/dist/components/Variables/variable-model.js.map +1 -1
  60. package/dist/context/ProjectStoreProvider.d.ts.map +1 -1
  61. package/dist/context/ProjectStoreProvider.js +7 -4
  62. package/dist/context/ProjectStoreProvider.js.map +1 -1
  63. package/dist/context/ValidationProvider.d.ts +19 -0
  64. package/dist/context/ValidationProvider.d.ts.map +1 -0
  65. package/dist/context/ValidationProvider.js +52 -0
  66. package/dist/context/ValidationProvider.js.map +1 -0
  67. package/dist/context/index.d.ts +1 -0
  68. package/dist/context/index.d.ts.map +1 -1
  69. package/dist/context/index.js +1 -0
  70. package/dist/context/index.js.map +1 -1
  71. package/dist/index.d.ts +0 -1
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +0 -1
  74. package/dist/index.js.map +1 -1
  75. package/dist/runtime/DataQueriesProvider/model.d.ts +1 -1
  76. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  77. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  78. package/dist/runtime/QueryCountProvider.d.ts +9 -0
  79. package/dist/runtime/QueryCountProvider.d.ts.map +1 -0
  80. package/dist/{validation/duration.js → runtime/QueryCountProvider.js} +13 -4
  81. package/dist/runtime/QueryCountProvider.js.map +1 -0
  82. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts +32 -0
  83. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts.map +1 -0
  84. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +82 -0
  85. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -0
  86. package/dist/runtime/TimeRangeProvider/index.d.ts +1 -0
  87. package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -1
  88. package/dist/runtime/TimeRangeProvider/index.js +2 -1
  89. package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
  90. package/dist/runtime/builtin-variables.d.ts +1 -1
  91. package/dist/runtime/builtin-variables.d.ts.map +1 -1
  92. package/dist/runtime/builtin-variables.js +1 -1
  93. package/dist/runtime/builtin-variables.js.map +1 -1
  94. package/dist/runtime/datasources.d.ts.map +1 -1
  95. package/dist/runtime/datasources.js +22 -13
  96. package/dist/runtime/datasources.js.map +1 -1
  97. package/dist/runtime/index.d.ts +2 -1
  98. package/dist/runtime/index.d.ts.map +1 -1
  99. package/dist/runtime/index.js +3 -2
  100. package/dist/runtime/index.js.map +1 -1
  101. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  102. package/dist/runtime/plugin-registry.js +33 -22
  103. package/dist/runtime/plugin-registry.js.map +1 -1
  104. package/dist/runtime/time-series-queries.d.ts +2 -2
  105. package/dist/runtime/time-series-queries.d.ts.map +1 -1
  106. package/dist/runtime/time-series-queries.js +3 -3
  107. package/dist/runtime/time-series-queries.js.map +1 -1
  108. package/dist/runtime/trace-queries.d.ts.map +1 -1
  109. package/dist/runtime/trace-queries.js +5 -1
  110. package/dist/runtime/trace-queries.js.map +1 -1
  111. package/dist/runtime/{template-variables.d.ts → variables.d.ts} +4 -4
  112. package/dist/runtime/variables.d.ts.map +1 -0
  113. package/dist/runtime/{template-variables.js → variables.js} +18 -17
  114. package/dist/runtime/variables.js.map +1 -0
  115. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts +12 -0
  116. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts.map +1 -0
  117. package/dist/stories/shared-utils/decorators/{WithPluginSystemTemplateVariables.js → WithPluginSystemVariables.js} +9 -9
  118. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js.map +1 -0
  119. package/dist/stories/shared-utils/decorators/index.d.ts +1 -1
  120. package/dist/stories/shared-utils/decorators/index.d.ts.map +1 -1
  121. package/dist/stories/shared-utils/decorators/index.js +2 -2
  122. package/dist/stories/shared-utils/decorators/index.js.map +1 -1
  123. package/dist/test/mock-data.d.ts.map +1 -1
  124. package/dist/test/mock-data.js +25 -4
  125. package/dist/test/mock-data.js.map +1 -1
  126. package/dist/test/render.d.ts.map +1 -1
  127. package/dist/test/render.js +1 -9
  128. package/dist/test/render.js.map +1 -1
  129. package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
  130. package/dist/test/test-plugins/bert/index.js +20 -19
  131. package/dist/test/test-plugins/bert/index.js.map +1 -1
  132. package/dist/utils/variables.d.ts +4 -4
  133. package/dist/utils/variables.d.ts.map +1 -1
  134. package/dist/utils/variables.js +18 -18
  135. package/dist/utils/variables.js.map +1 -1
  136. package/package.json +5 -5
  137. package/dist/cjs/validation/datasource.js +0 -30
  138. package/dist/cjs/validation/duration.js +0 -25
  139. package/dist/cjs/validation/index.js +0 -34
  140. package/dist/cjs/validation/resource.js +0 -24
  141. package/dist/cjs/validation/role.js +0 -86
  142. package/dist/cjs/validation/rolebinding.js +0 -55
  143. package/dist/cjs/validation/secret.js +0 -176
  144. package/dist/cjs/validation/user.js +0 -46
  145. package/dist/cjs/validation/variable.js +0 -48
  146. package/dist/runtime/template-variables.d.ts.map +0 -1
  147. package/dist/runtime/template-variables.js.map +0 -1
  148. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts +0 -12
  149. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts.map +0 -1
  150. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +0 -1
  151. package/dist/validation/datasource.d.ts +0 -19
  152. package/dist/validation/datasource.d.ts.map +0 -1
  153. package/dist/validation/datasource.js +0 -22
  154. package/dist/validation/datasource.js.map +0 -1
  155. package/dist/validation/duration.d.ts +0 -3
  156. package/dist/validation/duration.d.ts.map +0 -1
  157. package/dist/validation/duration.js.map +0 -1
  158. package/dist/validation/index.d.ts +0 -6
  159. package/dist/validation/index.d.ts.map +0 -1
  160. package/dist/validation/index.js +0 -19
  161. package/dist/validation/index.js.map +0 -1
  162. package/dist/validation/resource.d.ts +0 -3
  163. package/dist/validation/resource.d.ts.map +0 -1
  164. package/dist/validation/resource.js +0 -16
  165. package/dist/validation/resource.js.map +0 -1
  166. package/dist/validation/role.d.ts +0 -228
  167. package/dist/validation/role.d.ts.map +0 -1
  168. package/dist/validation/role.js +0 -67
  169. package/dist/validation/role.js.map +0 -1
  170. package/dist/validation/rolebinding.d.ts +0 -137
  171. package/dist/validation/rolebinding.d.ts.map +0 -1
  172. package/dist/validation/rolebinding.js +0 -47
  173. package/dist/validation/rolebinding.js.map +0 -1
  174. package/dist/validation/secret.d.ts +0 -964
  175. package/dist/validation/secret.d.ts.map +0 -1
  176. package/dist/validation/secret.js +0 -157
  177. package/dist/validation/secret.js.map +0 -1
  178. package/dist/validation/user.d.ts +0 -93
  179. package/dist/validation/user.d.ts.map +0 -1
  180. package/dist/validation/user.js +0 -38
  181. package/dist/validation/user.js.map +0 -1
  182. package/dist/validation/variable.d.ts +0 -96
  183. package/dist/validation/variable.d.ts.map +0 -1
  184. package/dist/validation/variable.js +0 -40
  185. package/dist/validation/variable.js.map +0 -1
@@ -11,72 +11,416 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
- import React, { useCallback, useMemo, useState } from 'react';
14
+ import React, { useState } from 'react';
15
15
  import { Box, Typography, Switch, TextField, Grid, FormControlLabel, MenuItem, Button, Stack, ClickAwayListener, Divider } from '@mui/material';
16
- import { DiscardChangesConfirmationDialog, ErrorBoundary } from '@perses-dev/components';
17
- import { Controller, FormProvider, useForm } from 'react-hook-form';
16
+ import { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary } from '@perses-dev/components';
17
+ import { Controller, FormProvider, useForm, useFormContext, useWatch } from 'react-hook-form';
18
18
  import { zodResolver } from '@hookform/resolvers/zod';
19
- import { useImmer } from 'use-immer';
20
19
  import { getSubmitText, getTitleAction } from '../../../utils';
21
20
  import { VARIABLE_TYPES } from '../variable-model';
22
21
  import { PluginEditor } from '../../PluginEditor';
23
- import { variableEditorValidationSchema } from '../../../validation';
22
+ import { useValidationSchemas } from '../../../context';
24
23
  import { VariableListPreview, VariablePreview } from './VariablePreview';
25
- import { getVariableDefinitionFromState, getInitialState } from './variable-editor-form-model';
26
24
  function FallbackPreview() {
27
25
  return /*#__PURE__*/ _jsx("div", {
28
26
  children: "Error previewing values"
29
27
  });
30
28
  }
29
+ function TextVariableEditorForm({ action, control }) {
30
+ return /*#__PURE__*/ _jsxs(_Fragment, {
31
+ children: [
32
+ /*#__PURE__*/ _jsx(Typography, {
33
+ py: 1,
34
+ variant: "subtitle1",
35
+ children: "Text Options"
36
+ }),
37
+ /*#__PURE__*/ _jsxs(Stack, {
38
+ spacing: 2,
39
+ children: [
40
+ /*#__PURE__*/ _jsx(Controller, {
41
+ control: control,
42
+ name: "spec.value",
43
+ render: ({ field, fieldState })=>/*#__PURE__*/ {
44
+ var _fieldState_error;
45
+ var _field_value;
46
+ return _jsxs(_Fragment, {
47
+ children: [
48
+ /*#__PURE__*/ _jsx(Box, {
49
+ children: /*#__PURE__*/ _jsx(VariablePreview, {
50
+ values: [
51
+ field.value
52
+ ]
53
+ })
54
+ }),
55
+ /*#__PURE__*/ _jsx(TextField, {
56
+ ...field,
57
+ label: "Value",
58
+ InputLabelProps: {
59
+ shrink: action === 'read' ? true : undefined
60
+ },
61
+ InputProps: {
62
+ readOnly: action === 'read'
63
+ },
64
+ error: !!fieldState.error,
65
+ helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
66
+ value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
67
+ onChange: (event)=>{
68
+ field.onChange(event);
69
+ }
70
+ })
71
+ ]
72
+ });
73
+ }
74
+ }),
75
+ /*#__PURE__*/ _jsx(Controller, {
76
+ control: control,
77
+ name: "spec.constant",
78
+ render: ({ field })=>/*#__PURE__*/ {
79
+ var _field_value;
80
+ return _jsx(FormControlLabel, {
81
+ label: "Constant",
82
+ control: /*#__PURE__*/ _jsx(Switch, {
83
+ ...field,
84
+ checked: !!field.value,
85
+ readOnly: action === 'read',
86
+ value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : false,
87
+ onChange: (event)=>{
88
+ if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
89
+ field.onChange(event);
90
+ }
91
+ })
92
+ });
93
+ }
94
+ })
95
+ ]
96
+ })
97
+ ]
98
+ });
99
+ }
100
+ function ListVariableEditorForm({ action, control }) {
101
+ const form = useFormContext();
102
+ /** We use `previewSpec` to know when to explicitly update the
103
+ * spec that will be used for preview. The reason why we do this is to avoid
104
+ * having to re-fetch the values when the user is still editing the spec.
105
+ */ const [previewSpec, setPreviewSpec] = useState(form.getValues());
106
+ const refreshPreview = ()=>{
107
+ setPreviewSpec(form.getValues());
108
+ };
109
+ const kind = useWatch({
110
+ control: control,
111
+ name: 'spec.plugin.kind'
112
+ });
113
+ const _allowAllValue = useWatch({
114
+ control: control,
115
+ name: 'spec.allowAllValue'
116
+ });
117
+ // When variable kind is selected we need to provide default values
118
+ // TODO: check if react-hook-form has a better way to do this
119
+ const values = form.getValues();
120
+ if (values.spec.allowAllValue === undefined) {
121
+ form.setValue('spec.allowAllValue', false);
122
+ }
123
+ if (values.spec.allowMultiple === undefined) {
124
+ form.setValue('spec.allowMultiple', false);
125
+ }
126
+ return /*#__PURE__*/ _jsxs(_Fragment, {
127
+ children: [
128
+ /*#__PURE__*/ _jsx(Typography, {
129
+ py: 1,
130
+ variant: "subtitle1",
131
+ children: "List Options"
132
+ }),
133
+ /*#__PURE__*/ _jsxs(Stack, {
134
+ spacing: 2,
135
+ mb: 2,
136
+ children: [
137
+ kind ? /*#__PURE__*/ _jsx(Box, {
138
+ children: /*#__PURE__*/ _jsx(ErrorBoundary, {
139
+ FallbackComponent: FallbackPreview,
140
+ resetKeys: [
141
+ previewSpec
142
+ ],
143
+ children: /*#__PURE__*/ _jsx(VariableListPreview, {
144
+ definition: previewSpec,
145
+ onRefresh: refreshPreview
146
+ })
147
+ })
148
+ }) : /*#__PURE__*/ _jsx(VariablePreview, {
149
+ isLoading: true
150
+ }),
151
+ /*#__PURE__*/ _jsxs(Stack, {
152
+ children: [
153
+ /*#__PURE__*/ _jsx(ClickAwayListener, {
154
+ onClickAway: ()=>refreshPreview(),
155
+ children: /*#__PURE__*/ _jsx(Box, {})
156
+ }),
157
+ /*#__PURE__*/ _jsx(ErrorBoundary, {
158
+ FallbackComponent: ErrorAlert,
159
+ children: /*#__PURE__*/ _jsx(Controller, {
160
+ control: control,
161
+ name: "spec.plugin",
162
+ render: ({ field })=>/*#__PURE__*/ {
163
+ var _field_value, _field_value1;
164
+ var _field_value_kind, _field_value_spec;
165
+ return _jsx(PluginEditor, {
166
+ width: "100%",
167
+ pluginTypes: [
168
+ 'Variable'
169
+ ],
170
+ pluginKindLabel: "Source",
171
+ value: {
172
+ selection: {
173
+ type: 'Variable',
174
+ kind: (_field_value_kind = (_field_value = field.value) === null || _field_value === void 0 ? void 0 : _field_value.kind) !== null && _field_value_kind !== void 0 ? _field_value_kind : 'StaticListVariable'
175
+ },
176
+ spec: (_field_value_spec = (_field_value1 = field.value) === null || _field_value1 === void 0 ? void 0 : _field_value1.spec) !== null && _field_value_spec !== void 0 ? _field_value_spec : {
177
+ values: []
178
+ }
179
+ },
180
+ isReadonly: action === 'read',
181
+ onChange: (v)=>{
182
+ field.onChange({
183
+ kind: v.selection.kind,
184
+ spec: v.spec
185
+ });
186
+ }
187
+ });
188
+ }
189
+ })
190
+ })
191
+ ]
192
+ }),
193
+ /*#__PURE__*/ _jsx(Stack, {
194
+ children: /*#__PURE__*/ _jsx(Controller, {
195
+ control: control,
196
+ name: "spec.capturingRegexp",
197
+ render: ({ field, fieldState })=>/*#__PURE__*/ {
198
+ var _fieldState_error;
199
+ var _field_value;
200
+ return _jsx(TextField, {
201
+ ...field,
202
+ label: "Capturing Regexp Filter",
203
+ InputLabelProps: {
204
+ shrink: action === 'read' ? true : undefined
205
+ },
206
+ InputProps: {
207
+ readOnly: action === 'read'
208
+ },
209
+ error: !!fieldState.error,
210
+ value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
211
+ onChange: (event)=>{
212
+ if (event.target.value === '') {
213
+ field.onChange(undefined);
214
+ } else {
215
+ field.onChange(event);
216
+ }
217
+ },
218
+ helperText: ((_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message) ? fieldState.error.message : 'Optional, if you want to filter on captured result.'
219
+ });
220
+ }
221
+ })
222
+ }),
223
+ /*#__PURE__*/ _jsx(Stack, {
224
+ children: /*#__PURE__*/ _jsx(Controller, {
225
+ control: control,
226
+ name: "spec.sort",
227
+ render: ({ field, fieldState })=>/*#__PURE__*/ {
228
+ var _fieldState_error;
229
+ var _field_value;
230
+ return _jsxs(TextField, {
231
+ select: true,
232
+ ...field,
233
+ fullWidth: true,
234
+ label: "Sort",
235
+ InputLabelProps: {
236
+ shrink: action === 'read' ? true : undefined
237
+ },
238
+ InputProps: {
239
+ readOnly: action === 'read'
240
+ },
241
+ error: !!fieldState.error,
242
+ helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
243
+ value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : 'none',
244
+ onChange: (event)=>{
245
+ field.onChange(event);
246
+ },
247
+ children: [
248
+ /*#__PURE__*/ _jsx(MenuItem, {
249
+ value: "none",
250
+ children: "None"
251
+ }),
252
+ /*#__PURE__*/ _jsx(MenuItem, {
253
+ value: "alphabetical-asc",
254
+ children: "Alphabetical, asc"
255
+ }),
256
+ /*#__PURE__*/ _jsx(MenuItem, {
257
+ value: "alphabetical-desc",
258
+ children: "Alphabetical, desc"
259
+ }),
260
+ /*#__PURE__*/ _jsx(MenuItem, {
261
+ value: "numerical-asc",
262
+ children: "Numerical, asc"
263
+ }),
264
+ /*#__PURE__*/ _jsx(MenuItem, {
265
+ value: "numerical-desc",
266
+ children: "Numerical, desc"
267
+ }),
268
+ /*#__PURE__*/ _jsx(MenuItem, {
269
+ value: "alphabetical-ci-asc",
270
+ children: "Alphabetical, case-insensitive, asc"
271
+ }),
272
+ /*#__PURE__*/ _jsx(MenuItem, {
273
+ value: "alphabetical-ci-desc",
274
+ children: "Alphabetical, case-insensitive, desc"
275
+ })
276
+ ]
277
+ });
278
+ }
279
+ })
280
+ })
281
+ ]
282
+ }),
283
+ /*#__PURE__*/ _jsx(Divider, {}),
284
+ /*#__PURE__*/ _jsx(Typography, {
285
+ py: 1,
286
+ variant: "subtitle1",
287
+ children: "Dropdown Options"
288
+ }),
289
+ /*#__PURE__*/ _jsxs(Stack, {
290
+ spacing: "2",
291
+ children: [
292
+ /*#__PURE__*/ _jsxs(Stack, {
293
+ children: [
294
+ /*#__PURE__*/ _jsx(Controller, {
295
+ control: control,
296
+ name: "spec.allowMultiple",
297
+ render: ({ field })=>/*#__PURE__*/ {
298
+ var _field_value;
299
+ return _jsx(FormControlLabel, {
300
+ label: "Allow Multiple Values",
301
+ control: /*#__PURE__*/ _jsx(Switch, {
302
+ ...field,
303
+ checked: !!field.value,
304
+ readOnly: action === 'read',
305
+ value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : false,
306
+ onChange: (event)=>{
307
+ if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
308
+ field.onChange(event);
309
+ }
310
+ })
311
+ });
312
+ }
313
+ }),
314
+ /*#__PURE__*/ _jsx(Typography, {
315
+ variant: "caption",
316
+ children: "Enables multiple values to be selected at the same time"
317
+ })
318
+ ]
319
+ }),
320
+ /*#__PURE__*/ _jsxs(Stack, {
321
+ children: [
322
+ /*#__PURE__*/ _jsx(Controller, {
323
+ control: control,
324
+ name: "spec.allowAllValue",
325
+ render: ({ field })=>/*#__PURE__*/ {
326
+ var _field_value;
327
+ return _jsx(FormControlLabel, {
328
+ label: "Allow All option",
329
+ control: /*#__PURE__*/ _jsx(Switch, {
330
+ ...field,
331
+ checked: !!field.value,
332
+ readOnly: action === 'read',
333
+ value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : false,
334
+ onChange: (event)=>{
335
+ if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
336
+ field.onChange(event);
337
+ }
338
+ })
339
+ });
340
+ }
341
+ }),
342
+ /*#__PURE__*/ _jsx(Typography, {
343
+ mb: 1,
344
+ variant: "caption",
345
+ children: "Enables an option to include all variable values"
346
+ }),
347
+ _allowAllValue && /*#__PURE__*/ _jsx(Controller, {
348
+ control: control,
349
+ name: "spec.customAllValue",
350
+ render: ({ field, fieldState })=>/*#__PURE__*/ {
351
+ var _fieldState_error;
352
+ var _field_value;
353
+ return _jsx(TextField, {
354
+ ...field,
355
+ fullWidth: true,
356
+ label: "Custom All Value",
357
+ InputLabelProps: {
358
+ shrink: action === 'read' ? true : undefined
359
+ },
360
+ InputProps: {
361
+ readOnly: action === 'read'
362
+ },
363
+ error: !!fieldState.error,
364
+ helperText: ((_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message) ? fieldState.error.message : 'When All is selected, this value will be used',
365
+ value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
366
+ onChange: (event)=>{
367
+ if (event.target.value === '') {
368
+ field.onChange(undefined);
369
+ } else {
370
+ field.onChange(event);
371
+ }
372
+ }
373
+ });
374
+ }
375
+ })
376
+ ]
377
+ })
378
+ ]
379
+ })
380
+ ]
381
+ });
382
+ }
31
383
  export function VariableEditorForm(props) {
32
384
  const { initialVariableDefinition, initialAction, isDraft, isReadonly, onSave, onClose, onDelete } = props;
33
- const initialState = getInitialState(initialVariableDefinition);
34
- const [state, setState] = useImmer(initialState);
35
385
  const [isDiscardDialogOpened, setDiscardDialogOpened] = useState(false);
36
- const [previewKey, setPreviewKey] = useState(0);
37
386
  const [action, setAction] = useState(initialAction);
38
- const refreshPreview = ()=>{
39
- setPreviewKey((prev)=>prev + 1);
40
- };
41
- /** We use the `previewKey` that we increment to know when to explicitly update the
42
- * spec that will be used for preview. The reason why we do this is to avoid
43
- * having to re-fetch the values when the user is still editing the spec.
44
- */ const previewSpec = useMemo(()=>{
45
- return getVariableDefinitionFromState(state);
46
- // eslint-disable-next-line react-hooks/exhaustive-deps
47
- }, [
48
- previewKey
49
- ]);
50
387
  const titleAction = getTitleAction(action, isDraft);
51
388
  const submitText = getSubmitText(action, isDraft);
389
+ const { variableEditorSchema } = useValidationSchemas();
52
390
  const form = useForm({
53
- resolver: zodResolver(variableEditorValidationSchema),
391
+ resolver: zodResolver(variableEditorSchema),
54
392
  mode: 'onBlur',
55
- defaultValues: initialState
393
+ defaultValues: initialVariableDefinition
394
+ });
395
+ const kind = useWatch({
396
+ control: form.control,
397
+ name: 'kind'
56
398
  });
57
- const processForm = ()=>{
399
+ function clearFormData(data) {
400
+ var _result_spec_display, _result_spec_display1, _result_spec_display2;
401
+ const result = {
402
+ ...data
403
+ };
404
+ if (((_result_spec_display = result.spec.display) === null || _result_spec_display === void 0 ? void 0 : _result_spec_display.name) === undefined && ((_result_spec_display1 = result.spec.display) === null || _result_spec_display1 === void 0 ? void 0 : _result_spec_display1.description) === undefined && ((_result_spec_display2 = result.spec.display) === null || _result_spec_display2 === void 0 ? void 0 : _result_spec_display2.hidden) === undefined) {
405
+ delete result.spec.display;
406
+ }
407
+ return result;
408
+ }
409
+ const processForm = (data)=>{
58
410
  // reset display attributes to undefined when empty, because we don't want to save empty strings
59
- onSave(getVariableDefinitionFromState({
60
- ...state,
61
- title: state.title === '' ? undefined : state.title,
62
- description: state.description === '' ? undefined : state.description
63
- }));
411
+ onSave(clearFormData(data));
64
412
  };
65
413
  // When user click on cancel, several possibilities:
66
414
  // - create action: ask for discard approval
67
415
  // - update action: ask for discard approval if changed
68
416
  // - read action: don´t ask for discard approval
69
- const handleCancel = useCallback(()=>{
70
- if (JSON.stringify(initialState) !== JSON.stringify(state)) {
417
+ function handleCancel() {
418
+ if (JSON.stringify(initialVariableDefinition) !== JSON.stringify(clearFormData(form.getValues()))) {
71
419
  setDiscardDialogOpened(true);
72
420
  } else {
73
421
  onClose();
74
422
  }
75
- }, [
76
- initialState,
77
- state,
78
- onClose
79
- ]);
423
+ }
80
424
  return /*#__PURE__*/ _jsxs(FormProvider, {
81
425
  ...form,
82
426
  children: [
@@ -169,10 +513,12 @@ export function VariableEditorForm(props) {
169
513
  item: true,
170
514
  xs: 8,
171
515
  children: /*#__PURE__*/ _jsx(Controller, {
172
- name: "name",
173
- render: ({ field, fieldState })=>{
516
+ control: form.control,
517
+ name: "spec.name",
518
+ render: ({ field, fieldState })=>/*#__PURE__*/ {
174
519
  var _fieldState_error;
175
- return /*#__PURE__*/ _jsx(TextField, {
520
+ var _field_value;
521
+ return _jsx(TextField, {
176
522
  ...field,
177
523
  required: true,
178
524
  fullWidth: true,
@@ -186,12 +532,9 @@ export function VariableEditorForm(props) {
186
532
  },
187
533
  error: !!fieldState.error,
188
534
  helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
189
- value: state.name,
535
+ value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
190
536
  onChange: (event)=>{
191
537
  field.onChange(event);
192
- setState((draft)=>{
193
- draft.name = event.target.value;
194
- });
195
538
  }
196
539
  });
197
540
  }
@@ -201,10 +544,11 @@ export function VariableEditorForm(props) {
201
544
  item: true,
202
545
  xs: 4,
203
546
  children: /*#__PURE__*/ _jsx(Controller, {
204
- name: "title",
547
+ control: form.control,
548
+ name: "spec.display.name",
205
549
  render: ({ field, fieldState })=>/*#__PURE__*/ {
206
550
  var _fieldState_error;
207
- var _state_title;
551
+ var _field_value;
208
552
  return _jsx(TextField, {
209
553
  ...field,
210
554
  fullWidth: true,
@@ -217,12 +561,9 @@ export function VariableEditorForm(props) {
217
561
  },
218
562
  error: !!fieldState.error,
219
563
  helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
220
- value: (_state_title = state.title) !== null && _state_title !== void 0 ? _state_title : '',
564
+ value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
221
565
  onChange: (event)=>{
222
566
  field.onChange(event);
223
- setState((draft)=>{
224
- draft.title = event.target.value;
225
- });
226
567
  }
227
568
  });
228
569
  }
@@ -232,10 +573,11 @@ export function VariableEditorForm(props) {
232
573
  item: true,
233
574
  xs: 8,
234
575
  children: /*#__PURE__*/ _jsx(Controller, {
235
- name: "description",
576
+ control: form.control,
577
+ name: "spec.display.description",
236
578
  render: ({ field, fieldState })=>/*#__PURE__*/ {
237
579
  var _fieldState_error;
238
- var _state_description;
580
+ var _field_value;
239
581
  return _jsx(TextField, {
240
582
  ...field,
241
583
  fullWidth: true,
@@ -248,12 +590,9 @@ export function VariableEditorForm(props) {
248
590
  },
249
591
  error: !!fieldState.error,
250
592
  helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
251
- value: (_state_description = state.description) !== null && _state_description !== void 0 ? _state_description : '',
593
+ value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
252
594
  onChange: (event)=>{
253
595
  field.onChange(event);
254
- setState((draft)=>{
255
- draft.description = event.target.value;
256
- });
257
596
  }
258
597
  });
259
598
  }
@@ -263,10 +602,12 @@ export function VariableEditorForm(props) {
263
602
  item: true,
264
603
  xs: 4,
265
604
  children: /*#__PURE__*/ _jsx(Controller, {
605
+ control: form.control,
266
606
  name: "kind",
267
- render: ({ field, fieldState })=>{
607
+ render: ({ field, fieldState })=>/*#__PURE__*/ {
268
608
  var _fieldState_error;
269
- return /*#__PURE__*/ _jsx(TextField, {
609
+ var _field_value;
610
+ return _jsx(TextField, {
270
611
  select: true,
271
612
  ...field,
272
613
  fullWidth: true,
@@ -279,12 +620,9 @@ export function VariableEditorForm(props) {
279
620
  },
280
621
  error: !!fieldState.error,
281
622
  helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
282
- value: state.kind,
623
+ value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : 'TextVariable',
283
624
  onChange: (event)=>{
284
625
  field.onChange(event);
285
- setState((draft)=>{
286
- draft.kind = event.target.value;
287
- });
288
626
  },
289
627
  children: VARIABLE_TYPES.map((v)=>/*#__PURE__*/ _jsx(MenuItem, {
290
628
  value: v.kind,
@@ -297,325 +635,19 @@ export function VariableEditorForm(props) {
297
635
  ]
298
636
  }),
299
637
  /*#__PURE__*/ _jsx(Divider, {}),
300
- state.kind === 'TextVariable' && /*#__PURE__*/ _jsxs(_Fragment, {
301
- children: [
302
- /*#__PURE__*/ _jsx(Typography, {
303
- py: 1,
304
- variant: "subtitle1",
305
- children: "Text Options"
306
- }),
307
- /*#__PURE__*/ _jsxs(Stack, {
308
- spacing: 2,
309
- children: [
310
- /*#__PURE__*/ _jsx(Box, {
311
- children: /*#__PURE__*/ _jsx(VariablePreview, {
312
- values: [
313
- state.textVariableFields.value
314
- ]
315
- })
316
- }),
317
- /*#__PURE__*/ _jsx(Controller, {
318
- name: "textVariableFields.value",
319
- render: ({ field, fieldState })=>{
320
- var _fieldState_error;
321
- return /*#__PURE__*/ _jsx(TextField, {
322
- ...field,
323
- label: "Value",
324
- InputLabelProps: {
325
- shrink: action === 'read' ? true : undefined
326
- },
327
- InputProps: {
328
- readOnly: action === 'read'
329
- },
330
- error: !!fieldState.error,
331
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
332
- value: state.textVariableFields.value,
333
- onChange: (event)=>{
334
- field.onChange(event);
335
- setState((draft)=>{
336
- draft.textVariableFields.value = event.target.value;
337
- });
338
- }
339
- });
340
- }
341
- }),
342
- /*#__PURE__*/ _jsx(Controller, {
343
- name: "textVariableFields.constant",
344
- render: ({ field })=>/*#__PURE__*/ _jsx(FormControlLabel, {
345
- label: "Constant",
346
- control: /*#__PURE__*/ _jsx(Switch, {
347
- ...field,
348
- checked: !!field.value,
349
- readOnly: action === 'read',
350
- value: state.textVariableFields.constant,
351
- onChange: (event)=>{
352
- if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
353
- field.onChange(event);
354
- setState((draft)=>{
355
- draft.textVariableFields.constant = event.target.checked;
356
- });
357
- }
358
- })
359
- })
360
- })
361
- ]
362
- })
363
- ]
638
+ kind === 'TextVariable' && /*#__PURE__*/ _jsx(ErrorBoundary, {
639
+ FallbackComponent: ErrorAlert,
640
+ children: /*#__PURE__*/ _jsx(TextVariableEditorForm, {
641
+ action: action,
642
+ control: form.control
643
+ })
364
644
  }),
365
- state.kind === 'ListVariable' && /*#__PURE__*/ _jsxs(_Fragment, {
366
- children: [
367
- /*#__PURE__*/ _jsx(Typography, {
368
- py: 1,
369
- variant: "subtitle1",
370
- children: "List Options"
371
- }),
372
- /*#__PURE__*/ _jsxs(Stack, {
373
- spacing: 2,
374
- mb: 2,
375
- children: [
376
- state.listVariableFields.plugin.kind ? /*#__PURE__*/ _jsx(Box, {
377
- children: /*#__PURE__*/ _jsx(ErrorBoundary, {
378
- FallbackComponent: FallbackPreview,
379
- resetKeys: [
380
- previewSpec
381
- ],
382
- children: /*#__PURE__*/ _jsx(VariableListPreview, {
383
- definition: previewSpec,
384
- onRefresh: refreshPreview
385
- })
386
- })
387
- }) : /*#__PURE__*/ _jsx(VariablePreview, {
388
- isLoading: true
389
- }),
390
- /*#__PURE__*/ _jsxs(Stack, {
391
- children: [
392
- /*#__PURE__*/ _jsx(ClickAwayListener, {
393
- onClickAway: ()=>refreshPreview(),
394
- children: /*#__PURE__*/ _jsx(Box, {})
395
- }),
396
- /*#__PURE__*/ _jsx(Controller, {
397
- name: "listVariableFields.plugin",
398
- render: ({ field })=>/*#__PURE__*/ _jsx(PluginEditor, {
399
- width: "100%",
400
- pluginTypes: [
401
- 'Variable'
402
- ],
403
- pluginKindLabel: "Source",
404
- isReadonly: action === 'read',
405
- value: {
406
- selection: {
407
- kind: state.listVariableFields.plugin.kind,
408
- type: 'Variable'
409
- },
410
- spec: state.listVariableFields.plugin.spec
411
- },
412
- onChange: (val)=>{
413
- field.onChange({
414
- spec: val.spec,
415
- kind: val.selection.kind
416
- });
417
- setState((draft)=>{
418
- draft.listVariableFields.plugin.kind = val.selection.kind;
419
- draft.listVariableFields.plugin.spec = val.spec;
420
- });
421
- }
422
- })
423
- })
424
- ]
425
- }),
426
- /*#__PURE__*/ _jsx(Stack, {
427
- children: /*#__PURE__*/ _jsx(Controller, {
428
- name: "listVariableFields.capturingRegexp",
429
- render: ({ field, fieldState })=>/*#__PURE__*/ {
430
- var _fieldState_error;
431
- var _state_listVariableFields_capturingRegexp;
432
- return _jsx(TextField, {
433
- ...field,
434
- label: "Capturing Regexp Filter",
435
- InputLabelProps: {
436
- shrink: action === 'read' ? true : undefined
437
- },
438
- InputProps: {
439
- readOnly: action === 'read'
440
- },
441
- error: !!fieldState.error,
442
- value: (_state_listVariableFields_capturingRegexp = state.listVariableFields.capturingRegexp) !== null && _state_listVariableFields_capturingRegexp !== void 0 ? _state_listVariableFields_capturingRegexp : '',
443
- onChange: (event)=>{
444
- field.onChange(event);
445
- setState((draft)=>{
446
- if (event.target.value) {
447
- // TODO: do a better fix, if empty string => it should skip the filter
448
- draft.listVariableFields.capturingRegexp = event.target.value;
449
- } else {
450
- draft.listVariableFields.capturingRegexp = undefined;
451
- }
452
- });
453
- },
454
- helperText: ((_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message) ? fieldState.error.message : 'Optional, if you want to filter on captured result.'
455
- });
456
- }
457
- })
458
- }),
459
- /*#__PURE__*/ _jsx(Stack, {
460
- children: /*#__PURE__*/ _jsx(Controller, {
461
- name: "listVariableFields.sort",
462
- render: ({ field, fieldState })=>/*#__PURE__*/ {
463
- var _fieldState_error;
464
- var _state_listVariableFields_sort;
465
- return _jsxs(TextField, {
466
- select: true,
467
- ...field,
468
- fullWidth: true,
469
- label: "Sort",
470
- InputLabelProps: {
471
- shrink: action === 'read' ? true : undefined
472
- },
473
- InputProps: {
474
- readOnly: action === 'read'
475
- },
476
- error: !!fieldState.error,
477
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
478
- value: (_state_listVariableFields_sort = state.listVariableFields.sort) !== null && _state_listVariableFields_sort !== void 0 ? _state_listVariableFields_sort : 'none',
479
- onChange: (event)=>{
480
- field.onChange(event);
481
- setState((draft)=>{
482
- draft.listVariableFields.sort = event.target.value;
483
- });
484
- },
485
- children: [
486
- /*#__PURE__*/ _jsx(MenuItem, {
487
- value: "none",
488
- children: "None"
489
- }),
490
- /*#__PURE__*/ _jsx(MenuItem, {
491
- value: "alphabetical-asc",
492
- children: "Alphabetical, asc"
493
- }),
494
- /*#__PURE__*/ _jsx(MenuItem, {
495
- value: "alphabetical-desc",
496
- children: "Alphabetical, desc"
497
- }),
498
- /*#__PURE__*/ _jsx(MenuItem, {
499
- value: "numerical-asc",
500
- children: "Numerical, asc"
501
- }),
502
- /*#__PURE__*/ _jsx(MenuItem, {
503
- value: "numerical-desc",
504
- children: "Numerical, desc"
505
- }),
506
- /*#__PURE__*/ _jsx(MenuItem, {
507
- value: "alphabetical-ci-asc",
508
- children: "Alphabetical, case-insensitive, asc"
509
- }),
510
- /*#__PURE__*/ _jsx(MenuItem, {
511
- value: "alphabetical-ci-desc",
512
- children: "Alphabetical, case-insensitive, desc"
513
- })
514
- ]
515
- });
516
- }
517
- })
518
- })
519
- ]
520
- }),
521
- /*#__PURE__*/ _jsx(Divider, {}),
522
- /*#__PURE__*/ _jsx(Typography, {
523
- py: 1,
524
- variant: "subtitle1",
525
- children: "Dropdown Options"
526
- }),
527
- /*#__PURE__*/ _jsxs(Stack, {
528
- spacing: "2",
529
- children: [
530
- /*#__PURE__*/ _jsxs(Stack, {
531
- children: [
532
- /*#__PURE__*/ _jsx(Controller, {
533
- name: "listVariableFields.allowMultiple",
534
- render: ({ field })=>/*#__PURE__*/ _jsx(FormControlLabel, {
535
- label: "Allow Multiple Values",
536
- control: /*#__PURE__*/ _jsx(Switch, {
537
- ...field,
538
- checked: !!field.value,
539
- readOnly: action === 'read',
540
- value: state.listVariableFields.allowMultiple,
541
- onChange: (event)=>{
542
- if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
543
- field.onChange(event);
544
- setState((draft)=>{
545
- draft.listVariableFields.allowMultiple = event.target.checked;
546
- });
547
- }
548
- })
549
- })
550
- }),
551
- /*#__PURE__*/ _jsx(Typography, {
552
- variant: "caption",
553
- children: "Enables multiple values to be selected at the same time"
554
- })
555
- ]
556
- }),
557
- /*#__PURE__*/ _jsxs(Stack, {
558
- children: [
559
- /*#__PURE__*/ _jsx(Controller, {
560
- name: "listVariableFields.allowAllValue",
561
- render: ({ field })=>/*#__PURE__*/ _jsx(FormControlLabel, {
562
- label: "Allow All option",
563
- control: /*#__PURE__*/ _jsx(Switch, {
564
- ...field,
565
- checked: !!field.value,
566
- readOnly: action === 'read',
567
- value: state.listVariableFields.allowAllValue,
568
- onChange: (event)=>{
569
- if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
570
- field.onChange(event);
571
- setState((draft)=>{
572
- draft.listVariableFields.allowAllValue = event.target.checked;
573
- });
574
- }
575
- })
576
- })
577
- }),
578
- /*#__PURE__*/ _jsx(Typography, {
579
- mb: 1,
580
- variant: "caption",
581
- children: "Enables an option to include all variable values"
582
- }),
583
- state.listVariableFields.allowAllValue && /*#__PURE__*/ _jsx(Controller, {
584
- name: "listVariableFields.customAllValue",
585
- render: ({ field, fieldState })=>/*#__PURE__*/ {
586
- var _fieldState_error;
587
- var _state_listVariableFields_customAllValue;
588
- return _jsx(TextField, {
589
- ...field,
590
- fullWidth: true,
591
- label: "Custom All Value",
592
- InputLabelProps: {
593
- shrink: action === 'read' ? true : undefined
594
- },
595
- InputProps: {
596
- readOnly: action === 'read'
597
- },
598
- error: !!fieldState.error,
599
- helperText: ((_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message) ? fieldState.error.message : 'When All is selected, this value will be used',
600
- value: (_state_listVariableFields_customAllValue = state.listVariableFields.customAllValue) !== null && _state_listVariableFields_customAllValue !== void 0 ? _state_listVariableFields_customAllValue : '',
601
- onChange: (event)=>{
602
- field.onChange(event);
603
- setState((draft)=>{
604
- if (event.target.value) {
605
- draft.listVariableFields.customAllValue = event.target.value;
606
- } else {
607
- draft.listVariableFields.customAllValue = undefined;
608
- }
609
- });
610
- }
611
- });
612
- }
613
- })
614
- ]
615
- })
616
- ]
617
- })
618
- ]
645
+ kind === 'ListVariable' && /*#__PURE__*/ _jsx(ErrorBoundary, {
646
+ FallbackComponent: ErrorAlert,
647
+ children: /*#__PURE__*/ _jsx(ListVariableEditorForm, {
648
+ action: action,
649
+ control: form.control
650
+ })
619
651
  })
620
652
  ]
621
653
  }),