@finos/legend-query-builder 4.16.21 → 4.16.23

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 (32) hide show
  1. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts +2 -0
  2. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts.map +1 -1
  3. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js.map +1 -1
  4. package/lib/components/shared/BasicValueSpecificationEditor.d.ts +7 -0
  5. package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +1 -1
  6. package/lib/components/shared/BasicValueSpecificationEditor.js +39 -39
  7. package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -1
  8. package/lib/components/shared/CustomDatePicker.d.ts.map +1 -1
  9. package/lib/components/shared/CustomDatePicker.js +3 -3
  10. package/lib/components/shared/CustomDatePicker.js.map +1 -1
  11. package/lib/components/shared/V1_BasicValueSpecificationEditor.d.ts +2 -0
  12. package/lib/components/shared/V1_BasicValueSpecificationEditor.d.ts.map +1 -1
  13. package/lib/components/shared/V1_BasicValueSpecificationEditor.js +8 -8
  14. package/lib/components/shared/V1_BasicValueSpecificationEditor.js.map +1 -1
  15. package/lib/index.css +2 -2
  16. package/lib/index.css.map +1 -1
  17. package/lib/index.d.ts +1 -0
  18. package/lib/index.d.ts.map +1 -1
  19. package/lib/index.js +1 -0
  20. package/lib/index.js.map +1 -1
  21. package/lib/package.json +1 -1
  22. package/lib/stores/shared/V1_ValueSpecificationEditorHelper.d.ts +2 -2
  23. package/lib/stores/shared/V1_ValueSpecificationEditorHelper.d.ts.map +1 -1
  24. package/lib/stores/shared/V1_ValueSpecificationEditorHelper.js +23 -9
  25. package/lib/stores/shared/V1_ValueSpecificationEditorHelper.js.map +1 -1
  26. package/package.json +10 -10
  27. package/src/components/__test-utils__/QueryBuilderComponentTestUtils.tsx +2 -0
  28. package/src/components/shared/BasicValueSpecificationEditor.tsx +76 -19
  29. package/src/components/shared/CustomDatePicker.tsx +10 -3
  30. package/src/components/shared/V1_BasicValueSpecificationEditor.tsx +14 -1
  31. package/src/index.ts +2 -0
  32. package/src/stores/shared/V1_ValueSpecificationEditorHelper.ts +27 -9
@@ -267,6 +267,7 @@ export interface PrimitiveInstanceValueEditorProps<
267
267
  handleBlur?: (() => void) | undefined;
268
268
  handleKeyDown?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
269
269
  className?: string | undefined;
270
+ readOnly?: boolean | undefined;
270
271
  }
271
272
 
272
273
  export interface BasicValueSpecificationEditorSelectorSearchConfig {
@@ -288,6 +289,7 @@ interface StringPrimitiveInstanceValueEditorProps<T>
288
289
  | BasicValueSpecificationEditorSelectorSearchConfig
289
290
  | undefined;
290
291
  selectorConfig?: BasicValueSpecificationEditorSelectorConfig | undefined;
292
+ lightMode?: boolean | undefined;
291
293
  }
292
294
 
293
295
  // eslint-disable-next-line comma-spacing
@@ -306,6 +308,8 @@ const StringPrimitiveInstanceValueEditorInner = <T,>(
306
308
  className,
307
309
  selectorSearchConfig,
308
310
  selectorConfig,
311
+ lightMode,
312
+ readOnly,
309
313
  } = props;
310
314
  const useSelector = Boolean(selectorSearchConfig);
311
315
  const applicationStore = useApplicationStore();
