@bpmn-io/properties-panel 3.41.2 → 3.42.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/dist/index.js CHANGED
@@ -1068,9 +1068,12 @@ const DEFAULT_TOOLTIP = {};
1068
1068
  * A basic properties panel component. Describes *how* content will be rendered, accepts
1069
1069
  * data from implementor to describe *what* will be rendered.
1070
1070
  *
1071
+ * If `headerProvider` is omitted (or `null`), the built-in `<Header>` is not rendered;
1072
+ * consumers can render `<Header>` standalone elsewhere using the same provider shape.
1073
+ *
1071
1074
  * @param {Object} props
1072
1075
  * @param {Object|Array} props.element
1073
- * @param {import('./components/Header').HeaderProvider} props.headerProvider
1076
+ * @param {import('./components/Header').HeaderProvider} [props.headerProvider]
1074
1077
  * @param {PlaceholderProvider} [props.placeholderProvider]
1075
1078
  * @param {Array<GroupDefinition|ListGroupDefinition>} props.groups
1076
1079
  * @param {Object} [props.layoutConfig]
@@ -1199,10 +1202,10 @@ function PropertiesPanel(props) {
1199
1202
  value: eventContext,
1200
1203
  children: jsxRuntime.jsxs("div", {
1201
1204
  class: "bio-properties-panel",
1202
- children: [jsxRuntime.jsx(Header, {
1205
+ children: [headerProvider ? jsxRuntime.jsx(Header, {
1203
1206
  element: element,
1204
1207
  headerProvider: headerProvider
1205
- }), jsxRuntime.jsx("div", {
1208
+ }) : null, jsxRuntime.jsx("div", {
1206
1209
  class: "bio-properties-panel-scroll-container",
1207
1210
  children: groups.map(group => {
1208
1211
  const {
@@ -1964,6 +1967,7 @@ function JsonEditor(props) {
1964
1967
  * @param {boolean} [props.disabled]
1965
1968
  * @param {string} [props.placeholder]
1966
1969
  * @param {string} [props.tooltip]
1970
+ * @param {Function} [props.validate]
1967
1971
  */
1968
1972
  function JsonEditorEntry(props) {
1969
1973
  const {
@@ -1976,25 +1980,30 @@ function JsonEditorEntry(props) {
1976
1980
  setValue,
1977
1981
  disabled,
1978
1982
  placeholder,
1979
- tooltip
1983
+ tooltip,
1984
+ validate
1980
1985
  } = props;
1981
1986
  const globalError = useError(id);
1982
1987
  let value = getValue(element);
1988
+ const [localError, setLocalError] = hooks.useState(() => computeError(validate, value));
1983
1989
  const [editorValue, setEditorValue] = hooks.useState(value);
1984
1990
  hooks.useEffect(() => {
1985
1991
  if (value === editorValue) {
1986
1992
  return;
1987
1993
  }
1988
1994
  setEditorValue(value);
1989
- }, [value]);
1995
+ setLocalError(computeError(validate, value));
1996
+ }, [value, validate]);
1990
1997
  const onInput = useStaticCallback(newValue => {
1991
1998
  setEditorValue(newValue);
1992
1999
  const currentValue = getValue(element);
1993
2000
  if (newValue !== currentValue) {
1994
- setValue(newValue);
2001
+ const newValidationError = computeError(validate, newValue);
2002
+ setValue(newValue, newValidationError);
2003
+ setLocalError(newValidationError);
1995
2004
  }
1996
2005
  });
1997
- const error = globalError || validateJson(editorValue);
2006
+ const error = globalError || localError;
1998
2007
  return jsxRuntime.jsxs("div", {
1999
2008
  class: classnames('bio-properties-panel-entry', error && 'has-error'),
2000
2009
  "data-entry-id": id,
@@ -2028,6 +2037,9 @@ function isEdited$8(node) {
2028
2037
 
2029
2038
  // helpers /////////////////
2030
2039
 
2040
+ function computeError(validate, value) {
2041
+ return (minDash.isFunction(validate) ? validate(value) : null) || validateJson(value);
2042
+ }
2031
2043
  function validateJson(value) {
2032
2044
  if (!value || !value.trim()) return null;
2033
2045
  try {
@@ -2604,12 +2616,14 @@ function NumberFieldEntry(props) {
2604
2616
  }
2605
2617
  }, [value, validate]);
2606
2618
  const onInput = newValue => {
2607
- let newValidationError = null;
2608
- if (minDash.isFunction(validate)) {
2609
- newValidationError = validate(newValue) || null;
2619
+ if (newValue !== value) {
2620
+ let newValidationError = null;
2621
+ if (minDash.isFunction(validate)) {
2622
+ newValidationError = validate(newValue) || null;
2623
+ }
2624
+ setValue(newValue, newValidationError);
2625
+ setLocalError(newValidationError);
2610
2626
  }
2611
- setValue(newValue, newValidationError);
2612
- setLocalError(newValidationError);
2613
2627
  };
2614
2628
  const error = globalError || localError;
2615
2629
  return jsxRuntime.jsxs("div", {
@@ -3204,16 +3218,16 @@ function FeelEntry(props) {
3204
3218
  }, [value, validate]);
3205
3219
  const onInput = useStaticCallback(newValue => {
3206
3220
  const value = getValue(element);
3207
- let newValidationError = null;
3208
- if (minDash.isFunction(validate)) {
3209
- newValidationError = validate(newValue) || null;
3210
- }
3211
3221
 
3212
- // don't create multiple commandStack entries for the same value
3222
+ // don't create multiple commandStack entries and do validation for the same value
3213
3223
  if (newValue !== value) {
3224
+ let newValidationError = null;
3225
+ if (minDash.isFunction(validate)) {
3226
+ newValidationError = validate(newValue) || null;
3227
+ }
3214
3228
  setValue(newValue, newValidationError);
3229
+ setValidationError(newValidationError);
3215
3230
  }
3216
- setValidationError(newValidationError);
3217
3231
  });
3218
3232
  const onError = hooks.useCallback(err => {
3219
3233
  setLocalError(err);
@@ -3936,12 +3950,14 @@ function SelectEntry(props) {
3936
3950
  }
3937
3951
  }, [value, validate]);
3938
3952
  const onChange = newValue => {
3939
- let newValidationError = null;
3940
- if (minDash.isFunction(validate)) {
3941
- newValidationError = validate(newValue) || null;
3953
+ if (newValue !== value) {
3954
+ let newValidationError = null;
3955
+ if (minDash.isFunction(validate)) {
3956
+ newValidationError = validate(newValue) || null;
3957
+ }
3958
+ setValue(newValue, newValidationError);
3959
+ setLocalError(newValidationError);
3942
3960
  }
3943
- setValue(newValue, newValidationError);
3944
- setLocalError(newValidationError);
3945
3961
  };
3946
3962
  const error = globalError || localError;
3947
3963
  return jsxRuntime.jsxs("div", {
@@ -4216,14 +4232,14 @@ function TextAreaEntry(props) {
4216
4232
  }, [value, validate]);
4217
4233
  const onInput = useStaticCallback(newValue => {
4218
4234
  const value = getValue(element);
4219
- let newValidationError = null;
4220
- if (minDash.isFunction(validate)) {
4221
- newValidationError = validate(newValue) || null;
4222
- }
4223
4235
  if (newValue !== value) {
4236
+ let newValidationError = null;
4237
+ if (minDash.isFunction(validate)) {
4238
+ newValidationError = validate(newValue) || null;
4239
+ }
4224
4240
  setValue(newValue, newValidationError);
4241
+ setLocalError(newValidationError);
4225
4242
  }
4226
- setLocalError(newValidationError);
4227
4243
  });
4228
4244
  const error = globalError || localError;
4229
4245
  return jsxRuntime.jsxs("div", {
@@ -4415,14 +4431,14 @@ function TextfieldEntry(props) {
4415
4431
  }, [value, validate]);
4416
4432
  const onInput = useStaticCallback(newValue => {
4417
4433
  const value = getValue(element);
4418
- let newValidationError = null;
4419
- if (minDash.isFunction(validate)) {
4420
- newValidationError = validate(newValue) || null;
4421
- }
4422
4434
  if (newValue !== value) {
4435
+ let newValidationError = null;
4436
+ if (minDash.isFunction(validate)) {
4437
+ newValidationError = validate(newValue) || null;
4438
+ }
4423
4439
  setValue(newValue, newValidationError);
4440
+ setLocalError(newValidationError);
4424
4441
  }
4425
- setLocalError(newValidationError);
4426
4442
  });
4427
4443
  const error = globalError || localError;
4428
4444
  return jsxRuntime.jsxs("div", {