@bpmn-io/properties-panel 0.13.1 → 0.13.2

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.js CHANGED
@@ -174,19 +174,19 @@ const DescriptionContext = preact.createContext({
174
174
  getDescriptionForId: () => {}
175
175
  });
176
176
 
177
- /**
178
- * @typedef {Function} <propertiesPanel.showEntry> callback
179
- *
180
- * @example
181
- *
182
- * useEvent('propertiesPanel.showEntry', ({ focus = false, ...rest }) => {
183
- * // ...
184
- * });
185
- *
186
- * @param {Object} context
187
- * @param {boolean} [context.focus]
188
- *
189
- * @returns void
177
+ /**
178
+ * @typedef {Function} <propertiesPanel.showEntry> callback
179
+ *
180
+ * @example
181
+ *
182
+ * useEvent('propertiesPanel.showEntry', ({ focus = false, ...rest }) => {
183
+ * // ...
184
+ * });
185
+ *
186
+ * @param {Object} context
187
+ * @param {boolean} [context.focus]
188
+ *
189
+ * @returns void
190
190
  */
191
191
  const EventContext = preact.createContext({
192
192
  eventBus: null
@@ -199,20 +199,20 @@ const LayoutContext = preact.createContext({
199
199
  setLayoutForKey: () => {}
200
200
  });
201
201
 
202
- /**
203
- * Accesses the global DescriptionContext and returns a description for a given id and element.
204
- *
205
- * @example
206
- * ```jsx
207
- * function TextField(props) {
208
- * const description = useDescriptionContext('input1', element);
209
- * }
210
- * ```
211
- *
212
- * @param {string} id
213
- * @param {djs.model.Base} element
214
- *
215
- * @returns {string}
202
+ /**
203
+ * Accesses the global DescriptionContext and returns a description for a given id and element.
204
+ *
205
+ * @example
206
+ * ```jsx
207
+ * function TextField(props) {
208
+ * const description = useDescriptionContext('input1', element);
209
+ * }
210
+ * ```
211
+ *
212
+ * @param {string} id
213
+ * @param {djs.model.Base} element
214
+ *
215
+ * @returns {string}
216
216
  */
217
217
 
218
218
  function useDescriptionContext(id, element) {
@@ -223,14 +223,14 @@ function useDescriptionContext(id, element) {
223
223
  }
224
224
 
225
225
  const DEFAULT_PRIORITY = 1000;
226
- /**
227
- * Subscribe to an event.
228
- *
229
- * @param {string} event
230
- * @param {Function} callback
231
- * @param {number} [priority]
232
- *
233
- * @returns {import('preact').Ref}
226
+ /**
227
+ * Subscribe to an event.
228
+ *
229
+ * @param {string} event
230
+ * @param {Function} callback
231
+ * @param {number} [priority]
232
+ *
233
+ * @returns {import('preact').Ref}
234
234
  */
235
235
 
236
236
  function useEvent(event, callback, priority = DEFAULT_PRIORITY) {
@@ -248,11 +248,11 @@ function useEvent(event, callback, priority = DEFAULT_PRIORITY) {
248
248
  }
249
249
 
250
250
  const HIGH_PRIORITY = 10000;
251
- /**
252
- * Buffer events and re-fire during passive effect phase.
253
- *
254
- * @param {string[]} bufferedEvents
255
- * @param {Object} [eventBus]
251
+ /**
252
+ * Buffer events and re-fire during passive effect phase.
253
+ *
254
+ * @param {string[]} bufferedEvents
255
+ * @param {Object} [eventBus]
256
256
  */
257
257
 
258
258
  function useEventBuffer(bufferedEvents, eventBus) {
@@ -301,24 +301,24 @@ function useEventBuffer(bufferedEvents, eventBus) {
301
301
  }
302
302
 
303
303
  const KEY_LENGTH = 6;
304
- /**
305
- * Create a persistent key factory for plain objects without id.
306
- *
307
- * @example
308
- * ```jsx
309
- * function List({ objects }) {
310
- * const getKey = useKeyFactory();
311
- * return (<ol>{
312
- * objects.map(obj => {
313
- * const key = getKey(obj);
314
- * return <li key={key}>obj.name</li>
315
- * })
316
- * }</ol>);
317
- * }
318
- * ```
319
- *
320
- * @param {any[]} dependencies
321
- * @returns {(element: object) => string}
304
+ /**
305
+ * Create a persistent key factory for plain objects without id.
306
+ *
307
+ * @example
308
+ * ```jsx
309
+ * function List({ objects }) {
310
+ * const getKey = useKeyFactory();
311
+ * return (<ol>{
312
+ * objects.map(obj => {
313
+ * const key = getKey(obj);
314
+ * return <li key={key}>obj.name</li>
315
+ * })
316
+ * }</ol>);
317
+ * }
318
+ * ```
319
+ *
320
+ * @param {any[]} dependencies
321
+ * @returns {(element: object) => string}
322
322
  */
323
323
 
324
324
  function useKeyFactory(dependencies = []) {
@@ -338,20 +338,20 @@ function useKeyFactory(dependencies = []) {
338
338
  return getKey;
339
339
  }
340
340
 
341
- /**
342
- * Creates a state that persists in the global LayoutContext.
343
- *
344
- * @example
345
- * ```jsx
346
- * function Group(props) {
347
- * const [ open, setOpen ] = useLayoutState([ 'groups', 'foo', 'open' ], false);
348
- * }
349
- * ```
350
- *
351
- * @param {(string|number)[]} path
352
- * @param {any} [defaultValue]
353
- *
354
- * @returns {[ any, Function ]}
341
+ /**
342
+ * Creates a state that persists in the global LayoutContext.
343
+ *
344
+ * @example
345
+ * ```jsx
346
+ * function Group(props) {
347
+ * const [ open, setOpen ] = useLayoutState([ 'groups', 'foo', 'open' ], false);
348
+ * }
349
+ * ```
350
+ *
351
+ * @param {(string|number)[]} path
352
+ * @param {any} [defaultValue]
353
+ *
354
+ * @returns {[ any, Function ]}
355
355
  */
356
356
 
357
357
  function useLayoutState(path, defaultValue) {
@@ -372,11 +372,11 @@ function useLayoutState(path, defaultValue) {
372
372
  return [value, setState];
373
373
  }
374
374
 
375
- /**
376
- * @pinussilvestrus: we need to introduce our own hook to persist the previous
377
- * state on updates.
378
- *
379
- * cf. https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state
375
+ /**
376
+ * @pinussilvestrus: we need to introduce our own hook to persist the previous
377
+ * state on updates.
378
+ *
379
+ * cf. https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state
380
380
  */
381
381
 
382
382
  function usePrevious(value) {
@@ -387,12 +387,12 @@ function usePrevious(value) {
387
387
  return ref.current;
388
388
  }
389
389
 
390
- /**
391
- * Subscribe to `propertiesPanel.showEntry`.
392
- *
393
- * @param {Function} show
394
- *
395
- * @returns {import('preact').Ref}
390
+ /**
391
+ * Subscribe to `propertiesPanel.showEntry`.
392
+ *
393
+ * @param {Function} show
394
+ *
395
+ * @returns {import('preact').Ref}
396
396
  */
397
397
 
398
398
  function useShowEntryEvent(show) {
@@ -429,14 +429,14 @@ function useShowEntryEvent(show) {
429
429
  return ref;
430
430
  }
431
431
 
432
- /**
433
- * Subscribe to `propertiesPanel.showError`. On `propertiesPanel.showError` set
434
- * temporary error. Fire `propertiesPanel.showEntry` for temporary error to be
435
- * visible. Unset error on `propertiesPanel.updated`.
436
- *
437
- * @param {Function} show
438
- *
439
- * @returns {import('preact').Ref}
432
+ /**
433
+ * Subscribe to `propertiesPanel.showError`. On `propertiesPanel.showError` set
434
+ * temporary error. Fire `propertiesPanel.showEntry` for temporary error to be
435
+ * visible. Unset error on `propertiesPanel.updated`.
436
+ *
437
+ * @param {Function} show
438
+ *
439
+ * @returns {import('preact').Ref}
440
440
  */
441
441
 
442
442
  function useShowErrorEvent(show) {
@@ -547,66 +547,66 @@ const DEFAULT_LAYOUT = {
547
547
  };
548
548
  const DEFAULT_DESCRIPTION = {};
549
549
  const bufferedEvents = ['propertiesPanel.showEntry', 'propertiesPanel.showError'];
550
- /**
551
- * @typedef { {
552
- * component: import('preact').Component,
553
- * id: String,
554
- * isEdited?: Function
555
- * } } EntryDefinition
556
- *
557
- * @typedef { {
558
- * autoFocusEntry: String,
559
- * autoOpen?: Boolean,
560
- * entries: Array<EntryDefinition>,
561
- * id: String,
562
- * label: String,
563
- * remove: (event: MouseEvent) => void
564
- * } } ListItemDefinition
565
- *
566
- * @typedef { {
567
- * add: (event: MouseEvent) => void,
568
- * component: import('preact').Component,
569
- * element: Object,
570
- * id: String,
571
- * items: Array<ListItemDefinition>,
572
- * label: String,
573
- * shouldSort?: Boolean,
574
- * shouldOpen?: Boolean
575
- * } } ListGroupDefinition
576
- *
577
- * @typedef { {
578
- * component?: import('preact').Component,
579
- * entries: Array<EntryDefinition>,
580
- * id: String,
581
- * label: String,
582
- * shouldOpen?: Boolean
583
- * } } GroupDefinition
584
- *
585
- * @typedef { {
586
- * [id: String]: GetDescriptionFunction
587
- * } } DescriptionConfig
588
- *
589
- * @callback { {
590
- * @param {string} id
591
- * @param {djs.model.base} element
592
- * @returns {string}
593
- * } } GetDescriptionFunction
594
- *
550
+ /**
551
+ * @typedef { {
552
+ * component: import('preact').Component,
553
+ * id: String,
554
+ * isEdited?: Function
555
+ * } } EntryDefinition
556
+ *
557
+ * @typedef { {
558
+ * autoFocusEntry: String,
559
+ * autoOpen?: Boolean,
560
+ * entries: Array<EntryDefinition>,
561
+ * id: String,
562
+ * label: String,
563
+ * remove: (event: MouseEvent) => void
564
+ * } } ListItemDefinition
565
+ *
566
+ * @typedef { {
567
+ * add: (event: MouseEvent) => void,
568
+ * component: import('preact').Component,
569
+ * element: Object,
570
+ * id: String,
571
+ * items: Array<ListItemDefinition>,
572
+ * label: String,
573
+ * shouldSort?: Boolean,
574
+ * shouldOpen?: Boolean
575
+ * } } ListGroupDefinition
576
+ *
577
+ * @typedef { {
578
+ * component?: import('preact').Component,
579
+ * entries: Array<EntryDefinition>,
580
+ * id: String,
581
+ * label: String,
582
+ * shouldOpen?: Boolean
583
+ * } } GroupDefinition
584
+ *
585
+ * @typedef { {
586
+ * [id: String]: GetDescriptionFunction
587
+ * } } DescriptionConfig
588
+ *
589
+ * @callback { {
590
+ * @param {string} id
591
+ * @param {djs.model.base} element
592
+ * @returns {string}
593
+ * } } GetDescriptionFunction
594
+ *
595
595
  */
596
596
 
597
- /**
598
- * A basic properties panel component. Describes *how* content will be rendered, accepts
599
- * data from implementor to describe *what* will be rendered.
600
- *
601
- * @param {Object} props
602
- * @param {Object} props.element
603
- * @param {import('./components/Header').HeaderProvider} props.headerProvider
604
- * @param {Array<GroupDefinition|ListGroupDefinition>} props.groups
605
- * @param {Object} [props.layoutConfig]
606
- * @param {Function} [props.layoutChanged]
607
- * @param {DescriptionConfig} [props.descriptionConfig]
608
- * @param {Function} [props.descriptionLoaded]
609
- * @param {Object} [props.eventBus]
597
+ /**
598
+ * A basic properties panel component. Describes *how* content will be rendered, accepts
599
+ * data from implementor to describe *what* will be rendered.
600
+ *
601
+ * @param {Object} props
602
+ * @param {Object} props.element
603
+ * @param {import('./components/Header').HeaderProvider} props.headerProvider
604
+ * @param {Array<GroupDefinition|ListGroupDefinition>} props.groups
605
+ * @param {Object} [props.layoutConfig]
606
+ * @param {Function} [props.layoutChanged]
607
+ * @param {DescriptionConfig} [props.descriptionConfig]
608
+ * @param {Function} [props.descriptionLoaded]
609
+ * @param {Object} [props.eventBus]
610
610
  */
611
611
 
612
612
  function PropertiesPanel(props) {
@@ -787,17 +787,17 @@ function MenuItem({
787
787
  children: item.entry
788
788
  });
789
789
  }
790
- /**
791
- *
792
- * @param {Array<null | Element>} ignoredElements
793
- * @param {Function} callback
790
+ /**
791
+ *
792
+ * @param {Array<null | Element>} ignoredElements
793
+ * @param {Function} callback
794
794
  */
795
795
 
796
796
 
797
797
  function useGlobalClick(ignoredElements, callback) {
798
798
  hooks.useEffect(() => {
799
- /**
800
- * @param {MouseEvent} event
799
+ /**
800
+ * @param {MouseEvent} event
801
801
  */
802
802
  function listener(event) {
803
803
  if (ignoredElements.some(element => element && element.contains(event.target))) {
@@ -927,8 +927,8 @@ function ListItem(props) {
927
927
  }
928
928
 
929
929
  const noop$3 = () => {};
930
- /**
931
- * @param {import('../PropertiesPanel').ListGroupDefinition} props
930
+ /**
931
+ * @param {import('../PropertiesPanel').ListGroupDefinition} props
932
932
  */
933
933
 
934
934
 
@@ -1081,8 +1081,8 @@ function ListGroup(props) {
1081
1081
  });
1082
1082
  } // helpers ////////////////////
1083
1083
 
1084
- /**
1085
- * Sorts given items alphanumeric by label
1084
+ /**
1085
+ * Sorts given items alphanumeric by label
1086
1086
  */
1087
1087
 
1088
1088
  function sortItems(items) {
@@ -1151,15 +1151,15 @@ function Checkbox(props) {
1151
1151
  })]
1152
1152
  });
1153
1153
  }
1154
- /**
1155
- * @param {Object} props
1156
- * @param {Object} props.element
1157
- * @param {String} props.id
1158
- * @param {String} props.description
1159
- * @param {String} props.label
1160
- * @param {Function} props.getValue
1161
- * @param {Function} props.setValue
1162
- * @param {boolean} [props.disabled]
1154
+ /**
1155
+ * @param {Object} props
1156
+ * @param {Object} props.element
1157
+ * @param {String} props.id
1158
+ * @param {String} props.description
1159
+ * @param {String} props.label
1160
+ * @param {Function} props.getValue
1161
+ * @param {Function} props.setValue
1162
+ * @param {boolean} [props.disabled]
1163
1163
  */
1164
1164
 
1165
1165
 
@@ -1232,8 +1232,8 @@ function List(props) {
1232
1232
  setOpen(false);
1233
1233
  }
1234
1234
  }, [open, hasItems]);
1235
- /**
1236
- * @param {MouseEvent} event
1235
+ /**
1236
+ * @param {MouseEvent} event
1237
1237
  */
1238
1238
 
1239
1239
  function addItem(event) {
@@ -1343,14 +1343,14 @@ function ItemsList(props) {
1343
1343
  })
1344
1344
  });
1345
1345
  }
1346
- /**
1347
- * Place new items in the beginning of the list and sort the rest with provided function.
1348
- *
1349
- * @template Item
1350
- * @param {Item[]} currentItems
1351
- * @param {(a: Item, b: Item) => 0 | 1 | -1} [compareFn] function used to sort items
1352
- * @param {boolean} [shouldReset=false] set to `true` to reset state of the hook
1353
- * @returns {Item[]}
1346
+ /**
1347
+ * Place new items in the beginning of the list and sort the rest with provided function.
1348
+ *
1349
+ * @template Item
1350
+ * @param {Item[]} currentItems
1351
+ * @param {(a: Item, b: Item) => 0 | 1 | -1} [compareFn] function used to sort items
1352
+ * @param {boolean} [shouldReset=false] set to `true` to reset state of the hook
1353
+ * @returns {Item[]}
1354
1354
  */
1355
1355
 
1356
1356
 
@@ -1436,19 +1436,19 @@ function NumberField(props) {
1436
1436
  })]
1437
1437
  });
