@finos/legend-application-studio 13.0.2 → 13.1.1

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 (177) hide show
  1. package/lib/components/LegendStudioApplication.js +1 -1
  2. package/lib/components/LegendStudioApplication.js.map +1 -1
  3. package/lib/components/editor/command/project-search.css +1 -1
  4. package/lib/components/editor/command/project-search.css.map +1 -1
  5. package/lib/components/editor/command-center/ProjectSearchCommand.d.ts.map +1 -1
  6. package/lib/components/editor/command-center/ProjectSearchCommand.js +11 -3
  7. package/lib/components/editor/command-center/ProjectSearchCommand.js.map +1 -1
  8. package/lib/components/editor/edit-panel/FunctionEditor.d.ts.map +1 -1
  9. package/lib/components/editor/edit-panel/FunctionEditor.js +41 -34
  10. package/lib/components/editor/edit-panel/FunctionEditor.js.map +1 -1
  11. package/lib/components/editor/edit-panel/GenerationSpecificationEditor.d.ts.map +1 -1
  12. package/lib/components/editor/edit-panel/GenerationSpecificationEditor.js +35 -54
  13. package/lib/components/editor/edit-panel/GenerationSpecificationEditor.js.map +1 -1
  14. package/lib/components/editor/edit-panel/GrammarTextEditor.d.ts.map +1 -1
  15. package/lib/components/editor/edit-panel/GrammarTextEditor.js +2 -2
  16. package/lib/components/editor/edit-panel/GrammarTextEditor.js.map +1 -1
  17. package/lib/components/editor/edit-panel/RuntimeEditor.d.ts.map +1 -1
  18. package/lib/components/editor/edit-panel/RuntimeEditor.js +11 -20
  19. package/lib/components/editor/edit-panel/RuntimeEditor.js.map +1 -1
  20. package/lib/components/editor/edit-panel/data-editor/DataElementEditor.d.ts.map +1 -1
  21. package/lib/components/editor/edit-panel/data-editor/DataElementEditor.js +4 -8
  22. package/lib/components/editor/edit-panel/data-editor/DataElementEditor.js.map +1 -1
  23. package/lib/components/editor/edit-panel/data-editor/RelationalCSVDataEditor.js +1 -1
  24. package/lib/components/editor/edit-panel/data-editor/RelationalCSVDataEditor.js.map +1 -1
  25. package/lib/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.d.ts.map +1 -1
  26. package/lib/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.js +3 -7
  27. package/lib/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.js.map +1 -1
  28. package/lib/components/editor/edit-panel/external-format-editor/BindingElementEditor.d.ts.map +1 -1
  29. package/lib/components/editor/edit-panel/external-format-editor/BindingElementEditor.js +2 -2
  30. package/lib/components/editor/edit-panel/external-format-editor/BindingElementEditor.js.map +1 -1
  31. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.js +1 -1
  32. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.js.map +1 -1
  33. package/lib/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.d.ts.map +1 -1
  34. package/lib/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.js +2 -9
  35. package/lib/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.js.map +1 -1
  36. package/lib/components/editor/edit-panel/mapping-editor/FlatDataPropertyMappingEditor.d.ts.map +1 -1
  37. package/lib/components/editor/edit-panel/mapping-editor/FlatDataPropertyMappingEditor.js +3 -4
  38. package/lib/components/editor/edit-panel/mapping-editor/FlatDataPropertyMappingEditor.js.map +1 -1
  39. package/lib/components/editor/edit-panel/mapping-editor/InstanceSetImplementationEditor.d.ts.map +1 -1
  40. package/lib/components/editor/edit-panel/mapping-editor/InstanceSetImplementationEditor.js +3 -10
  41. package/lib/components/editor/edit-panel/mapping-editor/InstanceSetImplementationEditor.js.map +1 -1
  42. package/lib/components/editor/edit-panel/mapping-editor/MappingExecutionBuilder.d.ts.map +1 -1
  43. package/lib/components/editor/edit-panel/mapping-editor/MappingExecutionBuilder.js +4 -10
  44. package/lib/components/editor/edit-panel/mapping-editor/MappingExecutionBuilder.js.map +1 -1
  45. package/lib/components/editor/edit-panel/mapping-editor/MappingExplorer.js +7 -9
  46. package/lib/components/editor/edit-panel/mapping-editor/MappingExplorer.js.map +1 -1
  47. package/lib/components/editor/edit-panel/mapping-editor/MappingTestEditor.d.ts.map +1 -1
  48. package/lib/components/editor/edit-panel/mapping-editor/MappingTestEditor.js +3 -6
  49. package/lib/components/editor/edit-panel/mapping-editor/MappingTestEditor.js.map +1 -1
  50. package/lib/components/editor/edit-panel/mapping-editor/MappingTestsExplorer.d.ts.map +1 -1
  51. package/lib/components/editor/edit-panel/mapping-editor/MappingTestsExplorer.js +7 -8
  52. package/lib/components/editor/edit-panel/mapping-editor/MappingTestsExplorer.js.map +1 -1
  53. package/lib/components/editor/edit-panel/mapping-editor/NewMappingElementModal.js +2 -2
  54. package/lib/components/editor/edit-panel/mapping-editor/NewMappingElementModal.js.map +1 -1
  55. package/lib/components/editor/edit-panel/mapping-editor/OperationSetImplementationEditor.d.ts.map +1 -1
  56. package/lib/components/editor/edit-panel/mapping-editor/OperationSetImplementationEditor.js +5 -7
  57. package/lib/components/editor/edit-panel/mapping-editor/OperationSetImplementationEditor.js.map +1 -1
  58. package/lib/components/editor/edit-panel/mapping-editor/PurePropertyMappingEditor.d.ts.map +1 -1
  59. package/lib/components/editor/edit-panel/mapping-editor/PurePropertyMappingEditor.js +3 -4
  60. package/lib/components/editor/edit-panel/mapping-editor/PurePropertyMappingEditor.js.map +1 -1
  61. package/lib/components/editor/edit-panel/mapping-editor/relational/RelationalPropertyMappingEditor.d.ts.map +1 -1
  62. package/lib/components/editor/edit-panel/mapping-editor/relational/RelationalPropertyMappingEditor.js +1 -1
  63. package/lib/components/editor/edit-panel/mapping-editor/relational/RelationalPropertyMappingEditor.js.map +1 -1
  64. package/lib/components/editor/edit-panel/service-editor/ServiceExecutionEditor.d.ts.map +1 -1
  65. package/lib/components/editor/edit-panel/service-editor/ServiceExecutionEditor.js +3 -5
  66. package/lib/components/editor/edit-panel/service-editor/ServiceExecutionEditor.js.map +1 -1
  67. package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.js +1 -1
  68. package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.js.map +1 -1
  69. package/lib/components/editor/edit-panel/uml-editor/AssociationEditor.d.ts.map +1 -1
  70. package/lib/components/editor/edit-panel/uml-editor/AssociationEditor.js +4 -8
  71. package/lib/components/editor/edit-panel/uml-editor/AssociationEditor.js.map +1 -1
  72. package/lib/components/editor/edit-panel/uml-editor/ClassEditor.d.ts.map +1 -1
  73. package/lib/components/editor/edit-panel/uml-editor/ClassEditor.js +157 -57
  74. package/lib/components/editor/edit-panel/uml-editor/ClassEditor.js.map +1 -1
  75. package/lib/components/editor/edit-panel/uml-editor/EnumerationEditor.d.ts.map +1 -1
  76. package/lib/components/editor/edit-panel/uml-editor/EnumerationEditor.js +39 -21
  77. package/lib/components/editor/edit-panel/uml-editor/EnumerationEditor.js.map +1 -1
  78. package/lib/components/editor/edit-panel/uml-editor/ProfileEditor.d.ts.map +1 -1
  79. package/lib/components/editor/edit-panel/uml-editor/ProfileEditor.js +62 -9
  80. package/lib/components/editor/edit-panel/uml-editor/ProfileEditor.js.map +1 -1
  81. package/lib/components/editor/edit-panel/uml-editor/PropertyEditor.d.ts.map +1 -1
  82. package/lib/components/editor/edit-panel/uml-editor/PropertyEditor.js +4 -8
  83. package/lib/components/editor/edit-panel/uml-editor/PropertyEditor.js.map +1 -1
  84. package/lib/components/editor/edit-panel/uml-editor/StereotypeSelector.d.ts +7 -1
  85. package/lib/components/editor/edit-panel/uml-editor/StereotypeSelector.d.ts.map +1 -1
  86. package/lib/components/editor/edit-panel/uml-editor/StereotypeSelector.js +33 -5
  87. package/lib/components/editor/edit-panel/uml-editor/StereotypeSelector.js.map +1 -1
  88. package/lib/components/editor/edit-panel/uml-editor/TaggedValueEditor.d.ts +7 -1
  89. package/lib/components/editor/edit-panel/uml-editor/TaggedValueEditor.d.ts.map +1 -1
  90. package/lib/components/editor/edit-panel/uml-editor/TaggedValueEditor.js +35 -7
  91. package/lib/components/editor/edit-panel/uml-editor/TaggedValueEditor.js.map +1 -1
  92. package/lib/components/editor/side-bar/CreateNewElementModal.d.ts.map +1 -1
  93. package/lib/components/editor/side-bar/CreateNewElementModal.js +4 -4
  94. package/lib/components/editor/side-bar/CreateNewElementModal.js.map +1 -1
  95. package/lib/components/editor/side-bar/Explorer.d.ts.map +1 -1
  96. package/lib/components/editor/side-bar/Explorer.js +8 -15
  97. package/lib/components/editor/side-bar/Explorer.js.map +1 -1
  98. package/lib/components/shared/StudioLambdaEditor.d.ts +1 -0
  99. package/lib/components/shared/StudioLambdaEditor.d.ts.map +1 -1
  100. package/lib/components/shared/StudioLambdaEditor.js +2 -2
  101. package/lib/components/shared/StudioLambdaEditor.js.map +1 -1
  102. package/lib/index.css +2 -2
  103. package/lib/index.css.map +1 -1
  104. package/lib/package.json +5 -5
  105. package/lib/stores/EditorStore.d.ts.map +1 -1
  106. package/lib/stores/EditorStore.js +7 -7
  107. package/lib/stores/EditorStore.js.map +1 -1
  108. package/lib/stores/LegendStudioBaseStore.d.ts +3 -8
  109. package/lib/stores/LegendStudioBaseStore.d.ts.map +1 -1
  110. package/lib/stores/LegendStudioBaseStore.js +9 -105
  111. package/lib/stores/LegendStudioBaseStore.js.map +1 -1
  112. package/lib/stores/editor/NewElementState.d.ts.map +1 -1
  113. package/lib/stores/editor/NewElementState.js +8 -2
  114. package/lib/stores/editor/NewElementState.js.map +1 -1
  115. package/lib/stores/editor-state/GenerationSpecificationEditorState.d.ts +0 -2
  116. package/lib/stores/editor-state/GenerationSpecificationEditorState.d.ts.map +1 -1
  117. package/lib/stores/editor-state/GenerationSpecificationEditorState.js +1 -8
  118. package/lib/stores/editor-state/GenerationSpecificationEditorState.js.map +1 -1
  119. package/lib/stores/editor-state/element-editor-state/ElementEditorState.d.ts.map +1 -1
  120. package/lib/stores/editor-state/element-editor-state/ElementEditorState.js +2 -4
  121. package/lib/stores/editor-state/element-editor-state/ElementEditorState.js.map +1 -1
  122. package/lib/stores/editor-state/element-editor-state/mapping/MappingEditorState.js +1 -1
  123. package/lib/stores/editor-state/element-editor-state/mapping/MappingEditorState.js.map +1 -1
  124. package/lib/stores/editor-state/element-editor-state/mapping/MappingExecutionState.js +1 -1
  125. package/lib/stores/editor-state/element-editor-state/mapping/MappingExecutionState.js.map +1 -1
  126. package/lib/stores/graphModifier/DomainGraphModifierHelper.d.ts +10 -0
  127. package/lib/stores/graphModifier/DomainGraphModifierHelper.d.ts.map +1 -1
  128. package/lib/stores/graphModifier/DomainGraphModifierHelper.js +31 -1
  129. package/lib/stores/graphModifier/DomainGraphModifierHelper.js.map +1 -1
  130. package/lib/stores/shared/DnDUtil.d.ts +1 -2
  131. package/lib/stores/shared/DnDUtil.d.ts.map +1 -1
  132. package/lib/stores/shared/DnDUtil.js +0 -2
  133. package/lib/stores/shared/DnDUtil.js.map +1 -1
  134. package/package.json +13 -13
  135. package/src/components/LegendStudioApplication.tsx +2 -2
  136. package/src/components/editor/command-center/ProjectSearchCommand.tsx +13 -2
  137. package/src/components/editor/edit-panel/FunctionEditor.tsx +220 -152
  138. package/src/components/editor/edit-panel/GenerationSpecificationEditor.tsx +154 -184
  139. package/src/components/editor/edit-panel/GrammarTextEditor.tsx +4 -5
  140. package/src/components/editor/edit-panel/RuntimeEditor.tsx +89 -90
  141. package/src/components/editor/edit-panel/data-editor/DataElementEditor.tsx +57 -40
  142. package/src/components/editor/edit-panel/data-editor/RelationalCSVDataEditor.tsx +1 -1
  143. package/src/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.tsx +50 -45
  144. package/src/components/editor/edit-panel/external-format-editor/BindingElementEditor.tsx +36 -32
  145. package/src/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.tsx +1 -1
  146. package/src/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.tsx +46 -41
  147. package/src/components/editor/edit-panel/mapping-editor/FlatDataPropertyMappingEditor.tsx +9 -7
  148. package/src/components/editor/edit-panel/mapping-editor/InstanceSetImplementationEditor.tsx +18 -21
  149. package/src/components/editor/edit-panel/mapping-editor/MappingExecutionBuilder.tsx +39 -29
  150. package/src/components/editor/edit-panel/mapping-editor/MappingExplorer.tsx +39 -39
  151. package/src/components/editor/edit-panel/mapping-editor/MappingTestEditor.tsx +23 -15
  152. package/src/components/editor/edit-panel/mapping-editor/MappingTestsExplorer.tsx +40 -38
  153. package/src/components/editor/edit-panel/mapping-editor/NewMappingElementModal.tsx +2 -2
  154. package/src/components/editor/edit-panel/mapping-editor/OperationSetImplementationEditor.tsx +48 -45
  155. package/src/components/editor/edit-panel/mapping-editor/PurePropertyMappingEditor.tsx +12 -8
  156. package/src/components/editor/edit-panel/mapping-editor/relational/RelationalPropertyMappingEditor.tsx +2 -3
  157. package/src/components/editor/edit-panel/service-editor/ServiceExecutionEditor.tsx +75 -72
  158. package/src/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.tsx +1 -1
  159. package/src/components/editor/edit-panel/uml-editor/AssociationEditor.tsx +55 -38
  160. package/src/components/editor/edit-panel/uml-editor/ClassEditor.tsx +813 -499
  161. package/src/components/editor/edit-panel/uml-editor/EnumerationEditor.tsx +209 -113
  162. package/src/components/editor/edit-panel/uml-editor/ProfileEditor.tsx +184 -52
  163. package/src/components/editor/edit-panel/uml-editor/PropertyEditor.tsx +62 -39
  164. package/src/components/editor/edit-panel/uml-editor/StereotypeSelector.tsx +137 -52
  165. package/src/components/editor/edit-panel/uml-editor/TaggedValueEditor.tsx +171 -88
  166. package/src/components/editor/side-bar/CreateNewElementModal.tsx +4 -2
  167. package/src/components/editor/side-bar/Explorer.tsx +13 -20
  168. package/src/components/shared/StudioLambdaEditor.tsx +3 -0
  169. package/src/stores/EditorStore.ts +7 -6
  170. package/src/stores/LegendStudioBaseStore.ts +20 -147
  171. package/src/stores/editor/NewElementState.ts +8 -2
  172. package/src/stores/editor-state/GenerationSpecificationEditorState.ts +1 -15
  173. package/src/stores/editor-state/element-editor-state/ElementEditorState.ts +2 -3
  174. package/src/stores/editor-state/element-editor-state/mapping/MappingEditorState.ts +1 -1
  175. package/src/stores/editor-state/element-editor-state/mapping/MappingExecutionState.ts +1 -1
  176. package/src/stores/graphModifier/DomainGraphModifierHelper.ts +92 -0
  177. package/src/stores/shared/DnDUtil.ts +0 -2