@@ -376,9 +380,7 @@ const StringPrimitiveInstanceValueEditorInner = <T,>(
376
380
  value={selectedValue}
377
381
  inputValue={value ?? ''}
378
382
  onInputChange={handleInputChange}
379
- darkMode={
380
- !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
381
- }
383
+ darkMode={!lightMode}
382
384
  isLoading={isLoading}
383
385
  allowCreateWhileLoading={true}
384
386
  noOptionsMessage={noOptionsMessage}
@@ -393,6 +395,7 @@ const StringPrimitiveInstanceValueEditorInner = <T,>(
393
395
  }
394
396
  inputName={inputName}
395
397
  optionCustomization={selectorConfig?.optionCustomization}
398
+ disabled={readOnly}
396
399
  />
397
400
  ) : (
398
401
  <InputWithInlineValidation
@@ -409,6 +412,7 @@ const StringPrimitiveInstanceValueEditorInner = <T,>(
409
412
  }
410
413
  onKeyDown={handleKeyDown}
411
414
  name={inputName}
415
+ disabled={readOnly}
412
416
  />
413
417
  )}
414
418
  <button
@@ -416,6 +420,7 @@ const StringPrimitiveInstanceValueEditorInner = <T,>(
416
420
  name={resetButtonName}
417
421
  title="Reset"
418
422
  onClick={resetValue}
423
+ disabled={readOnly}
419
424
  >
420
425
  <RefreshIcon />
421
426
  </button>
@@ -446,6 +451,7 @@ const BooleanInstanceValueEditorInner = <T,>(
446
451
  updateValueSpecification,
447
452
  resetValue,
448
453
  className,
454
+ readOnly,
449
455
  } = props;
450
456
  const value = valueSelector(valueSpecification);
451
457
  const toggleValue = (): void => {
@@ -460,6 +466,7 @@ const BooleanInstanceValueEditorInner = <T,>(
460
466
  'value-spec-editor__toggler__btn--toggled': value,
461
467
  })}
462
468
  onClick={toggleValue}
469
+ disabled={readOnly}
463
470
  >
464
471
  {value ? <CheckSquareIcon /> : <SquareIcon />}
465
472
  </button>
