@bpmn-io/form-js-editor 1.4.0 → 1.4.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.
@@ -216,6 +216,17 @@
216
216
  display: none;
217
217
  }
218
218
 
219
+ .fjs-no-json-lint .cm-activeLine,
220
+ .fjs-no-json-lint .cm-activeLineGutter {
221
+ background: none;
222
+ }
223
+
224
+ .fjs-no-json-lint .cm-placeholder {
225
+ font-size: 12px;
226
+ line-height: 16px;
227
+ color: var(--cds-text-placeholder, var(--color-grey-225-10-35));
228
+ }
229
+
219
230
  .fjs-editor-container .fjs-form-editor {
220
231
  display: flex;
221
232
  flex: 1;
@@ -194,6 +194,17 @@
194
194
  display: none;
195
195
  }
196
196
 
197
+ .fjs-no-json-lint .cm-activeLine,
198
+ .fjs-no-json-lint .cm-activeLineGutter {
199
+ background: none;
200
+ }
201
+
202
+ .fjs-no-json-lint .cm-placeholder {
203
+ font-size: 12px;
204
+ line-height: 16px;
205
+ color: var(--cds-text-placeholder, var(--color-grey-225-10-35));
206
+ }
207
+
197
208
  .fjs-editor-container .fjs-form-editor {
198
209
  display: flex;
199
210
  flex: 1;
@@ -2052,6 +2063,8 @@ textarea.bio-properties-panel-input {
2052
2063
  .bio-properties-panel-popup .bio-properties-panel-popup__footer {
2053
2064
  padding: 12px;
2054
2065
  display: flex;
2066
+ justify-content: center;
2067
+ align-items: center;
2055
2068
  }
2056
2069
 
2057
2070
  .bio-properties-panel-popup .bio-properties-panel-popup__body:not(:first-child) {
@@ -2059,11 +2072,12 @@ textarea.bio-properties-panel-input {
2059
2072
  }
2060
2073
 
2061
2074
  .bio-properties-panel-popup .bio-properties-panel-popup__header {
2075
+ --popup-header-line-height: 16px;
2062
2076
  background-color: var(--popup-header-background-color);
2063
2077
  margin: 0;
2064
2078
  font-size: 12px;
2065
2079
  font-weight: 400;
2066
- line-height: 16px;
2080
+ line-height: var(--popup-header-line-height);
2067
2081
  text-align: left;
2068
2082
  color: var(--popup-title-color);
2069
2083
  }
@@ -2091,7 +2105,7 @@ textarea.bio-properties-panel-input {
2091
2105
  text-transform: capitalize;
2092
2106
  }
2093
2107
 
2094
- .bio-properties-panel-popup .bio-properties-panel-popup__header svg {
2108
+ .bio-properties-panel-popup .bio-properties-panel-popup__header .bio-properties-panel-popup__drag-handle svg {
2095
2109
  margin-left: -4px;
2096
2110
  }
2097
2111
 
@@ -2122,6 +2136,18 @@ textarea.bio-properties-panel-input {
2122
2136
  width: 100%;
2123
2137
  }
2124
2138
 
2139
+ .bio-properties-panel-feel-popup__title-link {
2140
+ margin-left: auto;
2141
+ display: flex;
2142
+ }
2143
+
2144
+ .bio-properties-panel-feel-popup__title-link svg {
2145
+ width: var(--popup-header-line-height);
2146
+ height: var(--popup-header-line-height);
2147
+ fill: currentColor;
2148
+ margin: 0 0.5em;
2149
+ }
2150
+
2125
2151
  .bio-properties-panel-feel-popup .bio-properties-panel-feel-editor-container {
2126
2152
  display: flex;
2127
2153
  min-width: 100%;
@@ -1271,6 +1271,8 @@ textarea.bio-properties-panel-input {
1271
1271
  .bio-properties-panel-popup .bio-properties-panel-popup__footer {
1272
1272
  padding: 12px;
1273
1273
  display: flex;
1274
+ justify-content: center;
1275
+ align-items: center;
1274
1276
  }
1275
1277
 
1276
1278
  .bio-properties-panel-popup .bio-properties-panel-popup__body:not(:first-child) {
@@ -1278,11 +1280,12 @@ textarea.bio-properties-panel-input {
1278
1280
  }
1279
1281
 
1280
1282
  .bio-properties-panel-popup .bio-properties-panel-popup__header {
1283
+ --popup-header-line-height: 16px;
1281
1284
  background-color: var(--popup-header-background-color);
1282
1285
  margin: 0;
1283
1286
  font-size: 12px;
1284
1287
  font-weight: 400;
1285
- line-height: 16px;
1288
+ line-height: var(--popup-header-line-height);
1286
1289
  text-align: left;
1287
1290
  color: var(--popup-title-color);
1288
1291
  }
@@ -1310,7 +1313,7 @@ textarea.bio-properties-panel-input {
1310
1313
  text-transform: capitalize;
1311
1314
  }
1312
1315
 
1313
- .bio-properties-panel-popup .bio-properties-panel-popup__header svg {
1316
+ .bio-properties-panel-popup .bio-properties-panel-popup__header .bio-properties-panel-popup__drag-handle svg {
1314
1317
  margin-left: -4px;
1315
1318
  }
1316
1319
 
@@ -1341,6 +1344,18 @@ textarea.bio-properties-panel-input {
1341
1344
  width: 100%;
1342
1345
  }
1343
1346
 
1347
+ .bio-properties-panel-feel-popup__title-link {
1348
+ margin-left: auto;
1349
+ display: flex;
1350
+ }
1351
+
1352
+ .bio-properties-panel-feel-popup__title-link svg {
1353
+ width: var(--popup-header-line-height);
1354
+ height: var(--popup-header-line-height);
1355
+ fill: currentColor;
1356
+ margin: 0 0.5em;
1357
+ }
1358
+
1344
1359
  .bio-properties-panel-feel-popup .bio-properties-panel-feel-editor-container {
1345
1360
  display: flex;
1346
1361
  min-width: 100%;
package/dist/index.cjs CHANGED
@@ -1990,6 +1990,7 @@ function Element$1(props) {
1990
1990
  const eventBus = useService$1('eventBus'),
1991
1991
  formEditor = useService$1('formEditor'),
1992
1992
  formFieldRegistry = useService$1('formFieldRegistry'),
1993
+ formFields = useService$1('formFields'),
1993
1994
  modeling = useService$1('modeling'),
1994
1995
  selection = useService$1('selection');
1995
1996
  const {
@@ -2075,6 +2076,7 @@ function Element$1(props) {
2075
2076
  field: field
2076
2077
  }), jsxRuntime.jsx(ContextPad, {
2077
2078
  children: selection.isSelected(field) && field.type !== 'default' ? jsxRuntime.jsx("button", {
2079
+ title: getRemoveButtonTitle(field, formFields),
2078
2080
  class: "fjs-context-pad-item",
2079
2081
  onClick: onRemove,
2080
2082
  children: jsxRuntime.jsx(DeleteIcon$1, {})
@@ -2395,6 +2397,13 @@ function findPaletteEntry(type, formFields) {
2395
2397
  function defaultPropertiesPanel(propertiesPanelConfig) {
2396
2398
  return !(propertiesPanelConfig && propertiesPanelConfig.parent);
2397
2399
  }
2400
+ function getRemoveButtonTitle(formField, formFields) {
2401
+ const entry = findPaletteEntry(formField.type, formFields);
2402
+ if (!entry) {
2403
+ return 'Remove form field';
2404
+ }
2405
+ return `Remove ${entry.label}`;
2406
+ }
2398
2407
 
2399
2408
  class Renderer {
2400
2409
  constructor(renderConfig, eventBus, formEditor, injector) {
@@ -4144,12 +4153,61 @@ class ValidateBehavior extends CommandInterceptor {
4144
4153
  }
4145
4154
  ValidateBehavior.$inject = ['eventBus'];
4146
4155
 
4156
+ class ValuesSourceBehavior extends CommandInterceptor {
4157
+ constructor(eventBus) {
4158
+ super(eventBus);
4159
+
4160
+ /**
4161
+ * Cleanup properties on changing the values source.
4162
+ *
4163
+ * 1) Remove other sources, e.g. set `values` => remove `valuesKey` and `valuesExpression`
4164
+ * 2) Remove default values for all other values sources
4165
+ */
4166
+ this.preExecute('formField.edit', function (context) {
4167
+ const {
4168
+ properties
4169
+ } = context;
4170
+ const newProperties = {};
4171
+ if (!isValuesSourceUpdate(properties)) {
4172
+ return;
4173
+ }
4174
+
4175
+ // clean up value sources that are not to going to be set
4176
+ Object.values(formJsViewer.VALUES_SOURCES).forEach(source => {
4177
+ const path = formJsViewer.VALUES_SOURCES_PATHS[source];
4178
+ if (minDash.get(properties, path) == undefined) {
4179
+ newProperties[formJsViewer.VALUES_SOURCES_PATHS[source]] = undefined;
4180
+ }
4181
+ });
4182
+
4183
+ // clean up default value
4184
+ if (minDash.get(properties, formJsViewer.VALUES_SOURCES_PATHS[formJsViewer.VALUES_SOURCES.EXPRESSION]) !== undefined || minDash.get(properties, formJsViewer.VALUES_SOURCES_PATHS[formJsViewer.VALUES_SOURCES.INPUT]) !== undefined) {
4185
+ newProperties['defaultValue'] = undefined;
4186
+ }
4187
+ context.properties = {
4188
+ ...properties,
4189
+ ...newProperties
4190
+ };
4191
+ }, true);
4192
+ }
4193
+ }
4194
+ ValuesSourceBehavior.$inject = ['eventBus'];
4195
+
4196
+ // helper ///////////////////
4197
+
4198
+ function isValuesSourceUpdate(properties) {
4199
+ return Object.values(formJsViewer.VALUES_SOURCES_PATHS).some(path => {
4200
+ return minDash.get(properties, path) !== undefined;
4201
+ });
4202
+ }
4203
+
4147
4204
  var behaviorModule = {
4148
- __init__: ['idBehavior', 'keyBehavior', 'pathBehavior', 'validateBehavior'],
4205
+ __init__: ['idBehavior', 'keyBehavior', 'pathBehavior', 'validateBehavior', 'valuesSourceBehavior'],
4149
4206
  idBehavior: ['type', IdBehavior],
4150
4207
  keyBehavior: ['type', KeyBehavior],
4151
4208
  pathBehavior: ['type', PathBehavior],
4152
- validateBehavior: ['type', ValidateBehavior]
4209
+ validateBehavior: ['type', ValidateBehavior],
4210
+ valuesSourceBehavior: ['type', ValuesSourceBehavior]
4153
4211
  };
4154
4212
 
4155
4213
  /**
@@ -4878,6 +4936,29 @@ FeelIcon$1.defaultProps = {
4878
4936
  fill: "none",
4879
4937
  xmlns: "http://www.w3.org/2000/svg"
4880
4938
  };
4939
+ var HelpIcon = function HelpIcon(props) {
4940
+ return jsxRuntime.jsxs("svg", {
4941
+ ...props,
4942
+ children: [jsxRuntime.jsx("path", {
4943
+ d: "M16 2a14 14 0 1 0 14 14A14 14 0 0 0 16 2Zm0 26a12 12 0 1 1 12-12 12 12 0 0 1-12 12Z"
4944
+ }), jsxRuntime.jsx("circle", {
4945
+ cx: "16",
4946
+ cy: "23.5",
4947
+ r: "1.5"
4948
+ }), jsxRuntime.jsx("path", {
4949
+ d: "M17 8h-1.5a4.49 4.49 0 0 0-4.5 4.5v.5h2v-.5a2.5 2.5 0 0 1 2.5-2.5H17a2.5 2.5 0 0 1 0 5h-2v4.5h2V17a4.5 4.5 0 0 0 0-9Z"
4950
+ }), jsxRuntime.jsx("path", {
4951
+ style: {
4952
+ fill: "none"
4953
+ },
4954
+ d: "M0 0h32v32H0z"
4955
+ })]
4956
+ });
4957
+ };
4958
+ HelpIcon.defaultProps = {
4959
+ xmlns: "http://www.w3.org/2000/svg",
4960
+ viewBox: "0 0 32 32"
4961
+ };
4881
4962
  function Header(props) {
4882
4963
  const {
4883
4964
  element,
@@ -5427,6 +5508,7 @@ function Group(props) {
5427
5508
  edited: edited,
5428
5509
  hasErrors: hasErrors
5429
5510
  }), jsxRuntime.jsx("button", {
5511
+ type: "button",
5430
5512
  title: "Toggle section",
5431
5513
  class: "bio-properties-panel-group-header-button bio-properties-panel-arrow",
5432
5514
  children: jsxRuntime.jsx(ArrowIcon, {
@@ -5607,6 +5689,7 @@ const CodeEditor$1 = React.forwardRef((props, ref) => {
5607
5689
  ref: inputRef,
5608
5690
  onClick: handleClick
5609
5691
  }), jsxRuntime.jsx("button", {
5692
+ type: "button",
5610
5693
  title: "Open pop-up editor",
5611
5694
  class: "bio-properties-panel-open-feel-popup",
5612
5695
  onClick: () => onPopupOpen('feelers'),
@@ -5727,6 +5810,7 @@ const CodeEditor = React.forwardRef((props, ref) => {
5727
5810
  ref: inputRef,
5728
5811
  onClick: handleClick
5729
5812
  }), jsxRuntime.jsx("button", {
5813
+ type: "button",
5730
5814
  title: "Open pop-up editor",
5731
5815
  class: "bio-properties-panel-open-feel-popup",
5732
5816
  onClick: () => onPopupOpen(),
@@ -5771,6 +5855,7 @@ function FeelIcon(props) {
5771
5855
  }
5772
5856
  };
5773
5857
  return jsxRuntime.jsx("button", {
5858
+ type: "button",
5774
5859
  class: classnames('bio-properties-panel-feel-icon', active ? 'active' : null, feel === 'required' ? 'required' : 'optional'),
5775
5860
  onClick: handleClick,
5776
5861
  disabled: feel === 'required' || disabled,
@@ -6217,6 +6302,12 @@ function FeelPopupComponent(props) {
6217
6302
  domNode: popupRef.current
6218
6303
  });
6219
6304
  }, []);
6305
+ hooks.useEffect(() => {
6306
+ // Set focus on editor when popup is opened
6307
+ if (editorRef.current) {
6308
+ editorRef.current.focus();
6309
+ }
6310
+ }, [editorRef]);
6220
6311
  return jsxRuntime.jsxs(Popup, {
6221
6312
  container: container,
6222
6313
  className: "bio-properties-panel-feel-popup",
@@ -6235,10 +6326,21 @@ function FeelPopupComponent(props) {
6235
6326
  height: FEEL_POPUP_HEIGHT,
6236
6327
  width: FEEL_POPUP_WIDTH,
6237
6328
  ref: popupRef,
6238
- children: [jsxRuntime.jsx(Popup.Title, {
6329
+ children: [jsxRuntime.jsxs(Popup.Title, {
6239
6330
  title: title,
6240
6331
  emit: emit,
6241
- draggable: true
6332
+ draggable: true,
6333
+ children: [type === 'feel' && jsxRuntime.jsxs("a", {
6334
+ href: "https://docs.camunda.io/docs/components/modeler/feel/what-is-feel/",
6335
+ target: "_blank",
6336
+ class: "bio-properties-panel-feel-popup__title-link",
6337
+ children: ["Learn FEEL expressions", jsxRuntime.jsx(HelpIcon, {})]
6338
+ }), type === 'feelers' && jsxRuntime.jsxs("a", {
6339
+ href: "https://docs.camunda.io/docs/components/modeler/forms/configuration/forms-config-templating-syntax/",
6340
+ target: "_blank",
6341
+ class: "bio-properties-panel-feel-popup__title-link",
6342
+ children: ["Learn templating", jsxRuntime.jsx(HelpIcon, {})]
6343
+ })]
6242
6344
  }), jsxRuntime.jsx(Popup.Body, {
6243
6345
  children: jsxRuntime.jsxs("div", {
6244
6346
  onKeyDownCapture: onKeyDownCapture,
@@ -6270,6 +6372,7 @@ function FeelPopupComponent(props) {
6270
6372
  })
6271
6373
  }), jsxRuntime.jsx(Popup.Footer, {
6272
6374
  children: jsxRuntime.jsx("button", {
6375
+ type: "button",
6273
6376
  onClick: onClose,
6274
6377
  title: "Close pop-up editor",
6275
6378
  class: "bio-properties-panel-feel-popup__close-btn",
@@ -7511,12 +7614,14 @@ function CollapsibleEntry(props) {
7511
7614
  class: classnames('bio-properties-panel-collapsible-entry-header-title', !label && 'empty'),
7512
7615
  children: label || placeholderLabel
7513
7616
  }), jsxRuntime.jsx("button", {
7617
+ type: "button",
7514
7618
  title: "Toggle list item",
7515
7619
  class: "bio-properties-panel-arrow bio-properties-panel-collapsible-entry-arrow",
7516
7620
  children: jsxRuntime.jsx(ArrowIcon, {
7517
7621
  class: open ? 'bio-properties-panel-arrow-down' : 'bio-properties-panel-arrow-right'
7518
7622
  })
7519
7623
  }), remove ? jsxRuntime.jsx("button", {
7624
+ type: "button",
7520
7625
  title: "Delete item",
7521
7626
  class: "bio-properties-panel-remove-entry",
7522
7627
  onClick: remove,
@@ -7718,6 +7823,7 @@ function ListGroup(props) {
7718
7823
  }), jsxRuntime.jsxs("div", {
7719
7824
  class: "bio-properties-panel-group-header-buttons",
7720
7825
  children: [add ? jsxRuntime.jsxs("button", {
7826
+ type: "button",
7721
7827
  title: "Create new list item",
7722
7828
  class: "bio-properties-panel-group-header-button bio-properties-panel-add-entry",
7723
7829
  onClick: handleAddClick,
@@ -7730,6 +7836,7 @@ function ListGroup(props) {
7730
7836
  class: classnames('bio-properties-panel-list-badge', hasError ? 'bio-properties-panel-list-badge--error' : ''),
7731
7837
  children: items.length
7732
7838
  }) : null, hasItems ? jsxRuntime.jsx("button", {
7839
+ type: "button",
7733
7840
  title: "Toggle section",
7734
7841
  class: "bio-properties-panel-group-header-button bio-properties-panel-arrow",
7735
7842
  children: jsxRuntime.jsx(ArrowIcon, {
@@ -10432,11 +10539,7 @@ function ValuesSourceSelect(props) {
10432
10539
  const setValue = value => {
10433
10540
  let newField = field;
10434
10541
  const newProperties = {};
10435
- Object.values(formJsViewer.VALUES_SOURCES).forEach(source => {
10436
- // Clear all values source definitions and default the newly selected one
10437
- const newValue = value === source ? formJsViewer.VALUES_SOURCES_DEFAULTS[source] : undefined;
10438
- newProperties[formJsViewer.VALUES_SOURCES_PATHS[source]] = newValue;
10439
- });
10542
+ newProperties[formJsViewer.VALUES_SOURCES_PATHS[value]] = formJsViewer.VALUES_SOURCES_DEFAULTS[value];
10440
10543
  newField = editField(field, newProperties);
10441
10544
  return newField;
10442
10545
  };