@@ -26,15 +26,19 @@ import {
26
26
  PlusIcon,
27
27
  TimesIcon,
28
28
  LockIcon,
29
+ PanelEntryDragHandle,
30
+ PanelEntryDropZonePlaceholder,
31
+ DragPreviewLayer,
32
+ useDragPreviewLayer,
29
33
  } from '@finos/legend-art';
30
34
  import { LEGEND_STUDIO_TEST_ID } from '../../../LegendStudioTestID.js';
31
35
  import { useEditorStore } from '../../EditorStoreProvider.js';
32
36
  import {
33
37
  type Profile,
34
- type Tag,
35
38
  type Stereotype,
36
39
  stub_Tag,
37
40
  stub_Stereotype,
41
+ type Tag,
38
42
  } from '@finos/legend-graph';
39
43
  import {
40
44
  profile_addTag,
@@ -42,55 +46,122 @@ import {
42
46
  profile_deleteTag,
43
47
  profile_deleteStereotype,
44
48
  tagStereotype_setValue,
49
+ profile_swapTags,
50
+ profile_swapStereotypes,
45
51
  } from '../../../../stores/graphModifier/DomainGraphModifierHelper.js';
46
52
  import { useApplicationNavigationContext } from '@finos/legend-application';
47
53
  import { LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY } from '../../../../stores/LegendStudioApplicationNavigationContext.js';
54
+ import { useRef, useCallback } from 'react';
55
+ import { useDrop, useDrag } from 'react-dnd';
56
+
57
+ type TagDragSource = {
58
+ tag: Tag;
59
+ };
60
+
61
+ const TAG_DND_TYPE = 'TAG';
48
62
 
49
63
  const TagBasicEditor = observer(
50
- (props: { tag: Tag; deleteValue: () => void; isReadOnly: boolean }) => {
51
- const { tag, deleteValue, isReadOnly } = props;
64
+ (props: {
65
+ tag: Tag;
66
+ deleteValue: () => void;
67
+ _profile: Profile;
68
+ isReadOnly: boolean;
69
+ }) => {
70
+ const ref = useRef<HTMLDivElement>(null);
71
+ const { tag, _profile, deleteValue, isReadOnly } = props;
52
72
  const changeValue: React.ChangeEventHandler<HTMLInputElement> = (event) => {
53
73
  tagStereotype_setValue(tag, event.target.value);
54
74
  };
55
75
  const isTagDuplicated = (val: Tag): boolean =>
56
76
  tag._OWNER.p_tags.filter((t) => t.value === val.value).length >= 2;
57
77
 
78
+ // Drag and Drop
79
+ const handleHover = useCallback(
80
+ (item: TagDragSource): void => {
81
+ const draggingTag = item.tag;
82
+ const hoveredTag = tag;
83
+ profile_swapTags(_profile, draggingTag, hoveredTag);
84
+ },
85
+ [_profile, tag],
86
+ );
87
+
88
+ const [{ isBeingDraggedTag }, dropConnector] = useDrop<
89
+ TagDragSource,
90
+ void,
91
+ { isBeingDraggedTag: Tag | undefined }
92
+ >(
93
+ () => ({
94
+ accept: [TAG_DND_TYPE],
95
+ hover: (item) => handleHover(item),
96
+ collect: (monitor) => ({
97
+ isBeingDraggedTag: monitor.getItem<TagDragSource | null>()?.tag,
98
+ }),
99
+ }),
100
+ [handleHover],
101
+ );
102
+ const isBeingDragged = tag === isBeingDraggedTag;
103
+
104
+ const [, dragConnector, dragPreviewConnector] = useDrag<TagDragSource>(
105
+ () => ({
106
+ type: TAG_DND_TYPE,
107
+ item: () => ({
108
+ tag: tag,
109
+ }),
110
+ }),
111
+ [tag],
112
+ );
113
+ dragConnector(dropConnector(ref));
114
+ useDragPreviewLayer(dragPreviewConnector);
115
+
58
116
  return (
59
- <div className="tag-basic-editor">
60
- <InputWithInlineValidation
61
- className="tag-basic-editor__value input-group__input"
62
- spellCheck={false}
63
- disabled={isReadOnly}
64
- value={tag.value}
65
- onChange={changeValue}
66
- placeholder={`Tag value`}
67
- validationErrorMessage={
68
- isTagDuplicated(tag) ? 'Duplicated tag' : undefined
69
- }
70
- />
71
- {!isReadOnly && (
72
- <button
73
- className="uml-element-editor__remove-btn"
74
- disabled={isReadOnly}
75
- onClick={deleteValue}
76
- tabIndex={-1}
77
- title={'Remove'}
78
- >
79
- <TimesIcon />
80
- </button>
81
- )}
117
+ <div ref={ref} className="tag-basic-editor__container">
118
+ <PanelEntryDropZonePlaceholder showPlaceholder={isBeingDragged}>
119
+ <div className="tag-basic-editor">
120
+ <PanelEntryDragHandle />
121
+ <InputWithInlineValidation
122
+ className="tag-basic-editor__value input-group__input"
123
+ spellCheck={false}
124
+ disabled={isReadOnly}
125
+ value={tag.value}
126
+ onChange={changeValue}
127
+ placeholder={`Tag value`}
128
+ validationErrorMessage={
129
+ isTagDuplicated(tag) ? 'Duplicated tag' : undefined
130
+ }
131
+ />
132
+ {!isReadOnly && (
133
+ <button
134
+ className="uml-element-editor__remove-btn"
135
+ disabled={isReadOnly}
136
+ onClick={deleteValue}
137
+ tabIndex={-1}
138
+ title={'Remove'}
139
+ >
140
+ <TimesIcon />
141
+ </button>
142
+ )}
143
+ </div>
144
+ </PanelEntryDropZonePlaceholder>
82
145
  </div>
83
146
  );
84
147
  },
85
148
  );
86
149
 
150
+ type StereotypeDragSource = {
151
+ stereotype: Stereotype;
152
+ };
153
+
154
+ const STEREOTYPE_DND_TYPE = 'STEREOTYPE';
155
+
87
156
  const StereotypeBasicEditor = observer(
88
157
  (props: {
89
158
  stereotype: Stereotype;
90
159
  deleteStereotype: () => void;
160
+ _profile: Profile;
91
161
  isReadOnly: boolean;
92
162
  }) => {
93
- const { stereotype, deleteStereotype, isReadOnly } = props;
163
+ const ref = useRef<HTMLDivElement>(null);
164
+ const { stereotype, _profile, deleteStereotype, isReadOnly } = props;
94
165
  const changeValue: React.ChangeEventHandler<HTMLInputElement> = (event) => {
95
166
  tagStereotype_setValue(stereotype, event.target.value);
96
167
  };
@@ -98,32 +169,77 @@ const StereotypeBasicEditor = observer(
98
169
  stereotype._OWNER.p_stereotypes.filter((s) => s.value === val.value)
99
170
  .length >= 2;
100
171
 
172
+ // Drag and Drop
173
+ const handleHover = useCallback(
174
+ (item: StereotypeDragSource): void => {
175
+ const draggingTag = item.stereotype;
176
+ const hoveredTag = stereotype;
177
+ profile_swapStereotypes(_profile, draggingTag, hoveredTag);
178
+ },
179
+ [_profile, stereotype],
180
+ );
181
+
182
+ const [{ isBeingDraggedTag }, dropConnector] = useDrop<
183
+ StereotypeDragSource,
184
+ void,
185
+ { isBeingDraggedTag: Tag | undefined }
186
+ >(
187
+ () => ({
188
+ accept: [STEREOTYPE_DND_TYPE],
189
+ hover: (item) => handleHover(item),
190
+ collect: (monitor) => ({
191
+ isBeingDraggedTag: monitor.getItem<StereotypeDragSource | null>()
192
+ ?.stereotype,
193
+ }),
194
+ }),
195
+ [handleHover],
196
+ );
197
+ const isBeingDragged = stereotype === isBeingDraggedTag;
198
+
199
+ const [, dragConnector, dragPreviewConnector] =
200
+ useDrag<StereotypeDragSource>(
201
+ () => ({
202
+ type: STEREOTYPE_DND_TYPE,
203
+ item: () => ({
204
+ stereotype: stereotype,
205
+ }),
206
+ }),
207
+ [stereotype],
208
+ );
209
+ dragConnector(dropConnector(ref));
210
+ useDragPreviewLayer(dragPreviewConnector);
211
+
101
212
  return (
102
- <div className="stereotype-basic-editor">
103
- <InputWithInlineValidation
104
- className="stereotype-basic-editor__value input-group__input"
105
- spellCheck={false}
106
- disabled={isReadOnly}
107
- value={stereotype.value}
108
- onChange={changeValue}
109
- placeholder={`Stereotype value`}
110
- validationErrorMessage={
111
- isStereotypeDuplicated(stereotype)
112
- ? 'Duplicated stereotype'
113
- : undefined
114
- }
115
- />
116
- {!isReadOnly && (
117
- <button
118
- className="uml-element-editor__remove-btn"
119
- disabled={isReadOnly}
120
- onClick={deleteStereotype}
121
- tabIndex={-1}
122
- title={'Remove'}
123
- >
124
- <TimesIcon />
125
- </button>
126
- )}
213
+ <div ref={ref} className="stereotype-basic-editor__container">
214
+ <PanelEntryDropZonePlaceholder showPlaceholder={isBeingDragged}>
215
+ <div className="stereotype-basic-editor">
216
+ <PanelEntryDragHandle />
217
+ <InputWithInlineValidation
218
+ className="stereotype-basic-editor__value input-group__input"
219
+ spellCheck={false}
220
+ disabled={isReadOnly}
221
+ value={stereotype.value}
222
+ onChange={changeValue}
223
+ placeholder={`Stereotype value`}
224
+ validationErrorMessage={
225
+ isStereotypeDuplicated(stereotype)
226
+ ? 'Duplicated stereotype'
227
+ : undefined
228
+ }
229
+ />
230
+ {!isReadOnly && (
231
+ <button
232
+ className="uml-element-editor__remove-btn"
233
+ disabled={isReadOnly}
234
+ onClick={deleteStereotype}
235
+ tabIndex={-1}
236
+ title={'Remove'}
237
+ >
238
+ <TimesIcon />
239
+ </button>
240
+ )}
241
+ </div>
242
+ </PanelEntryDropZonePlaceholder>
127
243
  </div>
128
244
  );
129
245
  },
@@ -221,10 +337,17 @@ export const ProfileEditor = observer((props: { profile: Profile }) => {
221
337
  <div className="panel__content">
222
338
  {selectedTab === UML_EDITOR_TAB.TAGS && (
223
339
  <div className="panel__content__lists">
340
+ <DragPreviewLayer
341
+ labelGetter={(item: TagDragSource): string =>
342
+ item.tag.value === '' ? '(unknown)' : item.tag.value
343
+ }
344
+ types={[TAG_DND_TYPE]}
345
+ />
224
346
  {profile.p_tags.map((tag) => (
225
347
  <TagBasicEditor
226
348
  key={tag._UUID}
227
349
  tag={tag}
350
+ _profile={profile}
228
351
  deleteValue={deleteTag(tag)}
229
352
  isReadOnly={isReadOnly}
230
353
  />
@@ -233,9 +356,18 @@ export const ProfileEditor = observer((props: { profile: Profile }) => {
233
356
  )}
234
357
  {selectedTab === UML_EDITOR_TAB.STEREOTYPES && (
235
358
  <div className="panel__content__lists">
359
+ <DragPreviewLayer
360
+ labelGetter={(item: StereotypeDragSource): string =>
361
+ item.stereotype.value === ''
362
+ ? '(unknown)'
363
+ : item.stereotype.value
364
+ }
365
+ types={[STEREOTYPE_DND_TYPE]}
366
+ />
236
367
  {profile.p_stereotypes.map((stereotype) => (
237
368
  <StereotypeBasicEditor
238
369
  key={stereotype._UUID}
370
+ _profile={profile}
239
371
  stereotype={stereotype}
240
372
  deleteStereotype={deleteStereotype(stereotype)}
241
373
  isReadOnly={isReadOnly}
@@ -22,9 +22,21 @@ import {
22
22
  type ElementDragSource,
23
23
  type UMLEditorElementDropTarget,
24
24
  } from '../../../../stores/shared/DnDUtil.js';
25
- import { clsx, LockIcon, PlusIcon, TimesIcon } from '@finos/legend-art';
26
- import { StereotypeSelector } from './StereotypeSelector.js';
27
- import { TaggedValueEditor } from './TaggedValueEditor.js';
25
+ import {
26
+ clsx,
27
+ LockIcon,
28
+ PanelDropZone,
29
+ PlusIcon,
30
+ TimesIcon,
31
+ } from '@finos/legend-art';
32
+ import {
33
+ StereotypeSelector,
34
+ StereotypeDragPreviewLayer,
35
+ } from './StereotypeSelector.js';
36
+ import {
37
+ TaggedValueDragPreviewLayer,
38
+ TaggedValueEditor,
39
+ } from './TaggedValueEditor.js';
28
40
  import { LEGEND_STUDIO_TEST_ID } from '../../../LegendStudioTestID.js';
29
41
  import { prettyCONSTName } from '@finos/legend-shared';
30
42
  import { UML_EDITOR_TAB } from '../../../../stores/editor-state/element-editor-state/UMLEditorState.js';
@@ -109,11 +121,15 @@ export const PropertyEditor = observer(
109
121
  },
110
122
  [isReadOnly, property],
111
123
  );
112
- const [{ isTaggedValueDragOver }, dropTaggedValueRef] = useDrop(
124
+ const [{ isTaggedValueDragOver }, dropTaggedValueRef] = useDrop<
125
+ ElementDragSource,
126
+ void,
127
+ { isTaggedValueDragOver: boolean }
128
+ >(
113
129
  () => ({
114
130
  accept: [CORE_DND_TYPE.PROJECT_EXPLORER_PROFILE],
115
- drop: (item: ElementDragSource): void => handleDropTaggedValue(item),
116
- collect: (monitor): { isTaggedValueDragOver: boolean } => ({
131
+ drop: (item) => handleDropTaggedValue(item),
132
+ collect: (monitor) => ({
117
133
  isTaggedValueDragOver: monitor.isOver({ shallow: true }),
118
134
  }),
119
135
  }),
@@ -132,16 +148,21 @@ export const PropertyEditor = observer(
132
148
  },
133
149
  [isReadOnly, property],
134
150
  );
135
- const [{ isStereotypeDragOver }, dropStereotypeRef] = useDrop(
151
+ const [{ isStereotypeDragOver }, dropStereotypeRef] = useDrop<
152
+ ElementDragSource,
153
+ void,
154
+ { isStereotypeDragOver: boolean }
155
+ >(
136
156
  () => ({
137
157
  accept: [CORE_DND_TYPE.PROJECT_EXPLORER_PROFILE],
138
- drop: (item: ElementDragSource): void => handleDropStereotype(item),
139
- collect: (monitor): { isStereotypeDragOver: boolean } => ({
158
+ drop: (item) => handleDropStereotype(item),
159
+ collect: (monitor) => ({
140
160
  isStereotypeDragOver: monitor.isOver({ shallow: true }),
141
161
  }),
142
162
  }),
143
163
  [handleDropStereotype],
144
164
  );
165
+
145
166
  return (
146
167
  <div className="uml-element-editor property-editor">
147
168
  <div data-testid={LEGEND_STUDIO_TEST_ID.PANEL} className="panel">
@@ -196,40 +217,42 @@ export const PropertyEditor = observer(
196
217
  </div>
197
218
  <div className="panel__content">
198
219
  {selectedTab === UML_EDITOR_TAB.TAGGED_VALUES && (
199
- <div
200
- ref={dropTaggedValueRef}
201
- className={clsx('panel__content__lists', {
202
- 'panel__content__lists--dnd-over':
203
- isTaggedValueDragOver && !isReadOnly,
204
- })}
220
+ <PanelDropZone
221
+ isDragOver={isTaggedValueDragOver && !isReadOnly}
222
+ dropTargetConnector={dropTaggedValueRef}
205
223
  >
206
- {property.taggedValues.map((taggedValue) => (
207
- <TaggedValueEditor
208
- key={taggedValue._UUID}
209
- taggedValue={taggedValue}
210
- deleteValue={_deleteTaggedValue(taggedValue)}
211
- isReadOnly={isReadOnly}
212
- />
213
- ))}
214
- </div>
224
+ <div className="panel__content__lists">
225
+ <TaggedValueDragPreviewLayer />
226
+ {property.taggedValues.map((taggedValue) => (
227
+ <TaggedValueEditor
228
+ annotatedElement={property}
229
+ key={taggedValue._UUID}
230
+ taggedValue={taggedValue}
231
+ deleteValue={_deleteTaggedValue(taggedValue)}
232
+ isReadOnly={isReadOnly}
233
+ />
234
+ ))}
235
+ </div>
236
+ </PanelDropZone>
215
237
  )}
216
238
  {selectedTab === UML_EDITOR_TAB.STEREOTYPES && (
217
- <div
218
- ref={dropStereotypeRef}
219
- className={clsx('panel__content__lists', {
220
- 'panel__content__lists--dnd-over':
221
- isStereotypeDragOver && !isReadOnly,
222
- })}
239
+ <PanelDropZone
240
+ isDragOver={isStereotypeDragOver && !isReadOnly}
241
+ dropTargetConnector={dropStereotypeRef}
223
242
  >
224
- {property.stereotypes.map((stereotype) => (
225
- <StereotypeSelector
226
- key={stereotype.value._UUID}
227
- stereotype={stereotype}
228
- deleteStereotype={_deleteStereotype(stereotype)}
229
- isReadOnly={isReadOnly}
230
- />
231
- ))}
232
- </div>
243
+ <div className="panel__content__lists">
244
+ <StereotypeDragPreviewLayer />
245
+ {property.stereotypes.map((stereotype) => (
246
+ <StereotypeSelector
247
+ key={stereotype.value._UUID}
248
+ annotatedElement={property}
249
+ stereotype={stereotype}
250
+ deleteStereotype={_deleteStereotype(stereotype)}
251
+ isReadOnly={isReadOnly}
252
+ />
253
+ ))}
254
+ </div>
255
+ </PanelDropZone>
233
256
  )}
234
257
  </div>
235
258
  </div>