@@ -468,6 +475,7 @@ const BooleanInstanceValueEditorInner = <T,>(
468
475
  name="Reset"
469
476
  title="Reset"
470
477
  onClick={resetValue}
478
+ disabled={readOnly}
471
479
  >
472
480
  <RefreshIcon />
473
481
  </button>
@@ -501,6 +509,7 @@ const NumberPrimitiveInstanceValueEditorInner = <T,>(
501
509
  handleKeyDown,
502
510
  className,
503
511
  isInteger,
512
+ readOnly,
504
513
  } = props;
505
514
  const [value, setValue] = useState(
506
515
  valueSelector(valueSpecification)?.toString() ?? '',
@@ -624,6 +633,7 @@ const NumberPrimitiveInstanceValueEditorInner = <T,>(
624
633
  handleKeyDown?.(event);
625
634
  }}
626
635
  name={inputName}
636
+ disabled={readOnly}
627
637
  />
628
638
  <div className="value-spec-editor__number__actions">
629
639
  <button
@@ -631,6 +641,7 @@ const NumberPrimitiveInstanceValueEditorInner = <T,>(
631
641
  title="Evaluate Expression (Enter)"
632
642
  name={calculateButtonName}
633
643
  onClick={calculateExpression}
644
+ disabled={readOnly}
634
645
  >
635
646
  <CalculateIcon />
636
647
  </button>
@@ -641,6 +652,7 @@ const NumberPrimitiveInstanceValueEditorInner = <T,>(
641
652
  name={resetButtonName}
642
653
  title="Reset"
643
654
  onClick={resetValue}
655
+ disabled={readOnly}
644
656
  >
645
657
  <RefreshIcon />
646
658
  </button>
@@ -664,6 +676,7 @@ interface EnumInstanceValueEditorProps<T>
664
676
  extends PrimitiveInstanceValueEditorProps<T, string | null> {
665
677
  options: { label: string; value: string }[];
666
678
  selectorConfig?: BasicValueSpecificationEditorSelectorConfig | undefined;
679
+ lightMode?: boolean | undefined;
667
680
  }
668
681
 
669
682
  // eslint-disable-next-line comma-spacing
@@ -680,8 +693,9 @@ const EnumInstanceValueEditorInner = <T,>(
680
693
  options,
681
694
  className,
682
695
  selectorConfig,
696
+ lightMode,
697
+ readOnly,
683
698
  } = props;
684
- const applicationStore = useApplicationStore();
685
699
  const enumValue = valueSelector(valueSpecification);
686
700
  const resetButtonName = `reset-${valueSelector(valueSpecification)}`;
687
701
  const inputName = `input-${valueSelector(valueSpecification)}`;
@@ -709,20 +723,20 @@ const EnumInstanceValueEditorInner = <T,>(
709
723
  options={options}
710
724
  onChange={changeValue}
711
725
  value={enumValue ? { value: enumValue, label: enumValue } : null}
712
- darkMode={
713
- !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
714
- }
726
+ darkMode={!lightMode}
715
727
  hasError={errorChecker?.(valueSpecification)}
716
728
  placeholder="Select value"
717
729
  autoFocus={true}
718
730
  inputName={inputName}
719
731
  optionCustomization={selectorConfig?.optionCustomization}
732
+ disabled={readOnly}
720
733
  />
721
734
  <button
722
735
  className="value-spec-editor__reset-btn"
723
736
  name={resetButtonName}
724
737
  title="Reset"
725
738
  onClick={resetValue}
739
+ disabled={readOnly}
726
740
  >
727
741
  <RefreshIcon />
728
742
  </button>
@@ -818,6 +832,8 @@ interface PrimitiveCollectionInstanceValueEditorProps<
818
832
  selectorConfig?: BasicValueSpecificationEditorSelectorConfig | undefined;
819
833
  errorChecker?: (valueSpecification: U) => boolean;
820
834
  className?: string | undefined;
835
+ lightMode?: boolean | undefined;
836
+ readOnly?: boolean | undefined;
821
837
  }
822
838
 
823
839
  const PrimitiveCollectionInstanceValueEditorInner = <
@@ -835,6 +851,8 @@ const PrimitiveCollectionInstanceValueEditorInner = <
835
851
  selectorSearchConfig,
836
852
  selectorConfig,
837
853
  expectedType,
854
+ lightMode,
855
+ readOnly,
838
856
  } = props;
839
857
 
840
858
  // local state and variables
@@ -1063,9 +1081,7 @@ const PrimitiveCollectionInstanceValueEditorInner = <
1063
1081
  onKeyDown={handleKeyDown}
1064
1082
  onPaste={handlePaste}
1065
1083
  value={selectedOptions}
1066
- darkMode={
1067
- !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
1068
- }
1084
+ darkMode={!lightMode}
1069
1085
  isLoading={isLoading}
1070
1086
  noMatchMessage={noMatchMessage}
1071
1087
  placeholder={getPlaceHolder(expectedType)}
@@ -1074,6 +1090,7 @@ const PrimitiveCollectionInstanceValueEditorInner = <
1074
1090
  }}
1075
1091
  inputName={inputName}
1076
1092
  optionCustomization={selectorConfig?.optionCustomization}
1093
+ disabled={readOnly}
1077
1094
  />
1078
1095
  <button
1079
1096
  className="value-spec-editor__list-editor__copy-button"
@@ -1089,6 +1106,7 @@ const PrimitiveCollectionInstanceValueEditorInner = <
1089
1106
  name="Save"
1090
1107
  title="Save"
1091
1108
  onClick={updateValueSpecAndSaveEdit}
1109
+ disabled={readOnly}
1092
1110
  >
1093
1111
  <SaveIcon />
1094
1112
  </button>
@@ -1119,6 +1137,8 @@ const EnumCollectionInstanceValueEditorInner = <T, U extends { values: T[] }>(
1119
1137
  expectedType,
1120
1138
  enumOptions,
1121
1139
  selectorConfig,
1140
+ lightMode,
1141
+ readOnly,
1122
1142
  } = props;
1123
1143
 