1438
1438
  }
1439
- /**
1440
- * @param {Object} props
1441
- * @param {Boolean} props.debounce
1442
- * @param {String} props.description
1443
- * @param {Boolean} props.disabled
1444
- * @param {Object} props.element
1445
- * @param {Function} props.getValue
1446
- * @param {String} props.id
1447
- * @param {String} props.label
1448
- * @param {String} props.max
1449
- * @param {String} props.min
1450
- * @param {Function} props.setValue
1451
- * @param {String} props.step
1439
+ /**
1440
+ * @param {Object} props
1441
+ * @param {Boolean} props.debounce
1442
+ * @param {String} props.description
1443
+ * @param {Boolean} props.disabled
1444
+ * @param {Object} props.element
1445
+ * @param {Function} props.getValue
1446
+ * @param {String} props.id
1447
+ * @param {String} props.label
1448
+ * @param {String} props.max
1449
+ * @param {String} props.min
1450
+ * @param {Function} props.setValue
1451
+ * @param {String} props.step
1452
1452
  */
1453
1453
 
1454
1454
 
@@ -1496,21 +1496,21 @@ function prefixId$5(id) {
1496
1496
  }
1497
1497
 
1498
1498
  const noop$1 = () => {};
1499
- /**
1500
- * @typedef { { value: string, label: string, disabled: boolean } } Option
1499
+ /**
1500
+ * @typedef { { value: string, label: string, disabled: boolean } } Option
1501
1501
  */
