@bpmn-io/properties-panel 0.10.1 → 0.10.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.esm.js CHANGED
@@ -6,14 +6,14 @@ import { query } from 'min-dom';
6
6
  import { createContext } from '../preact';
7
7
  import '../preact/compat';
8
8
 
9
- /**
10
- * @typedef { { getElementLabel: Function, getTypeLabel: Function, getElementIcon: Function } } HeaderProvider
9
+ /**
10
+ * @typedef { { getElementLabel: Function, getTypeLabel: Function, getElementIcon: Function } } HeaderProvider
11
11
  */
12
12
 
13
- /**
14
- * @param {Object} props
15
- * @param {Object} props.element,
16
- * @param {HeaderProvider} props.headerProvider
13
+ /**
14
+ * @param {Object} props
15
+ * @param {Object} props.element,
16
+ * @param {HeaderProvider} props.headerProvider
17
17
  */
18
18
  function Header(props) {
19
19
  const {
@@ -52,11 +52,11 @@ function Header(props) {
52
52
  });
53
53
  }
54
54
 
55
- /**
56
- * @pinussilvestrus: we need to introduce our own hook to persist the previous
57
- * state on updates.
58
- *
59
- * cf. https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state
55
+ /**
56
+ * @pinussilvestrus: we need to introduce our own hook to persist the previous
57
+ * state on updates.
58
+ *
59
+ * cf. https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state
60
60
  */
61
61
 
