@bpmn-io/properties-panel 2.1.0 → 2.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/assets/properties-panel.css +11 -6
- package/dist/index.esm.js +251 -169
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +254 -171
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -99,11 +99,13 @@
|
|
|
99
99
|
--dropdown-item-hover-background-color: var(--color-grey-225-10-95);
|
|
100
100
|
--dropdown-separator-background-color: var(--color-grey-225-10-75);
|
|
101
101
|
|
|
102
|
-
--feel-background-color:
|
|
102
|
+
--feel-background-color: transparent;
|
|
103
103
|
--feel-active-color: var(--color-blue-205-100-45);
|
|
104
104
|
--feel-inactive-color: var(--color-grey-225-10-35);
|
|
105
|
-
--feel-hover-
|
|
106
|
-
--feel-
|
|
105
|
+
--feel-hover-color: var(--color-grey-225-10-15);
|
|
106
|
+
--feel-hover-background-color: var(--color-grey-225-10-97);
|
|
107
|
+
--feel-active-background-color: transparent;
|
|
108
|
+
--feel-required-color: var(--color-grey-225-10-55);
|
|
107
109
|
|
|
108
110
|
--feel-indicator-background-color: var(--color-grey-225-10-90);
|
|
109
111
|
|
|
@@ -990,7 +992,7 @@ textarea.bio-properties-panel-input {
|
|
|
990
992
|
|
|
991
993
|
.bio-properties-panel-feel-icon {
|
|
992
994
|
display: inline-flex;
|
|
993
|
-
height:
|
|
995
|
+
height: 18px;
|
|
994
996
|
width: 22px;
|
|
995
997
|
vertical-align: text-bottom;
|
|
996
998
|
padding: 0;
|
|
@@ -1005,7 +1007,6 @@ textarea.bio-properties-panel-input {
|
|
|
1005
1007
|
|
|
1006
1008
|
.bio-properties-panel-feel-icon.optional {
|
|
1007
1009
|
cursor: pointer;
|
|
1008
|
-
|
|
1009
1010
|
background: var(--feel-background-color);
|
|
1010
1011
|
}
|
|
1011
1012
|
|
|
@@ -1017,6 +1018,10 @@ textarea.bio-properties-panel-input {
|
|
|
1017
1018
|
background: var(--feel-hover-background-color);
|
|
1018
1019
|
}
|
|
1019
1020
|
|
|
1021
|
+
.bio-properties-panel-feel-icon:hover svg * {
|
|
1022
|
+
fill: var(--feel-hover-color);
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1020
1025
|
.bio-properties-panel-feel-icon.active {
|
|
1021
1026
|
background: var(--feel-active-background-color);
|
|
1022
1027
|
}
|
|
@@ -1034,7 +1039,7 @@ textarea.bio-properties-panel-input {
|
|
|
1034
1039
|
}
|
|
1035
1040
|
|
|
1036
1041
|
.bio-properties-panel-feel-icon.required.active svg * {
|
|
1037
|
-
fill: var(--feel-
|
|
1042
|
+
fill: var(--feel-required-color);
|
|
1038
1043
|
}
|
|
1039
1044
|
|
|
1040
1045
|
.bio-properties-panel-feel-editor-container {
|
package/dist/index.esm.js
CHANGED
|
@@ -1622,6 +1622,166 @@ function prefixId$6(id) {
|
|
|
1622
1622
|
return `bio-properties-panel-${id}`;
|
|
1623
1623
|
}
|
|
1624
1624
|
|
|
1625
|
+
function NumberField(props) {
|
|
1626
|
+
const {
|
|
1627
|
+
debounce,
|
|
1628
|
+
disabled,
|
|
1629
|
+
displayLabel = true,
|
|
1630
|
+
id,
|
|
1631
|
+
inputRef,
|
|
1632
|
+
label,
|
|
1633
|
+
max,
|
|
1634
|
+
min,
|
|
1635
|
+
onInput,
|
|
1636
|
+
step,
|
|
1637
|
+
value = '',
|
|
1638
|
+
onFocus,
|
|
1639
|
+
onBlur
|
|
1640
|
+
} = props;
|
|
1641
|
+
const [localValue, setLocalValue] = useState(value);
|
|
1642
|
+
const handleInputCallback = useMemo(() => {
|
|
1643
|
+
return debounce(event => {
|
|
1644
|
+
const {
|
|
1645
|
+
validity,
|
|
1646
|
+
value
|
|
1647
|
+
} = event.target;
|
|
1648
|
+
if (validity.valid) {
|
|
1649
|
+
onInput(value ? parseFloat(value) : undefined);
|
|
1650
|
+
}
|
|
1651
|
+
});
|
|
1652
|
+
}, [onInput, debounce]);
|
|
1653
|
+
const handleInput = e => {
|
|
1654
|
+
handleInputCallback(e);
|
|
1655
|
+
setLocalValue(e.target.value);
|
|
1656
|
+
};
|
|
1657
|
+
useEffect(() => {
|
|
1658
|
+
if (value === localValue) {
|
|
1659
|
+
return;
|
|
1660
|
+
}
|
|
1661
|
+
setLocalValue(value);
|
|
1662
|
+
}, [value]);
|
|
1663
|
+
return jsxs("div", {
|
|
1664
|
+
class: "bio-properties-panel-numberfield",
|
|
1665
|
+
children: [displayLabel && jsx("label", {
|
|
1666
|
+
for: prefixId$5(id),
|
|
1667
|
+
class: "bio-properties-panel-label",
|
|
1668
|
+
children: label
|
|
1669
|
+
}), jsx("input", {
|
|
1670
|
+
id: prefixId$5(id),
|
|
1671
|
+
ref: inputRef,
|
|
1672
|
+
type: "number",
|
|
1673
|
+
name: id,
|
|
1674
|
+
spellCheck: "false",
|
|
1675
|
+
autoComplete: "off",
|
|
1676
|
+
disabled: disabled,
|
|
1677
|
+
class: "bio-properties-panel-input",
|
|
1678
|
+
max: max,
|
|
1679
|
+
min: min,
|
|
1680
|
+
onInput: handleInput,
|
|
1681
|
+
onFocus: onFocus,
|
|
1682
|
+
onBlur: onBlur,
|
|
1683
|
+
step: step,
|
|
1684
|
+
value: localValue
|
|
1685
|
+
})]
|
|
1686
|
+
});
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
/**
|
|
1690
|
+
* @param {Object} props
|
|
1691
|
+
* @param {Boolean} props.debounce
|
|
1692
|
+
* @param {String} props.description
|
|
1693
|
+
* @param {Boolean} props.disabled
|
|
1694
|
+
* @param {Object} props.element
|
|
1695
|
+
* @param {Function} props.getValue
|
|
1696
|
+
* @param {String} props.id
|
|
1697
|
+
* @param {String} props.label
|
|
1698
|
+
* @param {String} props.max
|
|
1699
|
+
* @param {String} props.min
|
|
1700
|
+
* @param {Function} props.setValue
|
|
1701
|
+
* @param {Function} props.onFocus
|
|
1702
|
+
* @param {Function} props.onBlur
|
|
1703
|
+
* @param {String} props.step
|
|
1704
|
+
* @param {Function} props.validate
|
|
1705
|
+
*/
|
|
1706
|
+
function NumberFieldEntry(props) {
|
|
1707
|
+
const {
|
|
1708
|
+
debounce,
|
|
1709
|
+
description,
|
|
1710
|
+
disabled,
|
|
1711
|
+
element,
|
|
1712
|
+
getValue,
|
|
1713
|
+
id,
|
|
1714
|
+
label,
|
|
1715
|
+
max,
|
|
1716
|
+
min,
|
|
1717
|
+
setValue,
|
|
1718
|
+
step,
|
|
1719
|
+
onFocus,
|
|
1720
|
+
onBlur,
|
|
1721
|
+
validate
|
|
1722
|
+
} = props;
|
|
1723
|
+
const [cachedInvalidValue, setCachedInvalidValue] = useState(null);
|
|
1724
|
+
const globalError = useError(id);
|
|
1725
|
+
const [localError, setLocalError] = useState(null);
|
|
1726
|
+
let value = getValue(element);
|
|
1727
|
+
const previousValue = usePrevious(value);
|
|
1728
|
+
useEffect(() => {
|
|
1729
|
+
if (isFunction(validate)) {
|
|
1730
|
+
const newValidationError = validate(value) || null;
|
|
1731
|
+
setLocalError(newValidationError);
|
|
1732
|
+
}
|
|
1733
|
+
}, [value]);
|
|
1734
|
+
const onInput = newValue => {
|
|
1735
|
+
let newValidationError = null;
|
|
1736
|
+
if (isFunction(validate)) {
|
|
1737
|
+
newValidationError = validate(newValue) || null;
|
|
1738
|
+
}
|
|
1739
|
+
if (newValidationError) {
|
|
1740
|
+
setCachedInvalidValue(newValue);
|
|
1741
|
+
} else {
|
|
1742
|
+
setValue(newValue);
|
|
1743
|
+
}
|
|
1744
|
+
setLocalError(newValidationError);
|
|
1745
|
+
};
|
|
1746
|
+
if (previousValue === value && localError) {
|
|
1747
|
+
value = cachedInvalidValue;
|
|
1748
|
+
}
|
|
1749
|
+
const error = globalError || localError;
|
|
1750
|
+
return jsxs("div", {
|
|
1751
|
+
class: classnames('bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
1752
|
+
"data-entry-id": id,
|
|
1753
|
+
children: [jsx(NumberField, {
|
|
1754
|
+
debounce: debounce,
|
|
1755
|
+
disabled: disabled,
|
|
1756
|
+
id: id,
|
|
1757
|
+
label: label,
|
|
1758
|
+
onFocus: onFocus,
|
|
1759
|
+
onBlur: onBlur,
|
|
1760
|
+
onInput: onInput,
|
|
1761
|
+
max: max,
|
|
1762
|
+
min: min,
|
|
1763
|
+
step: step,
|
|
1764
|
+
value: value
|
|
1765
|
+
}, element), error && jsx("div", {
|
|
1766
|
+
class: "bio-properties-panel-error",
|
|
1767
|
+
children: error
|
|
1768
|
+
}), jsx(Description, {
|
|
1769
|
+
forId: id,
|
|
1770
|
+
element: element,
|
|
1771
|
+
value: description
|
|
1772
|
+
})]
|
|
1773
|
+
});
|
|
1774
|
+
}
|
|
1775
|
+
function isEdited$6(node) {
|
|
1776
|
+
return node && !!node.value;
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
// helpers /////////////////
|
|
1780
|
+
|
|
1781
|
+
function prefixId$5(id) {
|
|
1782
|
+
return `bio-properties-panel-${id}`;
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1625
1785
|
const noop$1 = () => {};
|
|
1626
1786
|
function FeelTextfield(props) {
|
|
1627
1787
|
const {
|
|
@@ -1748,7 +1908,7 @@ function FeelTextfield(props) {
|
|
|
1748
1908
|
'feel-active': feelActive
|
|
1749
1909
|
}),
|
|
1750
1910
|
children: [jsxs("label", {
|
|
1751
|
-
for: prefixId$
|
|
1911
|
+
for: prefixId$4(id),
|
|
1752
1912
|
class: "bio-properties-panel-label",
|
|
1753
1913
|
onClick: () => setFocus(),
|
|
1754
1914
|
children: [label, jsx(FeelIcon, {
|
|
@@ -1765,7 +1925,7 @@ function FeelTextfield(props) {
|
|
|
1765
1925
|
disabled: feel !== 'optional' || disabled,
|
|
1766
1926
|
onClick: handleFeelToggle
|
|
1767
1927
|
}), feelActive ? jsx(CodeEditor, {
|
|
1768
|
-
id: prefixId$
|
|
1928
|
+
id: prefixId$4(id),
|
|
1769
1929
|
name: id,
|
|
1770
1930
|
onInput: handleLocalInput,
|
|
1771
1931
|
disabled: disabled,
|
|
@@ -1782,7 +1942,7 @@ function FeelTextfield(props) {
|
|
|
1782
1942
|
...props,
|
|
1783
1943
|
onInput: handleLocalInput,
|
|
1784
1944
|
contentAttributes: {
|
|
1785
|
-
'id': prefixId$
|
|
1945
|
+
'id': prefixId$4(id),
|
|
1786
1946
|
'aria-label': label
|
|
1787
1947
|
},
|
|
1788
1948
|
value: localValue,
|
|
@@ -1820,7 +1980,7 @@ const OptionalFeelInput = forwardRef((props, ref) => {
|
|
|
1820
1980
|
}
|
|
1821
1981
|
};
|
|
1822
1982
|
return jsx("input", {
|
|
1823
|
-
id: prefixId$
|
|
1983
|
+
id: prefixId$4(id),
|
|
1824
1984
|
type: "text",
|
|
1825
1985
|
ref: inputRef,
|
|
1826
1986
|
name: id,
|
|
@@ -1834,6 +1994,53 @@ const OptionalFeelInput = forwardRef((props, ref) => {
|
|
|
1834
1994
|
value: value || ''
|
|
1835
1995
|
});
|
|
1836
1996
|
});
|
|
1997
|
+
const OptionalFeelNumberField = forwardRef((props, ref) => {
|
|
1998
|
+
const {
|
|
1999
|
+
id,
|
|
2000
|
+
debounce,
|
|
2001
|
+
disabled,
|
|
2002
|
+
onInput,
|
|
2003
|
+
value,
|
|
2004
|
+
min,
|
|
2005
|
+
max,
|
|
2006
|
+
step,
|
|
2007
|
+
onFocus,
|
|
2008
|
+
onBlur
|
|
2009
|
+
} = props;
|
|
2010
|
+
const inputRef = useRef();
|
|
2011
|
+
|
|
2012
|
+
// To be consistent with the FEEL editor, set focus at start of input
|
|
2013
|
+
// this ensures clean editing experience when switching with the keyboard
|
|
2014
|
+
ref.current = {
|
|
2015
|
+
focus: position => {
|
|
2016
|
+
const input = inputRef.current;
|
|
2017
|
+
if (!input) {
|
|
2018
|
+
return;
|
|
2019
|
+
}
|
|
2020
|
+
input.focus();
|
|
2021
|
+
if (typeof position === 'number' && position !== Infinity) {
|
|
2022
|
+
if (position > value.length) {
|
|
2023
|
+
position = value.length;
|
|
2024
|
+
}
|
|
2025
|
+
input.setSelectionRange(position, position);
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
};
|
|
2029
|
+
return jsx(NumberField, {
|
|
2030
|
+
id: id,
|
|
2031
|
+
debounce: debounce,
|
|
2032
|
+
disabled: disabled,
|
|
2033
|
+
displayLabel: false,
|
|
2034
|
+
inputRef: inputRef,
|
|
2035
|
+
max: max,
|
|
2036
|
+
min: min,
|
|
2037
|
+
onInput: onInput,
|
|
2038
|
+
step: step,
|
|
2039
|
+
value: value,
|
|
2040
|
+
onFocus: onFocus,
|
|
2041
|
+
onBlur: onBlur
|
|
2042
|
+
});
|
|
2043
|
+
});
|
|
1837
2044
|
const OptionalFeelTextArea = forwardRef((props, ref) => {
|
|
1838
2045
|
const {
|
|
1839
2046
|
id,
|
|
@@ -1858,7 +2065,7 @@ const OptionalFeelTextArea = forwardRef((props, ref) => {
|
|
|
1858
2065
|
}
|
|
1859
2066
|
};
|
|
1860
2067
|
return jsx("textarea", {
|
|
1861
|
-
id: prefixId$
|
|
2068
|
+
id: prefixId$4(id),
|
|
1862
2069
|
type: "text",
|
|
1863
2070
|
ref: inputRef,
|
|
1864
2071
|
name: id,
|
|
@@ -1934,7 +2141,7 @@ const OptionalFeelCheckbox = forwardRef((props, ref) => {
|
|
|
1934
2141
|
};
|
|
1935
2142
|
return jsx("input", {
|
|
1936
2143
|
ref: inputRef,
|
|
1937
|
-
id: prefixId$
|
|
2144
|
+
id: prefixId$4(id),
|
|
1938
2145
|
name: id,
|
|
1939
2146
|
onFocus: onFocus,
|
|
1940
2147
|
onBlur: onBlur,
|
|
@@ -2023,11 +2230,13 @@ function FeelEntry(props) {
|
|
|
2023
2230
|
return jsxs("div", {
|
|
2024
2231
|
class: classnames(props.class, 'bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
2025
2232
|
"data-entry-id": id,
|
|
2026
|
-
children: [
|
|
2233
|
+
children: [createElement(FeelTextfield, {
|
|
2234
|
+
...props,
|
|
2027
2235
|
debounce: debounce,
|
|
2028
2236
|
disabled: disabled,
|
|
2029
2237
|
feel: feel,
|
|
2030
2238
|
id: id,
|
|
2239
|
+
key: element,
|
|
2031
2240
|
label: label,
|
|
2032
2241
|
onInput: onInput,
|
|
2033
2242
|
onError: onError,
|
|
@@ -2041,7 +2250,7 @@ function FeelEntry(props) {
|
|
|
2041
2250
|
variables: variables,
|
|
2042
2251
|
tooltipContainer: tooltipContainer,
|
|
2043
2252
|
OptionalComponent: props.OptionalComponent
|
|
2044
|
-
}
|
|
2253
|
+
}), error && jsx("div", {
|
|
2045
2254
|
class: "bio-properties-panel-error",
|
|
2046
2255
|
children: error
|
|
2047
2256
|
}), jsx(Description, {
|
|
@@ -2052,6 +2261,36 @@ function FeelEntry(props) {
|
|
|
2052
2261
|
});
|
|
2053
2262
|
}
|
|
2054
2263
|
|
|
2264
|
+
/**
|
|
2265
|
+
* @param {Object} props
|
|
2266
|
+
* @param {Object} props.element
|
|
2267
|
+
* @param {String} props.id
|
|
2268
|
+
* @param {String} props.description
|
|
2269
|
+
* @param {Boolean} props.debounce
|
|
2270
|
+
* @param {Boolean} props.disabled
|
|
2271
|
+
* @param {String} props.max
|
|
2272
|
+
* @param {String} props.min
|
|
2273
|
+
* @param {String} props.step
|
|
2274
|
+
* @param {Boolean} props.feel
|
|
2275
|
+
* @param {String} props.label
|
|
2276
|
+
* @param {Function} props.getValue
|
|
2277
|
+
* @param {Function} props.setValue
|
|
2278
|
+
* @param {Function} props.tooltipContainer
|
|
2279
|
+
* @param {Function} props.validate
|
|
2280
|
+
* @param {Function} props.show
|
|
2281
|
+
* @param {Function} props.example
|
|
2282
|
+
* @param {Function} props.variables
|
|
2283
|
+
* @param {Function} props.onFocus
|
|
2284
|
+
* @param {Function} props.onBlur
|
|
2285
|
+
*/
|
|
2286
|
+
function FeelNumberEntry(props) {
|
|
2287
|
+
return jsx(FeelEntry, {
|
|
2288
|
+
class: "bio-properties-panel-feel-number",
|
|
2289
|
+
OptionalComponent: OptionalFeelNumberField,
|
|
2290
|
+
...props
|
|
2291
|
+
});
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2055
2294
|
/**
|
|
2056
2295
|
* @param {Object} props
|
|
2057
2296
|
* @param {Object} props.element
|
|
@@ -2161,7 +2400,7 @@ function FeelTemplatingEntry(props) {
|
|
|
2161
2400
|
...props
|
|
2162
2401
|
});
|
|
2163
2402
|
}
|
|
2164
|
-
function isEdited$
|
|
2403
|
+
function isEdited$5(node) {
|
|
2165
2404
|
if (!node) {
|
|
2166
2405
|
return false;
|
|
2167
2406
|
}
|
|
@@ -2173,7 +2412,7 @@ function isEdited$6(node) {
|
|
|
2173
2412
|
|
|
2174
2413
|
// helpers /////////////////
|
|
2175
2414
|
|
|
2176
|
-
function prefixId$
|
|
2415
|
+
function prefixId$4(id) {
|
|
2177
2416
|
return `bio-properties-panel-${id}`;
|
|
2178
2417
|
}
|
|
2179
2418
|
|
|
@@ -2340,7 +2579,7 @@ function Templating(props) {
|
|
|
2340
2579
|
})]
|
|
2341
2580
|
});
|
|
2342
2581
|
}
|
|
2343
|
-
function isEdited$
|
|
2582
|
+
function isEdited$4(node) {
|
|
2344
2583
|
return node && (!!node.value || node.classList.contains('edited'));
|
|
2345
2584
|
}
|
|
2346
2585
|
|
|
@@ -2533,163 +2772,6 @@ function useNewItems(items = [], shouldReset) {
|
|
|
2533
2772
|
return previousItems ? items.filter(item => !previousItems.includes(item)) : [];
|
|
2534
2773
|
}
|
|
2535
2774
|
|
|
2536
|
-
function NumberField(props) {
|
|
2537
|
-
const {
|
|
2538
|
-
debounce,
|
|
2539
|
-
disabled,
|
|
2540
|
-
id,
|
|
2541
|
-
label,
|
|
2542
|
-
max,
|
|
2543
|
-
min,
|
|
2544
|
-
onInput,
|
|
2545
|
-
step,
|
|
2546
|
-
value = '',
|
|
2547
|
-
onFocus,
|
|
2548
|
-
onBlur
|
|
2549
|
-
} = props;
|
|
2550
|
-
const [localValue, setLocalValue] = useState(value);
|
|
2551
|
-
const handleInputCallback = useMemo(() => {
|
|
2552
|
-
return debounce(event => {
|
|
2553
|
-
const {
|
|
2554
|
-
validity,
|
|
2555
|
-
value
|
|
2556
|
-
} = event.target;
|
|
2557
|
-
if (validity.valid) {
|
|
2558
|
-
onInput(value ? parseFloat(value) : undefined);
|
|
2559
|
-
}
|
|
2560
|
-
});
|
|
2561
|
-
}, [onInput, debounce]);
|
|
2562
|
-
const handleInput = e => {
|
|
2563
|
-
handleInputCallback(e);
|
|
2564
|
-
setLocalValue(e.target.value);
|
|
2565
|
-
};
|
|
2566
|
-
useEffect(() => {
|
|
2567
|
-
if (value === localValue) {
|
|
2568
|
-
return;
|
|
2569
|
-
}
|
|
2570
|
-
setLocalValue(value);
|
|
2571
|
-
}, [value]);
|
|
2572
|
-
return jsxs("div", {
|
|
2573
|
-
class: "bio-properties-panel-numberfield",
|
|
2574
|
-
children: [jsx("label", {
|
|
2575
|
-
for: prefixId$4(id),
|
|
2576
|
-
class: "bio-properties-panel-label",
|
|
2577
|
-
children: label
|
|
2578
|
-
}), jsx("input", {
|
|
2579
|
-
id: prefixId$4(id),
|
|
2580
|
-
type: "number",
|
|
2581
|
-
name: id,
|
|
2582
|
-
spellCheck: "false",
|
|
2583
|
-
autoComplete: "off",
|
|
2584
|
-
disabled: disabled,
|
|
2585
|
-
class: "bio-properties-panel-input",
|
|
2586
|
-
max: max,
|
|
2587
|
-
min: min,
|
|
2588
|
-
onInput: handleInput,
|
|
2589
|
-
onFocus: onFocus,
|
|
2590
|
-
onBlur: onBlur,
|
|
2591
|
-
step: step,
|
|
2592
|
-
value: localValue
|
|
2593
|
-
})]
|
|
2594
|
-
});
|
|
2595
|
-
}
|
|
2596
|
-
|
|
2597
|
-
/**
|
|
2598
|
-
* @param {Object} props
|
|
2599
|
-
* @param {Boolean} props.debounce
|
|
2600
|
-
* @param {String} props.description
|
|
2601
|
-
* @param {Boolean} props.disabled
|
|
2602
|
-
* @param {Object} props.element
|
|
2603
|
-
* @param {Function} props.getValue
|
|
2604
|
-
* @param {String} props.id
|
|
2605
|
-
* @param {String} props.label
|
|
2606
|
-
* @param {String} props.max
|
|
2607
|
-
* @param {String} props.min
|
|
2608
|
-
* @param {Function} props.setValue
|
|
2609
|
-
* @param {Function} props.onFocus
|
|
2610
|
-
* @param {Function} props.onBlur
|
|
2611
|
-
* @param {String} props.step
|
|
2612
|
-
* @param {Function} props.validate
|
|
2613
|
-
*/
|
|
2614
|
-
function NumberFieldEntry(props) {
|
|
2615
|
-
const {
|
|
2616
|
-
debounce,
|
|
2617
|
-
description,
|
|
2618
|
-
disabled,
|
|
2619
|
-
element,
|
|
2620
|
-
getValue,
|
|
2621
|
-
id,
|
|
2622
|
-
label,
|
|
2623
|
-
max,
|
|
2624
|
-
min,
|
|
2625
|
-
setValue,
|
|
2626
|
-
step,
|
|
2627
|
-
onFocus,
|
|
2628
|
-
onBlur,
|
|
2629
|
-
validate
|
|
2630
|
-
} = props;
|
|
2631
|
-
const [cachedInvalidValue, setCachedInvalidValue] = useState(null);
|
|
2632
|
-
const globalError = useError(id);
|
|
2633
|
-
const [localError, setLocalError] = useState(null);
|
|
2634
|
-
let value = getValue(element);
|
|
2635
|
-
const previousValue = usePrevious(value);
|
|
2636
|
-
useEffect(() => {
|
|
2637
|
-
if (isFunction(validate)) {
|
|
2638
|
-
const newValidationError = validate(value) || null;
|
|
2639
|
-
setLocalError(newValidationError);
|
|
2640
|
-
}
|
|
2641
|
-
}, [value]);
|
|
2642
|
-
const onInput = newValue => {
|
|
2643
|
-
let newValidationError = null;
|
|
2644
|
-
if (isFunction(validate)) {
|
|
2645
|
-
newValidationError = validate(newValue) || null;
|
|
2646
|
-
}
|
|
2647
|
-
if (newValidationError) {
|
|
2648
|
-
setCachedInvalidValue(newValue);
|
|
2649
|
-
} else {
|
|
2650
|
-
setValue(newValue);
|
|
2651
|
-
}
|
|
2652
|
-
setLocalError(newValidationError);
|
|
2653
|
-
};
|
|
2654
|
-
if (previousValue === value && localError) {
|
|
2655
|
-
value = cachedInvalidValue;
|
|
2656
|
-
}
|
|
2657
|
-
const error = globalError || localError;
|
|
2658
|
-
return jsxs("div", {
|
|
2659
|
-
class: classnames('bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
2660
|
-
"data-entry-id": id,
|
|
2661
|
-
children: [jsx(NumberField, {
|
|
2662
|
-
debounce: debounce,
|
|
2663
|
-
disabled: disabled,
|
|
2664
|
-
id: id,
|
|
2665
|
-
label: label,
|
|
2666
|
-
onFocus: onFocus,
|
|
2667
|
-
onBlur: onBlur,
|
|
2668
|
-
onInput: onInput,
|
|
2669
|
-
max: max,
|
|
2670
|
-
min: min,
|
|
2671
|
-
step: step,
|
|
2672
|
-
value: value
|
|
2673
|
-
}, element), error && jsx("div", {
|
|
2674
|
-
class: "bio-properties-panel-error",
|
|
2675
|
-
children: error
|
|
2676
|
-
}), jsx(Description, {
|
|
2677
|
-
forId: id,
|
|
2678
|
-
element: element,
|
|
2679
|
-
value: description
|
|
2680
|
-
})]
|
|
2681
|
-
});
|
|
2682
|
-
}
|
|
2683
|
-
function isEdited$4(node) {
|
|
2684
|
-
return node && !!node.value;
|
|
2685
|
-
}
|
|
2686
|
-
|
|
2687
|
-
// helpers /////////////////
|
|
2688
|
-
|
|
2689
|
-
function prefixId$4(id) {
|
|
2690
|
-
return `bio-properties-panel-${id}`;
|
|
2691
|
-
}
|
|
2692
|
-
|
|
2693
2775
|
function Select(props) {
|
|
2694
2776
|
const {
|
|
2695
2777
|
id,
|
|
@@ -3214,5 +3296,5 @@ var index = {
|
|
|
3214
3296
|
debounceInput: ['factory', debounceInput]
|
|
3215
3297
|
};
|
|
3216
3298
|
|
|
3217
|
-
export { ArrowIcon, CheckboxEntry, CollapsibleEntry, CreateIcon, index as DebounceInputModule, DeleteIcon, DescriptionContext, Description as DescriptionEntry, DropdownButton, ErrorsContext, EventContext, ExternalLinkIcon, FeelCheckboxEntry, FeelEntry, FeelIcon$1 as FeelIcon, FeelTemplatingEntry, FeelTextAreaEntry, FeelToggleSwitchEntry, Group, Header, HeaderButton, LayoutContext, List as ListEntry, ListGroup, ListItem, NumberFieldEntry, Placeholder, PropertiesPanel, LayoutContext as PropertiesPanelContext, SelectEntry, Simple as SimpleEntry, TemplatingEntry, TextAreaEntry, TextfieldEntry as TextFieldEntry, ToggleSwitchEntry, isEdited$8 as isCheckboxEntryEdited, isEdited$
|
|
3299
|
+
export { ArrowIcon, CheckboxEntry, CollapsibleEntry, CreateIcon, index as DebounceInputModule, DeleteIcon, DescriptionContext, Description as DescriptionEntry, DropdownButton, ErrorsContext, EventContext, ExternalLinkIcon, FeelCheckboxEntry, FeelEntry, FeelIcon$1 as FeelIcon, FeelNumberEntry, FeelTemplatingEntry, FeelTextAreaEntry, FeelToggleSwitchEntry, Group, Header, HeaderButton, LayoutContext, List as ListEntry, ListGroup, ListItem, NumberFieldEntry, Placeholder, PropertiesPanel, LayoutContext as PropertiesPanelContext, SelectEntry, Simple as SimpleEntry, TemplatingEntry, TextAreaEntry, TextfieldEntry as TextFieldEntry, ToggleSwitchEntry, isEdited$8 as isCheckboxEntryEdited, isEdited$5 as isFeelEntryEdited, isEdited$6 as isNumberFieldEntryEdited, isEdited$3 as isSelectEntryEdited, isEdited$2 as isSimpleEntryEdited, isEdited$4 as isTemplatingEntryEdited, isEdited$1 as isTextAreaEntryEdited, isEdited as isTextFieldEntryEdited, isEdited$7 as isToggleSwitchEntryEdited, useDescriptionContext, useError, useEvent, useKeyFactory, useLayoutState, usePrevious, useShowEntryEvent, useStaticCallback, useStickyIntersectionObserver };
|
|
3218
3300
|
//# sourceMappingURL=index.esm.js.map
|