@bpmn-io/properties-panel 0.10.2 → 0.11.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.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ All notable changes to [`@bpmn-io/properties-panel`](https://github.com/bpmn-io/
6
6
 
7
7
  ___Note:__ Yet to be released changes appear here._
8
8
 
9
+ ## 0.11.0
10
+
11
+ * `FEAT`: all group and entry components specified as `component` are actual components, not elements ([#134](https://github.com/bpmn-io/properties-panel/pull/134))
12
+
13
+ ### BREAKING CHANGES
14
+
15
+ * `component` property of an entry must be an actual component, not an element
16
+
9
17
  ## 0.10.2
10
18
 
11
19
  * `FIX`: add missing aria label for `simple` component ([67f374](https://github.com/bpmn-io/properties-panel/commit/67f37491ab8dc8493c8dd1e749d7418d11825125))
package/dist/index.esm.js CHANGED
@@ -3,7 +3,7 @@ import { isFunction, get, assign, set, sortBy, find, isNumber, debounce } from '
3
3
  import classnames from 'classnames';
4
4
  import { jsxs, jsx } from '../preact/jsx-runtime';
5
5
  import { query } from 'min-dom';
6
- import { createContext } from '../preact';
6
+ import { createContext, createElement } from '../preact';
7
7
  import '../preact/compat';
8
8
 
9
9
  /**
@@ -221,8 +221,9 @@ DeleteIcon.defaultProps = {
221
221
 
222
222
  function Group(props) {
223
223
  const {
224
- id,
224
+ element,
225
225
  entries = [],
226
+ id,
226
227
  label
227
228
  } = props;
228
229
  const [open, setOpen] = useLayoutState(['groups', id, 'open'], false);
@@ -270,7 +271,16 @@ function Group(props) {
270
271
  })]
271
272
  }), jsx("div", {
272
273
  class: classnames('bio-properties-panel-group-entries', open ? 'open' : ''),
273
- children: entries.map(e => e.component)
274
+ children: entries.map(entry => {
275
+ const {
276
+ component: Component,
277
+ id
278
+ } = entry;
279
+ return createElement(Component, { ...entry,
280
+ key: id,
281
+ element: element
282
+ });
283
+ })
274
284
  })]
275
285
  });
276
286
  }
@@ -288,7 +298,7 @@ const DEFAULT_LAYOUT = {
288
298
  const DEFAULT_DESCRIPTION = {};
289
299
  /**
290
300
  * @typedef { {
291
- * component: import('preact').ComponentChild,
301
+ * component: import('preact').Component,
292
302
  * id: String,
293
303
  * isEdited?: Function
294
304
  * } } EntryDefinition
@@ -416,13 +426,13 @@ function PropertiesPanel(props) {
416
426
  class: "bio-properties-panel-scroll-container",
417
427
  children: groups.map(group => {
418
428
  const {
419
- component: GroupComponent = Group,
429
+ component: Component = Group,
420
430
  id
421
431
  } = group;
422
- return jsx(GroupComponent, {
423
- element: element,
424
- ...group
425
- }, id);
432
+ return createElement(Component, { ...group,
433
+ key: id,
434
+ element: element
435
+ });
426
436
  })
427
437
  })]
428
438
  })
@@ -555,11 +565,12 @@ function HeaderButton(props) {
555
565
 
556
566
  function CollapsibleEntry(props) {
557
567
  const {
558
- id,
568
+ element,
559
569
  entries = [],
570
+ id,
560
571
  label,
561
- remove,
562
- open: shouldOpen
572
+ open: shouldOpen,
573
+ remove
563
574
  } = props;
564
575
  const [open, setOpen] = useState(shouldOpen);
565
576
 
@@ -591,15 +602,24 @@ function CollapsibleEntry(props) {
591
602
  }) : null]
592
603
  }), jsx("div", {
593
604
  class: classnames('bio-properties-panel-collapsible-entry-entries', open ? 'open' : ''),
594
- children: entries.map(e => e.component)
605
+ children: entries.map(entry => {
606
+ const {
607
+ component: Component,
608
+ id
609
+ } = entry;
610
+ return createElement(Component, { ...entry,
611
+ key: id,
612
+ element: element
613
+ });
614
+ })
595
615
  })]
596
616
  });
597
617
  }
598
618
 
599
619
  function ListItem(props) {
600
620
  const {
601
- autoOpen,
602
- autoFocusEntry
621
+ autoFocusEntry,
622
+ autoOpen
603
623
  } = props; // focus specified entry on auto open
604
624
 
605
625
  useEffect(() => {
@@ -632,13 +652,13 @@ const noop = () => {};
632
652
 
633
653
  function ListGroup(props) {
634
654
  const {
655
+ add,
635
656
  element,
636
657
  id,
637
658
  items,
638
659
  label,
639
- add,
640
- shouldSort = true,
641
- shouldOpen = true
660
+ shouldOpen = true,
661
+ shouldSort = true
642
662
  } = props;
643
663
  const [open, setOpen] = useLayoutState(['groups', id, 'open'], false);
644
664
  const [ordering, setOrdering] = useState([]);
@@ -756,11 +776,16 @@ function ListGroup(props) {
756
776
  return;
757
777
  }
758
778
 
759
- return jsx(ListItem, {
760
- // if item was added, open first or last item based on ordering
761
- autoOpen: newItemAdded && (shouldSort ? index === 0 : index === ordering.length - 1),
762
- ...item
763
- }, item.id);
779
+ const {
780
+ id
781
+ } = item;
782
+ return createElement(ListItem, { ...item,
783
+ element: element,
784
+ index: index,
785
+ key: id // if item was added, open first or last item based on ordering
786
+ ,
787
+ autoOpen: newItemAdded && (shouldSort ? index === 0 : index === ordering.length - 1)
788
+ });
764
789
  })
765
790
  })]
766
791
  });
@@ -883,7 +908,7 @@ function List(props) {
883
908
  id,
884
909
  element,
885
910
  items = [],
886
- renderItem,
911
+ component,
887
912
  label = '<empty>',
888
913
  open: shouldOpen,
889
914
  onAdd,
@@ -953,12 +978,13 @@ function List(props) {
953
978
  })]
954
979
  }), hasItems && jsx(ItemsList, {
955
980
  autoFocusEntry: autoFocusEntry,
981
+ component: component,
982
+ element: element,
956
983
  id: id,
957
- open: open,
958
984
  items: sortedItems,
959
985
  newItems: newItems,
960
986
  onRemove: onRemove,
961
- renderItem: renderItem
987
+ open: open
962
988
  })]
963
989
  });
964
990
  }
@@ -966,12 +992,13 @@ function List(props) {
966
992
  function ItemsList(props) {
967
993
  const {
968
994
  autoFocusEntry,
995
+ component: Component,
996
+ element,
969
997
  id,
970
998
  items,
971
999
  newItems,
972
- open,
973
1000
  onRemove,
974
- renderItem
1001
+ open
975
1002
  } = props;
976
1003
  const getKey = useKeyFactory();
977
1004
  const newItem = newItems[0];
@@ -998,7 +1025,13 @@ function ItemsList(props) {
998
1025
  const key = getKey(item);
999
1026
  return jsxs("li", {
1000
1027
  class: "bio-properties-panel-list-entry-item",
1001
- children: [renderItem(item, index, item === newItem), onRemove && jsx("button", {
1028
+ children: [jsx(Component, {
1029
+ element: element,
1030
+ id: id,
1031
+ index: index,
1032
+ item: item,
1033
+ open: item === newItem
1034
+ }), onRemove && jsx("button", {
1002
1035
  type: "button",
1003
1036
  title: "Delete item",
1004
1037
  class: "bio-properties-panel-remove-entry bio-properties-panel-remove-list-entry",