1124
1144
  guaranteeNonNullable(
@@ -1127,7 +1147,6 @@ const EnumCollectionInstanceValueEditorInner = <T, U extends { values: T[] }>(
1127
1147
  );
1128
1148
 
1129
1149
  // local state and variables
1130
- const applicationStore = useApplicationStore();
1131
1150
  const [inputValue, setInputValue] = useState('');
1132
1151
  const [inputValueIsError, setInputValueIsError] = useState(false);
1133
1152
  const [selectedOptions, setSelectedOptions] = useState<
@@ -1288,13 +1307,12 @@ const EnumCollectionInstanceValueEditorInner = <T, U extends { values: T[] }>(
1288
1307
  onKeyDown={handleKeyDown}
1289
1308
  onPaste={handlePaste}
1290
1309
  value={selectedOptions}
1291
- darkMode={
1292
- !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
1293
- }
1310
+ darkMode={!lightMode}
1294
1311
  placeholder="Add"
1295
1312
  menuIsOpen={true}
1296
1313
  inputName={inputName}
1297
1314
  optionCustomization={selectorConfig?.optionCustomization}
1315
+ disabled={readOnly}
1298
1316
  />
1299
1317
  <button
1300
1318
  className="value-spec-editor__list-editor__copy-button"
@@ -1310,6 +1328,7 @@ const EnumCollectionInstanceValueEditorInner = <T, U extends { values: T[] }>(
1310
1328
  name="Save"
1311
1329
  title="Save"
1312
1330
  onClick={updateValueSpecAndSaveEdit}
1331
+ disabled={readOnly}
1313
1332
  >
1314
1333
  <SaveIcon />
1315
1334
  </button>
@@ -1346,6 +1365,8 @@ const CollectionValueInstanceValueEditorInner = <T, U extends { values: T[] }>(
1346
1365
  selectorConfig,
1347
1366
  expectedType,
1348
1367
  enumOptions,
1368
+ lightMode,
1369
+ readOnly,
1349
1370
  } = props;
1350
1371
 
1351
1372
  const [editable, setEditable] = useState(false);
@@ -1384,6 +1405,8 @@ const CollectionValueInstanceValueEditorInner = <T, U extends { values: T[] }>(
1384
1405
  saveEdit={saveEdit}
1385
1406
  enumOptions={enumOptions}
1386
1407
  selectorConfig={selectorConfig}
1408
+ lightMode={lightMode}
1409
+ readOnly={readOnly}
1387
1410
  />
1388
1411
  ) : (
1389
1412
  <PrimitiveCollectionInstanceValueEditor<T, U>
@@ -1395,6 +1418,8 @@ const CollectionValueInstanceValueEditorInner = <T, U extends { values: T[] }>(
1395
1418
  saveEdit={saveEdit}
1396
1419
  selectorSearchConfig={selectorSearchConfig}
1397
1420
  selectorConfig={selectorConfig}
1421
+ lightMode={lightMode}
1422
+ readOnly={readOnly}
1398
1423
  />
1399
1424
  )}
1400
1425
  </div>
@@ -1404,8 +1429,9 @@ const CollectionValueInstanceValueEditorInner = <T, U extends { values: T[] }>(
1404
1429
  return (
1405
1430
  <div
1406
1431
  className={clsx('value-spec-editor', className)}
1407
- onClick={enableEdit}
1408
- title="Click to edit"
1432
+ onClick={readOnly ? () => {} : enableEdit}
1433
+ title={readOnly ? '' : 'Click to edit'}
1434
+ style={{ cursor: readOnly ? 'not-allowed' : '' }}
1409
1435
  >
1410
1436
  <div
1411
1437
  className={clsx('value-spec-editor__list-editor__preview', {
@@ -1457,6 +1483,7 @@ const DateInstanceValueEditorInner = <
1457
1483
  typeCheckOption,
1458
1484
  displayAsEditableValue,
1459
1485
  className,
1486
+ readOnly,
1460
1487
  } = props;
1461
1488
 
1462
1489
  return (
@@ -1472,6 +1499,7 @@ const DateInstanceValueEditorInner = <
1472
1499
  }
1473
1500
  handleBlur={handleBlur}
1474
1501
  displayAsEditableValue={displayAsEditableValue}
1502
+ readOnly={readOnly}
1475
1503
  />
1476
1504
  {!displayAsEditableValue && (
1477
1505
  <button
@@ -1479,6 +1507,7 @@ const DateInstanceValueEditorInner = <
1479
1507
  name="Reset"
1480
1508
  title="Reset"
1481
1509
  onClick={resetValue}
1510
+ disabled={readOnly}
1482
1511
  >
1483
1512
  <RefreshIcon />
1484
1513
  </button>
@@ -1521,6 +1550,7 @@ export const BasicValueSpecificationEditor = forwardRef<
1521
1550
  | ((event: React.KeyboardEvent<HTMLInputElement>) => void)
1522
1551
  | undefined;
1523
1552
  displayDateEditorAsEditableValue?: boolean | undefined;
1553
+ readOnly?: boolean | undefined;
1524
1554
  }
1525
1555
  >(function BasicValueSpecificationEditorInner(props, ref) {
1526
1556
  const {
@@ -1537,6 +1567,7 @@ export const BasicValueSpecificationEditor = forwardRef<
1537
1567
  handleBlur,
1538
1568
  handleKeyDown,
1539
1569
  displayDateEditorAsEditableValue,
1570
+ readOnly,
1540
1571
  } = props;
1541
1572
 
1542
1573
  const applicationStore = useApplicationStore();
@@ -1643,6 +1674,10 @@ export const BasicValueSpecificationEditor = forwardRef<
1643
1674
  }
1644
1675
  handleBlur={handleBlur}
1645
1676
  handleKeyDown={handleKeyDown}
1677
+ lightMode={
1678
+ applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
1679
+ }
1680
+ readOnly={readOnly}
1646
1681
  />
1647
1682
  );
1648
1683
  case PRIMITIVE_TYPE.BOOLEAN:
@@ -1653,6 +1688,7 @@ export const BasicValueSpecificationEditor = forwardRef<
1653
1688
  updateValueSpecification={updateValueSpecification}
1654
1689
  className={className}
1655
1690
  resetValue={resetValue}
1691
+ readOnly={readOnly}
1656
1692
  />
1657
1693
  );
1658
1694
  case PRIMITIVE_TYPE.NUMBER:
@@ -1673,6 +1709,7 @@ export const BasicValueSpecificationEditor = forwardRef<
1673
1709
  ref={ref}
1674
1710
  handleBlur={handleBlur}
1675
1711
  handleKeyDown={handleKeyDown}
1712
+ readOnly={readOnly}
1676
1713
  />
1677
1714
  );
1678
1715
  case PRIMITIVE_TYPE.DATE:
@@ -1695,6 +1732,7 @@ export const BasicValueSpecificationEditor = forwardRef<
1695
1732
  _valueSpecification instanceof PrimitiveInstanceValue &&
1696
1733
  errorChecker(_valueSpecification)
1697
1734
  }
1735
+ readOnly={readOnly}
1698
1736
  />
1699
1737
  );
1700
1738
  default:
@@ -1739,6 +1777,10 @@ export const BasicValueSpecificationEditor = forwardRef<
1739
1777
  }
1740
1778
  handleBlur={handleBlur}
1741
1779
  selectorConfig={selectorConfig}
1780
+ lightMode={
1781
+ applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
1782
+ }
1783
+ readOnly={readOnly}
1742
1784
  />
1743
1785
  );
1744
1786
  } else if (
@@ -1824,6 +1866,10 @@ export const BasicValueSpecificationEditor = forwardRef<
1824
1866
  }
1825
1867
  convertTextToValueSpecification={convertTextToValueSpecification}
1826
1868
  enumOptions={enumOptions}
1869
+ lightMode={
1870
+ applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
1871
+ }
1872
+ readOnly={readOnly}
1827
1873
  />
1828
1874
  );
