@bpmn-io/properties-panel 3.2.0 → 3.2.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/dist/index.esm.js +103 -95
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +24 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useContext, useRef, useEffect
|
|
1
|
+
import { useContext, useState, useRef, useEffect, useMemo, useCallback, useLayoutEffect } from '../preact/hooks';
|
|
2
2
|
import { isFunction, isArray, get, assign, set, sortBy, find, isString, isNumber, debounce } from 'min-dash';
|
|
3
|
-
import {
|
|
3
|
+
import { createPortal, forwardRef } from '../preact/compat';
|
|
4
4
|
import { jsx, jsxs } from '../preact/jsx-runtime';
|
|
5
5
|
import { createContext, createElement } from '../preact';
|
|
6
6
|
import classnames from 'classnames';
|
|
@@ -212,7 +212,8 @@ function TooltipWrapper(props) {
|
|
|
212
212
|
function Tooltip(props) {
|
|
213
213
|
const {
|
|
214
214
|
forId,
|
|
215
|
-
value
|
|
215
|
+
value,
|
|
216
|
+
parent
|
|
216
217
|
} = props;
|
|
217
218
|
const [visible, setShow] = useState(false);
|
|
218
219
|
let timeout = null;
|
|
@@ -263,25 +264,17 @@ function Tooltip(props) {
|
|
|
263
264
|
hideTooltip();
|
|
264
265
|
}
|
|
265
266
|
};
|
|
267
|
+
document.addEventListener('wheel', hideHoveredTooltip);
|
|
266
268
|
document.addEventListener('focusout', hideFocusedTooltip);
|
|
267
269
|
document.addEventListener('mousemove', hideHoveredTooltip);
|
|
268
270
|
return () => {
|
|
271
|
+
document.removeEventListener('wheel', hideHoveredTooltip);
|
|
269
272
|
document.removeEventListener('mousemove', hideHoveredTooltip);
|
|
270
273
|
document.removeEventListener('focusout', hideFocusedTooltip);
|
|
271
274
|
};
|
|
272
275
|
}, [wrapperRef.current, visible]);
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
tabIndex: "0",
|
|
276
|
-
ref: wrapperRef,
|
|
277
|
-
onMouseEnter: showTooltip,
|
|
278
|
-
onMouseLeave: () => clearTimeout(timeout),
|
|
279
|
-
onFocus: showTooltip,
|
|
280
|
-
onKeyDown: hideTooltipViaEscape,
|
|
281
|
-
onMouseDown: e => {
|
|
282
|
-
e.preventDefault();
|
|
283
|
-
},
|
|
284
|
-
children: [props.children, visible ? jsxs("div", {
|
|
276
|
+
const renderTooltip = () => {
|
|
277
|
+
return jsxs("div", {
|
|
285
278
|
class: "bio-properties-panel-tooltip",
|
|
286
279
|
role: "tooltip",
|
|
287
280
|
id: "bio-properties-panel-tooltip",
|
|
@@ -295,7 +288,20 @@ function Tooltip(props) {
|
|
|
295
288
|
}), jsx("div", {
|
|
296
289
|
class: "bio-properties-panel-tooltip-arrow"
|
|
297
290
|
})]
|
|
298
|
-
})
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
return jsxs("div", {
|
|
294
|
+
class: "bio-properties-panel-tooltip-wrapper",
|
|
295
|
+
tabIndex: "0",
|
|
296
|
+
ref: wrapperRef,
|
|
297
|
+
onMouseEnter: showTooltip,
|
|
298
|
+
onMouseLeave: () => clearTimeout(timeout),
|
|
299
|
+
onFocus: showTooltip,
|
|
300
|
+
onKeyDown: hideTooltipViaEscape,
|
|
301
|
+
onMouseDown: e => {
|
|
302
|
+
e.preventDefault();
|
|
303
|
+
},
|
|
304
|
+
children: [props.children, visible ? parent ? createPortal(renderTooltip(), parent.current) : renderTooltip() : null]
|
|
299
305
|
});
|
|
300
306
|
}
|
|
301
307
|
|
|
@@ -378,7 +384,7 @@ function useEvent(event, callback, eventBus) {
|
|
|
378
384
|
}
|
|
379
385
|
|
|
380
386
|
// (2) update subscription after inputs changed
|
|
381
|
-
useEffect
|
|
387
|
+
useEffect(() => {
|
|
382
388
|
if (eventBus && didMount.current) {
|
|
383
389
|
eventBus.on(event, callback);
|
|
384
390
|
}
|
|
@@ -461,7 +467,7 @@ function useLayoutState(path, defaultValue) {
|
|
|
461
467
|
|
|
462
468
|
function usePrevious(value) {
|
|
463
469
|
const ref = useRef();
|
|
464
|
-
useEffect
|
|
470
|
+
useEffect(() => {
|
|
465
471
|
ref.current = value;
|
|
466
472
|
});
|
|
467
473
|
return ref.current;
|
|
@@ -488,7 +494,7 @@ function useShowEntryEvent(id) {
|
|
|
488
494
|
}
|
|
489
495
|
}
|
|
490
496
|
}, [id]);
|
|
491
|
-
useEffect
|
|
497
|
+
useEffect(() => {
|
|
492
498
|
if (focus.current && ref.current) {
|
|
493
499
|
if (isFunction(ref.current.focus)) {
|
|
494
500
|
ref.current.focus();
|
|
@@ -519,19 +525,19 @@ function useShowEntryEvent(id) {
|
|
|
519
525
|
* @param {setSticky} setSticky
|
|
520
526
|
*/
|
|
521
527
|
function useStickyIntersectionObserver(ref, scrollContainerSelector, setSticky) {
|
|
522
|
-
const [scrollContainer, setScrollContainer] = useState
|
|
528
|
+
const [scrollContainer, setScrollContainer] = useState(query(scrollContainerSelector));
|
|
523
529
|
const updateScrollContainer = useCallback(() => {
|
|
524
530
|
const newScrollContainer = query(scrollContainerSelector);
|
|
525
531
|
if (newScrollContainer !== scrollContainer) {
|
|
526
532
|
setScrollContainer(newScrollContainer);
|
|
527
533
|
}
|
|
528
534
|
}, [scrollContainerSelector, scrollContainer]);
|
|
529
|
-
useEffect
|
|
535
|
+
useEffect(() => {
|
|
530
536
|
updateScrollContainer();
|
|
531
537
|
}, [updateScrollContainer]);
|
|
532
538
|
useEvent('propertiesPanel.attach', updateScrollContainer);
|
|
533
539
|
useEvent('propertiesPanel.detach', updateScrollContainer);
|
|
534
|
-
useEffect
|
|
540
|
+
useEffect(() => {
|
|
535
541
|
const Observer = IntersectionObserver;
|
|
536
542
|
|
|
537
543
|
// return early if IntersectionObserver is not available
|
|
@@ -602,11 +608,11 @@ function Group(props) {
|
|
|
602
608
|
const [open, setOpen] = useLayoutState(['groups', id, 'open'], shouldOpen);
|
|
603
609
|
const onShow = useCallback(() => setOpen(true), [setOpen]);
|
|
604
610
|
const toggleOpen = () => setOpen(!open);
|
|
605
|
-
const [edited, setEdited] = useState
|
|
606
|
-
const [sticky, setSticky] = useState
|
|
611
|
+
const [edited, setEdited] = useState(false);
|
|
612
|
+
const [sticky, setSticky] = useState(false);
|
|
607
613
|
|
|
608
614
|
// set edited state depending on all entries
|
|
609
|
-
useEffect
|
|
615
|
+
useEffect(() => {
|
|
610
616
|
const hasOneEditedEntry = entries.find(entry => {
|
|
611
617
|
const {
|
|
612
618
|
id,
|
|
@@ -646,6 +652,7 @@ function Group(props) {
|
|
|
646
652
|
value: props.tooltip,
|
|
647
653
|
forId: 'group-' + id,
|
|
648
654
|
element: element,
|
|
655
|
+
parent: groupRef,
|
|
649
656
|
children: label
|
|
650
657
|
})
|
|
651
658
|
}), jsxs("div", {
|
|
@@ -826,14 +833,14 @@ function PropertiesPanel(props) {
|
|
|
826
833
|
} = props;
|
|
827
834
|
|
|
828
835
|
// set-up layout context
|
|
829
|
-
const [layout, setLayout] = useState
|
|
836
|
+
const [layout, setLayout] = useState(createLayout(layoutConfig));
|
|
830
837
|
|
|
831
838
|
// react to external changes in the layout config
|
|
832
839
|
useUpdateLayoutEffect(() => {
|
|
833
840
|
const newLayout = createLayout(layoutConfig);
|
|
834
841
|
setLayout(newLayout);
|
|
835
842
|
}, [layoutConfig]);
|
|
836
|
-
useEffect
|
|
843
|
+
useEffect(() => {
|
|
837
844
|
if (typeof layoutChanged === 'function') {
|
|
838
845
|
layoutChanged(layout);
|
|
839
846
|
}
|
|
@@ -855,7 +862,7 @@ function PropertiesPanel(props) {
|
|
|
855
862
|
|
|
856
863
|
// set-up description context
|
|
857
864
|
const description = useMemo(() => createDescriptionContext(descriptionConfig), [descriptionConfig]);
|
|
858
|
-
useEffect
|
|
865
|
+
useEffect(() => {
|
|
859
866
|
if (typeof descriptionLoaded === 'function') {
|
|
860
867
|
descriptionLoaded(description);
|
|
861
868
|
}
|
|
@@ -870,7 +877,7 @@ function PropertiesPanel(props) {
|
|
|
870
877
|
|
|
871
878
|
// set-up tooltip context
|
|
872
879
|
const tooltip = useMemo(() => createTooltipContext(tooltipConfig), [tooltipConfig]);
|
|
873
|
-
useEffect
|
|
880
|
+
useEffect(() => {
|
|
874
881
|
if (typeof tooltipLoaded === 'function') {
|
|
875
882
|
tooltipLoaded(tooltip);
|
|
876
883
|
}
|
|
@@ -882,7 +889,7 @@ function PropertiesPanel(props) {
|
|
|
882
889
|
tooltip,
|
|
883
890
|
getTooltipForId
|
|
884
891
|
};
|
|
885
|
-
const [errors, setErrors] = useState
|
|
892
|
+
const [errors, setErrors] = useState({});
|
|
886
893
|
const onSetErrors = ({
|
|
887
894
|
errors
|
|
888
895
|
}) => setErrors(errors);
|
|
@@ -998,7 +1005,7 @@ function DropdownButton(props) {
|
|
|
998
1005
|
} = props;
|
|
999
1006
|
const dropdownRef = useRef(null);
|
|
1000
1007
|
const menuRef = useRef(null);
|
|
1001
|
-
const [open, setOpen] = useState
|
|
1008
|
+
const [open, setOpen] = useState(false);
|
|
1002
1009
|
const close = () => setOpen(false);
|
|
1003
1010
|
function onDropdownToggle(event) {
|
|
1004
1011
|
if (menuRef.current && menuRef.current.contains(event.target)) {
|
|
@@ -1057,7 +1064,7 @@ function MenuItem({
|
|
|
1057
1064
|
* @param {Function} callback
|
|
1058
1065
|
*/
|
|
1059
1066
|
function useGlobalClick(ignoredElements, callback) {
|
|
1060
|
-
useEffect
|
|
1067
|
+
useEffect(() => {
|
|
1061
1068
|
/**
|
|
1062
1069
|
* @param {MouseEvent} event
|
|
1063
1070
|
*/
|
|
@@ -1100,7 +1107,7 @@ function CollapsibleEntry(props) {
|
|
|
1100
1107
|
open: shouldOpen,
|
|
1101
1108
|
remove
|
|
1102
1109
|
} = props;
|
|
1103
|
-
const [open, setOpen] = useState
|
|
1110
|
+
const [open, setOpen] = useState(shouldOpen);
|
|
1104
1111
|
const toggleOpen = () => setOpen(!open);
|
|
1105
1112
|
const {
|
|
1106
1113
|
onShow
|
|
@@ -1166,7 +1173,7 @@ function ListItem(props) {
|
|
|
1166
1173
|
} = props;
|
|
1167
1174
|
|
|
1168
1175
|
// focus specified entry on auto open
|
|
1169
|
-
useEffect
|
|
1176
|
+
useEffect(() => {
|
|
1170
1177
|
if (autoOpen && autoFocusEntry) {
|
|
1171
1178
|
const entry = query(`[data-entry-id="${autoFocusEntry}"]`);
|
|
1172
1179
|
const focusableInput = query('.bio-properties-panel-input', entry);
|
|
@@ -1205,13 +1212,13 @@ function ListGroup(props) {
|
|
|
1205
1212
|
} = props;
|
|
1206
1213
|
const groupRef = useRef(null);
|
|
1207
1214
|
const [open, setOpen] = useLayoutState(['groups', id, 'open'], false);
|
|
1208
|
-
const [sticky, setSticky] = useState
|
|
1215
|
+
const [sticky, setSticky] = useState(false);
|
|
1209
1216
|
const onShow = useCallback(() => setOpen(true), [setOpen]);
|
|
1210
|
-
const [ordering, setOrdering] = useState
|
|
1211
|
-
const [newItemAdded, setNewItemAdded] = useState
|
|
1217
|
+
const [ordering, setOrdering] = useState([]);
|
|
1218
|
+
const [newItemAdded, setNewItemAdded] = useState(false);
|
|
1212
1219
|
|
|
1213
1220
|
// Flag to mark that add button was clicked in the last render cycle
|
|
1214
|
-
const [addTriggered, setAddTriggered] = useState
|
|
1221
|
+
const [addTriggered, setAddTriggered] = useState(false);
|
|
1215
1222
|
const prevItems = usePrevious(items);
|
|
1216
1223
|
const prevElement = usePrevious(element);
|
|
1217
1224
|
const elementChanged = element !== prevElement;
|
|
@@ -1225,14 +1232,14 @@ function ListGroup(props) {
|
|
|
1225
1232
|
// keep ordering in sync to items - and open changes
|
|
1226
1233
|
|
|
1227
1234
|
// (0) set initial ordering from given items
|
|
1228
|
-
useEffect
|
|
1235
|
+
useEffect(() => {
|
|
1229
1236
|
if (!prevItems || !shouldSort) {
|
|
1230
1237
|
setOrdering(createOrdering(items));
|
|
1231
1238
|
}
|
|
1232
1239
|
}, [items, element]);
|
|
1233
1240
|
|
|
1234
1241
|
// (1) items were added
|
|
1235
|
-
useEffect
|
|
1242
|
+
useEffect(() => {
|
|
1236
1243
|
// reset addTriggered flag
|
|
1237
1244
|
setAddTriggered(false);
|
|
1238
1245
|
if (shouldHandleEffects && prevItems && items.length > prevItems.length) {
|
|
@@ -1273,14 +1280,14 @@ function ListGroup(props) {
|
|
|
1273
1280
|
}, [items, open, shouldHandleEffects, addTriggered]);
|
|
1274
1281
|
|
|
1275
1282
|
// (2) sort items on open if shouldSort is set
|
|
1276
|
-
useEffect
|
|
1283
|
+
useEffect(() => {
|
|
1277
1284
|
if (shouldSort && open && !newItemAdded) {
|
|
1278
1285
|
setOrdering(createOrdering(sortItems(items)));
|
|
1279
1286
|
}
|
|
1280
1287
|
}, [open, shouldSort]);
|
|
1281
1288
|
|
|
1282
1289
|
// (3) items were deleted
|
|
1283
|
-
useEffect
|
|
1290
|
+
useEffect(() => {
|
|
1284
1291
|
if (shouldHandleEffects && prevItems && items.length < prevItems.length) {
|
|
1285
1292
|
let keep = [];
|
|
1286
1293
|
ordering.forEach(o => {
|
|
@@ -1330,6 +1337,7 @@ function ListGroup(props) {
|
|
|
1330
1337
|
value: props.tooltip,
|
|
1331
1338
|
forId: 'group-' + id,
|
|
1332
1339
|
element: element,
|
|
1340
|
+
parent: groupRef,
|
|
1333
1341
|
children: label
|
|
1334
1342
|
})
|
|
1335
1343
|
}), jsxs("div", {
|
|
@@ -1425,7 +1433,7 @@ function Checkbox(props) {
|
|
|
1425
1433
|
onBlur,
|
|
1426
1434
|
tooltip
|
|
1427
1435
|
} = props;
|
|
1428
|
-
const [localValue, setLocalValue] = useState
|
|
1436
|
+
const [localValue, setLocalValue] = useState(value);
|
|
1429
1437
|
const handleChangeCallback = ({
|
|
1430
1438
|
target
|
|
1431
1439
|
}) => {
|
|
@@ -1435,7 +1443,7 @@ function Checkbox(props) {
|
|
|
1435
1443
|
handleChangeCallback(e);
|
|
1436
1444
|
setLocalValue(e.target.value);
|
|
1437
1445
|
};
|
|
1438
|
-
useEffect
|
|
1446
|
+
useEffect(() => {
|
|
1439
1447
|
if (value === localValue) {
|
|
1440
1448
|
return;
|
|
1441
1449
|
}
|
|
@@ -1530,7 +1538,7 @@ function prefixId$7(id) {
|
|
|
1530
1538
|
}
|
|
1531
1539
|
|
|
1532
1540
|
const useBufferedFocus$1 = function (editor, ref) {
|
|
1533
|
-
const [buffer, setBuffer] = useState
|
|
1541
|
+
const [buffer, setBuffer] = useState(undefined);
|
|
1534
1542
|
ref.current = useMemo(() => ({
|
|
1535
1543
|
focus: offset => {
|
|
1536
1544
|
if (editor) {
|
|
@@ -1543,7 +1551,7 @@ const useBufferedFocus$1 = function (editor, ref) {
|
|
|
1543
1551
|
}
|
|
1544
1552
|
}
|
|
1545
1553
|
}), [editor]);
|
|
1546
|
-
useEffect
|
|
1554
|
+
useEffect(() => {
|
|
1547
1555
|
if (typeof buffer !== 'undefined' && editor) {
|
|
1548
1556
|
editor.focus(buffer);
|
|
1549
1557
|
setBuffer(false);
|
|
@@ -1563,14 +1571,14 @@ const CodeEditor$1 = forwardRef((props, ref) => {
|
|
|
1563
1571
|
singleLine = false
|
|
1564
1572
|
} = props;
|
|
1565
1573
|
const inputRef = useRef();
|
|
1566
|
-
const [editor, setEditor] = useState
|
|
1567
|
-
const [localValue, setLocalValue] = useState
|
|
1574
|
+
const [editor, setEditor] = useState();
|
|
1575
|
+
const [localValue, setLocalValue] = useState(value || '');
|
|
1568
1576
|
useBufferedFocus$1(editor, ref);
|
|
1569
1577
|
const handleInput = useStaticCallback(newValue => {
|
|
1570
1578
|
onInput(newValue);
|
|
1571
1579
|
setLocalValue(newValue);
|
|
1572
1580
|
});
|
|
1573
|
-
useEffect
|
|
1581
|
+
useEffect(() => {
|
|
1574
1582
|
let editor;
|
|
1575
1583
|
editor = new FeelersEditor({
|
|
1576
1584
|
container: inputRef.current,
|
|
@@ -1590,7 +1598,7 @@ const CodeEditor$1 = forwardRef((props, ref) => {
|
|
|
1590
1598
|
setEditor(null);
|
|
1591
1599
|
};
|
|
1592
1600
|
}, []);
|
|
1593
|
-
useEffect
|
|
1601
|
+
useEffect(() => {
|
|
1594
1602
|
if (!editor) {
|
|
1595
1603
|
return;
|
|
1596
1604
|
}
|
|
@@ -1612,7 +1620,7 @@ const CodeEditor$1 = forwardRef((props, ref) => {
|
|
|
1612
1620
|
});
|
|
1613
1621
|
|
|
1614
1622
|
const useBufferedFocus = function (editor, ref) {
|
|
1615
|
-
const [buffer, setBuffer] = useState
|
|
1623
|
+
const [buffer, setBuffer] = useState(undefined);
|
|
1616
1624
|
ref.current = useMemo(() => ({
|
|
1617
1625
|
focus: offset => {
|
|
1618
1626
|
if (editor) {
|
|
@@ -1625,7 +1633,7 @@ const useBufferedFocus = function (editor, ref) {
|
|
|
1625
1633
|
}
|
|
1626
1634
|
}
|
|
1627
1635
|
}), [editor]);
|
|
1628
|
-
useEffect
|
|
1636
|
+
useEffect(() => {
|
|
1629
1637
|
if (typeof buffer !== 'undefined' && editor) {
|
|
1630
1638
|
editor.focus(buffer);
|
|
1631
1639
|
setBuffer(false);
|
|
@@ -1643,14 +1651,14 @@ const CodeEditor = forwardRef((props, ref) => {
|
|
|
1643
1651
|
variables
|
|
1644
1652
|
} = props;
|
|
1645
1653
|
const inputRef = useRef();
|
|
1646
|
-
const [editor, setEditor] = useState
|
|
1647
|
-
const [localValue, setLocalValue] = useState
|
|
1654
|
+
const [editor, setEditor] = useState();
|
|
1655
|
+
const [localValue, setLocalValue] = useState(value || '');
|
|
1648
1656
|
useBufferedFocus(editor, ref);
|
|
1649
1657
|
const handleInput = useStaticCallback(newValue => {
|
|
1650
1658
|
onInput(newValue);
|
|
1651
1659
|
setLocalValue(newValue);
|
|
1652
1660
|
});
|
|
1653
|
-
useEffect
|
|
1661
|
+
useEffect(() => {
|
|
1654
1662
|
let editor;
|
|
1655
1663
|
|
|
1656
1664
|
/* Trigger FEEL toggle when
|
|
@@ -1684,7 +1692,7 @@ const CodeEditor = forwardRef((props, ref) => {
|
|
|
1684
1692
|
setEditor(null);
|
|
1685
1693
|
};
|
|
1686
1694
|
}, []);
|
|
1687
|
-
useEffect
|
|
1695
|
+
useEffect(() => {
|
|
1688
1696
|
if (!editor) {
|
|
1689
1697
|
return;
|
|
1690
1698
|
}
|
|
@@ -1694,7 +1702,7 @@ const CodeEditor = forwardRef((props, ref) => {
|
|
|
1694
1702
|
editor.setValue(value);
|
|
1695
1703
|
setLocalValue(value);
|
|
1696
1704
|
}, [value]);
|
|
1697
|
-
useEffect
|
|
1705
|
+
useEffect(() => {
|
|
1698
1706
|
if (!editor) {
|
|
1699
1707
|
return;
|
|
1700
1708
|
}
|
|
@@ -1773,7 +1781,7 @@ function ToggleSwitch(props) {
|
|
|
1773
1781
|
inputRef,
|
|
1774
1782
|
tooltip
|
|
1775
1783
|
} = props;
|
|
1776
|
-
const [localValue, setLocalValue] = useState
|
|
1784
|
+
const [localValue, setLocalValue] = useState(value);
|
|
1777
1785
|
const handleInputCallback = async () => {
|
|
1778
1786
|
onInput(!value);
|
|
1779
1787
|
};
|
|
@@ -1781,7 +1789,7 @@ function ToggleSwitch(props) {
|
|
|
1781
1789
|
handleInputCallback();
|
|
1782
1790
|
setLocalValue(e.target.value);
|
|
1783
1791
|
};
|
|
1784
|
-
useEffect
|
|
1792
|
+
useEffect(() => {
|
|
1785
1793
|
if (value === localValue) {
|
|
1786
1794
|
return;
|
|
1787
1795
|
}
|
|
@@ -1901,7 +1909,7 @@ function NumberField(props) {
|
|
|
1901
1909
|
onFocus,
|
|
1902
1910
|
onBlur
|
|
1903
1911
|
} = props;
|
|
1904
|
-
const [localValue, setLocalValue] = useState
|
|
1912
|
+
const [localValue, setLocalValue] = useState(value);
|
|
1905
1913
|
const handleInputCallback = useMemo(() => {
|
|
1906
1914
|
return debounce(event => {
|
|
1907
1915
|
const {
|
|
@@ -1917,7 +1925,7 @@ function NumberField(props) {
|
|
|
1917
1925
|
handleInputCallback(e);
|
|
1918
1926
|
setLocalValue(e.target.value);
|
|
1919
1927
|
};
|
|
1920
|
-
useEffect
|
|
1928
|
+
useEffect(() => {
|
|
1921
1929
|
if (value === localValue) {
|
|
1922
1930
|
return;
|
|
1923
1931
|
}
|
|
@@ -1984,9 +1992,9 @@ function NumberFieldEntry(props) {
|
|
|
1984
1992
|
validate
|
|
1985
1993
|
} = props;
|
|
1986
1994
|
const globalError = useError(id);
|
|
1987
|
-
const [localError, setLocalError] = useState
|
|
1995
|
+
const [localError, setLocalError] = useState(null);
|
|
1988
1996
|
let value = getValue(element);
|
|
1989
|
-
useEffect
|
|
1997
|
+
useEffect(() => {
|
|
1990
1998
|
if (isFunction(validate)) {
|
|
1991
1999
|
const newValidationError = validate(value) || null;
|
|
1992
2000
|
setLocalError(newValidationError);
|
|
@@ -2052,12 +2060,12 @@ function FeelTextfield(props) {
|
|
|
2052
2060
|
OptionalComponent = OptionalFeelInput,
|
|
2053
2061
|
tooltip
|
|
2054
2062
|
} = props;
|
|
2055
|
-
const [localValue, _setLocalValue] = useState
|
|
2063
|
+
const [localValue, _setLocalValue] = useState(value);
|
|
2056
2064
|
const editorRef = useShowEntryEvent(id);
|
|
2057
2065
|
const containerRef = useRef();
|
|
2058
2066
|
const feelActive = isString(localValue) && localValue.startsWith('=') || feel === 'required';
|
|
2059
2067
|
const feelOnlyValue = isString(localValue) && localValue.startsWith('=') ? localValue.substring(1) : localValue;
|
|
2060
|
-
const [focus, _setFocus] = useState
|
|
2068
|
+
const [focus, _setFocus] = useState(undefined);
|
|
2061
2069
|
const setFocus = (offset = 0) => {
|
|
2062
2070
|
const hasFocus = containerRef.current.contains(document.activeElement);
|
|
2063
2071
|
|
|
@@ -2110,13 +2118,13 @@ function FeelTextfield(props) {
|
|
|
2110
2118
|
const message = `${error.source}: ${error.message}`;
|
|
2111
2119
|
onError(message);
|
|
2112
2120
|
});
|
|
2113
|
-
useEffect
|
|
2121
|
+
useEffect(() => {
|
|
2114
2122
|
if (typeof focus !== 'undefined') {
|
|
2115
2123
|
editorRef.current.focus(focus);
|
|
2116
2124
|
_setFocus(undefined);
|
|
2117
2125
|
}
|
|
2118
2126
|
}, [focus]);
|
|
2119
|
-
useEffect
|
|
2127
|
+
useEffect(() => {
|
|
2120
2128
|
if (value === localValue) {
|
|
2121
2129
|
return;
|
|
2122
2130
|
}
|
|
@@ -2130,7 +2138,7 @@ function FeelTextfield(props) {
|
|
|
2130
2138
|
}, [value]);
|
|
2131
2139
|
|
|
2132
2140
|
// copy-paste integration
|
|
2133
|
-
useEffect
|
|
2141
|
+
useEffect(() => {
|
|
2134
2142
|
const copyHandler = event => {
|
|
2135
2143
|
if (!feelActive) {
|
|
2136
2144
|
return;
|
|
@@ -2455,10 +2463,10 @@ function FeelEntry(props) {
|
|
|
2455
2463
|
onBlur,
|
|
2456
2464
|
tooltip
|
|
2457
2465
|
} = props;
|
|
2458
|
-
const [validationError, setValidationError] = useState
|
|
2459
|
-
const [localError, setLocalError] = useState
|
|
2466
|
+
const [validationError, setValidationError] = useState(null);
|
|
2467
|
+
const [localError, setLocalError] = useState(null);
|
|
2460
2468
|
let value = getValue(element);
|
|
2461
|
-
useEffect
|
|
2469
|
+
useEffect(() => {
|
|
2462
2470
|
if (isFunction(validate)) {
|
|
2463
2471
|
const newValidationError = validate(value) || null;
|
|
2464
2472
|
setValidationError(newValidationError);
|
|
@@ -2701,10 +2709,10 @@ function TemplatingEntry(props) {
|
|
|
2701
2709
|
validate,
|
|
2702
2710
|
show = noop
|
|
2703
2711
|
} = props;
|
|
2704
|
-
const [validationError, setValidationError] = useState
|
|
2705
|
-
const [localError, setLocalError] = useState
|
|
2712
|
+
const [validationError, setValidationError] = useState(null);
|
|
2713
|
+
const [localError, setLocalError] = useState(null);
|
|
2706
2714
|
let value = getValue(element);
|
|
2707
|
-
useEffect
|
|
2715
|
+
useEffect(() => {
|
|
2708
2716
|
if (isFunction(validate)) {
|
|
2709
2717
|
const newValidationError = validate(value) || null;
|
|
2710
2718
|
setValidationError(newValidationError);
|
|
@@ -2761,10 +2769,10 @@ function Templating(props) {
|
|
|
2761
2769
|
disabled = false,
|
|
2762
2770
|
tooltipContainer
|
|
2763
2771
|
} = props;
|
|
2764
|
-
const [localValue, setLocalValue] = useState
|
|
2772
|
+
const [localValue, setLocalValue] = useState(value);
|
|
2765
2773
|
const editorRef = useShowEntryEvent(id);
|
|
2766
2774
|
const containerRef = useRef();
|
|
2767
|
-
const [focus, _setFocus] = useState
|
|
2775
|
+
const [focus, _setFocus] = useState(undefined);
|
|
2768
2776
|
const setFocus = (offset = 0) => {
|
|
2769
2777
|
const hasFocus = containerRef.current.contains(document.activeElement);
|
|
2770
2778
|
|
|
@@ -2789,13 +2797,13 @@ function Templating(props) {
|
|
|
2789
2797
|
const message = `${error.source}: ${error.message}`;
|
|
2790
2798
|
onError(message);
|
|
2791
2799
|
});
|
|
2792
|
-
useEffect
|
|
2800
|
+
useEffect(() => {
|
|
2793
2801
|
if (typeof focus !== 'undefined') {
|
|
2794
2802
|
editorRef.current.focus(focus);
|
|
2795
2803
|
_setFocus(undefined);
|
|
2796
2804
|
}
|
|
2797
2805
|
}, [focus]);
|
|
2798
|
-
useEffect
|
|
2806
|
+
useEffect(() => {
|
|
2799
2807
|
if (value === localValue) {
|
|
2800
2808
|
return;
|
|
2801
2809
|
}
|
|
@@ -2850,7 +2858,7 @@ function List(props) {
|
|
|
2850
2858
|
compareFn,
|
|
2851
2859
|
...restProps
|
|
2852
2860
|
} = props;
|
|
2853
|
-
const [open, setOpen] = useState
|
|
2861
|
+
const [open, setOpen] = useState(!!shouldOpen);
|
|
2854
2862
|
const hasItems = !!items.length;
|
|
2855
2863
|
const toggleOpen = () => hasItems && setOpen(!open);
|
|
2856
2864
|
const opening = !usePrevious(open) && open;
|
|
@@ -2858,7 +2866,7 @@ function List(props) {
|
|
|
2858
2866
|
const shouldReset = opening || elementChanged;
|
|
2859
2867
|
const sortedItems = useSortedItems(items, compareFn, shouldReset);
|
|
2860
2868
|
const newItems = useNewItems(items, elementChanged);
|
|
2861
|
-
useEffect
|
|
2869
|
+
useEffect(() => {
|
|
2862
2870
|
if (open && !hasItems) {
|
|
2863
2871
|
setOpen(false);
|
|
2864
2872
|
}
|
|
@@ -2933,7 +2941,7 @@ function ItemsList(props) {
|
|
|
2933
2941
|
} = props;
|
|
2934
2942
|
const getKey = useKeyFactory();
|
|
2935
2943
|
const newItem = newItems[0];
|
|
2936
|
-
useEffect
|
|
2944
|
+
useEffect(() => {
|
|
2937
2945
|
if (newItem && autoFocusEntry) {
|
|
2938
2946
|
// (0) select the parent entry (containing all list items)
|
|
2939
2947
|
const entry = query(`[data-entry-id="${id}"]`);
|
|
@@ -3032,7 +3040,7 @@ function Select(props) {
|
|
|
3032
3040
|
tooltip
|
|
3033
3041
|
} = props;
|
|
3034
3042
|
const ref = useShowEntryEvent(id);
|
|
3035
|
-
const [localValue, setLocalValue] = useState
|
|
3043
|
+
const [localValue, setLocalValue] = useState(value);
|
|
3036
3044
|
const handleChangeCallback = ({
|
|
3037
3045
|
target
|
|
3038
3046
|
}) => {
|
|
@@ -3042,7 +3050,7 @@ function Select(props) {
|
|
|
3042
3050
|
handleChangeCallback(e);
|
|
3043
3051
|
setLocalValue(e.target.value);
|
|
3044
3052
|
};
|
|
3045
|
-
useEffect
|
|
3053
|
+
useEffect(() => {
|
|
3046
3054
|
if (value === localValue) {
|
|
3047
3055
|
return;
|
|
3048
3056
|
}
|
|
@@ -3122,9 +3130,9 @@ function SelectEntry(props) {
|
|
|
3122
3130
|
} = props;
|
|
3123
3131
|
const options = getOptions(element);
|
|
3124
3132
|
const globalError = useError(id);
|
|
3125
|
-
const [localError, setLocalError] = useState
|
|
3133
|
+
const [localError, setLocalError] = useState(null);
|
|
3126
3134
|
let value = getValue(element);
|
|
3127
|
-
useEffect
|
|
3135
|
+
useEffect(() => {
|
|
3128
3136
|
if (isFunction(validate)) {
|
|
3129
3137
|
const newValidationError = validate(value) || null;
|
|
3130
3138
|
setLocalError(newValidationError);
|
|
@@ -3185,7 +3193,7 @@ function Simple(props) {
|
|
|
3185
3193
|
setValue
|
|
3186
3194
|
} = props;
|
|
3187
3195
|
const value = getValue(element);
|
|
3188
|
-
const [localValue, setLocalValue] = useState
|
|
3196
|
+
const [localValue, setLocalValue] = useState(value);
|
|
3189
3197
|
const handleInputCallback = useMemo(() => {
|
|
3190
3198
|
return debounce(({
|
|
3191
3199
|
target
|
|
@@ -3195,7 +3203,7 @@ function Simple(props) {
|
|
|
3195
3203
|
handleInputCallback(e);
|
|
3196
3204
|
setLocalValue(e.target.value);
|
|
3197
3205
|
};
|
|
3198
|
-
useEffect
|
|
3206
|
+
useEffect(() => {
|
|
3199
3207
|
if (value === localValue) {
|
|
3200
3208
|
return;
|
|
3201
3209
|
}
|
|
@@ -3251,7 +3259,7 @@ function TextArea(props) {
|
|
|
3251
3259
|
rows = autoResize ? 1 : 2,
|
|
3252
3260
|
tooltip
|
|
3253
3261
|
} = props;
|
|
3254
|
-
const [localValue, setLocalValue] = useState
|
|
3262
|
+
const [localValue, setLocalValue] = useState(value);
|
|
3255
3263
|
const ref = useShowEntryEvent(id);
|
|
3256
3264
|
const handleInputCallback = useMemo(() => {
|
|
3257
3265
|
return debounce(({
|
|
@@ -3266,7 +3274,7 @@ function TextArea(props) {
|
|
|
3266
3274
|
useLayoutEffect(() => {
|
|
3267
3275
|
autoResize && resizeToContents(ref.current);
|
|
3268
3276
|
}, []);
|
|
3269
|
-
useEffect
|
|
3277
|
+
useEffect(() => {
|
|
3270
3278
|
if (value === localValue) {
|
|
3271
3279
|
return;
|
|
3272
3280
|
}
|
|
@@ -3335,9 +3343,9 @@ function TextAreaEntry(props) {
|
|
|
3335
3343
|
tooltip
|
|
3336
3344
|
} = props;
|
|
3337
3345
|
const globalError = useError(id);
|
|
3338
|
-
const [localError, setLocalError] = useState
|
|
3346
|
+
const [localError, setLocalError] = useState(null);
|
|
3339
3347
|
let value = getValue(element);
|
|
3340
|
-
useEffect
|
|
3348
|
+
useEffect(() => {
|
|
3341
3349
|
if (isFunction(validate)) {
|
|
3342
3350
|
const newValidationError = validate(value) || null;
|
|
3343
3351
|
setLocalError(newValidationError);
|
|
@@ -3401,7 +3409,7 @@ function Textfield(props) {
|
|
|
3401
3409
|
value = '',
|
|
3402
3410
|
tooltip
|
|
3403
3411
|
} = props;
|
|
3404
|
-
const [localValue, setLocalValue] = useState
|
|
3412
|
+
const [localValue, setLocalValue] = useState(value || '');
|
|
3405
3413
|
const ref = useShowEntryEvent(id);
|
|
3406
3414
|
const handleInputCallback = useMemo(() => {
|
|
3407
3415
|
return debounce(({
|
|
@@ -3412,7 +3420,7 @@ function Textfield(props) {
|
|
|
3412
3420
|
handleInputCallback(e);
|
|
3413
3421
|
setLocalValue(e.target.value);
|
|
3414
3422
|
};
|
|
3415
|
-
useEffect
|
|
3423
|
+
useEffect(() => {
|
|
3416
3424
|
if (value === localValue) {
|
|
3417
3425
|
return;
|
|
3418
3426
|
}
|
|
@@ -3477,9 +3485,9 @@ function TextfieldEntry(props) {
|
|
|
3477
3485
|
tooltip
|
|
3478
3486
|
} = props;
|
|
3479
3487
|
const globalError = useError(id);
|
|
3480
|
-
const [localError, setLocalError] = useState
|
|
3488
|
+
const [localError, setLocalError] = useState(null);
|
|
3481
3489
|
let value = getValue(element);
|
|
3482
|
-
useEffect
|
|
3490
|
+
useEffect(() => {
|
|
3483
3491
|
if (isFunction(validate)) {
|
|
3484
3492
|
const newValidationError = validate(value) || null;
|
|
3485
3493
|
setLocalError(newValidationError);
|