@bpmn-io/form-js-editor 1.4.1 → 1.5.0

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 (59) hide show
  1. package/dist/assets/form-js-editor-base.css +6 -6
  2. package/dist/assets/form-js-editor.css +6 -6
  3. package/dist/index.cjs +223 -66
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.es.js +224 -67
  6. package/dist/index.es.js.map +1 -1
  7. package/dist/types/core/Debounce.d.ts +1 -1
  8. package/dist/types/core/FormLayoutValidator.d.ts +2 -2
  9. package/dist/types/core/index.d.ts +9 -9
  10. package/dist/types/features/dragging/Dragging.d.ts +2 -2
  11. package/dist/types/features/dragging/index.d.ts +2 -2
  12. package/dist/types/features/editor-actions/FormEditorActions.d.ts +1 -1
  13. package/dist/types/features/editor-actions/index.d.ts +2 -2
  14. package/dist/types/features/expression-language/EditorTemplating.d.ts +1 -1
  15. package/dist/types/features/expression-language/index.d.ts +3 -3
  16. package/dist/types/features/keyboard/FormEditorKeyboardBindings.d.ts +1 -1
  17. package/dist/types/features/keyboard/index.d.ts +3 -3
  18. package/dist/types/features/modeling/FormLayoutUpdater.d.ts +1 -1
  19. package/dist/types/features/modeling/Modeling.d.ts +1 -1
  20. package/dist/types/features/modeling/behavior/IdBehavior.d.ts +1 -1
  21. package/dist/types/features/modeling/behavior/KeyBehavior.d.ts +1 -1
  22. package/dist/types/features/modeling/behavior/PathBehavior.d.ts +1 -1
  23. package/dist/types/features/modeling/behavior/ValidateBehavior.d.ts +1 -1
  24. package/dist/types/features/modeling/behavior/ValuesSourceBehavior.d.ts +1 -1
  25. package/dist/types/features/modeling/behavior/index.d.ts +6 -6
  26. package/dist/types/features/modeling/cmd/AddFormFieldHandler.d.ts +1 -1
  27. package/dist/types/features/modeling/cmd/EditFormFieldHandler.d.ts +1 -1
  28. package/dist/types/features/modeling/cmd/MoveFormFieldHandler.d.ts +4 -2
  29. package/dist/types/features/modeling/cmd/RemoveFormFieldHandler.d.ts +1 -1
  30. package/dist/types/features/modeling/cmd/UpdateIdClaimHandler.d.ts +1 -1
  31. package/dist/types/features/modeling/cmd/UpdateKeyClaimHandler.d.ts +1 -1
  32. package/dist/types/features/modeling/cmd/UpdatePathClaimHandler.d.ts +1 -1
  33. package/dist/types/features/modeling/index.d.ts +4 -4
  34. package/dist/types/features/palette/PaletteModule.d.ts +1 -1
  35. package/dist/types/features/palette/index.d.ts +1 -1
  36. package/dist/types/features/properties-panel/PropertiesPanelRenderer.d.ts +1 -1
  37. package/dist/types/features/properties-panel/PropertiesProvider.d.ts +1 -1
  38. package/dist/types/features/properties-panel/entries/GroupEntries.d.ts +2 -0
  39. package/dist/types/features/properties-panel/entries/HeightEntry.d.ts +12 -0
  40. package/dist/types/features/properties-panel/entries/IFrameHeightEntry.d.ts +10 -0
  41. package/dist/types/features/properties-panel/entries/IFrameUrlEntry.d.ts +10 -0
  42. package/dist/types/features/properties-panel/entries/SelectEntries.d.ts +2 -0
  43. package/dist/types/features/properties-panel/entries/factories/simpleBoolEntryFactory.d.ts +2 -0
  44. package/dist/types/features/properties-panel/entries/index.d.ts +3 -1
  45. package/dist/types/features/properties-panel/groups/GeneralGroup.d.ts +2 -0
  46. package/dist/types/features/properties-panel/index.d.ts +4 -4
  47. package/dist/types/features/render-injection/RenderInjector.d.ts +1 -1
  48. package/dist/types/features/render-injection/index.d.ts +2 -2
  49. package/dist/types/features/selection/Selection.d.ts +1 -1
  50. package/dist/types/features/selection/SelectionBehavior.d.ts +1 -1
  51. package/dist/types/features/selection/index.d.ts +3 -3
  52. package/dist/types/render/Renderer.d.ts +1 -1
  53. package/dist/types/render/components/ModularSection.d.ts +1 -1
  54. package/dist/types/render/components/editor-form-fields/EditorIFrame.d.ts +6 -0
  55. package/dist/types/render/components/editor-form-fields/EditorText.d.ts +1 -1
  56. package/dist/types/render/components/editor-form-fields/index.d.ts +2 -1
  57. package/dist/types/render/index.d.ts +3 -3
  58. package/package.json +3 -3
  59. package/dist/types/features/properties-panel/entries/SpacerEntry.d.ts +0 -10