1829
1875
  }
@@ -1851,6 +1897,7 @@ export const BasicValueSpecificationEditor = forwardRef<
1851
1897
  displayDateEditorAsEditableValue={displayDateEditorAsEditableValue}
1852
1898
  selectorSearchConfig={selectorSearchConfig}
1853
1899
  selectorConfig={selectorConfig}
1900
+ readOnly={readOnly}
1854
1901
  />
1855
1902
  );
1856
1903
  } else if (valueSpecification instanceof SimpleFunctionExpression) {
@@ -1868,6 +1915,7 @@ export const BasicValueSpecificationEditor = forwardRef<
1868
1915
  resetValue={resetValue}
1869
1916
  handleBlur={handleBlur}
1870
1917
  displayAsEditableValue={displayDateEditorAsEditableValue}
1918
+ readOnly={readOnly}
1871
1919
  />
1872
1920
  );
1873
1921
  } else {
@@ -1918,6 +1966,7 @@ export const BasicValueSpecificationEditor = forwardRef<
1918
1966
  ref={ref}
1919
1967
  handleBlur={handleBlur}
1920
1968
  handleKeyDown={handleKeyDown}
1969
+ readOnly={readOnly}
1921
1970
  />
1922
1971
  );
1923
1972
  }
@@ -1941,6 +1990,7 @@ export const EditableBasicValueSpecificationEditor = observer(
1941
1990
  selectorConfig?: BasicValueSpecificationEditorSelectorConfig | undefined;
1942
1991
  isConstant?: boolean;
1943
1992
  initializeAsEditable?: boolean;
1993
+ readOnly?: boolean;
1944
1994
  }) => {
1945
1995
  const {
1946
1996
  valueSpecification,
@@ -1953,6 +2003,7 @@ export const EditableBasicValueSpecificationEditor = observer(
1953
2003
  selectorConfig,
1954
2004
  isConstant,
1955
2005
  initializeAsEditable,
2006
+ readOnly,
1956
2007
  } = props;
1957
2008
  const applicationStore = useApplicationStore();
1958
2009
 
@@ -2006,6 +2057,7 @@ export const EditableBasicValueSpecificationEditor = observer(
2006
2057
  }
2007
2058
  }}