62
62
  function usePrevious(value) {
@@ -68,24 +68,24 @@ function usePrevious(value) {
68
68
  }
69
69
 
70
70
  const KEY_LENGTH = 6;
71
- /**
72
- * Create a persistent key factory for plain objects without id.
73
- *
74
- * @example
75
- * ```jsx
76
- * function List({ objects }) {
77
- * const getKey = useKeyFactory();
78
- * return (<ol>{
79
- * objects.map(obj => {
80
- * const key = getKey(obj);
81
- * return <li key={key}>obj.name</li>
82
- * })
83
- * }</ol>);
84
- * }
85
- * ```
86
- *
87
- * @param {any[]} dependencies
88
- * @returns {(element: object) => string}
71
+ /**
72
+ * Create a persistent key factory for plain objects without id.
73
+ *
74
+ * @example
75
+ * ```jsx
76
+ * function List({ objects }) {
77
+ * const getKey = useKeyFactory();
78
+ * return (<ol>{
79
+ * objects.map(obj => {
80
+ * const key = getKey(obj);
81
+ * return <li key={key}>obj.name</li>
82
+ * })
83
+ * }</ol>);
84
+ * }
85
+ * ```
86
+ *
87
+ * @param {any[]} dependencies
88
+ * @returns {(element: object) => string}
89
89
  */
90
90
 
91
91
  function useKeyFactory(dependencies = []) {
@@ -117,20 +117,20 @@ const LayoutContext = createContext({
117
117
  setLayoutForKey: () => {}
118
118
  });
119
119
 
120
- /**
121
- * Creates a state that persists in the global LayoutContext.
122
- *
123
- * @example
124
- * ```jsx
125
- * function Group(props) {
126
- * const [ open, setOpen ] = useLayoutState([ 'groups', 'foo', 'open' ], false);
127
- * }
128
- * ```
129
- *
130
- * @param {(string|number)[]} path
131
- * @param {any} [defaultValue]
132
- *
133
- * @returns {[ any, Function ]}
120
+ /**
121
+ * Creates a state that persists in the global LayoutContext.
122
+ *
123
+ * @example
124
+ * ```jsx
125
+ * function Group(props) {
126
+ * const [ open, setOpen ] = useLayoutState([ 'groups', 'foo', 'open' ], false);
127
+ * }
128
+ * ```
129
+ *
130
+ * @param {(string|number)[]} path
131
+ * @param {any} [defaultValue]
132
+ *
133
+ * @returns {[ any, Function ]}
134
134
  */
135
135
 
136
136
  function useLayoutState(path, defaultValue) {
@@ -151,20 +151,20 @@ function useLayoutState(path, defaultValue) {
151
151
  return [value, setState];
152
152
  }
153
153
 
154
- /**
155
- * Accesses the global DescriptionContext and returns a description for a given id and element.
156
- *
157
- * @example
158
- * ```jsx
159
- * function TextField(props) {
160
- * const description = useDescriptionContext('input1', element);
161
- * }
162
- * ```
163
- *
164
- * @param {string} id
165
- * @param {djs.model.Base} element
166
- *
167
- * @returns {string}
154
+ /**
155
+ * Accesses the global DescriptionContext and returns a description for a given id and element.
156
+ *
157
+ * @example
158
+ * ```jsx
159
+ * function TextField(props) {
160
+ * const description = useDescriptionContext('input1', element);
161
+ * }
162
+ * ```
163
+ *
164
+ * @param {string} id
165
+ * @param {djs.model.Base} element
166
+ *
167
+ * @returns {string}
168
168
  */
169
169
 
170
170
  function useDescriptionContext(id, element) {
@@ -286,64 +286,64 @@ const DEFAULT_LAYOUT = {
286
286
  open: true
287
287
  };
288
288
  const DEFAULT_DESCRIPTION = {};
289
- /**
290
- * @typedef { {
291
- * component: import('preact').ComponentChild,
292
- * id: String,
293
- * isEdited?: Function
294
- * } } EntryDefinition
295
- *
296
- * @typedef { {
297
- * autoFocusEntry: String,
298
- * autoOpen?: Boolean,
299
- * entries: Array<EntryDefinition>,
300
- * id: String,
301
- * label: String,
302
- * remove: (event: MouseEvent) => void
303
- * } } ListItemDefinition
304
- *
305
- * @typedef { {
306
- * add: (event: MouseEvent) => void,
307
- * component: import('preact').Component,
308
- * element: Object,
309
- * id: String,
310
- * items: Array<ListItemDefinition>,
311
- * label: String,
312
- * shouldSort?: Boolean,
313
- * shouldOpen?: Boolean
314
- * } } ListGroupDefinition
315
- *
316
- * @typedef { {
317
- * component?: import('preact').Component,
318
- * entries: Array<EntryDefinition>,
319
- * id: String,
320
- * label: String
321
- * } } GroupDefinition
322
- *
323
- * @typedef { {
324
- * [id: String]: GetDescriptionFunction
325
- * } } DescriptionConfig
326
- *
327
- * @callback { {
328
- * @param {string} id
329
- * @param {djs.model.base} element
330
- * @returns {string}
331
- * } } GetDescriptionFunction
332
- *
289
+ /**
290
+ * @typedef { {
291
+ * component: import('preact').ComponentChild,
292
+ * id: String,
293
+ * isEdited?: Function
294
+ * } } EntryDefinition
295
+ *
296
+ * @typedef { {
297
+ * autoFocusEntry: String,
298
+ * autoOpen?: Boolean,
299
+ * entries: Array<EntryDefinition>,
300
+ * id: String,
301
+ * label: String,
302
+ * remove: (event: MouseEvent) => void
303
+ * } } ListItemDefinition
304
+ *
305
+ * @typedef { {
306
+ * add: (event: MouseEvent) => void,
307
+ * component: import('preact').Component,
308
+ * element: Object,
309
+ * id: String,
310
+ * items: Array<ListItemDefinition>,
311
+ * label: String,
312
+ * shouldSort?: Boolean,
313
+ * shouldOpen?: Boolean
314
+ * } } ListGroupDefinition
315
+ *
316
+ * @typedef { {
317
+ * component?: import('preact').Component,
318
+ * entries: Array<EntryDefinition>,
319
+ * id: String,
320
+ * label: String
321
+ * } } GroupDefinition
322
+ *
323
+ * @typedef { {
324
+ * [id: String]: GetDescriptionFunction
325
+ * } } DescriptionConfig
326
+ *
327
+ * @callback { {
328
+ * @param {string} id
329
+ * @param {djs.model.base} element
330
+ * @returns {string}
331
+ * } } GetDescriptionFunction
332
+ *
333
333
  */
334
334
 
335
- /**
336
- * A basic properties panel component. Describes *how* content will be rendered, accepts
337
- * data from implementor to describe *what* will be rendered.
338
- *
339
- * @param {Object} props
340
- * @param {Object} props.element
341
- * @param {import('./components/Header').HeaderProvider} props.headerProvider
342
- * @param {Array<GroupDefinition|ListGroupDefinition>} props.groups
343
- * @param {Object} [props.layoutConfig]
344
- * @param {Function} [props.layoutChanged]
345
- * @param {DescriptionConfig} [props.descriptionConfig]
346
- * @param {Function} [props.descriptionLoaded]
335
+ /**
336
+ * A basic properties panel component. Describes *how* content will be rendered, accepts
337
+ * data from implementor to describe *what* will be rendered.
338
+ *
339
+ * @param {Object} props
340
+ * @param {Object} props.element
341
+ * @param {import('./components/Header').HeaderProvider} props.headerProvider
342
+ * @param {Array<GroupDefinition|ListGroupDefinition>} props.groups
343
+ * @param {Object} [props.layoutConfig]
344
+ * @param {Function} [props.layoutChanged]
345
+ * @param {DescriptionConfig} [props.descriptionConfig]
346
+ * @param {Function} [props.descriptionLoaded]
347
347
  */
348
348
 
349
349
  function PropertiesPanel(props) {
@@ -510,17 +510,17 @@ function MenuItem({
510
510
  children: item.entry
511
511
  });
512
512
  }
513
- /**
514
- *
515
- * @param {Array<null | Element>} ignoredElements
516
- * @param {Function} callback
513
+ /**
514
+ *
515
+ * @param {Array<null | Element>} ignoredElements
516
+ * @param {Function} callback
517
517
  */
518
518
 
519
519
 
520
520
  function useGlobalClick(ignoredElements, callback) {
521
521
  useEffect(() => {
522
- /**
523
- * @param {MouseEvent} event
522
+ /**
523
+ * @param {MouseEvent} event
524
524
  */
525
525
  function listener(event) {
526
526
  if (ignoredElements.some(element => element && element.contains(event.target))) {
@@ -625,8 +625,8 @@ function ListItem(props) {
625
625
  }
626
626
 
627
627
  const noop = () => {};
628
- /**
629
- * @param {import('../PropertiesPanel').ListGroupDefinition} props
628
+ /**
629
+ * @param {import('../PropertiesPanel').ListGroupDefinition} props
630
630
  */
631
631
 
632
632
 
@@ -766,8 +766,8 @@ function ListGroup(props) {
766
766
  });
767
767
  } // helpers ////////////////////
768
768
 
769
- /**
770
- * Sorts given items alphanumeric by label
769
+ /**
770
+ * Sorts given items alphanumeric by label
771
771
  */
772
772
 
773
773
  function sortItems(items) {
@@ -831,15 +831,15 @@ function Checkbox(props) {
831
831
  })]
832
832
  });
833
833
  }
834
- /**
835
- * @param {Object} props
836
- * @param {Object} props.element
837
- * @param {String} props.id
838
- * @param {String} props.description
839
- * @param {String} props.label
840
- * @param {Function} props.getValue
841
- * @param {Function} props.setValue
842
- * @param {boolean} [props.disabled]
834
+ /**
835
+ * @param {Object} props
836
+ * @param {Object} props.element
837
+ * @param {String} props.id
838
+ * @param {String} props.description
839
+ * @param {String} props.label
840
+ * @param {Function} props.getValue
841
+ * @param {Function} props.setValue
842
+ * @param {boolean} [props.disabled]
843
843
  */
844
844
 
845
845
 
@@ -906,8 +906,8 @@ function List(props) {
906
906
  setOpen(false);
907
907
  }
908
908
  }, [open, hasItems]);
909
- /**
910
- * @param {MouseEvent} event
909
+ /**
910
+ * @param {MouseEvent} event
911
911
  */
912
912
 
913
913
  function addItem(event) {
@@ -1009,14 +1009,14 @@ function ItemsList(props) {
1009
1009
  })
1010
1010
  });