1502
1502
 
1503
- /**
1504
- * Provides basic select input.
1505
- *
1506
- * @param {object} props
1507
- * @param {string} props.id
1508
- * @param {string[]} props.path
1509
- * @param {string} props.label
1510
- * @param {Function} props.onChange
1511
- * @param {Array<Option>} [props.options]
1512
- * @param {string} props.value
1513
- * @param {boolean} [props.disabled]
1503
+ /**
1504
+ * Provides basic select input.
1505
+ *
1506
+ * @param {object} props
1507
+ * @param {string} props.id
1508
+ * @param {string[]} props.path
1509
+ * @param {string} props.label
1510
+ * @param {Function} props.onChange
1511
+ * @param {Array<Option>} [props.options]
1512
+ * @param {string} props.value
1513
+ * @param {boolean} [props.disabled]
1514
1514
  */
1515
1515
 
1516
1516
 
@@ -1556,16 +1556,16 @@ function Select(props) {
1556
1556
  })]
1557
1557
  });
1558
1558
  }
1559
- /**
1560
- * @param {object} props
1561
- * @param {object} props.element
1562
- * @param {string} props.id
1563
- * @param {string} [props.description]
1564
- * @param {string} props.label
1565
- * @param {Function} props.getValue
1566
- * @param {Function} props.setValue
1567
- * @param {Function} props.getOptions
1568
- * @param {boolean} [props.disabled]
1559
+ /**
1560
+ * @param {object} props
1561
+ * @param {object} props.element
1562
+ * @param {string} props.id
1563
+ * @param {string} [props.description]
1564
+ * @param {string} props.label
1565
+ * @param {Function} props.getValue
1566
+ * @param {Function} props.setValue
1567
+ * @param {Function} props.getOptions
1568
+ * @param {boolean} [props.disabled]
1569
1569
  */