@@ -68,7 +68,7 @@
68
68
  var(--cds-border-strong-01, var(--color-grey-225-10-55))
69
69
  );
70
70
  --cursor-palette-field: grab;
71
- --palette-width: 246px;
71
+ --palette-width: 270px;
72
72
  }
73
73
 
74
74
  .fjs-properties-container {
@@ -620,7 +620,7 @@
620
620
  .fjs-palette-container .fjs-palette-group {
621
621
  display: flex;
622
622
  flex-direction: column;
623
- width: 212px;
623
+ width: 236px;
624
624
  margin: auto;
625
625
  }
626
626
 
@@ -639,7 +639,7 @@
639
639
  }
640
640
 
641
641
  .fjs-palette-field {
642
- height: 64px;
642
+ height: 72px;
643
643
  display: flex;
644
644
  flex-direction: column;
645
645
  justify-content: center;
@@ -656,7 +656,7 @@
656
656
  }
657
657
 
658
658
  .fjs-palette-container .fjs-palette-field {
659
- width: 64px;
659
+ width: 72px;
660
660
  }
661
661
 
662
662
  .fjs-palette-container .fjs-palette-field:focus {
@@ -719,8 +719,8 @@
719
719
  }
720
720
 
721
721
  .fjs-editor-container .fjs-form-field-placeholder svg {
722
- width: 36px;
723
- height: 36px;
722
+ width: 32px;
723
+ height: 32px;
724
724
  vertical-align: middle;
725
725
  margin-top: -2px;
726
726
  margin-right: 2px;
@@ -65,7 +65,7 @@
65
65
  var(--cds-border-strong-01, var(--color-grey-225-10-55))
66
66
  );
67
67
  --cursor-palette-field: grab;
68
- --palette-width: 246px;
68
+ --palette-width: 270px;
69
69
  }
70
70
 
71
71
  .fjs-properties-container {
@@ -596,7 +596,7 @@
596
596
  .fjs-palette-container .fjs-palette-group {
597
597
  display: flex;
598
598
  flex-direction: column;
599
- width: 212px;
599
+ width: 236px;
600
600
  margin: auto;
601
601
  }
602
602
 
@@ -615,7 +615,7 @@
615
615
  }
616
616
 
617
617
  .fjs-palette-field {
618
- height: 64px;
618
+ height: 72px;
619
619
  display: flex;
620
620
  flex-direction: column;
621
621
  justify-content: center;
@@ -632,7 +632,7 @@
632
632
  }
633
633
 
634
634
  .fjs-palette-container .fjs-palette-field {
635
- width: 64px;
635
+ width: 72px;
636
636
  }
637
637
 
638
638
  .fjs-palette-container .fjs-palette-field:focus {
@@ -695,8 +695,8 @@
695
695
  }
696
696
 
