@bpmn-io/properties-panel 1.2.0 → 1.3.1
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/LICENSE +20 -20
- package/README.md +34 -34
- package/assets/properties-panel.css +1020 -1016
- package/dist/index.esm.js +320 -306
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +319 -305
- package/dist/index.js.map +1 -1
- package/package.json +89 -89
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useContext, useRef, useEffect, useMemo, useState, useCallback } from '../preact/hooks';
|
|
1
|
+
import { useContext, useRef, useEffect, useMemo, useState, useCallback, useLayoutEffect } from '../preact/hooks';
|
|
2
2
|
import { isFunction, isArray, get, assign, set, sortBy, find, isNumber, debounce } from 'min-dash';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { forwardRef } from '../preact/compat';
|
|
@@ -166,19 +166,19 @@ const ErrorsContext = createContext({
|
|
|
166
166
|
errors: {}
|
|
167
167
|
});
|
|
168
168
|
|
|
169
|
-
/**
|
|
170
|
-
* @typedef {Function} <propertiesPanel.showEntry> callback
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
*
|
|
174
|
-
* useEvent('propertiesPanel.showEntry', ({ focus = false, ...rest }) => {
|
|
175
|
-
* // ...
|
|
176
|
-
* });
|
|
177
|
-
*
|
|
178
|
-
* @param {Object} context
|
|
179
|
-
* @param {boolean} [context.focus]
|
|
180
|
-
*
|
|
181
|
-
* @returns void
|
|
169
|
+
/**
|
|
170
|
+
* @typedef {Function} <propertiesPanel.showEntry> callback
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
*
|
|
174
|
+
* useEvent('propertiesPanel.showEntry', ({ focus = false, ...rest }) => {
|
|
175
|
+
* // ...
|
|
176
|
+
* });
|
|
177
|
+
*
|
|
178
|
+
* @param {Object} context
|
|
179
|
+
* @param {boolean} [context.focus]
|
|
180
|
+
*
|
|
181
|
+
* @returns void
|
|
182
182
|
*/
|
|
183
183
|
const EventContext = createContext({
|
|
184
184
|
eventBus: null
|
|
@@ -191,20 +191,20 @@ const LayoutContext = createContext({
|
|
|
191
191
|
setLayoutForKey: () => {}
|
|
192
192
|
});
|
|
193
193
|
|
|
194
|
-
/**
|
|
195
|
-
* Accesses the global DescriptionContext and returns a description for a given id and element.
|
|
196
|
-
*
|
|
197
|
-
* @example
|
|
198
|
-
* ```jsx
|
|
199
|
-
* function TextField(props) {
|
|
200
|
-
* const description = useDescriptionContext('input1', element);
|
|
201
|
-
* }
|
|
202
|
-
* ```
|
|
203
|
-
*
|
|
204
|
-
* @param {string} id
|
|
205
|
-
* @param {object} element
|
|
206
|
-
*
|
|
207
|
-
* @returns {string}
|
|
194
|
+
/**
|
|
195
|
+
* Accesses the global DescriptionContext and returns a description for a given id and element.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```jsx
|
|
199
|
+
* function TextField(props) {
|
|
200
|
+
* const description = useDescriptionContext('input1', element);
|
|
201
|
+
* }
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* @param {string} id
|
|
205
|
+
* @param {object} element
|
|
206
|
+
*
|
|
207
|
+
* @returns {string}
|
|
208
208
|
*/
|
|
209
209
|
function useDescriptionContext(id, element) {
|
|
210
210
|
const {
|
|
@@ -220,11 +220,11 @@ function useError(id) {
|
|
|
220
220
|
return errors[id];
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
/**
|
|
224
|
-
* Subscribe to an event immediately. Update subscription after inputs changed.
|
|
225
|
-
*
|
|
226
|
-
* @param {string} event
|
|
227
|
-
* @param {Function} callback
|
|
223
|
+
/**
|
|
224
|
+
* Subscribe to an event immediately. Update subscription after inputs changed.
|
|
225
|
+
*
|
|
226
|
+
* @param {string} event
|
|
227
|
+
* @param {Function} callback
|
|
228
228
|
*/
|
|
229
229
|
function useEvent(event, callback, eventBus) {
|
|
230
230
|
const eventContext = useContext(EventContext);
|
|
@@ -256,24 +256,24 @@ function useEvent(event, callback, eventBus) {
|
|
|
256
256
|
|
|
257
257
|
const KEY_LENGTH = 6;
|
|
258
258
|
|
|
259
|
-
/**
|
|
260
|
-
* Create a persistent key factory for plain objects without id.
|
|
261
|
-
*
|
|
262
|
-
* @example
|
|
263
|
-
* ```jsx
|
|
264
|
-
* function List({ objects }) {
|
|
265
|
-
* const getKey = useKeyFactory();
|
|
266
|
-
* return (<ol>{
|
|
267
|
-
* objects.map(obj => {
|
|
268
|
-
* const key = getKey(obj);
|
|
269
|
-
* return <li key={key}>obj.name</li>
|
|
270
|
-
* })
|
|
271
|
-
* }</ol>);
|
|
272
|
-
* }
|
|
273
|
-
* ```
|
|
274
|
-
*
|
|
275
|
-
* @param {any[]} dependencies
|
|
276
|
-
* @returns {(element: object) => string}
|
|
259
|
+
/**
|
|
260
|
+
* Create a persistent key factory for plain objects without id.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```jsx
|
|
264
|
+
* function List({ objects }) {
|
|
265
|
+
* const getKey = useKeyFactory();
|
|
266
|
+
* return (<ol>{
|
|
267
|
+
* objects.map(obj => {
|
|
268
|
+
* const key = getKey(obj);
|
|
269
|
+
* return <li key={key}>obj.name</li>
|
|
270
|
+
* })
|
|
271
|
+
* }</ol>);
|
|
272
|
+
* }
|
|
273
|
+
* ```
|
|
274
|
+
*
|
|
275
|
+
* @param {any[]} dependencies
|
|
276
|
+
* @returns {(element: object) => string}
|
|
277
277
|
*/
|
|
278
278
|
function useKeyFactory(dependencies = []) {
|
|
279
279
|
const map = useMemo(() => new Map(), dependencies);
|
|
@@ -288,20 +288,20 @@ function useKeyFactory(dependencies = []) {
|
|
|
288
288
|
return getKey;
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
/**
|
|
292
|
-
* Creates a state that persists in the global LayoutContext.
|
|
293
|
-
*
|
|
294
|
-
* @example
|
|
295
|
-
* ```jsx
|
|
296
|
-
* function Group(props) {
|
|
297
|
-
* const [ open, setOpen ] = useLayoutState([ 'groups', 'foo', 'open' ], false);
|
|
298
|
-
* }
|
|
299
|
-
* ```
|
|
300
|
-
*
|
|
301
|
-
* @param {(string|number)[]} path
|
|
302
|
-
* @param {any} [defaultValue]
|
|
303
|
-
*
|
|
304
|
-
* @returns {[ any, Function ]}
|
|
291
|
+
/**
|
|
292
|
+
* Creates a state that persists in the global LayoutContext.
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```jsx
|
|
296
|
+
* function Group(props) {
|
|
297
|
+
* const [ open, setOpen ] = useLayoutState([ 'groups', 'foo', 'open' ], false);
|
|
298
|
+
* }
|
|
299
|
+
* ```
|
|
300
|
+
*
|
|
301
|
+
* @param {(string|number)[]} path
|
|
302
|
+
* @param {any} [defaultValue]
|
|
303
|
+
*
|
|
304
|
+
* @returns {[ any, Function ]}
|
|
305
305
|
*/
|
|
306
306
|
function useLayoutState(path, defaultValue) {
|
|
307
307
|
const {
|
|
@@ -320,11 +320,11 @@ function useLayoutState(path, defaultValue) {
|
|
|
320
320
|
return [value, setState];
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
/**
|
|
324
|
-
* @pinussilvestrus: we need to introduce our own hook to persist the previous
|
|
325
|
-
* state on updates.
|
|
326
|
-
*
|
|
327
|
-
* cf. https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state
|
|
323
|
+
/**
|
|
324
|
+
* @pinussilvestrus: we need to introduce our own hook to persist the previous
|
|
325
|
+
* state on updates.
|
|
326
|
+
*
|
|
327
|
+
* cf. https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state
|
|
328
328
|
*/
|
|
329
329
|
|
|
330
330
|
function usePrevious(value) {
|
|
@@ -335,12 +335,12 @@ function usePrevious(value) {
|
|
|
335
335
|
return ref.current;
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
/**
|
|
339
|
-
* Subscribe to `propertiesPanel.showEntry`.
|
|
340
|
-
*
|
|
341
|
-
* @param {string} id
|
|
342
|
-
*
|
|
343
|
-
* @returns {import('preact').Ref}
|
|
338
|
+
/**
|
|
339
|
+
* Subscribe to `propertiesPanel.showEntry`.
|
|
340
|
+
*
|
|
341
|
+
* @param {string} id
|
|
342
|
+
*
|
|
343
|
+
* @returns {import('preact').Ref}
|
|
344
344
|
*/
|
|
345
345
|
function useShowEntryEvent(id) {
|
|
346
346
|
const {
|
|
@@ -371,20 +371,20 @@ function useShowEntryEvent(id) {
|
|
|
371
371
|
return ref;
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
-
/**
|
|
375
|
-
* @callback setSticky
|
|
376
|
-
* @param {boolean} value
|
|
374
|
+
/**
|
|
375
|
+
* @callback setSticky
|
|
376
|
+
* @param {boolean} value
|
|
377
377
|
*/
|
|
378
378
|
|
|
379
|
-
/**
|
|
380
|
-
* Use IntersectionObserver to identify when DOM element is in sticky mode.
|
|
381
|
-
* If sticky is observered setSticky(true) will be called.
|
|
382
|
-
* If sticky mode is left, setSticky(false) will be called.
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
* @param {Object} ref
|
|
386
|
-
* @param {string} scrollContainerSelector
|
|
387
|
-
* @param {setSticky} setSticky
|
|
379
|
+
/**
|
|
380
|
+
* Use IntersectionObserver to identify when DOM element is in sticky mode.
|
|
381
|
+
* If sticky is observered setSticky(true) will be called.
|
|
382
|
+
* If sticky mode is left, setSticky(false) will be called.
|
|
383
|
+
*
|
|
384
|
+
*
|
|
385
|
+
* @param {Object} ref
|
|
386
|
+
* @param {string} scrollContainerSelector
|
|
387
|
+
* @param {setSticky} setSticky
|
|
388
388
|
*/
|
|
389
389
|
function useStickyIntersectionObserver(ref, scrollContainerSelector, setSticky) {
|
|
390
390
|
useEffect(() => {
|
|
@@ -423,19 +423,19 @@ function useStickyIntersectionObserver(ref, scrollContainerSelector, setSticky)
|
|
|
423
423
|
}, [ref, scrollContainerSelector, setSticky]);
|
|
424
424
|
}
|
|
425
425
|
|
|
426
|
-
/**
|
|
427
|
-
* Creates a static function reference with changing body.
|
|
428
|
-
* This is necessary when external libraries require a callback function
|
|
429
|
-
* that has references to state variables.
|
|
430
|
-
*
|
|
431
|
-
* Usage:
|
|
432
|
-
* const callback = useStaticCallback((val) => {val === currentState});
|
|
433
|
-
*
|
|
434
|
-
* The `callback` reference is static and can be safely used in external
|
|
435
|
-
* libraries or as a prop that does not cause rerendering of children.
|
|
436
|
-
*
|
|
437
|
-
* @param {Function} callback function with changing reference
|
|
438
|
-
* @returns {Function} static function reference
|
|
426
|
+
/**
|
|
427
|
+
* Creates a static function reference with changing body.
|
|
428
|
+
* This is necessary when external libraries require a callback function
|
|
429
|
+
* that has references to state variables.
|
|
430
|
+
*
|
|
431
|
+
* Usage:
|
|
432
|
+
* const callback = useStaticCallback((val) => {val === currentState});
|
|
433
|
+
*
|
|
434
|
+
* The `callback` reference is static and can be safely used in external
|
|
435
|
+
* libraries or as a prop that does not cause rerendering of children.
|
|
436
|
+
*
|
|
437
|
+
* @param {Function} callback function with changing reference
|
|
438
|
+
* @returns {Function} static function reference
|
|
439
439
|
*/
|
|
440
440
|
function useStaticCallback(callback) {
|
|
441
441
|
const callbackRef = useRef(callback);
|
|
@@ -528,13 +528,13 @@ function DataMarker() {
|
|
|
528
528
|
});
|
|
529
529
|
}
|
|
530
530
|
|
|
531
|
-
/**
|
|
532
|
-
* @typedef { {
|
|
533
|
-
* text: (element: object) => string,
|
|
534
|
-
* icon?: (element: Object) => import('preact').Component
|
|
535
|
-
* } } PlaceholderDefinition
|
|
536
|
-
*
|
|
537
|
-
* @param { PlaceholderDefinition } props
|
|
531
|
+
/**
|
|
532
|
+
* @typedef { {
|
|
533
|
+
* text: (element: object) => string,
|
|
534
|
+
* icon?: (element: Object) => import('preact').Component
|
|
535
|
+
* } } PlaceholderDefinition
|
|
536
|
+
*
|
|
537
|
+
* @param { PlaceholderDefinition } props
|
|
538
538
|
*/
|
|
539
539
|
function Placeholder(props) {
|
|
540
540
|
const {
|
|
@@ -560,72 +560,72 @@ const DEFAULT_LAYOUT = {
|
|
|
560
560
|
};
|
|
561
561
|
const DEFAULT_DESCRIPTION = {};
|
|
562
562
|
|
|
563
|
-
/**
|
|
564
|
-
* @typedef { {
|
|
565
|
-
* component: import('preact').Component,
|
|
566
|
-
* id: String,
|
|
567
|
-
* isEdited?: Function
|
|
568
|
-
* } } EntryDefinition
|
|
569
|
-
*
|
|
570
|
-
* @typedef { {
|
|
571
|
-
* autoFocusEntry: String,
|
|
572
|
-
* autoOpen?: Boolean,
|
|
573
|
-
* entries: Array<EntryDefinition>,
|
|
574
|
-
* id: String,
|
|
575
|
-
* label: String,
|
|
576
|
-
* remove: (event: MouseEvent) => void
|
|
577
|
-
* } } ListItemDefinition
|
|
578
|
-
*
|
|
579
|
-
* @typedef { {
|
|
580
|
-
* add: (event: MouseEvent) => void,
|
|
581
|
-
* component: import('preact').Component,
|
|
582
|
-
* element: Object,
|
|
583
|
-
* id: String,
|
|
584
|
-
* items: Array<ListItemDefinition>,
|
|
585
|
-
* label: String,
|
|
586
|
-
* shouldSort?: Boolean,
|
|
587
|
-
* shouldOpen?: Boolean
|
|
588
|
-
* } } ListGroupDefinition
|
|
589
|
-
*
|
|
590
|
-
* @typedef { {
|
|
591
|
-
* component?: import('preact').Component,
|
|
592
|
-
* entries: Array<EntryDefinition>,
|
|
593
|
-
* id: String,
|
|
594
|
-
* label: String,
|
|
595
|
-
* shouldOpen?: Boolean
|
|
596
|
-
* } } GroupDefinition
|
|
597
|
-
*
|
|
598
|
-
* @typedef { {
|
|
599
|
-
* [id: String]: GetDescriptionFunction
|
|
600
|
-
* } } DescriptionConfig
|
|
601
|
-
*
|
|
602
|
-
* @callback { {
|
|
603
|
-
* @param {string} id
|
|
604
|
-
* @param {Object} element
|
|
605
|
-
* @returns {string}
|
|
606
|
-
* } } GetDescriptionFunction
|
|
607
|
-
*
|
|
608
|
-
* @typedef { {
|
|
609
|
-
* getEmpty: (element: object) => import('./components/Placeholder').PlaceholderDefinition,
|
|
610
|
-
* getMultiple: (element: Object) => import('./components/Placeholder').PlaceholderDefinition
|
|
611
|
-
* } } PlaceholderProvider
|
|
612
|
-
*
|
|
563
|
+
/**
|
|
564
|
+
* @typedef { {
|
|
565
|
+
* component: import('preact').Component,
|
|
566
|
+
* id: String,
|
|
567
|
+
* isEdited?: Function
|
|
568
|
+
* } } EntryDefinition
|
|
569
|
+
*
|
|
570
|
+
* @typedef { {
|
|
571
|
+
* autoFocusEntry: String,
|
|
572
|
+
* autoOpen?: Boolean,
|
|
573
|
+
* entries: Array<EntryDefinition>,
|
|
574
|
+
* id: String,
|
|
575
|
+
* label: String,
|
|
576
|
+
* remove: (event: MouseEvent) => void
|
|
577
|
+
* } } ListItemDefinition
|
|
578
|
+
*
|
|
579
|
+
* @typedef { {
|
|
580
|
+
* add: (event: MouseEvent) => void,
|
|
581
|
+
* component: import('preact').Component,
|
|
582
|
+
* element: Object,
|
|
583
|
+
* id: String,
|
|
584
|
+
* items: Array<ListItemDefinition>,
|
|
585
|
+
* label: String,
|
|
586
|
+
* shouldSort?: Boolean,
|
|
587
|
+
* shouldOpen?: Boolean
|
|
588
|
+
* } } ListGroupDefinition
|
|
589
|
+
*
|
|
590
|
+
* @typedef { {
|
|
591
|
+
* component?: import('preact').Component,
|
|
592
|
+
* entries: Array<EntryDefinition>,
|
|
593
|
+
* id: String,
|
|
594
|
+
* label: String,
|
|
595
|
+
* shouldOpen?: Boolean
|
|
596
|
+
* } } GroupDefinition
|
|
597
|
+
*
|
|
598
|
+
* @typedef { {
|
|
599
|
+
* [id: String]: GetDescriptionFunction
|
|
600
|
+
* } } DescriptionConfig
|
|
601
|
+
*
|
|
602
|
+
* @callback { {
|
|
603
|
+
* @param {string} id
|
|
604
|
+
* @param {Object} element
|
|
605
|
+
* @returns {string}
|
|
606
|
+
* } } GetDescriptionFunction
|
|
607
|
+
*
|
|
608
|
+
* @typedef { {
|
|
609
|
+
* getEmpty: (element: object) => import('./components/Placeholder').PlaceholderDefinition,
|
|
610
|
+
* getMultiple: (element: Object) => import('./components/Placeholder').PlaceholderDefinition
|
|
611
|
+
* } } PlaceholderProvider
|
|
612
|
+
*
|
|
613
613
|
*/
|
|
614
614
|
|
|
615
|
-
/**
|
|
616
|
-
* A basic properties panel component. Describes *how* content will be rendered, accepts
|
|
617
|
-
* data from implementor to describe *what* will be rendered.
|
|
618
|
-
*
|
|
619
|
-
* @param {Object} props
|
|
620
|
-
* @param {Object|Array} props.element
|
|
621
|
-
* @param {import('./components/Header').HeaderProvider} props.headerProvider
|
|
622
|
-
* @param {PlaceholderProvider} [props.placeholderProvider]
|
|
623
|
-
* @param {Array<GroupDefinition|ListGroupDefinition>} props.groups
|
|
624
|
-
* @param {Object} [props.layoutConfig]
|
|
625
|
-
* @param {Function} [props.layoutChanged]
|
|
626
|
-
* @param {DescriptionConfig} [props.descriptionConfig]
|
|
627
|
-
* @param {Function} [props.descriptionLoaded]
|
|
628
|
-
* @param {Object} [props.eventBus]
|
|
615
|
+
/**
|
|
616
|
+
* A basic properties panel component. Describes *how* content will be rendered, accepts
|
|
617
|
+
* data from implementor to describe *what* will be rendered.
|
|
618
|
+
*
|
|
619
|
+
* @param {Object} props
|
|
620
|
+
* @param {Object|Array} props.element
|
|
621
|
+
* @param {import('./components/Header').HeaderProvider} props.headerProvider
|
|
622
|
+
* @param {PlaceholderProvider} [props.placeholderProvider]
|
|
623
|
+
* @param {Array<GroupDefinition|ListGroupDefinition>} props.groups
|
|
624
|
+
* @param {Object} [props.layoutConfig]
|
|
625
|
+
* @param {Function} [props.layoutChanged]
|
|
626
|
+
* @param {DescriptionConfig} [props.descriptionConfig]
|
|
627
|
+
* @param {Function} [props.descriptionLoaded]
|
|
628
|
+
* @param {Object} [props.eventBus]
|
|
629
629
|
*/
|
|
630
630
|
function PropertiesPanel(props) {
|
|
631
631
|
const {
|
|
@@ -815,15 +815,15 @@ function MenuItem({
|
|
|
815
815
|
});
|
|
816
816
|
}
|
|
817
817
|
|
|
818
|
-
/**
|
|
819
|
-
*
|
|
820
|
-
* @param {Array<null | Element>} ignoredElements
|
|
821
|
-
* @param {Function} callback
|
|
818
|
+
/**
|
|
819
|
+
*
|
|
820
|
+
* @param {Array<null | Element>} ignoredElements
|
|
821
|
+
* @param {Function} callback
|
|
822
822
|
*/
|
|
823
823
|
function useGlobalClick(ignoredElements, callback) {
|
|
824
824
|
useEffect(() => {
|
|
825
|
-
/**
|
|
826
|
-
* @param {MouseEvent} event
|
|
825
|
+
/**
|
|
826
|
+
* @param {MouseEvent} event
|
|
827
827
|
*/
|
|
828
828
|
function listener(event) {
|
|
829
829
|
if (ignoredElements.some(element => element && element.contains(event.target))) {
|
|
@@ -954,8 +954,8 @@ function ListItem(props) {
|
|
|
954
954
|
|
|
955
955
|
const noop$2 = () => {};
|
|
956
956
|
|
|
957
|
-
/**
|
|
958
|
-
* @param {import('../PropertiesPanel').ListGroupDefinition} props
|
|
957
|
+
/**
|
|
958
|
+
* @param {import('../PropertiesPanel').ListGroupDefinition} props
|
|
959
959
|
*/
|
|
960
960
|
function ListGroup(props) {
|
|
961
961
|
const {
|
|
@@ -1118,8 +1118,8 @@ function ListGroup(props) {
|
|
|
1118
1118
|
|
|
1119
1119
|
// helpers ////////////////////
|
|
1120
1120
|
|
|
1121
|
-
/**
|
|
1122
|
-
* Sorts given items alphanumeric by label
|
|
1121
|
+
/**
|
|
1122
|
+
* Sorts given items alphanumeric by label
|
|
1123
1123
|
*/
|
|
1124
1124
|
function sortItems(items) {
|
|
1125
1125
|
return sortBy(items, i => i.label.toLowerCase());
|
|
@@ -1195,17 +1195,17 @@ function Checkbox(props) {
|
|
|
1195
1195
|
});
|
|
1196
1196
|
}
|
|
1197
1197
|
|
|
1198
|
-
/**
|
|
1199
|
-
* @param {Object} props
|
|
1200
|
-
* @param {Object} props.element
|
|
1201
|
-
* @param {String} props.id
|
|
1202
|
-
* @param {String} props.description
|
|
1203
|
-
* @param {String} props.label
|
|
1204
|
-
* @param {Function} props.getValue
|
|
1205
|
-
* @param {Function} props.setValue
|
|
1206
|
-
* @param {Function} props.onFocus
|
|
1207
|
-
* @param {Function} props.onBlur
|
|
1208
|
-
* @param {boolean} [props.disabled]
|
|
1198
|
+
/**
|
|
1199
|
+
* @param {Object} props
|
|
1200
|
+
* @param {Object} props.element
|
|
1201
|
+
* @param {String} props.id
|
|
1202
|
+
* @param {String} props.description
|
|
1203
|
+
* @param {String} props.label
|
|
1204
|
+
* @param {Function} props.getValue
|
|
1205
|
+
* @param {Function} props.setValue
|
|
1206
|
+
* @param {Function} props.onFocus
|
|
1207
|
+
* @param {Function} props.onBlur
|
|
1208
|
+
* @param {boolean} [props.disabled]
|
|
1209
1209
|
*/
|
|
1210
1210
|
function CheckboxEntry(props) {
|
|
1211
1211
|
const {
|
|
@@ -1294,10 +1294,10 @@ const CodeEditor = forwardRef((props, ref) => {
|
|
|
1294
1294
|
useEffect(() => {
|
|
1295
1295
|
let editor;
|
|
1296
1296
|
|
|
1297
|
-
/* Trigger FEEL toggle when
|
|
1298
|
-
*
|
|
1299
|
-
* - `backspace` is pressed
|
|
1300
|
-
* - AND the cursor is at the beginning of the input
|
|
1297
|
+
/* Trigger FEEL toggle when
|
|
1298
|
+
*
|
|
1299
|
+
* - `backspace` is pressed
|
|
1300
|
+
* - AND the cursor is at the beginning of the input
|
|
1301
1301
|
*/
|
|
1302
1302
|
const onKeyDown = e => {
|
|
1303
1303
|
if (e.key !== 'Backspace' || !editor) {
|
|
@@ -1370,10 +1370,10 @@ function FeelIndicator(props) {
|
|
|
1370
1370
|
|
|
1371
1371
|
const noop$1 = () => {};
|
|
1372
1372
|
|
|
1373
|
-
/**
|
|
1374
|
-
* @param {Object} props
|
|
1375
|
-
* @param {Object} props.label
|
|
1376
|
-
* @param {String} props.feel
|
|
1373
|
+
/**
|
|
1374
|
+
* @param {Object} props
|
|
1375
|
+
* @param {Object} props.label
|
|
1376
|
+
* @param {String} props.feel
|
|
1377
1377
|
*/
|
|
1378
1378
|
function FeelIcon(props) {
|
|
1379
1379
|
const {
|
|
@@ -1648,17 +1648,17 @@ const OptionalFeelTextArea = forwardRef((props, ref) => {
|
|
|
1648
1648
|
});
|
|
1649
1649
|
});
|
|
1650
1650
|
|
|
1651
|
-
/**
|
|
1652
|
-
* @param {Object} props
|
|
1653
|
-
* @param {Object} props.element
|
|
1654
|
-
* @param {String} props.id
|
|
1655
|
-
* @param {String} props.description
|
|
1656
|
-
* @param {Boolean} props.debounce
|
|
1657
|
-
* @param {Boolean} props.disabled
|
|
1658
|
-
* @param {String} props.label
|
|
1659
|
-
* @param {Function} props.getValue
|
|
1660
|
-
* @param {Function} props.setValue
|
|
1661
|
-
* @param {Function} props.validate
|
|
1651
|
+
/**
|
|
1652
|
+
* @param {Object} props
|
|
1653
|
+
* @param {Object} props.element
|
|
1654
|
+
* @param {String} props.id
|
|
1655
|
+
* @param {String} props.description
|
|
1656
|
+
* @param {Boolean} props.debounce
|
|
1657
|
+
* @param {Boolean} props.disabled
|
|
1658
|
+
* @param {String} props.label
|
|
1659
|
+
* @param {Function} props.getValue
|
|
1660
|
+
* @param {Function} props.setValue
|
|
1661
|
+
* @param {Function} props.validate
|
|
1662
1662
|
*/
|
|
1663
1663
|
function FeelEntry(props) {
|
|
1664
1664
|
const {
|
|
@@ -1743,19 +1743,19 @@ function FeelEntry(props) {
|
|
|
1743
1743
|
});
|
|
1744
1744
|
}
|
|
1745
1745
|
|
|
1746
|
-
/**
|
|
1747
|
-
* @param {Object} props
|
|
1748
|
-
* @param {Object} props.element
|
|
1749
|
-
* @param {String} props.id
|
|
1750
|
-
* @param {String} props.description
|
|
1751
|
-
* @param {Boolean} props.debounce
|
|
1752
|
-
* @param {Boolean} props.disabled
|
|
1753
|
-
* @param {String} props.label
|
|
1754
|
-
* @param {Function} props.getValue
|
|
1755
|
-
* @param {Function} props.setValue
|
|
1756
|
-
* @param {Function} props.onFocus
|
|
1757
|
-
* @param {Function} props.onBlur
|
|
1758
|
-
* @param {Function} props.validate
|
|
1746
|
+
/**
|
|
1747
|
+
* @param {Object} props
|
|
1748
|
+
* @param {Object} props.element
|
|
1749
|
+
* @param {String} props.id
|
|
1750
|
+
* @param {String} props.description
|
|
1751
|
+
* @param {Boolean} props.debounce
|
|
1752
|
+
* @param {Boolean} props.disabled
|
|
1753
|
+
* @param {String} props.label
|
|
1754
|
+
* @param {Function} props.getValue
|
|
1755
|
+
* @param {Function} props.setValue
|
|
1756
|
+
* @param {Function} props.onFocus
|
|
1757
|
+
* @param {Function} props.onBlur
|
|
1758
|
+
* @param {Function} props.validate
|
|
1759
1759
|
*/
|
|
1760
1760
|
function FeelTextArea(props) {
|
|
1761
1761
|
return jsx(FeelEntry, {
|
|
@@ -1802,8 +1802,8 @@ function List(props) {
|
|
|
1802
1802
|
}
|
|
1803
1803
|
}, [open, hasItems]);
|
|
1804
1804
|
|
|
1805
|
-
/**
|
|
1806
|
-
* @param {MouseEvent} event
|
|
1805
|
+
/**
|
|
1806
|
+
* @param {MouseEvent} event
|
|
1807
1807
|
*/
|
|
1808
1808
|
function addItem(event) {
|
|
1809
1809
|
event.stopPropagation();
|
|
@@ -1915,14 +1915,14 @@ function ItemsList(props) {
|
|
|
1915
1915
|
});
|
|
1916
1916
|
}
|
|
1917
1917
|
|
|
1918
|
-
/**
|
|
1919
|
-
* Place new items in the beginning of the list and sort the rest with provided function.
|
|
1920
|
-
*
|
|
1921
|
-
* @template Item
|
|
1922
|
-
* @param {Item[]} currentItems
|
|
1923
|
-
* @param {(a: Item, b: Item) => 0 | 1 | -1} [compareFn] function used to sort items
|
|
1924
|
-
* @param {boolean} [shouldReset=false] set to `true` to reset state of the hook
|
|
1925
|
-
* @returns {Item[]}
|
|
1918
|
+
/**
|
|
1919
|
+
* Place new items in the beginning of the list and sort the rest with provided function.
|
|
1920
|
+
*
|
|
1921
|
+
* @template Item
|
|
1922
|
+
* @param {Item[]} currentItems
|
|
1923
|
+
* @param {(a: Item, b: Item) => 0 | 1 | -1} [compareFn] function used to sort items
|
|
1924
|
+
* @param {boolean} [shouldReset=false] set to `true` to reset state of the hook
|
|
1925
|
+
* @returns {Item[]}
|
|
1926
1926
|
*/
|
|
1927
1927
|
function useSortedItems(currentItems, compareFn, shouldReset = false) {
|
|
1928
1928
|
const itemsRef = useRef(currentItems.slice());
|
|
@@ -2018,22 +2018,22 @@ function NumberField(props) {
|
|
|
2018
2018
|
});
|
|
2019
2019
|
}
|
|
2020
2020
|
|
|
2021
|
-
/**
|
|
2022
|
-
* @param {Object} props
|
|
2023
|
-
* @param {Boolean} props.debounce
|
|
2024
|
-
* @param {String} props.description
|
|
2025
|
-
* @param {Boolean} props.disabled
|
|
2026
|
-
* @param {Object} props.element
|
|
2027
|
-
* @param {Function} props.getValue
|
|
2028
|
-
* @param {String} props.id
|
|
2029
|
-
* @param {String} props.label
|
|
2030
|
-
* @param {String} props.max
|
|
2031
|
-
* @param {String} props.min
|
|
2032
|
-
* @param {Function} props.setValue
|
|
2033
|
-
* @param {Function} props.onFocus
|
|
2034
|
-
* @param {Function} props.onBlur
|
|
2035
|
-
* @param {String} props.step
|
|
2036
|
-
* @param {Function} props.validate
|
|
2021
|
+
/**
|
|
2022
|
+
* @param {Object} props
|
|
2023
|
+
* @param {Boolean} props.debounce
|
|
2024
|
+
* @param {String} props.description
|
|
2025
|
+
* @param {Boolean} props.disabled
|
|
2026
|
+
* @param {Object} props.element
|
|
2027
|
+
* @param {Function} props.getValue
|
|
2028
|
+
* @param {String} props.id
|
|
2029
|
+
* @param {String} props.label
|
|
2030
|
+
* @param {String} props.max
|
|
2031
|
+
* @param {String} props.min
|
|
2032
|
+
* @param {Function} props.setValue
|
|
2033
|
+
* @param {Function} props.onFocus
|
|
2034
|
+
* @param {Function} props.onBlur
|
|
2035
|
+
* @param {String} props.step
|
|
2036
|
+
* @param {Function} props.validate
|
|
2037
2037
|
*/
|
|
2038
2038
|
function NumberFieldEntry(props) {
|
|
2039
2039
|
const {
|
|
@@ -2169,18 +2169,18 @@ function Select(props) {
|
|
|
2169
2169
|
});
|
|
2170
2170
|
}
|
|
2171
2171
|
|
|
2172
|
-
/**
|
|
2173
|
-
* @param {object} props
|
|
2174
|
-
* @param {object} props.element
|
|
2175
|
-
* @param {string} props.id
|
|
2176
|
-
* @param {string} [props.description]
|
|
2177
|
-
* @param {string} props.label
|
|
2178
|
-
* @param {Function} props.getValue
|
|
2179
|
-
* @param {Function} props.setValue
|
|
2180
|
-
* @param {Function} props.onFocus
|
|
2181
|
-
* @param {Function} props.onBlur
|
|
2182
|
-
* @param {Function} props.getOptions
|
|
2183
|
-
* @param {boolean} [props.disabled]
|
|
2172
|
+
/**
|
|
2173
|
+
* @param {object} props
|
|
2174
|
+
* @param {object} props.element
|
|
2175
|
+
* @param {string} props.id
|
|
2176
|
+
* @param {string} [props.description]
|
|
2177
|
+
* @param {string} props.label
|
|
2178
|
+
* @param {Function} props.getValue
|
|
2179
|
+
* @param {Function} props.setValue
|
|
2180
|
+
* @param {Function} props.onFocus
|
|
2181
|
+
* @param {Function} props.onBlur
|
|
2182
|
+
* @param {Function} props.getOptions
|
|
2183
|
+
* @param {boolean} [props.disabled]
|
|
2184
2184
|
*/
|
|
2185
2185
|
function SelectEntry(props) {
|
|
2186
2186
|
const {
|
|
@@ -2286,18 +2286,26 @@ function prefixId$3(id) {
|
|
|
2286
2286
|
return `bio-properties-panel-${id}`;
|
|
2287
2287
|
}
|
|
2288
2288
|
|
|
2289
|
+
function resizeToContents(element) {
|
|
2290
|
+
element.style.height = 'auto';
|
|
2291
|
+
|
|
2292
|
+
// a 2px pixel offset is required to prevent scrollbar from
|
|
2293
|
+
// appearing on OS with a full length scroll bar (Windows/Linux)
|
|
2294
|
+
element.style.height = `${element.scrollHeight + 2}px`;
|
|
2295
|
+
}
|
|
2289
2296
|
function TextArea(props) {
|
|
2290
2297
|
const {
|
|
2291
2298
|
id,
|
|
2292
2299
|
label,
|
|
2293
|
-
rows = 2,
|
|
2294
2300
|
debounce,
|
|
2295
2301
|
onInput,
|
|
2296
2302
|
value = '',
|
|
2297
2303
|
disabled,
|
|
2298
2304
|
monospace,
|
|
2299
2305
|
onFocus,
|
|
2300
|
-
onBlur
|
|
2306
|
+
onBlur,
|
|
2307
|
+
autoResize,
|
|
2308
|
+
rows = autoResize ? 1 : 2
|
|
2301
2309
|
} = props;
|
|
2302
2310
|
const [localValue, setLocalValue] = useState(value);
|
|
2303
2311
|
const ref = useShowEntryEvent(id);
|
|
@@ -2308,8 +2316,12 @@ function TextArea(props) {
|
|
|
2308
2316
|
}, [onInput, debounce]);
|
|
2309
2317
|
const handleInput = e => {
|
|
2310
2318
|
handleInputCallback(e);
|
|
2319
|
+
autoResize && resizeToContents(e.target);
|
|
2311
2320
|
setLocalValue(e.target.value);
|
|
2312
2321
|
};
|
|
2322
|
+
useLayoutEffect(() => {
|
|
2323
|
+
autoResize && resizeToContents(ref.current);
|
|
2324
|
+
}, []);
|
|
2313
2325
|
useEffect(() => {
|
|
2314
2326
|
if (value === localValue) {
|
|
2315
2327
|
return;
|
|
@@ -2327,7 +2339,7 @@ function TextArea(props) {
|
|
|
2327
2339
|
id: prefixId$2(id),
|
|
2328
2340
|
name: id,
|
|
2329
2341
|
spellCheck: "false",
|
|
2330
|
-
class: classnames('bio-properties-panel-input', monospace ? 'bio-properties-panel-input-monospace' : ''),
|
|
2342
|
+
class: classnames('bio-properties-panel-input', monospace ? 'bio-properties-panel-input-monospace' : '', autoResize ? 'auto-resize' : ''),
|
|
2331
2343
|
onInput: handleInput,
|
|
2332
2344
|
onFocus: onFocus,
|
|
2333
2345
|
onBlur: onBlur,
|
|
@@ -2339,20 +2351,20 @@ function TextArea(props) {
|
|
|
2339
2351
|
});
|
|
2340
2352
|
}
|
|
2341
2353
|
|
|
2342
|
-
/**
|
|
2343
|
-
* @param {object} props
|
|
2344
|
-
* @param {object} props.element
|
|
2345
|
-
* @param {string} props.id
|
|
2346
|
-
* @param {string} props.description
|
|
2347
|
-
* @param {boolean} props.debounce
|
|
2348
|
-
* @param {string} props.label
|
|
2349
|
-
* @param {Function} props.getValue
|
|
2350
|
-
* @param {Function} props.setValue
|
|
2351
|
-
* @param {Function} props.onFocus
|
|
2352
|
-
* @param {Function} props.onBlur
|
|
2353
|
-
* @param {number} props.rows
|
|
2354
|
-
* @param {boolean} props.monospace
|
|
2355
|
-
* @param {boolean} [props.disabled]
|
|
2354
|
+
/**
|
|
2355
|
+
* @param {object} props
|
|
2356
|
+
* @param {object} props.element
|
|
2357
|
+
* @param {string} props.id
|
|
2358
|
+
* @param {string} props.description
|
|
2359
|
+
* @param {boolean} props.debounce
|
|
2360
|
+
* @param {string} props.label
|
|
2361
|
+
* @param {Function} props.getValue
|
|
2362
|
+
* @param {Function} props.setValue
|
|
2363
|
+
* @param {Function} props.onFocus
|
|
2364
|
+
* @param {Function} props.onBlur
|
|
2365
|
+
* @param {number} props.rows
|
|
2366
|
+
* @param {boolean} props.monospace
|
|
2367
|
+
* @param {boolean} [props.disabled]
|
|
2356
2368
|
*/
|
|
2357
2369
|
function TextAreaEntry(props) {
|
|
2358
2370
|
const {
|
|
@@ -2367,7 +2379,8 @@ function TextAreaEntry(props) {
|
|
|
2367
2379
|
monospace,
|
|
2368
2380
|
disabled,
|
|
2369
2381
|
onFocus,
|
|
2370
|
-
onBlur
|
|
2382
|
+
onBlur,
|
|
2383
|
+
autoResize
|
|
2371
2384
|
} = props;
|
|
2372
2385
|
const value = getValue(element);
|
|
2373
2386
|
const error = useError(id);
|
|
@@ -2384,7 +2397,8 @@ function TextAreaEntry(props) {
|
|
|
2384
2397
|
rows: rows,
|
|
2385
2398
|
debounce: debounce,
|
|
2386
2399
|
monospace: monospace,
|
|
2387
|
-
disabled: disabled
|
|
2400
|
+
disabled: disabled,
|
|
2401
|
+
autoResize: autoResize
|
|
2388
2402
|
}, element), error && jsx("div", {
|
|
2389
2403
|
class: "bio-properties-panel-error",
|
|
2390
2404
|
children: error
|
|
@@ -2456,19 +2470,19 @@ function Textfield(props) {
|
|
|
2456
2470
|
});
|
|
2457
2471
|
}
|
|
2458
2472
|
|
|
2459
|
-
/**
|
|
2460
|
-
* @param {Object} props
|
|
2461
|
-
* @param {Object} props.element
|
|
2462
|
-
* @param {String} props.id
|
|
2463
|
-
* @param {String} props.description
|
|
2464
|
-
* @param {Boolean} props.debounce
|
|
2465
|
-
* @param {Boolean} props.disabled
|
|
2466
|
-
* @param {String} props.label
|
|
2467
|
-
* @param {Function} props.getValue
|
|
2468
|
-
* @param {Function} props.setValue
|
|
2469
|
-
* @param {Function} props.onFocus
|
|
2470
|
-
* @param {Function} props.onBlur
|
|
2471
|
-
* @param {Function} props.validate
|
|
2473
|
+
/**
|
|
2474
|
+
* @param {Object} props
|
|
2475
|
+
* @param {Object} props.element
|
|
2476
|
+
* @param {String} props.id
|
|
2477
|
+
* @param {String} props.description
|
|
2478
|
+
* @param {Boolean} props.debounce
|
|
2479
|
+
* @param {Boolean} props.disabled
|
|
2480
|
+
* @param {String} props.label
|
|
2481
|
+
* @param {Function} props.getValue
|
|
2482
|
+
* @param {Function} props.setValue
|
|
2483
|
+
* @param {Function} props.onFocus
|
|
2484
|
+
* @param {Function} props.onBlur
|
|
2485
|
+
* @param {Function} props.validate
|
|
2472
2486
|
*/
|
|
2473
2487
|
function TextfieldEntry(props) {
|
|
2474
2488
|
const {
|
|
@@ -2597,17 +2611,17 @@ function ToggleSwitch(props) {
|
|
|
2597
2611
|
});
|
|
2598
2612
|
}
|
|
2599
2613
|
|
|
2600
|
-
/**
|
|
2601
|
-
* @param {Object} props
|
|
2602
|
-
* @param {Object} props.element
|
|
2603
|
-
* @param {String} props.id
|
|
2604
|
-
* @param {String} props.description
|
|
2605
|
-
* @param {String} props.label
|
|
2606
|
-
* @param {String} props.switcherLabel
|
|
2607
|
-
* @param {Function} props.getValue
|
|
2608
|
-
* @param {Function} props.setValue
|
|
2609
|
-
* @param {Function} props.onFocus
|
|
2610
|
-
* @param {Function} props.onBlur
|
|
2614
|
+
/**
|
|
2615
|
+
* @param {Object} props
|
|
2616
|
+
* @param {Object} props.element
|
|
2617
|
+
* @param {String} props.id
|
|
2618
|
+
* @param {String} props.description
|
|
2619
|
+
* @param {String} props.label
|
|
2620
|
+
* @param {String} props.switcherLabel
|
|
2621
|
+
* @param {Function} props.getValue
|
|
2622
|
+
* @param {Function} props.setValue
|
|
2623
|
+
* @param {Function} props.onFocus
|
|
2624
|
+
* @param {Function} props.onBlur
|
|
2611
2625
|
*/
|
|
2612
2626
|
function ToggleSwitchEntry(props) {
|
|
2613
2627
|
const {
|