2008
2059
  displayDateEditorAsEditableValue={true}
2060
+ readOnly={readOnly}
2009
2061
  />
2010
2062
  ) : (
2011
2063
  <div className="value-spec-editor__editable__display">
@@ -2018,9 +2070,14 @@ export const EditableBasicValueSpecificationEditor = observer(
2018
2070
  !isValidInstanceValue(valueSpecification),
2019
2071
  },
2020
2072
  )}
2021
- onClick={() => {
2022
- setIsEditingValue(true);
2023
- }}
2073
+ onClick={
2074
+ readOnly
2075
+ ? () => {}
2076
+ : () => {
2077
+ setIsEditingValue(true);
2078
+ }
2079
+ }
2080
+ style={{ cursor: readOnly ? 'not-allowed' : '' }}
2024
2081
  >
2025
2082
  {`"${valueSpecStringValue !== undefined ? valueSpecStringValue : ''}"`}
2026
2083
  </span>
@@ -506,6 +506,7 @@ export const CustomDatePicker = <
506
506
  typeCheckOption,
507
507
  displayAsEditableValue,
508
508
  handleBlur,
509
+ readOnly,
509
510
  } = props;
510
511
  const applicationStore = useApplicationStore();
511
512
  // For some cases where types need to be matched strictly.
@@ -651,8 +652,11 @@ export const CustomDatePicker = <
651
652
  hasError,
652
653
  },
653
654
  )}
654
- title="Click to edit and pick from more date options"
655
- onClick={openCustomDatePickerPopover}
655
+ title={
656
+ readOnly ? '' : 'Click to edit and pick from more date options'
657
+ }
658
+ onClick={readOnly ? () => {} : openCustomDatePickerPopover}
659
+ style={{ cursor: readOnly ? 'not-allowed' : '' }}
656
660
  >
