@finos/legend-query-builder 4.14.24 → 4.14.26

Sign up to get free protection for your applications and to get access to all the features.
@@ -70,7 +70,13 @@ import {
70
70
  } from '@finos/legend-shared';
71
71
  import { flowResult } from 'mobx';
72
72
  import { observer } from 'mobx-react-lite';
73
- import { useEffect, useRef, useState } from 'react';
73
+ import {
74
+ forwardRef,
75
+ useEffect,
76
+ useImperativeHandle,
77
+ useRef,
78
+ useState,
79
+ } from 'react';
74
80
  import {
75
81
  instanceValue_setValue,
76
82
  instanceValue_setValues,
@@ -204,23 +210,26 @@ const VariableExpressionParameterEditor = observer(
204
210
  );
205
211
 
206
212
  const StringPrimitiveInstanceValueEditor = observer(
207
- (props: {
208
- valueSpecification: PrimitiveInstanceValue;
209
- className?: string | undefined;
210
- setValueSpecification: (val: ValueSpecification) => void;
211
- resetValue: () => void;
212
- selectorConfig?:
213
- | {
214
- values: string[] | undefined;
215
- isLoading: boolean;
216
- reloadValues:
217
- | DebouncedFunc<(inputValue: string) => GeneratorFn<void>>
218
- | undefined;
219
- cleanUpReloadValues?: () => void;
220
- }
221
- | undefined;
222
- obseverContext: ObserverContext;
223
- }) => {
213
+ forwardRef<
214
+ HTMLInputElement,
215
+ {
216
+ valueSpecification: PrimitiveInstanceValue;
217
+ className?: string | undefined;
218
+ setValueSpecification: (val: ValueSpecification) => void;
219
+ resetValue: () => void;
220
+ selectorConfig?:
221
+ | {
222
+ values: string[] | undefined;
223
+ isLoading: boolean;
224
+ reloadValues:
225
+ | DebouncedFunc<(inputValue: string) => GeneratorFn<void>>
226
+ | undefined;
227
+ cleanUpReloadValues?: () => void;
228
+ }
229
+ | undefined;
230
+ obseverContext: ObserverContext;
231
+ }
232
+ >(function StringPrimitiveInstanceValueEditor(props, ref) {
224
233
  const {
225
234
  valueSpecification,
226
235
  className,
@@ -307,6 +316,7 @@ const StringPrimitiveInstanceValueEditor = observer(
307
316
  value={value}
308
317
  placeholder={value === '' ? '(empty)' : undefined}
309
318
  onChange={changeInputValue}
319
+ ref={ref}
310
320
  />
311
321
  )}
312
322
  <button
@@ -319,7 +329,7 @@ const StringPrimitiveInstanceValueEditor = observer(
319
329
  </button>
320
330
  </div>
321
331
  );
322
- },
332
+ }),
323
333
  );
324
334
 
325
335
  const BooleanPrimitiveInstanceValueEditor = observer(
@@ -367,14 +377,17 @@ const BooleanPrimitiveInstanceValueEditor = observer(
367
377
  );
368
378
 
369
379
  const NumberPrimitiveInstanceValueEditor = observer(
370
- (props: {
371
- valueSpecification: PrimitiveInstanceValue;
372
- isInteger: boolean;
373
- className?: string | undefined;
374
- resetValue: () => void;
375
- setValueSpecification: (val: ValueSpecification) => void;
376
- obseverContext: ObserverContext;
377
- }) => {
380
+ forwardRef<
381
+ HTMLInputElement,
382
+ {
383
+ valueSpecification: PrimitiveInstanceValue;
384
+ isInteger: boolean;
385
+ className?: string | undefined;
386
+ resetValue: () => void;
387
+ setValueSpecification: (val: ValueSpecification) => void;
388
+ obseverContext: ObserverContext;
389
+ }
390
+ >(function NumberPrimitiveInstanceValueEditor(props, ref) {
378
391
  const {
379
392
  valueSpecification,
380
393
  isInteger,
@@ -387,6 +400,7 @@ const NumberPrimitiveInstanceValueEditor = observer(
387
400
  (valueSpecification.values[0] as number).toString(),
388
401
  );
389
402
  const inputRef = useRef<HTMLInputElement>(null);
403
+ useImperativeHandle(ref, () => inputRef.current as HTMLInputElement, []);
390
404
  const numericValue = isInteger
391
405
  ? Number.parseInt(Number(value).toString(), 10)
392
406
  : Number(value);
@@ -484,7 +498,7 @@ const NumberPrimitiveInstanceValueEditor = observer(
484
498
  </button>
485
499
  </div>
486
500
  );
487
- },
501
+ }),
488
502
  );
489
503
 
490
504
  const EnumValueInstanceValueEditor = observer(
@@ -947,26 +961,29 @@ const DateInstanceValueEditor = observer(
947
961
  *
948
962
  * See https://github.com/finos/legend-studio/pull/1021
949
963
  */
950
- export const BasicValueSpecificationEditor: React.FC<{
951
- valueSpecification: ValueSpecification;
952
- graph: PureModel;
953
- obseverContext: ObserverContext;
954
- typeCheckOption: TypeCheckOption;
955
- className?: string | undefined;
956
- setValueSpecification: (val: ValueSpecification) => void;
957
- resetValue: () => void;
958
- isConstant?: boolean;
959
- selectorConfig?:
960
- | {
961
- values: string[] | undefined;
962
- isLoading: boolean;
963
- reloadValues:
964
- | DebouncedFunc<(inputValue: string) => GeneratorFn<void>>
965
- | undefined;
966
- cleanUpReloadValues?: () => void;
967
- }
968
- | undefined;
969
- }> = (props) => {
964
+ export const BasicValueSpecificationEditor = forwardRef<
965
+ HTMLInputElement,
966
+ {
967
+ valueSpecification: ValueSpecification;
968
+ graph: PureModel;
969
+ obseverContext: ObserverContext;
970
+ typeCheckOption: TypeCheckOption;
971
+ className?: string | undefined;
972
+ setValueSpecification: (val: ValueSpecification) => void;
973
+ resetValue: () => void;
974
+ isConstant?: boolean;
975
+ selectorConfig?:
976
+ | {
977
+ values: string[] | undefined;
978
+ isLoading: boolean;
979
+ reloadValues:
980
+ | DebouncedFunc<(inputValue: string) => GeneratorFn<void>>
981
+ | undefined;
982
+ cleanUpReloadValues?: () => void;
983
+ }
984
+ | undefined;
985
+ }
986
+ >(function BasicValueSpecificationEditor(props, ref) {
970
987
  const {
971
988
  className,
972
989
  valueSpecification,
@@ -990,6 +1007,7 @@ export const BasicValueSpecificationEditor: React.FC<{
990
1007
  resetValue={resetValue}
991
1008
  selectorConfig={selectorConfig}
992
1009
  obseverContext={obseverContext}
1010
+ ref={ref}
993
1011
  />
994
1012
  );
995
1013
  case PRIMITIVE_TYPE.BOOLEAN:
@@ -1016,6 +1034,7 @@ export const BasicValueSpecificationEditor: React.FC<{
1016
1034
  className={className}
1017
1035
  resetValue={resetValue}
1018
1036
  obseverContext={obseverContext}
1037
+ ref={ref}
1019
1038
  />
1020
1039
  );
1021
1040
  case PRIMITIVE_TYPE.DATE:
@@ -1134,6 +1153,7 @@ export const BasicValueSpecificationEditor: React.FC<{
1134
1153
  className={className}
1135
1154
  resetValue={resetValue}
1136
1155
  obseverContext={obseverContext}
1156
+ ref={ref}
1137
1157
  />
1138
1158
  );
1139
1159
  }
@@ -1141,4 +1161,4 @@ export const BasicValueSpecificationEditor: React.FC<{
1141
1161
  }
1142
1162
 
1143
1163
  return <UnsupportedValueSpecificationEditor />;
1144
- };
1164
+ });