1011
1011
  }
1012
- /**
1013
- * Place new items in the beginning of the list and sort the rest with provided function.
1014
- *
1015
- * @template Item
1016
- * @param {Item[]} currentItems
1017
- * @param {(a: Item, b: Item) => 0 | 1 | -1} [compareFn] function used to sort items
1018
- * @param {boolean} [shouldReset=false] set to `true` to reset state of the hook
1019
- * @returns {Item[]}
1012
+ /**
1013
+ * Place new items in the beginning of the list and sort the rest with provided function.
1014
+ *
1015
+ * @template Item
1016
+ * @param {Item[]} currentItems
1017
+ * @param {(a: Item, b: Item) => 0 | 1 | -1} [compareFn] function used to sort items
1018
+ * @param {boolean} [shouldReset=false] set to `true` to reset state of the hook
1019
+ * @returns {Item[]}
1020
1020
  */
1021
1021
 
1022
1022
 
@@ -1102,19 +1102,19 @@ function NumberField(props) {
1102
1102
  })]
1103
1103
  });
1104
1104
  }
1105
- /**
1106
- * @param {Object} props
1107
- * @param {Boolean} props.debounce
1108
- * @param {String} props.description
1109
- * @param {Boolean} props.disabled
1110
- * @param {Object} props.element
1111
- * @param {Function} props.getValue
1112
- * @param {String} props.id
1113
- * @param {String} props.label
1114
- * @param {String} props.max
1115
- * @param {String} props.min
1116
- * @param {Function} props.setValue
1117
- * @param {String} props.step
1105
+ /**
1106
+ * @param {Object} props
1107
+ * @param {Boolean} props.debounce
1108
+ * @param {String} props.description
1109
+ * @param {Boolean} props.disabled
1110
+ * @param {Object} props.element
1111
+ * @param {Function} props.getValue
1112
+ * @param {String} props.id
1113
+ * @param {String} props.label
1114
+ * @param {String} props.max
1115
+ * @param {String} props.min
1116
+ * @param {Function} props.setValue
1117
+ * @param {String} props.step
1118
1118
  */