657
661
  {datePickerOption.label ? (
658
662
  `"${datePickerOption.label}"`
@@ -665,8 +669,11 @@ export const CustomDatePicker = <
665
669
  className={clsx('value-spec-editor__date-picker__trigger', {
666
670
  'value-spec-editor__date-picker__trigger--error': hasError,
667
671
  })}
668
- title="Click to edit and pick from more date options"
672
+ title={
673
+ readOnly ? '' : 'Click to edit and pick from more date options'
674
+ }
669
675
  onClick={openCustomDatePickerPopover}
676
+ disabled={readOnly}
670
677
  >
671
678
  {datePickerOption.label || 'Select value'}
672
679
  </button>
@@ -137,6 +137,8 @@ export const V1_BasicValueSpecificationEditor = forwardRef<
137
137
  | undefined;
138
138
  displayDateEditorAsEditableValue?: boolean | undefined;
139
139
  enumeration?: V1_Enumeration | undefined;
140
+ lightMode?: boolean | undefined;
141
+ readOnly?: boolean | undefined;
140
142
  }
141
143
  >(function V1_BasicValueSpecificationEditor(props, ref) {
142
144
  const {
@@ -150,11 +152,13 @@ export const V1_BasicValueSpecificationEditor = forwardRef<
150
152
  handleKeyDown,
151
153
  enumeration,
152
154
  selectorConfig,
155
+ lightMode,
156
+ readOnly,
153
157
  } = props;
154
158
 
155
159
  const applicationStore = useApplicationStore();
156
160
  const errorChecker = (_valueSpecification: V1_PrimitiveValueSpecification) =>
157
- !isValidV1_ValueSpecification(_valueSpecification);
161
+ !isValidV1_ValueSpecification(_valueSpecification, multiplicity);
158
162
 
159
163
  // Handle non-collection editors
160
164
  if (multiplicity.upperBound !== undefined) {
@@ -179,6 +183,8 @@ export const V1_BasicValueSpecificationEditor = forwardRef<
179
183
  handleKeyDown={handleKeyDown}
180
184
  errorChecker={errorChecker}
181
185
  selectorConfig={selectorConfig}
186
+ lightMode={lightMode}
187
+ readOnly={readOnly}
182
188
  />
183
189
  );
184
190
  } else if (
@@ -197,6 +203,7 @@ export const V1_BasicValueSpecificationEditor = forwardRef<
197
203
  }}
198
204
  className={className}
199
205
  resetValue={resetValue}
206
+ readOnly={readOnly}
200
207
  />
201
208
  );
202
209
  } else if (
@@ -235,6 +242,7 @@ export const V1_BasicValueSpecificationEditor = forwardRef<
235
242
  handleBlur={handleBlur}
236
243
  handleKeyDown={handleKeyDown}
237
244
  errorChecker={errorChecker}
245
+ readOnly={readOnly}
238
246
  />
239
247
  );
240
248
  } else if (
@@ -278,6 +286,7 @@ export const V1_BasicValueSpecificationEditor = forwardRef<
278
286
  resetValue={resetValue}
279
287
  className={className}
280
288
  errorChecker={errorChecker}
289
+ readOnly={readOnly}
281
290
  />
282
291
  );
283
292
  }
@@ -310,6 +319,8 @@ export const V1_BasicValueSpecificationEditor = forwardRef<
310
319
  handleBlur={handleBlur}
311
320
  errorChecker={errorChecker}
312
321
  selectorConfig={selectorConfig}
322
+ lightMode={lightMode}
323
+ readOnly={readOnly}
313
324
  />
314
325
  );
315
326
  }
@@ -383,6 +394,8 @@ export const V1_BasicValueSpecificationEditor = forwardRef<
383
394
  errorChecker={errorChecker}
384
395
  className={className}
385
396
  selectorConfig={selectorConfig}
397
+ lightMode={lightMode}
398
+ readOnly={readOnly}
386
399
  />
387
400
  );
388
401
  }
package/src/index.ts CHANGED
@@ -113,6 +113,8 @@ export * from './components/shared/LambdaParameterValuesEditor.js';
113
113
 