697
697
  .fjs-editor-container .fjs-form-field-placeholder svg {
698
- width: 36px;
699
- height: 36px;
698
+ width: 32px;
699
+ height: 32px;
700
700
  vertical-align: middle;
701
701
  margin-top: -2px;
702
702
  margin-right: 2px;
package/dist/index.cjs CHANGED
@@ -3,8 +3,8 @@
3
3
  var formJsViewer = require('@bpmn-io/form-js-viewer');
4
4
  var Ids = require('ids');
5
5
  var minDash = require('min-dash');
6
- var classnames = require('classnames');
7
6
  var jsxRuntime = require('preact/jsx-runtime');
7
+ var classnames = require('classnames');
8
8
  var hooks = require('preact/hooks');
9
9
  var preact = require('preact');
10
10
  var React = require('preact/compat');
@@ -664,6 +664,25 @@ function calculateMaxColumnsWithAuto(autoCols) {
664
664
  return MAX_COLUMNS_PER_ROW - autoCols * 2;
665
665
  }
666
666
 
667
+ function EditorIFrame(props) {
668
+ const {
669
+ field
670
+ } = props;
671
+ const Icon = formJsViewer.iconsByType(field.type);
672
+ return jsxRuntime.jsx("div", {
673
+ class: "fjs-iframe-placeholder",
674
+ children: jsxRuntime.jsxs("p", {
675
+ class: "fjs-iframe-placeholder-text",
676
+ children: [jsxRuntime.jsx(Icon, {
677
+ width: "32",
678
+ height: "24",
679
+ viewBox: "0 0 56 56"
680
+ }), "iFrame"]
681
+ })
682
+ });
683
+ }
684
+ EditorIFrame.config = formJsViewer.IFrame.config;
685
+
667
686
  const emptyImage = createEmptyImage();
668
687
  function editorFormFieldClasses(type, {
669
688
  disabled = false
@@ -999,7 +1018,7 @@ function EditorText(props) {
999
1018
  }
1000
1019
  EditorText.config = formJsViewer.Text.config;
1001
1020
 
1002
- const editorFormFields = [EditorText];
1021
+ const editorFormFields = [EditorIFrame, EditorText];
1003
1022
 
1004
1023
  class EditorFormFields extends formJsViewer.FormFields {
1005
1024
  constructor() {
@@ -1298,6 +1317,9 @@ const PALETTE_GROUPS = [{
1298
1317
  }, {
1299
1318
  label: 'Presentation',
1300
1319
  id: 'presentation'
1320
+ }, {
1321
+ label: 'Containers',
1322
+ id: 'container'
1301
1323
  }, {
1302
1324
  label: 'Action',
1303
1325
  id: 'action'
@@ -3320,11 +3342,13 @@ class MoveFormFieldHandler {
3320
3342
  * @param { import('../../../FormEditor').default } formEditor
3321
3343
  * @param { import('../../../core/FormFieldRegistry').default } formFieldRegistry
3322
3344
  * @param { import('@bpmn-io/form-js-viewer').PathRegistry } pathRegistry
3345
+ * @param { import('@bpmn-io/form-js-viewer').FormLayouter } formLayouter
3323
3346
  */
3324
- constructor(formEditor, formFieldRegistry, pathRegistry) {
3347
+ constructor(formEditor, formFieldRegistry, pathRegistry, formLayouter) {
3325
3348
  this._formEditor = formEditor;
3326
3349
  this._formFieldRegistry = formFieldRegistry;
3327
3350
  this._pathRegistry = pathRegistry;
3351
+ this._formLayouter = formLayouter;
3328
3352
  }
3329
3353
  execute(context) {
3330
3354
  this.moveFormField(context);
@@ -3371,8 +3395,8 @@ class MoveFormFieldHandler {
3371
3395
  }
3372
3396
  const formField = minDash.get(schema, [...sourcePath, sourceIndex]);
3373
3397
 
3374
- // (1) Add to row
3375
- updateRow(formField, targetRow ? targetRow.id : null);
3398
+ // (1) Add to row or create new one
3399
+ updateRow(formField, targetRow ? targetRow.id : this._formLayouter.nextRowId());
3376
3400
 
3377
3401
  // (2) Move form field
3378
3402
  arrayMove.mutate(minDash.get(schema, sourcePath), sourceIndex, targetIndex);
@@ -3397,8 +3421,8 @@ class MoveFormFieldHandler {
3397
3421
  minDash.get(schema, sourcePath).forEach((formField, index) => updatePath(this._formFieldRegistry, formField, index));
3398
3422
  const targetPath = [...targetFormField._path, 'components'];
3399
3423
 
3400
- // (4) Add to row
3401
- updateRow(formField, targetRow ? targetRow.id : null);
3424
+ // (4) Add to row or create new one
3425
+ updateRow(formField, targetRow ? targetRow.id : this._formLayouter.nextRowId());
3402
3426
 
3403
3427
  // (5) Add form field
3404
3428
  arrayAdd$1(minDash.get(schema, targetPath), targetIndex, formField);
@@ -3421,7 +3445,7 @@ class MoveFormFieldHandler {
3421
3445
  });
3422
3446
  }
3423
3447
  }
3424
- MoveFormFieldHandler.$inject = ['formEditor', 'formFieldRegistry', 'pathRegistry'];
3448
+ MoveFormFieldHandler.$inject = ['formEditor', 'formFieldRegistry', 'pathRegistry', 'formLayouter'];
3425
3449
 
3426
3450
  class RemoveFormFieldHandler {
3427
3451
  /**
@@ -4011,12 +4035,21 @@ class FormLayoutUpdater extends CommandInterceptor {
4011
4035
  const {
4012
4036
  schema
4013
4037
  } = this._formEditor._getState();
4038
+ const setRowIds = parent => {
4039
+ if (!parent.components || !parent.components.length) {
4040
+ return;
4041
+ }
4042
+ parent.components.forEach(formField => {
4043
+ const row = this._formLayouter.getRowForField(formField);
4044
+ updateRow(formField, row.id);
4045
+
4046
+ // handle children recursively
4047
+ setRowIds(formField);
4048
+ });
4049
+ };
4014
4050
 
4015
4051
  // make sure rows are persisted in schema (e.g. for migration case)
4016
- schema.components.forEach(formField => {
4017
- const row = this._formLayouter.getRowForField(formField);
4018
- updateRow(formField, row.id);
4019
- });
4052
+ setRowIds(schema);
4020
4053
  }
4021
4054
  }
4022
4055
  FormLayoutUpdater.$inject = ['eventBus', 'formLayouter', 'modeling', 'formEditor'];
@@ -9560,6 +9593,8 @@ function simpleBoolEntryFactory(options) {
9560
9593
  description,
9561
9594
  path,
9562
9595
  props,
9596
+ getValue,
9597
+ setValue,
9563
9598
  isDefaultVisible
9564
9599
  } = options;
9565
9600
  const {
@@ -9574,8 +9609,10 @@ function simpleBoolEntryFactory(options) {
9574
9609
  editField,
9575
9610
  description,
9576
9611
  component: SimpleBoolComponent,
9577
- isEdited: isEdited$5,
9578
- isDefaultVisible
9612
+ isEdited: isEdited$8,
9613
+ isDefaultVisible,
9614
+ getValue,
9615
+ setValue
9579
9616
  };
9580
9617
  }
9581
9618
  const SimpleBoolComponent = props => {
@@ -9585,16 +9622,17 @@ const SimpleBoolComponent = props => {
9585
9622
  path,
9586
9623
  field,
9587
9624
  editField,
9625
+ getValue = () => minDash.get(field, path, ''),
9626
+ setValue = value => editField(field, path, value || false),
9588
9627
  description
9589
9628
  } = props;
9590
- const getValue = () => minDash.get(field, path, '');
9591
- const setValue = value => editField(field, path, value || false);
9592
- return CheckboxEntry({
9629
+ return ToggleSwitchEntry({
9593
9630
  element: field,
9594
9631
  getValue,
9595
9632
  id,
9596
9633
  label,
9597
9634
  setValue,
9635
+ inline: true,
9598
9636
  description
9599
9637
  });
9600
9638
  };
@@ -9650,7 +9688,7 @@ function LabelEntry(props) {
9650
9688
  editField,
9651
9689
  field,
9652
9690
  isEdited: isEdited$6,
9653
- isDefaultVisible: field => INPUTS.includes(field.type) || field.type === 'button' || field.type === 'group'
9691
+ isDefaultVisible: field => INPUTS.includes(field.type) || field.type === 'button' || field.type === 'group' || field.type === 'iframe'
9654
9692
  });
9655
9693
  return entries;
9656
9694
  }
@@ -9671,7 +9709,7 @@ function Label$1(props) {
9671
9709
  const setValue = value => {
9672
9710
  return editField(field, path, value || '');
9673
9711
  };
9674
- const label = field.type === 'group' ? 'Group label' : 'Field label';
9712
+ const label = getLabelText(field);
9675
9713
  return FeelTemplatingEntry({
9676
9714
  debounce,
9677
9715
  element: field,
@@ -9740,6 +9778,165 @@ function TimeLabel(props) {
9740
9778
  });
9741
9779
  }
9742
9780
 
9781
+ // helpers //////////
9782
+
9783
+ function getLabelText(field) {
9784
+ const {
9785
+ type
9786
+ } = field;
9787
+ if (type === 'group') {
9788
+ return 'Group label';
9789
+ }
9790
+ if (type === 'iframe') {
9791
+ return 'Title';
9792
+ }
9793
+ return 'Field label';
9794
+ }
9795
+
9796
+ function HeightEntry(props) {
9797
+ const {
9798
+ editField,
9799
+ field,
9800
+ id,
9801
+ description,
9802
+ isDefaultVisible,
9803
+ defaultValue
9804
+ } = props;
9805
+ const entries = [];
9806
+ entries.push({
9807
+ id: id + '-height',
9808
+ component: Height,
9809
+ description,
9810
+ isEdited: isEdited$7,
9811
+ editField,
9812
+ field,
9813
+ defaultValue,
9814
+ isDefaultVisible: field => {
9815
+ if (minDash.isFunction(isDefaultVisible)) {
9816
+ return isDefaultVisible(field);
9817
+ }
9818
+ return field.type === 'spacer';
9819
+ }
9820
+ });
9821
+ return entries;
9822
+ }
9823
+ function Height(props) {
9824
+ const {
9825
+ description,
9826
+ editField,
9827
+ field,
9828
+ id,
9829
+ defaultValue = 60 // default value for spacer
9830
+ } = props;
9831
+ const debounce = useService('debounce');
9832
+ const getValue = e => minDash.get(field, ['height'], defaultValue);
9833
+ const setValue = (value, error) => {
9834
+ if (error) {
9835
+ return;
9836
+ }
9837
+ editField(field, ['height'], value);
9838
+ };
9839
+ return NumberFieldEntry({
9840
+ debounce,
9841
+ description,
9842
+ label: 'Height',
9843
+ element: field,
9844
+ id,
9845
+ getValue,
9846
+ setValue,
9847
+ validate: value => {
9848
+ if (value === undefined || value === null) return;
9849
+ if (value < 1) return 'Should be greater than zero.';
9850
+ if (!Number.isInteger(value)) return 'Should be an integer.';
9851
+ }
9852
+ });
9853
+ }
9854
+
9855
+ function IFrameHeightEntry(props) {
9856
+ return [...HeightEntry({
9857
+ ...props,
9858
+ defaultValue: 300,
9859
+ description: 'Height of the container in pixels.',
9860
+ isDefaultVisible: field => field.type === 'iframe'
9861
+ })];
9862
+ }
9863
+
9864
+ const HTTPS_PATTERN = /^(https):\/\/*/i; // eslint-disable-line no-useless-escape
9865
+
9866
+ function IFrameUrlEntry(props) {
9867
+ const {
9868
+ editField,
9869
+ field
9870
+ } = props;
9871
+ const entries = [];
9872
+ entries.push({
9873
+ id: 'url',
9874
+ component: Url,
9875
+ editField: editField,
9876
+ field: field,
9877
+ isEdited: isEdited$6,
9878
+ isDefaultVisible: field => field.type === 'iframe'
9879
+ });
9880
+ return entries;
9881
+ }
9882
+ function Url(props) {
9883
+ const {
9884
+ editField,
9885
+ field,
9886
+ id
9887
+ } = props;
9888
+ const debounce = useService('debounce');
9889
+ const variables = useVariables().map(name => ({
9890
+ name
9891
+ }));
9892
+ const path = ['url'];
9893
+ const getValue = () => {
9894
+ return minDash.get(field, path, '');
9895
+ };
9896
+ const setValue = value => {
9897
+ return editField(field, path, value);
9898
+ };
9899
+ const validate = value => {
9900
+ if (!value) {
9901
+ return;
9902
+ }
9903
+ if (!HTTPS_PATTERN.test(value)) {
9904
+ return 'For security reasons the URL must start with "https".';
9905
+ }
9906
+ };
9907
+ return FeelTemplatingEntry({
9908
+ debounce,
9909
+ element: field,
9910
+ feel: 'optional',
9911
+ getValue,
9912
+ id,
9913
+ label: 'URL',
9914
+ setValue,
9915
+ singleLine: true,
9916
+ tooltip: getTooltip(),
9917
+ validate,
9918
+ variables
9919
+ });
9920
+ }
9921
+
9922
+ // helper //////////////////////
9923
+
9924
+ function getTooltip() {
9925
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
9926
+ children: [jsxRuntime.jsx("p", {
9927
+ children: "Enter a HTTPS URL to a source or populate it dynamically via a template or an expression (e.g., to pass a value from the variable)."
9928
+ }), jsxRuntime.jsx("p", {
9929
+ children: "Please make sure that the URL is safe as it might impose security risks."
9930
+ }), jsxRuntime.jsxs("p", {
9931
+ children: ["Not all external sources can be displayed in the iFrame. Read more about it in the ", jsxRuntime.jsx("a", {
9932
+ target: "_blank",
9933
+ href: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options",
9934
+ children: "X-FRAME-OPTIONS documentation"
9935
+ }), "."]
9936
+ })]
9937
+ });
9938
+ }
9939
+
9743
9940
  function SourceEntry(props) {
9744
9941
  const {
9745
9942
  editField,
@@ -9852,52 +10049,6 @@ function Text(props) {
9852
10049
  });
9853
10050
  }
9854
10051
 
9855
- function SpacerEntry(props) {
9856
- const {
9857
- editField,
9858
- field,
9859
- id
9860
- } = props;
9861
- const entries = [];
9862
- entries.push({
9863
- id: id + '-height',
9864
- component: SpacerHeight,
9865
- isEdited: isEdited$7,
9866
- editField,
9867
- field,
9868
- isDefaultVisible: field => field.type === 'spacer'
9869
- });
9870
- return entries;
9871
- }
9872
- function SpacerHeight(props) {
9873
- const {
9874
- editField,
9875
- field,
9876
- id
9877
- } = props;
9878
- const debounce = useService('debounce');
9879
- const getValue = e => minDash.get(field, ['height']);
9880
- const setValue = (value, error) => {
9881
- if (error) {
9882
- return;
9883
- }
9884
- editField(field, ['height'], value);
9885
- };
9886
- return NumberFieldEntry({
9887
- debounce,
9888
- label: 'Height',
9889
- element: field,
9890
- id,
9891
- getValue,
9892
- setValue,
9893
- validate: value => {
9894
- if (value === undefined || value === null) return;
9895
- if (value < 1) return 'Should be greater than zero.';
9896
- if (!Number.isInteger(value)) return 'Should be an integer.';
9897
- }
9898
- });
9899
- }
9900
-
9901
10052
  function NumberEntries(props) {
9902
10053
  const {
9903
10054
  editField,
@@ -10968,7 +11119,13 @@ function GeneralGroup(field, editField, getService) {
10968
11119
  field,
10969
11120
  editField,
10970
11121
  getService
10971
- }), ...SpacerEntry({
11122
+ }), ...IFrameUrlEntry({
11123
+ field,
11124
+ editField
11125
+ }), ...IFrameHeightEntry({
11126
+ field,
11127
+ editField
11128
+ }), ...HeightEntry({
10972
11129
  field,
10973
11130
  editField
10974
11131
  }), ...NumberEntries({