@finos/legend-query-builder 4.14.72 → 4.14.74

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. package/lib/components/explorer/QueryBuilderPropertySearchPanel.d.ts.map +1 -1
  2. package/lib/components/explorer/QueryBuilderPropertySearchPanel.js +108 -36
  3. package/lib/components/explorer/QueryBuilderPropertySearchPanel.js.map +1 -1
  4. package/lib/components/result/QueryBuilderResultPanel.d.ts.map +1 -1
  5. package/lib/components/result/QueryBuilderResultPanel.js +29 -9
  6. package/lib/components/result/QueryBuilderResultPanel.js.map +1 -1
  7. package/lib/index.css +1 -17
  8. package/lib/index.css.map +1 -1
  9. package/lib/package.json +1 -1
  10. package/lib/stores/QueryBuilderConfig.d.ts +2 -1
  11. package/lib/stores/QueryBuilderConfig.d.ts.map +1 -1
  12. package/lib/stores/QueryBuilderConfig.js +2 -1
  13. package/lib/stores/QueryBuilderConfig.js.map +1 -1
  14. package/lib/stores/QueryBuilderResultState.d.ts.map +1 -1
  15. package/lib/stores/QueryBuilderResultState.js +4 -1
  16. package/lib/stores/QueryBuilderResultState.js.map +1 -1
  17. package/lib/stores/explorer/QueryBuilderExplorerState.d.ts +4 -3
  18. package/lib/stores/explorer/QueryBuilderExplorerState.d.ts.map +1 -1
  19. package/lib/stores/explorer/QueryBuilderExplorerState.js +22 -7
  20. package/lib/stores/explorer/QueryBuilderExplorerState.js.map +1 -1
  21. package/lib/stores/explorer/QueryBuilderFuzzySearchAdvancedConfigState.d.ts.map +1 -1
  22. package/lib/stores/explorer/QueryBuilderFuzzySearchAdvancedConfigState.js +1 -1
  23. package/lib/stores/explorer/QueryBuilderFuzzySearchAdvancedConfigState.js.map +1 -1
  24. package/lib/stores/explorer/QueryBuilderPropertySearchState.d.ts +7 -1
  25. package/lib/stores/explorer/QueryBuilderPropertySearchState.d.ts.map +1 -1
  26. package/lib/stores/explorer/QueryBuilderPropertySearchState.js +160 -74
  27. package/lib/stores/explorer/QueryBuilderPropertySearchState.js.map +1 -1
  28. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts.map +1 -1
  29. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js +1 -1
  30. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js.map +1 -1
  31. package/lib/stores/filter/QueryBuilderFilterState.d.ts +1 -1
  32. package/lib/stores/filter/QueryBuilderFilterState.d.ts.map +1 -1
  33. package/lib/stores/filter/QueryBuilderFilterState.js +1 -1
  34. package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
  35. package/package.json +3 -3
  36. package/src/components/explorer/QueryBuilderPropertySearchPanel.tsx +249 -226
  37. package/src/components/result/QueryBuilderResultPanel.tsx +75 -16
  38. package/src/stores/QueryBuilderConfig.ts +2 -1
  39. package/src/stores/QueryBuilderResultState.ts +4 -0
  40. package/src/stores/explorer/QueryBuilderExplorerState.ts +58 -5
  41. package/src/stores/explorer/QueryBuilderFuzzySearchAdvancedConfigState.ts +1 -1
  42. package/src/stores/explorer/QueryBuilderPropertySearchState.ts +194 -92
  43. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.ts +4 -3
  44. package/src/stores/filter/QueryBuilderFilterState.ts +5 -4
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
+ import { useState } from 'react';
17
18
  import {
18
19
  clsx,
19
20
  CheckSquareIcon,
@@ -257,6 +258,7 @@ const QueryBuilderTreeNodeViewer = observer(
257
258
  node instanceof QueryBuilderExplorerTreePropertyNodeData
258
259
  ? { node }
259
260
  : {},
261
+ canDrag: () => !(node.type instanceof Class),
260
262
  collect: (monitor) => ({
261
263
  isDragging: monitor.isDragging(),
262
264
  }),
@@ -312,9 +314,11 @@ const QueryBuilderTreeNodeViewer = observer(
312
314
  );
313
315
 
314
316
  const propertyName =
315
- parentNode instanceof QueryBuilderExplorerTreeSubTypeNodeData
316
- ? prettyPropertyNameForSubType(node.id, true)
317
- : prettyPropertyNameFromNodeId(node.id, true);
317
+ parentNode?.type instanceof Class && level > 1
318
+ ? prettyCONSTName(node.label)
319
+ : parentNode instanceof QueryBuilderExplorerTreeSubTypeNodeData
320
+ ? prettyPropertyNameForSubType(node.id, true)
321
+ : prettyPropertyNameFromNodeId(node.id, true);
318
322
 
319
323
  const nodeExpandIcon = isExpandable ? (
320
324
  node.isOpen ? (
@@ -345,6 +349,8 @@ const QueryBuilderTreeNodeViewer = observer(
345
349
  )
346
350
  : null;
347
351
 
352
+ const isMultiple = propertySearchState.isNodeMultiple(node);
353
+
348
354
  return (
349
355
  <>
350
356
  <div
@@ -377,6 +383,14 @@ const QueryBuilderTreeNodeViewer = observer(
377
383
  QUERY_BUILDER_PROPERTY_SEARCH_LABEL_TEXT_CLASS,
378
384
  node.id,
379
385
  )}
386
+ {isMultiple && (
387
+ <div
388
+ className="query-builder-explorer-tree__node__label__multiple"
389
+ title="Multiple values of this property can cause row explosion"
390
+ >
391
+ *
392
+ </div>
393
+ )}
380
394
  </div>
381
395
  <div className="tree-view__node__label query-builder-property-search-panel__node__doc">
382
396
  {formattedDocText}
@@ -434,21 +448,119 @@ const QueryBuilderTreeNodeViewer = observer(
434
448
  </div>
435
449
  </div>
436
450
  {node.isOpen &&
437
- getChildrenNodes().map((childNode) => (
438
- <QueryBuilderTreeNodeViewer
439
- key={`${node.id}>${childNode.id}`}
440
- node={childNode}
441
- queryBuilderState={queryBuilderState}
442
- level={level + 1}
443
- stepPaddingInRem={2}
444
- explorerState={queryBuilderState.explorerState}
445
- />
446
- ))}
451
+ getChildrenNodes()
452
+ .filter((childNode) =>
453
+ propertySearchState.isNodeIncludedInFilter(childNode),
454
+ )
455
+ .sort((nodeA, nodeB) => nodeA.label.localeCompare(nodeB.label))
456
+ .map((childNode) => (
457
+ <QueryBuilderTreeNodeViewer
458
+ key={`${node.id}>${childNode.id}`}
459
+ node={childNode}
460
+ queryBuilderState={queryBuilderState}
461
+ level={level + 1}
462
+ stepPaddingInRem={2}
463
+ explorerState={queryBuilderState.explorerState}
464
+ />
465
+ ))}
447
466
  </>
448
467
  );
449
468
  },
450
469
  );
451
470
 
471
+ const QueryBuilderSearchConfigToggleButton = observer(
472
+ (props: {
473
+ label: string;
474
+ enabled: boolean;
475
+ onClick: () => void;
476
+ showOnlyButton?: boolean;
477
+ onOnlyButtonClick?: (() => void) | undefined;
478
+ }) => {
479
+ const { label, enabled, onClick, showOnlyButton, onOnlyButtonClick } =
480
+ props;
481
+
482
+ const [isMouseOver, setIsMouseOver] = useState(false);
483
+
484
+ return (
485
+ <div
486
+ className="query-builder-property-search-panel__form__section__toggler__btn__container"
487
+ onMouseEnter={() => setIsMouseOver(true)}
488
+ onMouseLeave={() => setIsMouseOver(false)}
489
+ >
490
+ <button
491
+ className={clsx(
492
+ 'query-builder-property-search-panel__form__section__toggler__btn',
493
+ {
494
+ 'query-builder-property-search-panel__form__section__toggler__btn--toggled':
495
+ enabled,
496
+ },
497
+ )}
498
+ onClick={onClick}
499
+ tabIndex={-1}
500
+ >
501
+ {enabled ? <CheckSquareIcon /> : <SquareIcon />}
502
+ <div className="query-builder-property-search-panel__form__section__toggler__prompt">
503
+ {label}
504
+ </div>
505
+ </button>
506
+ {showOnlyButton && isMouseOver && (
507
+ <button
508
+ className="query-builder-property-search-panel__form__section__toggler__only-btn"
509
+ onClick={onOnlyButtonClick}
510
+ >
511
+ only
512
+ </button>
513
+ )}
514
+ </div>
515
+ );
516
+ },
517
+ );
518
+
519
+ const QueryBuilderSearchConfigToggleButtonGroup = observer(
520
+ (props: {
521
+ header: string;
522
+ headerTooltipText?: string;
523
+ buttons: {
524
+ label: string;
525
+ enabled: boolean;
526
+ onClick: () => void;
527
+ onOnlyButtonClick?: () => void;
528
+ }[];
529
+ }) => {
530
+ const { header, headerTooltipText, buttons } = props;
531
+
532
+ return (
533
+ <div className="query-builder-property-search-panel__form__section">
534
+ <div className="query-builder-property-search-panel__form__section__header__label">
535
+ {header}
536
+ {headerTooltipText && (
537
+ <Tooltip
538
+ TransitionProps={{
539
+ timeout: 0,
540
+ }}
541
+ title={<div>{headerTooltipText}</div>}
542
+ >
543
+ <div className="query-builder-property-search-panel__tagged-values__tooltip">
544
+ <InfoCircleIcon />
545
+ </div>
546
+ </Tooltip>
547
+ )}
548
+ </div>
549
+ {buttons.map(({ label, enabled, onClick, onOnlyButtonClick }) => (
550
+ <QueryBuilderSearchConfigToggleButton
551
+ key={label}
552
+ label={label}
553
+ enabled={enabled}
554
+ onClick={onClick}
555
+ showOnlyButton={buttons.length > 1}
556
+ onOnlyButtonClick={onOnlyButtonClick}
557
+ />
558
+ ))}
559
+ </div>
560
+ );
561
+ },
562
+ );
563
+
452
564
  export const QueryBuilderPropertySearchPanel = observer(
453
565
  (props: {
454
566
  queryBuilderState: QueryBuilderState;
@@ -568,234 +680,145 @@ export const QueryBuilderPropertySearchPanel = observer(
568
680
  />
569
681
  </div>
570
682
  </div>
571
- <div className="query-builder-property-search-panel__form__section">
572
- <div className="query-builder-property-search-panel__form__section__header__label">
573
- Documentation
574
- <Tooltip
575
- TransitionProps={{
576
- timeout: 0,
577
- }}
578
- title={
579
- <div>
580
- Include &quot;doc&quot; type tagged values in
581
- search results
582
- </div>
583
- }
584
- >
585
- <div className="query-builder-property-search-panel__tagged-values__tooltip">
586
- <InfoCircleIcon />
587
- </div>
588
- </Tooltip>
589
- </div>
590
- <div className="query-builder-property-search-panel__filter__element">
591
- <button
592
- className={clsx(
593
- 'query-builder-property-search-panel__form__section__toggler__btn',
594
- {
595
- 'query-builder-property-search-panel__form__section__toggler__btn--toggled':
596
- propertySearchState.searchConfigurationState
597
- .includeDocumentation,
598
- },
599
- )}
600
- onClick={handleToggleIncludeDocumentation}
601
- tabIndex={-1}
602
- >
603
- {propertySearchState.searchConfigurationState
604
- .includeDocumentation ? (
605
- <CheckSquareIcon />
606
- ) : (
607
- <SquareIcon />
608
- )}
609
- </button>
610
- <div className="query-builder-property-search-panel__form__section__toggler__prompt">
611
- Include
612
- </div>
613
- </div>
614
- </div>
615
- <div className="query-builder-property-search-panel__form__section">
616
- <div className="query-builder-property-search-panel__form__section__header__label">
617
- Sub-types
618
- </div>
619
- <div className="query-builder-property-search-panel__filter__element">
620
- <button
621
- className={clsx(
622
- 'query-builder-property-search-panel__form__section__toggler__btn',
623
- {
624
- 'query-builder-property-search-panel__form__section__toggler__btn--toggled':
625
- propertySearchState.searchConfigurationState
626
- .includeSubTypes,
627
- },
628
- )}
629
- onClick={handleToggleIncludeSubTypes}
630
- tabIndex={-1}
631
- >
632
- {propertySearchState.searchConfigurationState
633
- .includeSubTypes ? (
634
- <CheckSquareIcon />
635
- ) : (
636
- <SquareIcon />
637
- )}
638
- </button>
639
- <div className="query-builder-property-search-panel__form__section__toggler__prompt">
640
- Include
641
- </div>
642
- </div>
643
- </div>
644
- <div className="query-builder-property-search-panel__form__section">
645
- <div className="query-builder-property-search-panel__form__section__header__label">
646
- By type
647
- </div>
648
- <div className="query-builder-property-search-panel__filter__element">
649
- <button
650
- className={clsx(
651
- 'query-builder-property-search-panel__form__section__toggler__btn',
652
- {
653
- 'query-builder-property-search-panel__form__section__toggler__btn--toggled':
654
- propertySearchState.typeFilters.includes(
655
- QUERY_BUILDER_PROPERTY_SEARCH_TYPE.CLASS,
656
- ),
657
- },
658
- )}
659
- onClick={(): void => {
683
+ <QueryBuilderSearchConfigToggleButtonGroup
684
+ header="One-Many rows"
685
+ buttons={[
686
+ {
687
+ label: 'Include',
688
+ enabled: propertySearchState.includeOneMany,
689
+ onClick: () =>
690
+ propertySearchState.setIncludeOneMany(
691
+ !propertySearchState.includeOneMany,
692
+ ),
693
+ },
694
+ ]}
695
+ />
696
+ <QueryBuilderSearchConfigToggleButtonGroup
697
+ header="Documentation"
698
+ headerTooltipText={`Include "doc" type tagged values in search results`}
699
+ buttons={[
700
+ {
701
+ label: 'Include',
702
+ enabled:
703
+ propertySearchState.searchConfigurationState
704
+ .includeDocumentation,
705
+ onClick: handleToggleIncludeDocumentation,
706
+ },
707
+ ]}
708
+ />
709
+ <QueryBuilderSearchConfigToggleButtonGroup
710
+ header="Sub-types"
711
+ buttons={[
712
+ {
713
+ label: 'Include',
714
+ enabled:
715
+ propertySearchState.searchConfigurationState
716
+ .includeSubTypes,
717
+ onClick: handleToggleIncludeSubTypes,
718
+ },
719
+ ]}
720
+ />
721
+ <QueryBuilderSearchConfigToggleButtonGroup
722
+ header="By type"
723
+ buttons={[
724
+ {
725
+ label: 'Class',
726
+ enabled: propertySearchState.typeFilters.includes(
727
+ QUERY_BUILDER_PROPERTY_SEARCH_TYPE.CLASS,
728
+ ),
729
+ onClick: () => {
660
730
  propertySearchState.toggleFilterForType(
661
731
  QUERY_BUILDER_PROPERTY_SEARCH_TYPE.CLASS,
662
732
  );
663
- }}
664
- tabIndex={-1}
665
- >
666
- {propertySearchState.typeFilters.includes(
667
- QUERY_BUILDER_PROPERTY_SEARCH_TYPE.CLASS,
668
- ) ? (
669
- <CheckSquareIcon />
670
- ) : (
671
- <SquareIcon />
672
- )}
673
- </button>
674
- <div className="query-builder-property-search-panel__form__section__toggler__prompt">
675
- Class
676
- </div>
677
- </div>
678
- <div className="query-builder-property-search-panel__filter__element">
679
- <button
680
- className={clsx(
681
- 'query-builder-property-search-panel__form__section__toggler__btn',
682
- {
683
- 'query-builder-property-search-panel__form__section__toggler__btn--toggled':
684
- propertySearchState.typeFilters.includes(
685
- QUERY_BUILDER_PROPERTY_SEARCH_TYPE.STRING,
686
- ),
687
- },
688
- )}
689
- onClick={(): void => {
733
+ },
734
+ onOnlyButtonClick: () => {
735
+ propertySearchState.setFilterOnlyType(
736
+ QUERY_BUILDER_PROPERTY_SEARCH_TYPE.CLASS,
737
+ );
738
+ },
739
+ },
740
+ {
741
+ label: 'Enumeration',
742
+ enabled: propertySearchState.typeFilters.includes(
743
+ QUERY_BUILDER_PROPERTY_SEARCH_TYPE.ENUMERATION,
744
+ ),
745
+ onClick: () => {
690
746
  propertySearchState.toggleFilterForType(
691
- QUERY_BUILDER_PROPERTY_SEARCH_TYPE.STRING,
747
+ QUERY_BUILDER_PROPERTY_SEARCH_TYPE.ENUMERATION,
748
+ );
749
+ },
750
+ onOnlyButtonClick: () => {
751
+ propertySearchState.setFilterOnlyType(
752
+ QUERY_BUILDER_PROPERTY_SEARCH_TYPE.ENUMERATION,
692
753
  );
693
- }}
694
- tabIndex={-1}
695
- >
696
- {propertySearchState.typeFilters.includes(
754
+ },
755
+ },
756
+ {
757
+ label: 'String',
758
+ enabled: propertySearchState.typeFilters.includes(
697
759
  QUERY_BUILDER_PROPERTY_SEARCH_TYPE.STRING,
698
- ) ? (
699
- <CheckSquareIcon />
700
- ) : (
701
- <SquareIcon />
702
- )}
703
- </button>
704
- <div className="query-builder-property-search-panel__form__section__toggler__prompt">
705
- String
706
- </div>
707
- </div>
708
- <div className="query-builder-property-search-panel__filter__element">
709
- <button
710
- className={clsx(
711
- 'query-builder-property-search-panel__form__section__toggler__btn',
712
- {
713
- 'query-builder-property-search-panel__form__section__toggler__btn--toggled':
714
- propertySearchState.typeFilters.includes(
715
- QUERY_BUILDER_PROPERTY_SEARCH_TYPE.BOOLEAN,
716
- ),
717
- },
718
- )}
719
- onClick={(): void => {
760
+ ),
761
+ onClick: () => {
720
762
  propertySearchState.toggleFilterForType(
721
- QUERY_BUILDER_PROPERTY_SEARCH_TYPE.BOOLEAN,
763
+ QUERY_BUILDER_PROPERTY_SEARCH_TYPE.STRING,
764
+ );
765
+ },
766
+ onOnlyButtonClick: () => {
767
+ propertySearchState.setFilterOnlyType(
768
+ QUERY_BUILDER_PROPERTY_SEARCH_TYPE.STRING,
722
769
  );
723
- }}
724
- tabIndex={-1}
725
- >
726
- {propertySearchState.typeFilters.includes(
770
+ },
771
+ },
772
+ {
773
+ label: 'Boolean',
774
+ enabled: propertySearchState.typeFilters.includes(
727
775
  QUERY_BUILDER_PROPERTY_SEARCH_TYPE.BOOLEAN,
728
- ) ? (
729
- <CheckSquareIcon />
730
- ) : (
731
- <SquareIcon />
732
- )}
733
- </button>
734
- <div className="query-builder-property-search-panel__form__section__toggler__prompt">
735
- Boolean
736
- </div>
737
- </div>
738
- <div className="query-builder-property-search-panel__filter__element">
739
- <button
740
- className={clsx(
741
- 'query-builder-property-search-panel__form__section__toggler__btn',
742
- {
743
- 'query-builder-property-search-panel__form__section__toggler__btn--toggled':
744
- propertySearchState.typeFilters.includes(
745
- QUERY_BUILDER_PROPERTY_SEARCH_TYPE.NUMBER,
746
- ),
747
- },
748
- )}
749
- onClick={(): void => {
776
+ ),
777
+ onClick: () => {
750
778
  propertySearchState.toggleFilterForType(
751
- QUERY_BUILDER_PROPERTY_SEARCH_TYPE.NUMBER,
779
+ QUERY_BUILDER_PROPERTY_SEARCH_TYPE.BOOLEAN,
752
780
  );
753
- }}
754
- tabIndex={-1}
755
- >
756
- {propertySearchState.typeFilters.includes(
781
+ },
782
+ onOnlyButtonClick: () => {
783
+ propertySearchState.setFilterOnlyType(
784
+ QUERY_BUILDER_PROPERTY_SEARCH_TYPE.BOOLEAN,
785
+ );
786
+ },
787
+ },
788
+ {
789
+ label: 'Number',
790
+ enabled: propertySearchState.typeFilters.includes(
757
791
  QUERY_BUILDER_PROPERTY_SEARCH_TYPE.NUMBER,
758
- ) ? (
759
- <CheckSquareIcon />
760
- ) : (
761
- <SquareIcon />
762
- )}
763
- </button>
764
- <div className="query-builder-property-search-panel__form__section__toggler__prompt">
765
- Number
766
- </div>
767
- </div>
768
- <div className="query-builder-property-search-panel__filter__element">
769
- <button
770
- className={clsx(
771
- 'query-builder-property-search-panel__form__section__toggler__btn',
772
- {
773
- 'query-builder-property-search-panel__form__section__toggler__btn--toggled':
774
- propertySearchState.typeFilters.includes(
775
- QUERY_BUILDER_PROPERTY_SEARCH_TYPE.DATE,
776
- ),
777
- },
778
- )}
779
- onClick={(): void => {
792
+ ),
793
+ onClick: () => {
780
794
  propertySearchState.toggleFilterForType(
781
- QUERY_BUILDER_PROPERTY_SEARCH_TYPE.DATE,
795
+ QUERY_BUILDER_PROPERTY_SEARCH_TYPE.NUMBER,
796
+ );
797
+ },
798
+ onOnlyButtonClick: () => {
799
+ propertySearchState.setFilterOnlyType(
800
+ QUERY_BUILDER_PROPERTY_SEARCH_TYPE.NUMBER,
782
801
  );
783
- }}
784
- tabIndex={-1}
785
- >
786
- {propertySearchState.typeFilters.includes(
802
+ },
803
+ },
804
+ {
805
+ label: 'Date',
806
+ enabled: propertySearchState.typeFilters.includes(
787
807
  QUERY_BUILDER_PROPERTY_SEARCH_TYPE.DATE,
788
- ) ? (
789
- <CheckSquareIcon />
790
- ) : (
791
- <SquareIcon />
792
- )}
793
- </button>
794
- <div className="query-builder-property-search-panel__form__section__toggler__prompt">
795
- Date
796
- </div>
797
- </div>
798
- </div>
808
+ ),
809
+ onClick: () => {
810
+ propertySearchState.toggleFilterForType(
811
+ QUERY_BUILDER_PROPERTY_SEARCH_TYPE.DATE,
812
+ );
813
+ },
814
+ onOnlyButtonClick: () => {
815
+ propertySearchState.setFilterOnlyType(
816
+ QUERY_BUILDER_PROPERTY_SEARCH_TYPE.DATE,
817
+ );
818
+ },
819
+ },
820
+ ]}
821
+ />
799
822
  </div>
800
823
  </ResizablePanel>
801
824
  <ResizablePanelSplitter>