114
114
  export * from './components/shared/V1_BasicValueSpecificationEditor.js';
115
115
 
116
+ export * from './components/shared/CustomDatePickerHelper.js';
117
+
116
118
  export * from './stores/shared/ValueSpecificationModifierHelper.js';
117
119
  export * from './stores/shared/ValueSpecificationEditorHelper.js';
118
120
 
@@ -16,6 +16,7 @@
16
16
 
17
17
  import {
18
18
  type V1_ValueSpecification,
19
+ V1_AppliedFunction,
19
20
  V1_AppliedProperty,
20
21
  V1_CBoolean,
21
22
  V1_CByteArray,
@@ -29,6 +30,7 @@ import {
29
30
  V1_CStrictTime,
30
31
  V1_CString,
31
32
  V1_EnumValue,
33
+ V1_Multiplicity,
32
34
  V1_PrimitiveValueSpecification,
33
35
  } from '@finos/legend-graph';
34
36
  import { buildDatePickerOption } from '../../components/shared/CustomDatePickerHelper.js';
@@ -70,6 +72,8 @@ export const getV1_ValueSpecificationStringValue = (
70
72
  return valueSpecification.value.toString();
71
73
  } else if (valueSpecification instanceof V1_AppliedProperty) {
72
74
  return valueSpecification.property;
75
+ } else if (valueSpecification instanceof V1_AppliedFunction) {
76
+ return valueSpecification.function;
73
77
  } else if (valueSpecification instanceof V1_Collection) {
74
78
  return valueSpecification.values
75
79
  .map((valueSpec) =>
@@ -86,27 +90,41 @@ export const getV1_ValueSpecificationStringValue = (
86
90
 
87
91
  export const isValidV1_ValueSpecification = (
88
92
  valueSpecification: V1_ValueSpecification,
93
+ multiplicity: V1_Multiplicity,
89
94
  ): boolean => {
95
+ const isRequired = multiplicity.lowerBound >= 1;
90
96
  if (valueSpecification instanceof V1_PrimitiveValueSpecification) {
91
- const isRequired = valueSpecification.multiplicity.lowerBound >= 1;
92
97
  // required and no values provided. LatestDate doesn't have any values so we skip that check for it.
93
- if (
94
- isRequired &&
95
- (valueSpecification instanceof V1_CBoolean ||
98
+ if (isRequired) {
99
+ if (valueSpecification instanceof V1_CString) {
100
+ return valueSpecification.value.length > 0;
101
+ } else if (
102
+ valueSpecification instanceof V1_CBoolean ||
96
103
  valueSpecification instanceof V1_CByteArray ||
97
104
  valueSpecification instanceof V1_CDecimal ||
98
105
  valueSpecification instanceof V1_CFloat ||
99
106
  valueSpecification instanceof V1_CInteger ||
100
107
  valueSpecification instanceof V1_CStrictTime ||
101
- valueSpecification instanceof V1_CString ||
102
108
  valueSpecification instanceof V1_CDateTime ||
103
- valueSpecification instanceof V1_CStrictDate)
104
- ) {
105
- return true;
109
+ valueSpecification instanceof V1_CStrictDate
110
+ ) {
111
+ return true;
112
+ }
106
113
  }
114
+ } else if (valueSpecification instanceof V1_AppliedProperty && isRequired) {
115
+ return valueSpecification.property.length > 0;
107
116
  } else if (valueSpecification instanceof V1_Collection) {
117
+ // collection instance can't be empty if multiplicity lower bound is 1 or more.
118
+ if (
119
+ multiplicity.lowerBound >= 1 &&
120
+ valueSpecification.values.length === 0
121
+ ) {
122
+ return false;
123
+ }
108
124
  // collection instance must have all valid values.
109
- return valueSpecification.values.every(isValidV1_ValueSpecification);
125
+ return valueSpecification.values.every((val) =>
126
+ isValidV1_ValueSpecification(val, V1_Multiplicity.ONE),
127
+ );
110
128
  }
111
129
 
112
130
  return true;