1119
1119
 
1120
1120
 
@@ -1200,16 +1200,16 @@ function Select(props) {
1200
1200
  })]
1201
1201
  });
1202
1202
  }
1203
- /**
1204
- * @param {object} props
1205
- * @param {object} props.element
1206
- * @param {string} props.id
1207
- * @param {string} [props.description]
1208
- * @param {string} props.label
1209
- * @param {Function} props.getValue
1210
- * @param {Function} props.setValue
1211
- * @param {Function} props.getOptions
1212
- * @param {boolean} [props.disabled]
1203
+ /**
1204
+ * @param {object} props
1205
+ * @param {object} props.element
1206
+ * @param {string} props.id
1207
+ * @param {string} [props.description]
1208
+ * @param {string} props.label
1209
+ * @param {Function} props.getValue
1210
+ * @param {Function} props.setValue
1211
+ * @param {Function} props.getOptions
1212
+ * @param {boolean} [props.disabled]
1213
1213
  */
1214
1214
 
1215
1215
 
@@ -1279,6 +1279,7 @@ function Simple(props) {
1279
1279
  disabled: disabled,
1280
1280
  class: "bio-properties-panel-input",
1281
1281
  onInput: handleInput,
1282
+ "aria-label": value || '<empty>',
1282
1283
  onFocus: onFocus,
1283
1284
  onBlur: onBlur,
1284
1285
  value: value || ''
@@ -1329,18 +1330,18 @@ function TextArea(props) {
1329
1330
  })]
1330
1331
  });
1331
1332
  }
1332
- /**
1333
- * @param {object} props
1334
- * @param {object} props.element
1335
- * @param {string} props.id
1336
- * @param {string} props.description
1337
- * @param {boolean} props.debounce
1338
- * @param {string} props.label
1339
- * @param {Function} props.getValue
1340
- * @param {Function} props.setValue
1341
- * @param {number} props.rows
1342
- * @param {boolean} props.monospace
1343
- * @param {boolean} [props.disabled]
1333
+ /**
1334
+ * @param {object} props
1335
+ * @param {object} props.element
1336
+ * @param {string} props.id
1337
+ * @param {string} props.description
1338
+ * @param {boolean} props.debounce
1339
+ * @param {string} props.label
1340
+ * @param {Function} props.getValue
1341
+ * @param {Function} props.setValue
1342
+ * @param {number} props.rows
1343
+ * @param {boolean} props.monospace
1344
+ * @param {boolean} [props.disabled]
1344
1345
  */
1345
1346
 
1346
1347
 
@@ -1420,17 +1421,17 @@ function Textfield(props) {
1420
1421
  })]
1421
1422
  });
1422
1423
  }
1423
- /**
1424
- * @param {Object} props
1425
- * @param {Object} props.element
1426
- * @param {String} props.id
1427
- * @param {String} props.description
1428
- * @param {Boolean} props.debounce
1429
- * @param {Boolean} props.disabled
1430
- * @param {String} props.label
1431
- * @param {Function} props.getValue
1432
- * @param {Function} props.setValue
1433
- * @param {Function} props.validate
1424
+ /**
1425
+ * @param {Object} props
1426
+ * @param {Object} props.element
1427
+ * @param {String} props.id
1428
+ * @param {String} props.description
1429
+ * @param {Boolean} props.debounce
1430
+ * @param {Boolean} props.disabled
1431
+ * @param {String} props.label
1432
+ * @param {Function} props.getValue
1433
+ * @param {Function} props.setValue
1434
+ * @param {Function} props.validate
1434
1435
  */
1435
1436
 
1436
1437
 
@@ -1541,15 +1542,15 @@ function ToggleSwitch(props) {
1541
1542
  })]
1542
1543
  });
1543
1544
  }
1544
- /**
1545
- * @param {Object} props
1546
- * @param {Object} props.element
1547
- * @param {String} props.id
1548
- * @param {String} props.description
1549
- * @param {String} props.label
1550
- * @param {String} props.switcherLabel
1551
- * @param {Function} props.getValue
1552
- * @param {Function} props.setValue
1545
+ /**
1546
+ * @param {Object} props
1547
+ * @param {Object} props.element
1548
+ * @param {String} props.id
1549
+ * @param {String} props.description
1550
+ * @param {String} props.label
1551
+ * @param {String} props.switcherLabel
1552
+ * @param {Function} props.getValue
1553
+ * @param {Function} props.setValue
1553
1554
  */
1554
1555
 
1555
1556