@bpmn-io/properties-panel 1.1.1 → 1.3.0
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 +4 -0
- package/dist/index.esm.js +52 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +51 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2042,6 +2042,7 @@ function NumberField(props) {
|
|
|
2042
2042
|
* @param {Function} props.onFocus
|
|
2043
2043
|
* @param {Function} props.onBlur
|
|
2044
2044
|
* @param {String} props.step
|
|
2045
|
+
* @param {Function} props.validate
|
|
2045
2046
|
*/
|
|
2046
2047
|
function NumberFieldEntry(props) {
|
|
2047
2048
|
const {
|
|
@@ -2057,25 +2058,55 @@ function NumberFieldEntry(props) {
|
|
|
2057
2058
|
setValue,
|
|
2058
2059
|
step,
|
|
2059
2060
|
onFocus,
|
|
2060
|
-
onBlur
|
|
2061
|
+
onBlur,
|
|
2062
|
+
validate
|
|
2061
2063
|
} = props;
|
|
2062
|
-
const
|
|
2064
|
+
const [cachedInvalidValue, setCachedInvalidValue] = hooks.useState(null);
|
|
2065
|
+
const globalError = useError(id);
|
|
2066
|
+
const [localError, setLocalError] = hooks.useState(null);
|
|
2067
|
+
let value = getValue(element);
|
|
2068
|
+
const previousValue = usePrevious(value);
|
|
2069
|
+
hooks.useEffect(() => {
|
|
2070
|
+
if (minDash.isFunction(validate)) {
|
|
2071
|
+
const newValidationError = validate(value) || null;
|
|
2072
|
+
setLocalError(newValidationError);
|
|
2073
|
+
}
|
|
2074
|
+
}, [value]);
|
|
2075
|
+
const onInput = newValue => {
|
|
2076
|
+
let newValidationError = null;
|
|
2077
|
+
if (minDash.isFunction(validate)) {
|
|
2078
|
+
newValidationError = validate(newValue) || null;
|
|
2079
|
+
}
|
|
2080
|
+
if (newValidationError) {
|
|
2081
|
+
setCachedInvalidValue(newValue);
|
|
2082
|
+
} else {
|
|
2083
|
+
setValue(newValue);
|
|
2084
|
+
}
|
|
2085
|
+
setLocalError(newValidationError);
|
|
2086
|
+
};
|
|
2087
|
+
if (previousValue === value && localError) {
|
|
2088
|
+
value = cachedInvalidValue;
|
|
2089
|
+
}
|
|
2090
|
+
const error = globalError || localError;
|
|
2063
2091
|
return jsxRuntime.jsxs("div", {
|
|
2064
|
-
class: "bio-properties-panel-entry
|
|
2092
|
+
class: classnames__default["default"]('bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
2065
2093
|
"data-entry-id": id,
|
|
2066
2094
|
children: [jsxRuntime.jsx(NumberField, {
|
|
2067
2095
|
debounce: debounce,
|
|
2068
2096
|
disabled: disabled,
|
|
2069
2097
|
id: id,
|
|
2070
2098
|
label: label,
|
|
2071
|
-
onInput: setValue,
|
|
2072
2099
|
onFocus: onFocus,
|
|
2073
2100
|
onBlur: onBlur,
|
|
2101
|
+
onInput: onInput,
|
|
2074
2102
|
max: max,
|
|
2075
2103
|
min: min,
|
|
2076
2104
|
step: step,
|
|
2077
2105
|
value: value
|
|
2078
|
-
}, element), jsxRuntime.jsx(
|
|
2106
|
+
}, element), error && jsxRuntime.jsx("div", {
|
|
2107
|
+
class: "bio-properties-panel-error",
|
|
2108
|
+
children: error
|
|
2109
|
+
}), jsxRuntime.jsx(Description, {
|
|
2079
2110
|
forId: id,
|
|
2080
2111
|
element: element,
|
|
2081
2112
|
value: description
|
|
@@ -2264,6 +2295,10 @@ function prefixId$3(id) {
|
|
|
2264
2295
|
return `bio-properties-panel-${id}`;
|
|
2265
2296
|
}
|
|
2266
2297
|
|
|
2298
|
+
function resizeToContents(element) {
|
|
2299
|
+
element.style.height = 'auto';
|
|
2300
|
+
element.style.height = Math.min(element.scrollHeight + 2, 150) + 'px';
|
|
2301
|
+
}
|
|
2267
2302
|
function TextArea(props) {
|
|
2268
2303
|
const {
|
|
2269
2304
|
id,
|
|
@@ -2275,7 +2310,8 @@ function TextArea(props) {
|
|
|
2275
2310
|
disabled,
|
|
2276
2311
|
monospace,
|
|
2277
2312
|
onFocus,
|
|
2278
|
-
onBlur
|
|
2313
|
+
onBlur,
|
|
2314
|
+
autoResize
|
|
2279
2315
|
} = props;
|
|
2280
2316
|
const [localValue, setLocalValue] = hooks.useState(value);
|
|
2281
2317
|
const ref = useShowEntryEvent(id);
|
|
@@ -2286,8 +2322,12 @@ function TextArea(props) {
|
|
|
2286
2322
|
}, [onInput, debounce]);
|
|
2287
2323
|
const handleInput = e => {
|
|
2288
2324
|
handleInputCallback(e);
|
|
2325
|
+
autoResize && resizeToContents(e.target);
|
|
2289
2326
|
setLocalValue(e.target.value);
|
|
2290
2327
|
};
|
|
2328
|
+
hooks.useLayoutEffect(() => {
|
|
2329
|
+
autoResize && resizeToContents(ref.current);
|
|
2330
|
+
}, []);
|
|
2291
2331
|
hooks.useEffect(() => {
|
|
2292
2332
|
if (value === localValue) {
|
|
2293
2333
|
return;
|
|
@@ -2305,7 +2345,7 @@ function TextArea(props) {
|
|
|
2305
2345
|
id: prefixId$2(id),
|
|
2306
2346
|
name: id,
|
|
2307
2347
|
spellCheck: "false",
|
|
2308
|
-
class: classnames__default["default"]('bio-properties-panel-input', monospace ? 'bio-properties-panel-input-monospace' : ''),
|
|
2348
|
+
class: classnames__default["default"]('bio-properties-panel-input', monospace ? 'bio-properties-panel-input-monospace' : '', autoResize ? 'auto-resize' : ''),
|
|
2309
2349
|
onInput: handleInput,
|
|
2310
2350
|
onFocus: onFocus,
|
|
2311
2351
|
onBlur: onBlur,
|
|
@@ -2345,7 +2385,8 @@ function TextAreaEntry(props) {
|
|
|
2345
2385
|
monospace,
|
|
2346
2386
|
disabled,
|
|
2347
2387
|
onFocus,
|
|
2348
|
-
onBlur
|
|
2388
|
+
onBlur,
|
|
2389
|
+
autoResize
|
|
2349
2390
|
} = props;
|
|
2350
2391
|
const value = getValue(element);
|
|
2351
2392
|
const error = useError(id);
|
|
@@ -2362,7 +2403,8 @@ function TextAreaEntry(props) {
|
|
|
2362
2403
|
rows: rows,
|
|
2363
2404
|
debounce: debounce,
|
|
2364
2405
|
monospace: monospace,
|
|
2365
|
-
disabled: disabled
|
|
2406
|
+
disabled: disabled,
|
|
2407
|
+
autoResize: autoResize
|
|
2366
2408
|
}, element), error && jsxRuntime.jsx("div", {
|
|
2367
2409
|
class: "bio-properties-panel-error",
|
|
2368
2410
|
children: error
|