@bpmn-io/form-js-editor 1.0.0-alpha.8 → 1.0.0-alpha.9

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.
package/dist/index.es.js CHANGED
@@ -514,10 +514,10 @@ function invokeFunction(fn, args) {
514
514
  return fn.apply(null, args);
515
515
  }
516
516
 
517
- /**
518
- * A factory to create a configurable debouncer.
519
- *
520
- * @param {number|boolean} [config=true]
517
+ /**
518
+ * A factory to create a configurable debouncer.
519
+ *
520
+ * @param {number|boolean} [config=true]
521
521
  */
522
522
  function DebounceFactory(config = true) {
523
523
  const timeout = typeof config === 'number' ? config : config ? 300 : 0;
@@ -530,11 +530,11 @@ function DebounceFactory(config = true) {
530
530
  DebounceFactory.$inject = ['config.debounce'];
531
531
 
532
532
  class FieldFactory {
533
- /**
534
- * @constructor
535
- *
536
- * @param { import('./FormFieldRegistry').default } formFieldRegistry
537
- * @param { import('@bpmn-io/form-js-viewer').FormFields } formFields
533
+ /**
534
+ * @constructor
535
+ *
536
+ * @param { import('./FormFieldRegistry').default } formFieldRegistry
537
+ * @param { import('@bpmn-io/form-js-viewer').FormFields } formFields
538
538
  */
539
539
  constructor(formFieldRegistry, formFields) {
540
540
  this._formFieldRegistry = formFieldRegistry;
@@ -597,11 +597,11 @@ class FieldFactory {
597
597
  FieldFactory.$inject = ['formFieldRegistry', 'formFields'];
598
598
 
599
599
  class FormFieldRegistry extends FormFieldRegistry$1 {
600
- /**
601
- * Updates a form fields id.
602
- *
603
- * @param {Object} formField
604
- * @param {string} newId
600
+ /**
601
+ * Updates a form fields id.
602
+ *
603
+ * @param {Object} formField
604
+ * @param {string} newId
605
605
  */
606
606
  updateId(formField, newId) {
607
607
  this._validateId(newId);
@@ -622,13 +622,13 @@ class FormFieldRegistry extends FormFieldRegistry$1 {
622
622
  }
623
623
  }
624
624
 
625
- /**
626
- * Validate the suitability of the given id and signals a problem
627
- * with an exception.
628
- *
629
- * @param {string} id
630
- *
631
- * @throws {Error} if id is empty or already assigned
625
+ /**
626
+ * Validate the suitability of the given id and signals a problem
627
+ * with an exception.
628
+ *
629
+ * @param {string} id
630
+ *
631
+ * @throws {Error} if id is empty or already assigned
632
632
  */
633
633
  _validateId(id) {
634
634
  if (!id) {
@@ -645,11 +645,11 @@ const MAX_COLUMNS = 16;
645
645
  const MIN_COLUMNS = 2;
646
646
  const MAX_FIELDS_PER_ROW = 4;
647
647
  class FormLayoutValidator {
648
- /**
649
- * @constructor
650
- *
651
- * @param { import('./FormLayouter').default } formLayouter
652
- * @param { import('./FormFieldRegistry').default } formFieldRegistry
648
+ /**
649
+ * @constructor
650
+ *
651
+ * @param { import('./FormLayouter').default } formLayouter
652
+ * @param { import('./FormFieldRegistry').default } formFieldRegistry
653
653
  */
654
654
  constructor(formLayouter, formFieldRegistry) {
655
655
  this._formLayouter = formLayouter;
@@ -709,11 +709,11 @@ function calculateMaxColumnsWithAuto(autoCols) {
709
709
  }
710
710
 
711
711
  class Importer {
712
- /**
713
- * @constructor
714
- * @param { import('../core/FormFieldRegistry').default } formFieldRegistry
715
- * @param { import('../core/FieldFactory').default } fieldFactory
716
- * @param { import('../core/FormLayouter').default } formLayouter
712
+ /**
713
+ * @constructor
714
+ * @param { import('../core/FormFieldRegistry').default } formFieldRegistry
715
+ * @param { import('../core/FieldFactory').default } fieldFactory
716
+ * @param { import('../core/FormLayouter').default } formLayouter
717
717
  */
718
718
  constructor(formFieldRegistry, fieldFactory, formLayouter) {
719
719
  this._formFieldRegistry = formFieldRegistry;
@@ -721,21 +721,21 @@ class Importer {
721
721
  this._formLayouter = formLayouter;
722
722
  }
723
723
 
724
- /**
725
- * Import schema creating rows, fields, attaching additional
726
- * information to each field and adding fields to the
727
- * field registry.
728
- *
729
- * Additional information attached:
730
- *
731
- * * `id` (unless present)
732
- * * `_parent`
733
- * * `_path`
734
- *
735
- * @param {any} schema
736
- *
737
- * @typedef {{ warnings: Error[], schema: any }} ImportResult
738
- * @returns {ImportResult}
724
+ /**
725
+ * Import schema creating rows, fields, attaching additional
726
+ * information to each field and adding fields to the
727
+ * field registry.
728
+ *
729
+ * Additional information attached:
730
+ *
731
+ * * `id` (unless present)
732
+ * * `_parent`
733
+ * * `_path`
734
+ *
735
+ * @param {any} schema
736
+ *
737
+ * @typedef {{ warnings: Error[], schema: any }} ImportResult
738
+ * @returns {ImportResult}
739
739
  */
740
740
  importSchema(schema) {
741
741
  // TODO: Add warnings
@@ -753,12 +753,12 @@ class Importer {
753
753
  }
754
754
  }
755
755
 
756
- /**
757
- * @param {{[x: string]: any}} fieldAttrs
758
- * @param {String} [parentId]
759
- * @param {number} [index]
760
- *
761
- * @return {any} field
756
+ /**
757
+ * @param {{[x: string]: any}} fieldAttrs
758
+ * @param {String} [parentId]
759
+ * @param {number} [index]
760
+ *
761
+ * @return {any} field
762
762
  */
763
763
  importFormField(fieldAttrs, parentId, index) {
764
764
  const {
@@ -795,11 +795,11 @@ class Importer {
795
795
  return field;
796
796
  }
797
797
 
798
- /**
799
- * @param {Array<any>} components
800
- * @param {string} parentId
801
- *
802
- * @return {Array<any>} imported components
798
+ /**
799
+ * @param {Array<any>} components
800
+ * @param {string} parentId
801
+ *
802
+ * @return {Array<any>} imported components
803
803
  */
804
804
  importFormFields(components, parentId) {
805
805
  return components.map((component, index) => {
@@ -824,22 +824,22 @@ function editorFormFieldClasses(type, {
824
824
  });
825
825
  }
826
826
 
827
- /**
828
- * Add a dragger that calls back the passed function with
829
- * { event, delta } on drag.
830
- *
831
- * @example
832
- *
833
- * function dragMove(event, delta) {
834
- * // we are dragging (!!)
835
- * }
836
- *
837
- * domElement.addEventListener('dragstart', dragger(dragMove));
838
- *
839
- * @param {Function} fn
840
- * @param {Element} dragPreview
841
- *
842
- * @return {Function} drag start callback function
827
+ /**
828
+ * Add a dragger that calls back the passed function with
829
+ * { event, delta } on drag.
830
+ *
831
+ * @example
832
+ *
833
+ * function dragMove(event, delta) {
834
+ * // we are dragging (!!)
835
+ * }
836
+ *
837
+ * domElement.addEventListener('dragstart', dragger(dragMove));
838
+ *
839
+ * @param {Function} fn
840
+ * @param {Element} dragPreview
841
+ *
842
+ * @return {Function} drag start callback function
843
843
  */
844
844
  function createDragger(fn, dragPreview) {
845
845
  let self;
@@ -880,12 +880,12 @@ function createDragger(fn, dragPreview) {
880
880
  return onDragStart;
881
881
  }
882
882
 
883
- /**
884
- * Throttle function call according UI update cycle.
885
- *
886
- * @param {Function} fn
887
- *
888
- * @return {Function} throttled fn
883
+ /**
884
+ * Throttle function call according UI update cycle.
885
+ *
886
+ * @param {Function} fn
887
+ *
888
+ * @return {Function} throttled fn
889
889
  */
890
890
  function throttle(fn) {
891
891
  let active = false;
@@ -914,11 +914,11 @@ const DragAndDropContext = createContext({
914
914
  });
915
915
  var DragAndDropContext$1 = DragAndDropContext;
916
916
 
917
- /**
918
- * @param {string} type
919
- * @param {boolean} [strict]
920
- *
921
- * @returns {any}
917
+ /**
918
+ * @param {string} type
919
+ * @param {boolean} [strict]
920
+ *
921
+ * @returns {any}
922
922
  */
923
923
  function getService$1(type, strict) {}
924
924
  const FormEditorContext = createContext({
@@ -1205,23 +1205,23 @@ var Slot = (props => {
1205
1205
  return fillsAndSeparators;
1206
1206
  });
1207
1207
 
1208
- /**
1209
- * Creates a Fragment for a fill.
1210
- *
1211
- * @param {Object} fill Fill to be rendered
1212
- * @returns {Object} Preact Fragment containing fill's children
1208
+ /**
1209
+ * Creates a Fragment for a fill.
1210
+ *
1211
+ * @param {Object} fill Fill to be rendered
1212
+ * @returns {Object} Preact Fragment containing fill's children
1213
1213
  */
1214
1214
  const FillFragment = fill => jsx(Fragment, {
1215
1215
  children: fill.children
1216
1216
  }, fill.id);
1217
1217
 
1218
- /**
1219
- * Creates an array of fills, with separators inserted between groups.
1220
- *
1221
- * @param {Array} groups Groups of fills
1222
- * @param {Function} fillRenderer Function to create a fill
1223
- * @param {Function} separatorRenderer Function to create a separator
1224
- * @returns {Array} Array of fills and separators
1218
+ /**
1219
+ * Creates an array of fills, with separators inserted between groups.
1220
+ *
1221
+ * @param {Array} groups Groups of fills
1222
+ * @param {Function} fillRenderer Function to create a fill
1223
+ * @param {Function} separatorRenderer Function to create a separator
1224
+ * @returns {Array} Array of fills and separators
1225
1225
  */
1226
1226
  const buildFills = (groups, fillRenderer, separatorRenderer) => {
1227
1227
  const result = [];
@@ -1239,8 +1239,8 @@ const buildFills = (groups, fillRenderer, separatorRenderer) => {
1239
1239
  return result;
1240
1240
  };
1241
1241
 
1242
- /**
1243
- * Groups fills by group name property.
1242
+ /**
1243
+ * Groups fills by group name property.
1244
1244
  */
1245
1245
  const _groupByGroupName = fills => {
1246
1246
  const groups = [];
@@ -1260,8 +1260,8 @@ const _groupByGroupName = fills => {
1260
1260
  return Object.keys(groupsById).sort().map(id => groupsById[id]);
1261
1261
  };
1262
1262
 
1263
- /**
1264
- * Compares fills by priority.
1263
+ /**
1264
+ * Compares fills by priority.
1265
1265
  */
1266
1266
  const _comparePriority = (a, b) => {
1267
1267
  return (b.priority || 0) - (a.priority || 0);
@@ -1489,19 +1489,19 @@ const DRAG_NO_DROP_CLS = 'fjs-no-drop';
1489
1489
  const DRAG_NO_MOVE_CLS = 'fjs-no-move';
1490
1490
  const ERROR_DROP_CLS = 'fjs-error-drop';
1491
1491
 
1492
- /**
1493
- * @typedef { { id: String, components: Array<any> } } FormRow
1492
+ /**
1493
+ * @typedef { { id: String, components: Array<any> } } FormRow
1494
1494
  */
1495
1495
 
1496
1496
  class Dragging {
1497
- /**
1498
- * @constructor
1499
- *
1500
- * @param { import('../../core/FormFieldRegistry').default } formFieldRegistry
1501
- * @param { import('../../core/FormLayouter').default } formLayouter
1502
- * @param { import('../../core/FormLayoutValidator').default } formLayoutValidator
1503
- * @param { import('../../core/EventBus').default } eventBus
1504
- * @param { import('../modeling/Modeling').default } modeling
1497
+ /**
1498
+ * @constructor
1499
+ *
1500
+ * @param { import('../../core/FormFieldRegistry').default } formFieldRegistry
1501
+ * @param { import('../../core/FormLayouter').default } formLayouter
1502
+ * @param { import('../../core/FormLayoutValidator').default } formLayoutValidator
1503
+ * @param { import('../../core/EventBus').default } eventBus
1504
+ * @param { import('../modeling/Modeling').default } modeling
1505
1505
  */
1506
1506
  constructor(formFieldRegistry, formLayouter, formLayoutValidator, eventBus, modeling) {
1507
1507
  this._formFieldRegistry = formFieldRegistry;
@@ -1511,13 +1511,13 @@ class Dragging {
1511
1511
  this._modeling = modeling;
1512
1512
  }
1513
1513
 
1514
- /**
1515
- * Calculcates position in form schema given the dropped place.
1516
- *
1517
- * @param { FormRow } targetRow
1518
- * @param { any } targetFormField
1519
- * @param { HTMLElement } sibling
1520
- * @returns { number }
1514
+ /**
1515
+ * Calculcates position in form schema given the dropped place.
1516
+ *
1517
+ * @param { FormRow } targetRow
1518
+ * @param { any } targetFormField
1519
+ * @param { HTMLElement } sibling
1520
+ * @returns { number }
1521
1521
  */
1522
1522
  getTargetIndex(targetRow, targetFormField, sibling) {
1523
1523
  /** @type HTMLElement */
@@ -1619,8 +1619,8 @@ class Dragging {
1619
1619
  }
1620
1620
  }
1621
1621
 
1622
- /**
1623
- * @param { { container: Array<string>, direction: string, mirrorContainer: string } } options
1622
+ /**
1623
+ * @param { { container: Array<string>, direction: string, mirrorContainer: string } } options
1624
1624
  */
1625
1625
  createDragulaInstance(options) {
1626
1626
  const {
@@ -2017,7 +2017,7 @@ function DebugColumns(props) {
2017
2017
  return null;
2018
2018
  }
2019
2019
  return jsx("div", {
2020
- style: "width: fit-content; padding: 2px 6px; height: 16px; background: var(--color-blue-205-100-95); display: flex; justify-content: center; align-items: center; position: absolute; bottom: -2px; z-index: 2; font-size: 10px; right: 3px;",
2020
+ style: "width: fit-content;\r padding: 2px 6px;\r height: 16px;\r background: var(--color-blue-205-100-95);\r display: flex;\r justify-content: center;\r align-items: center;\r position: absolute;\r bottom: -2px;\r z-index: 2;\r font-size: 10px;\r right: 3px;",
2021
2021
  class: "fjs-debug-columns",
2022
2022
  children: (field.layout || {}).columns || 'auto'
2023
2023
  });
@@ -3076,10 +3076,10 @@ function updateRow(formField, rowId) {
3076
3076
  }
3077
3077
 
3078
3078
  class AddFormFieldHandler {
3079
- /**
3080
- * @constructor
3081
- * @param { import('../../../FormEditor').default } formEditor
3082
- * @param { import('../../../core/FormFieldRegistry').default } formFieldRegistry
3079
+ /**
3080
+ * @constructor
3081
+ * @param { import('../../../FormEditor').default } formEditor
3082
+ * @param { import('../../../core/FormFieldRegistry').default } formFieldRegistry
3083
3083
  */
3084
3084
  constructor(formEditor, formFieldRegistry) {
3085
3085
  this._formEditor = formEditor;
@@ -3140,10 +3140,10 @@ class AddFormFieldHandler {
3140
3140
  AddFormFieldHandler.$inject = ['formEditor', 'formFieldRegistry'];
3141
3141
 
3142
3142
  class EditFormFieldHandler {
3143
- /**
3144
- * @constructor
3145
- * @param { import('../../../FormEditor').default } formEditor
3146
- * @param { import('../../../core/FormFieldRegistry').default } formFieldRegistry
3143
+ /**
3144
+ * @constructor
3145
+ * @param { import('../../../FormEditor').default } formEditor
3146
+ * @param { import('../../../core/FormFieldRegistry').default } formFieldRegistry
3147
3147
  */
3148
3148
  constructor(formEditor, formFieldRegistry) {
3149
3149
  this._formEditor = formEditor;
@@ -3206,10 +3206,10 @@ class EditFormFieldHandler {
3206
3206
  EditFormFieldHandler.$inject = ['formEditor', 'formFieldRegistry'];
3207
3207
 
3208
3208
  class MoveFormFieldHandler {
3209
- /**
3210
- * @constructor
3211
- * @param { import('../../../FormEditor').default } formEditor
3212
- * @param { import('../../../core/FormFieldRegistry').default } formFieldRegistry
3209
+ /**
3210
+ * @constructor
3211
+ * @param { import('../../../FormEditor').default } formEditor
3212
+ * @param { import('../../../core/FormFieldRegistry').default } formFieldRegistry
3213
3213
  */
3214
3214
  constructor(formEditor, formFieldRegistry) {
3215
3215
  this._formEditor = formEditor;
@@ -3298,10 +3298,10 @@ class MoveFormFieldHandler {
3298
3298
  MoveFormFieldHandler.$inject = ['formEditor', 'formFieldRegistry'];
3299
3299
 
3300
3300
  class RemoveFormFieldHandler {
3301
- /**
3302
- * @constructor
3303
- * @param { import('../../../FormEditor').default } formEditor
3304
- * @param { import('../../../core/FormFieldRegistry').default } formFieldRegistry
3301
+ /**
3302
+ * @constructor
3303
+ * @param { import('../../../FormEditor').default } formEditor
3304
+ * @param { import('../../../core/FormFieldRegistry').default } formFieldRegistry
3305
3305
  */
3306
3306
  constructor(formEditor, formFieldRegistry) {
3307
3307
  this._formEditor = formEditor;
@@ -3361,9 +3361,9 @@ class RemoveFormFieldHandler {
3361
3361
  RemoveFormFieldHandler.$inject = ['formEditor', 'formFieldRegistry'];
3362
3362
 
3363
3363
  class UpdateIdClaimHandler {
3364
- /**
3365
- * @constructor
3366
- * @param { import('../../../core/FormFieldRegistry').default } formFieldRegistry
3364
+ /**
3365
+ * @constructor
3366
+ * @param { import('../../../core/FormFieldRegistry').default } formFieldRegistry
3367
3367
  */
3368
3368
  constructor(formFieldRegistry) {
3369
3369
  this._formFieldRegistry = formFieldRegistry;
@@ -3396,9 +3396,9 @@ class UpdateIdClaimHandler {
3396
3396
  UpdateIdClaimHandler.$inject = ['formFieldRegistry'];
3397
3397
 
3398
3398
  class UpdateKeyClaimHandler {
3399
- /**
3400
- * @constructor
3401
- * @param { import('../../../core/FormFieldRegistry').default } formFieldRegistry
3399
+ /**
3400
+ * @constructor
3401
+ * @param { import('../../../core/FormFieldRegistry').default } formFieldRegistry
3402
3402
  */
3403
3403
  constructor(formFieldRegistry) {
3404
3404
  this._formFieldRegistry = formFieldRegistry;
@@ -3864,8 +3864,8 @@ class ValidateBehavior extends CommandInterceptor {
3864
3864
  constructor(eventBus) {
3865
3865
  super(eventBus);
3866
3866
 
3867
- /**
3868
- * Remove custom validation if <validationType> is about to be added.
3867
+ /**
3868
+ * Remove custom validation if <validationType> is about to be added.
3869
3869
  */
3870
3870
  // @ts-ignore-next-line
3871
3871
  this.preExecute('formField.edit', function (context) {
@@ -4445,22 +4445,22 @@ var SelectionModule = {
4445
4445
  selectionBehavior: ['type', SelectionBehavior]
4446
4446
  };
4447
4447
 
4448
- /**
4449
- * Base class for sectionable UI modules.
4450
- *
4451
- * @property {EventBus} _eventBus - EventBus instance used for event handling.
4452
- * @property {string} managerType - Type of the render manager. Used to form event names.
4453
- *
4454
- * @class SectionModuleBase
4448
+ /**
4449
+ * Base class for sectionable UI modules.
4450
+ *
4451
+ * @property {EventBus} _eventBus - EventBus instance used for event handling.
4452
+ * @property {string} managerType - Type of the render manager. Used to form event names.
4453
+ *
4454
+ * @class SectionModuleBase
4455
4455
  */
4456
4456
  class SectionModuleBase {
4457
- /**
4458
- * Create a SectionModuleBase instance.
4459
- *
4460
- * @param {any} eventBus - The EventBus instance used for event handling.
4461
- * @param {string} sectionKey - The type of render manager. Used to form event names.
4462
- *
4463
- * @constructor
4457
+ /**
4458
+ * Create a SectionModuleBase instance.
4459
+ *
4460
+ * @param {any} eventBus - The EventBus instance used for event handling.
4461
+ * @param {string} sectionKey - The type of render manager. Used to form event names.
4462
+ *
4463
+ * @constructor
4464
4464
  */
4465
4465
  constructor(eventBus, sectionKey) {
4466
4466
  this._eventBus = eventBus;
@@ -4473,10 +4473,10 @@ class SectionModuleBase {
4473
4473
  });
4474
4474
  }
4475
4475
 
4476
- /**
4477
- * Attach the managed section to a parent node.
4478
- *
4479
- * @param {HTMLElement} container - The parent node to attach to.
4476
+ /**
4477
+ * Attach the managed section to a parent node.
4478
+ *
4479
+ * @param {HTMLElement} container - The parent node to attach to.
4480
4480
  */
4481
4481
  attachTo(container) {
4482
4482
  this._onceSectionRendered(() => this._eventBus.fire(`${this._sectionKey}.attach`, {
@@ -4484,22 +4484,22 @@ class SectionModuleBase {
4484
4484
  }));
4485
4485
  }
4486
4486
 
4487
- /**
4488
- * Detach the managed section from its parent node.
4487
+ /**
4488
+ * Detach the managed section from its parent node.
4489
4489
  */
4490
4490
  detach() {
4491
4491
  this._onceSectionRendered(() => this._eventBus.fire(`${this._sectionKey}.detach`));
4492
4492
  }
4493
4493
 
4494
- /**
4495
- * Reset the managed section to its initial state.
4494
+ /**
4495
+ * Reset the managed section to its initial state.
4496
4496
  */
4497
4497
  reset() {
4498
4498
  this._onceSectionRendered(() => this._eventBus.fire(`${this._sectionKey}.reset`));
4499
4499
  }
4500
4500
 
4501
- /**
4502
- * Circumvents timing issues.
4501
+ /**
4502
+ * Circumvents timing issues.
4503
4503
  */
4504
4504
  _onceSectionRendered(callback) {
4505
4505
  if (this.isSectionRendered) {
@@ -7087,11 +7087,11 @@ function prefixId(id) {
7087
7087
  return `bio-properties-panel-${id}`;
7088
7088
  }
7089
7089
 
7090
- /**
7091
- * @param {string} type
7092
- * @param {boolean} [strict]
7093
- *
7094
- * @returns {any}
7090
+ /**
7091
+ * @param {string} type
7092
+ * @param {boolean} [strict]
7093
+ *
7094
+ * @returns {any}
7095
7095
  */
7096
7096
  function getService(type, strict) {}
7097
7097
  const PropertiesPanelContext = createContext({
@@ -7180,8 +7180,8 @@ const PropertiesPanelHeaderProvider = {
7180
7180
  }
7181
7181
  };
7182
7182
 
7183
- /**
7184
- * Provide placeholders for empty and multiple state.
7183
+ /**
7184
+ * Provide placeholders for empty and multiple state.
7185
7185
  */
7186
7186
  const PropertiesPanelPlaceholderProvider = {
7187
7187
  getEmpty: () => {
@@ -7253,10 +7253,10 @@ function useService (type, strict) {
7253
7253
  return getService(type, strict);
7254
7254
  }
7255
7255
 
7256
- /**
7257
- * Retrieve list of variables from the form schema.
7258
- *
7259
- * @returns { string[] } list of variables used in form schema
7256
+ /**
7257
+ * Retrieve list of variables from the form schema.
7258
+ *
7259
+ * @returns { string[] } list of variables used in form schema
7260
7260
  */
7261
7261
  function useVariables() {
7262
7262
  const form = useService('formEditor');
@@ -8706,14 +8706,14 @@ function Value(props) {
8706
8706
 
8707
8707
  // helpers //////////
8708
8708
 
8709
- /**
8710
- * Returns copy of object with updated value.
8711
- *
8712
- * @param {Object} properties
8713
- * @param {string} key
8714
- * @param {string} value
8715
- *
8716
- * @returns {Object}
8709
+ /**
8710
+ * Returns copy of object with updated value.
8711
+ *
8712
+ * @param {Object} properties
8713
+ * @param {string} key
8714
+ * @param {string} value
8715
+ *
8716
+ * @returns {Object}
8717
8717
  */
8718
8718
  function updateValue(properties, key, value) {
8719
8719
  return {
@@ -8722,14 +8722,14 @@ function updateValue(properties, key, value) {
8722
8722
  };
8723
8723
  }
8724
8724
 
8725
- /**
8726
- * Returns copy of object with updated key.
8727
- *
8728
- * @param {Object} properties
8729
- * @param {string} oldKey
8730
- * @param {string} newKey
8731
- *
8732
- * @returns {Object}
8725
+ /**
8726
+ * Returns copy of object with updated key.
8727
+ *
8728
+ * @param {Object} properties
8729
+ * @param {string} oldKey
8730
+ * @param {string} newKey
8731
+ *
8732
+ * @returns {Object}
8733
8733
  */
8734
8734
  function updateKey(properties, oldKey, newKey) {
8735
8735
  return Object.entries(properties).reduce((newProperties, entry) => {
@@ -9423,8 +9423,8 @@ function ValuesGroups(field, editField) {
9423
9423
  };
9424
9424
  const valuesSourceId = `${fieldId}-valuesSource`;
9425
9425
 
9426
- /**
9427
- * @type {Array<Group|ListGroup>}
9426
+ /**
9427
+ * @type {Array<Group|ListGroup>}
9428
9428
  */
9429
9429
  const groups = [{
9430
9430
  id: valuesSourceId,
@@ -9526,13 +9526,13 @@ function CustomValuesGroup(field, editField) {
9526
9526
 
9527
9527
  // helpers //////////
9528
9528
 
9529
- /**
9530
- * Returns copy of object without key.
9531
- *
9532
- * @param {Object} properties
9533
- * @param {string} oldKey
9534
- *
9535
- * @returns {Object}
9529
+ /**
9530
+ * Returns copy of object without key.
9531
+ *
9532
+ * @param {Object} properties
9533
+ * @param {string} oldKey
9534
+ *
9535
+ * @returns {Object}
9536
9536
  */
9537
9537
  function removeKey(properties, oldKey) {
9538
9538
  return Object.entries(properties).reduce((newProperties, entry) => {
@@ -9617,47 +9617,37 @@ function FormPropertiesPanel(props) {
9617
9617
  } = props;
9618
9618
  const formEditor = injector.get('formEditor');
9619
9619
  const modeling = injector.get('modeling');
9620
- const selection = injector.get('selection');
9621
- const {
9622
- schema
9623
- } = formEditor._getState();
9620
+ const selectionModule = injector.get('selection');
9624
9621
  const [state, setState] = useState({
9625
- selectedFormField: selection.get() || schema
9622
+ selectedFormField: selectionModule.get() || formEditor._getState().schema
9626
9623
  });
9627
- const _update = field => {
9624
+ const selectedFormField = state.selectedFormField;
9625
+ const refresh = useCallback(field => {
9626
+ // TODO(skaiir): rework state management, re-rendering the whole properties panel is not the way to go
9627
+ // https://github.com/bpmn-io/form-js/issues/686
9628
9628
  setState({
9629
- ...state,
9630
- selectedFormField: field
9629
+ selectedFormField: selectionModule.get() || formEditor._getState().schema
9631
9630
  });
9632
9631
 
9633
9632
  // notify interested parties on property panel updates
9634
9633
  eventBus.fire('propertiesPanel.updated', {
9635
9634
  formField: field
9636
9635
  });
9637
- };
9638
- useLayoutEffect(() => {
9639
- function onSelectionChange(event) {
9640
- _update(event.selection || schema);
9641
- }
9642
- eventBus.on('selection.changed', onSelectionChange);
9643
- return () => {
9644
- eventBus.off('selection.changed', onSelectionChange);
9645
- };
9646
- }, []);
9636
+ }, [eventBus, formEditor, selectionModule]);
9647
9637
  useLayoutEffect(() => {
9648
- const onFieldChanged = () => {
9649
- /**
9650
- * TODO(pinussilvestrus): update with actual updated element,
9651
- * once we have a proper updater/change support
9652
- */
9653
- _update(selection.get() || schema);
9654
- };
9655
- eventBus.on('changed', onFieldChanged);
9638
+ /**
9639
+ * TODO(pinussilvestrus): update with actual updated element,
9640
+ * once we have a proper updater/change support
9641
+ */
9642
+ eventBus.on('changed', refresh);
9643
+ eventBus.on('import.done', refresh);
9644
+ eventBus.on('selection.changed', refresh);
9656
9645
  return () => {
9657
- eventBus.off('changed', onFieldChanged);
9646
+ eventBus.off('changed', refresh);
9647
+ eventBus.off('import.done', refresh);
9648
+ eventBus.off('selection.changed', refresh);
9658
9649
  };
9659
- }, []);
9660
- const selectedFormField = state.selectedFormField;
9650
+ }, [eventBus, refresh]);
9661
9651
  const getService = (type, strict = true) => injector.get(type, strict);
9662
9652
  const propertiesPanelContext = {
9663
9653
  getService
@@ -9699,10 +9689,10 @@ class PropertiesPanelRenderer {
9699
9689
  });
9700
9690
  }
9701
9691
 
9702
- /**
9703
- * Attach the properties panel to a parent node.
9704
- *
9705
- * @param {HTMLElement} container
9692
+ /**
9693
+ * Attach the properties panel to a parent node.
9694
+ *
9695
+ * @param {HTMLElement} container
9706
9696
  */
9707
9697
  attachTo(container) {
9708
9698
  if (!container) {
@@ -9722,8 +9712,8 @@ class PropertiesPanelRenderer {
9722
9712
  this._eventBus.fire('propertiesPanel.attach');
9723
9713
  }
9724
9714
 
9725
- /**
9726
- * Detach the properties panel from its parent node.
9715
+ /**
9716
+ * Detach the properties panel from its parent node.
9727
9717
  */
9728
9718
  detach() {
9729
9719
  const parentNode = this._container.parentNode;
@@ -9753,10 +9743,10 @@ var PropertiesPanelModule = {
9753
9743
  propertiesPanel: ['type', PropertiesPanelRenderer]
9754
9744
  };
9755
9745
 
9756
- /**
9757
- * Manages the rendering of visual plugins.
9758
- * @constructor
9759
- * @param {Object} eventBus - Event bus for the application.
9746
+ /**
9747
+ * Manages the rendering of visual plugins.
9748
+ * @constructor
9749
+ * @param {Object} eventBus - Event bus for the application.
9760
9750
  */
9761
9751
  class RenderInjector extends SectionModuleBase {
9762
9752
  constructor(eventBus) {
@@ -9765,10 +9755,10 @@ class RenderInjector extends SectionModuleBase {
9765
9755
  this.registeredRenderers = [];
9766
9756
  }
9767
9757
 
9768
- /**
9769
- * Inject a new renderer into the injector.
9770
- * @param {string} identifier - Identifier for the renderer.
9771
- * @param {Function} Renderer - The renderer function.
9758
+ /**
9759
+ * Inject a new renderer into the injector.
9760
+ * @param {string} identifier - Identifier for the renderer.
9761
+ * @param {Function} Renderer - The renderer function.
9772
9762
  */
9773
9763
  attachRenderer(identifier, Renderer) {
9774
9764
  this.registeredRenderers = [...this.registeredRenderers, {
@@ -9777,17 +9767,17 @@ class RenderInjector extends SectionModuleBase {
9777
9767
  }];
9778
9768
  }
9779
9769
 
9780
- /**
9781
- * Detach a renderer from the by key injector.
9782
- * @param {string} identifier - Identifier for the renderer.
9770
+ /**
9771
+ * Detach a renderer from the by key injector.
9772
+ * @param {string} identifier - Identifier for the renderer.
9783
9773
  */
9784
9774
  detachRenderer(identifier) {
9785
9775
  this.registeredRenderers = this.registeredRenderers.filter(r => r.identifier !== identifier);
9786
9776
  }
9787
9777
 
9788
- /**
9789
- * Returns the registered renderers.
9790
- * @returns {Array} Array of registered renderers.
9778
+ /**
9779
+ * Returns the registered renderers.
9780
+ * @returns {Array} Array of registered renderers.
9791
9781
  */
9792
9782
  fetchRenderers() {
9793
9783
  return this.registeredRenderers;
@@ -9821,48 +9811,48 @@ var ExpressionLanguageModule = {
9821
9811
 
9822
9812
  const ids = new Ids([32, 36, 1]);
9823
9813
 
9824
- /**
9825
- * @typedef { import('./types').Injector } Injector
9826
- * @typedef { import('./types').Module } Module
9827
- * @typedef { import('./types').Schema } Schema
9828
- *
9829
- * @typedef { import('./types').FormEditorOptions } FormEditorOptions
9830
- * @typedef { import('./types').FormEditorProperties } FormEditorProperties
9831
- *
9832
- * @typedef { {
9833
- * properties: FormEditorProperties,
9834
- * schema: Schema
9835
- * } } State
9836
- *
9837
- * @typedef { (type:string, priority:number, handler:Function) => void } OnEventWithPriority
9838
- * @typedef { (type:string, handler:Function) => void } OnEventWithOutPriority
9839
- * @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
9814
+ /**
9815
+ * @typedef { import('./types').Injector } Injector
9816
+ * @typedef { import('./types').Module } Module
9817
+ * @typedef { import('./types').Schema } Schema
9818
+ *
9819
+ * @typedef { import('./types').FormEditorOptions } FormEditorOptions
9820
+ * @typedef { import('./types').FormEditorProperties } FormEditorProperties
9821
+ *
9822
+ * @typedef { {
9823
+ * properties: FormEditorProperties,
9824
+ * schema: Schema
9825
+ * } } State
9826
+ *
9827
+ * @typedef { (type:string, priority:number, handler:Function) => void } OnEventWithPriority
9828
+ * @typedef { (type:string, handler:Function) => void } OnEventWithOutPriority
9829
+ * @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
9840
9830
  */
9841
9831
 
9842
- /**
9843
- * The form editor.
9832
+ /**
9833
+ * The form editor.
9844
9834
  */
9845
9835
  class FormEditor {
9846
- /**
9847
- * @constructor
9848
- * @param {FormEditorOptions} options
9836
+ /**
9837
+ * @constructor
9838
+ * @param {FormEditorOptions} options
9849
9839
  */
9850
9840
  constructor(options = {}) {
9851
- /**
9852
- * @public
9853
- * @type {OnEventType}
9841
+ /**
9842
+ * @public
9843
+ * @type {OnEventType}
9854
9844
  */
9855
9845
  this.on = this._onEvent;
9856
9846
 
9857
- /**
9858
- * @public
9859
- * @type {String}
9847
+ /**
9848
+ * @public
9849
+ * @type {String}
9860
9850
  */
9861
9851
  this._id = ids.next();
9862
9852
 
9863
- /**
9864
- * @private
9865
- * @type {Element}
9853
+ /**
9854
+ * @private
9855
+ * @type {Element}
9866
9856
  */
9867
9857
  this._container = createFormContainer();
9868
9858
  this._container.setAttribute('input-handle-modified-keys', 'z,y');
@@ -9873,15 +9863,15 @@ class FormEditor {
9873
9863
  properties = {}
9874
9864
  } = options;
9875
9865
 
9876
- /**
9877
- * @private
9878
- * @type {any}
9866
+ /**
9867
+ * @private
9868
+ * @type {any}
9879
9869
  */
9880
9870
  this.exporter = exporter;
9881
9871
 
9882
- /**
9883
- * @private
9884
- * @type {State}
9872
+ /**
9873
+ * @private
9874
+ * @type {State}
9885
9875
  */
9886
9876
  this._state = {
9887
9877
  properties,
@@ -9910,10 +9900,10 @@ class FormEditor {
9910
9900
  this._detach(false);
9911
9901
  }
9912
9902
 
9913
- /**
9914
- * @param {Schema} schema
9915
- *
9916
- * @return {Promise<{ warnings: Array<any> }>}
9903
+ /**
9904
+ * @param {Schema} schema
9905
+ *
9906
+ * @return {Promise<{ warnings: Array<any> }>}
9917
9907
  */
9918
9908
  importSchema(schema) {
9919
9909
  return new Promise((resolve, reject) => {
@@ -9942,15 +9932,15 @@ class FormEditor {
9942
9932
  });
9943
9933
  }
9944
9934
 
9945
- /**
9946
- * @returns {Schema}
9935
+ /**
9936
+ * @returns {Schema}
9947
9937
  */
9948
9938
  saveSchema() {
9949
9939
  return this.getSchema();
9950
9940
  }
9951
9941
 
9952
- /**
9953
- * @returns {Schema}
9942
+ /**
9943
+ * @returns {Schema}
9954
9944
  */
9955
9945
  getSchema() {
9956
9946
  const {
@@ -9959,8 +9949,8 @@ class FormEditor {
9959
9949
  return exportSchema(schema, this.exporter, schemaVersion);
9960
9950
  }
9961
9951
 
9962
- /**
9963
- * @param {Element|string} parentNode
9952
+ /**
9953
+ * @param {Element|string} parentNode
9964
9954
  */
9965
9955
  attachTo(parentNode) {
9966
9956
  if (!parentNode) {
@@ -9978,10 +9968,10 @@ class FormEditor {
9978
9968
  this._detach();
9979
9969
  }
9980
9970
 
9981
- /**
9982
- * @internal
9983
- *
9984
- * @param {boolean} [emit]
9971
+ /**
9972
+ * @internal
9973
+ *
9974
+ * @param {boolean} [emit]
9985
9975
  */
9986
9976
  _detach(emit = true) {
9987
9977
  const container = this._container,
@@ -9995,9 +9985,9 @@ class FormEditor {
9995
9985
  parentNode.removeChild(container);
9996
9986
  }
9997
9987
 
9998
- /**
9999
- * @param {any} property
10000
- * @param {any} value
9988
+ /**
9989
+ * @param {any} property
9990
+ * @param {any} value
10001
9991
  */
10002
9992
  setProperty(property, value) {
10003
9993
  const properties = set$1(this._getState().properties, [property], value);
@@ -10006,21 +9996,21 @@ class FormEditor {
10006
9996
  });
10007
9997
  }
10008
9998
 
10009
- /**
10010
- * @param {string} type
10011
- * @param {Function} handler
9999
+ /**
10000
+ * @param {string} type
10001
+ * @param {Function} handler
10012
10002
  */
10013
10003
  off(type, handler) {
10014
10004
  this.get('eventBus').off(type, handler);
10015
10005
  }
10016
10006
 
10017
- /**
10018
- * @internal
10019
- *
10020
- * @param {FormEditorOptions} options
10021
- * @param {Element} container
10022
- *
10023
- * @returns {Injector}
10007
+ /**
10008
+ * @internal
10009
+ *
10010
+ * @param {FormEditorOptions} options
10011
+ * @param {Element} container
10012
+ *
10013
+ * @returns {Injector}
10024
10014
  */
10025
10015
  _createInjector(options, container) {
10026
10016
  const {
@@ -10042,22 +10032,22 @@ class FormEditor {
10042
10032
  }, core, ...modules, ...additionalModules]);
10043
10033
  }
10044
10034
 
10045
- /**
10046
- * @internal
10035
+ /**
10036
+ * @internal
10047
10037
  */
10048
10038
  _emit(type, data) {
10049
10039
  this.get('eventBus').fire(type, data);
10050
10040
  }
10051
10041
 
10052
- /**
10053
- * @internal
10042
+ /**
10043
+ * @internal
10054
10044
  */
10055
10045
  _getState() {
10056
10046
  return this._state;
10057
10047
  }
10058
10048
 
10059
- /**
10060
- * @internal
10049
+ /**
10050
+ * @internal
10061
10051
  */
10062
10052
  _setState(state) {
10063
10053
  this._state = {
@@ -10067,15 +10057,15 @@ class FormEditor {
10067
10057
  this._emit('changed', this._getState());
10068
10058
  }
10069
10059
 
10070
- /**
10071
- * @internal
10060
+ /**
10061
+ * @internal
10072
10062
  */
10073
10063
  _getModules() {
10074
10064
  return [ModelingModule, EditorActionsModule, DraggingModule, KeyboardModule, SelectionModule, PaletteModule, ExpressionLanguageModule, MarkdownModule, PropertiesPanelModule, RenderInjectionModule];
10075
10065
  }
10076
10066
 
10077
- /**
10078
- * @internal
10067
+ /**
10068
+ * @internal
10079
10069
  */
10080
10070
  _onEvent(type, priority, handler) {
10081
10071
  this.get('eventBus').on(type, priority, handler);