1570
1570
 
1571
1571
 
@@ -1710,18 +1710,18 @@ function TextArea(props) {
1710
1710
  })]
1711
1711
  });
1712
1712
  }
1713
- /**
1714
- * @param {object} props
1715
- * @param {object} props.element
1716
- * @param {string} props.id
1717
- * @param {string} props.description
1718
- * @param {boolean} props.debounce
1719
- * @param {string} props.label
1720
- * @param {Function} props.getValue
1721
- * @param {Function} props.setValue
1722
- * @param {number} props.rows
1723
- * @param {boolean} props.monospace
1724
- * @param {boolean} [props.disabled]
1713
+ /**
1714
+ * @param {object} props
1715
+ * @param {object} props.element
1716
+ * @param {string} props.id
1717
+ * @param {string} props.description
1718
+ * @param {boolean} props.debounce
1719
+ * @param {string} props.label
1720
+ * @param {Function} props.getValue
1721
+ * @param {Function} props.setValue
1722
+ * @param {number} props.rows
1723
+ * @param {boolean} props.monospace
1724
+ * @param {boolean} [props.disabled]
1725
1725
  */
1726
1726
 
1727
1727
 
@@ -1812,17 +1812,17 @@ function Textfield(props) {
1812
1812
  })]
1813
1813
  });
