@bpmn-io/properties-panel 3.38.0 → 3.40.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.esm.js CHANGED
@@ -2363,7 +2363,7 @@ function prefixId$6(id) {
2363
2363
  const noop$2 = () => {};
2364
2364
 
2365
2365
  /**
2366
- * @typedef {'required'|'optional'|'static'} FeelType
2366
+ * @typedef {'required'|'optional'|'optional-default-enabled'|'static'} FeelType
2367
2367
  */
2368
2368
 
2369
2369
  /**
@@ -2406,7 +2406,7 @@ function FeelTextfield(props) {
2406
2406
  OptionalComponent = OptionalFeelInput,
2407
2407
  tooltip
2408
2408
  } = props;
2409
- const [localValue, setLocalValue] = useState(value);
2409
+ const [localValue, setLocalValue] = useState(getInitialFeelLocalValue(feel, value));
2410
2410
  const editorRef = useShowEntryEvent(id);
2411
2411
  const containerRef = useRef();
2412
2412
  const onInput = useCallback(newValue => {
@@ -2415,8 +2415,8 @@ function FeelTextfield(props) {
2415
2415
  const newModelValue = newValue === '' || newValue === '=' ? undefined : newValue;
2416
2416
  commitValue(newModelValue);
2417
2417
  }, [commitValue]);
2418
- const feelActive = isString(localValue) && localValue.startsWith('=') || feel === 'required';
2419
- const feelOnlyValue = isString(localValue) && localValue.startsWith('=') ? localValue.substring(1) : localValue;
2418
+ const feelActive = isFeelActive(feel, localValue);
2419
+ const feelOnlyValue = getFeelValue(localValue);
2420
2420
  const feelLanguageContext = useContext(FeelLanguageContext);
2421
2421
  const [focus, _setFocus] = useState(undefined);
2422
2422
  const {
@@ -2603,7 +2603,7 @@ function FeelTextfield(props) {
2603
2603
  ref: containerRef,
2604
2604
  children: [jsx(FeelIndicator, {
2605
2605
  active: feelActive,
2606
- disabled: feel !== 'optional' || disabled,
2606
+ disabled: !isFeelOptional(feel) || disabled,
2607
2607
  onClick: handleFeelToggle
2608
2608
  }), feelActive ? jsx(FeelEditor, {
2609
2609
  name: id,
@@ -3116,6 +3116,68 @@ function prefixId$5(id) {
3116
3116
  return `bio-properties-panel-${id}`;
3117
3117
  }
3118
3118
 
3119
+ /**
3120
+ * Determine if FEEL is optional for the configured {@link FeelType}.
3121
+ *
3122
+ * @param {FeelType} feelType
3123
+ *
3124
+ * @return {boolean}
3125
+ */
3126
+ function isFeelOptional(feelType) {
3127
+ return feelType === 'optional' || feelType === 'optional-default-enabled';
3128
+ }
3129
+
3130
+ /**
3131
+ * Determine if FEEL editing is currently active.
3132
+ *
3133
+ * @param {FeelType} feelType
3134
+ * @param {string} localValue
3135
+ *
3136
+ * @return {boolean}
3137
+ */
3138
+ function isFeelActive(feelType, localValue) {
3139
+ if (feelType === 'required') {
3140
+ return true;
3141
+ }
3142
+ if (isString(localValue)) {
3143
+ if (localValue.startsWith('=')) {
3144
+ return true;
3145
+ }
3146
+ }
3147
+ return false;
3148
+ }
3149
+
3150
+ /**
3151
+ * @template T
3152
+ * @param {T} value
3153
+ *
3154
+ * @return {string|T}
3155
+ */
3156
+ function getFeelValue(value) {
3157
+ if (isString(value) && value.startsWith('=')) {
3158
+ return value.substring(1);
3159
+ }
3160
+ return value;
3161
+ }
3162
+
3163
+ /**
3164
+ * Initialize local FEEL value.
3165
+ *
3166
+ * `optional-default-enabled` starts in FEEL mode if no value or empty string is provided.
3167
+ *
3168
+ * @template T
3169
+ * @param {FeelType} feelType
3170
+ * @param {T} value
3171
+ *
3172
+ * @return {string|T}
3173
+ */
3174
+ function getInitialFeelLocalValue(feelType, value) {
3175
+ if (feelType === 'optional-default-enabled' && (value === undefined || value === '')) {
3176
+ return '=';
3177
+ }
3178
+ return value;
3179
+ }
3180
+
3119
3181
  const noop$1 = () => {};
3120
3182
 
3121
3183
  /**