1814
1814
  }
1815
- /**
1816
- * @param {Object} props
1817
- * @param {Object} props.element
1818
- * @param {String} props.id
1819
- * @param {String} props.description
1820
- * @param {Boolean} props.debounce
1821
- * @param {Boolean} props.disabled
1822
- * @param {String} props.label
1823
- * @param {Function} props.getValue
1824
- * @param {Function} props.setValue
1825
- * @param {Function} props.validate
1815
+ /**
1816
+ * @param {Object} props
1817
+ * @param {Object} props.element
1818
+ * @param {String} props.id
1819
+ * @param {String} props.description
1820
+ * @param {Boolean} props.debounce
1821
+ * @param {Boolean} props.disabled
1822
+ * @param {String} props.label
1823
+ * @param {Function} props.getValue
1824
+ * @param {Function} props.setValue
1825
+ * @param {Function} props.validate
1826
1826
  */
1827
1827
 
1828
1828
 
@@ -1943,15 +1943,15 @@ function ToggleSwitch(props) {
1943
1943
  })]
1944
1944
  });
1945
1945
  }
1946
- /**
1947
- * @param {Object} props
1948
- * @param {Object} props.element
1949
- * @param {String} props.id
1950
- * @param {String} props.description
1951
- * @param {String} props.label
1952
- * @param {String} props.switcherLabel
1953
- * @param {Function} props.getValue
1954
- * @param {Function} props.setValue
1946
+ /**
1947
+ * @param {Object} props
1948
+ * @param {Object} props.element
1949
+ * @param {String} props.id
1950
+ * @param {String} props.description
1951
+ * @param {String} props.label
1952
+ * @param {String} props.switcherLabel
1953
+ * @param {Function} props.getValue
1954
+ * @param {Function} props.setValue
1955
1955
  */
1956
1956
 
1957
1957