@bpmn-io/properties-panel 3.20.0 → 3.21.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
@@ -173,6 +173,21 @@ PopupIcon.defaultProps = {
173
173
  height: "16",
174
174
  viewBox: "0 0 32 32"
175
175
  };
176
+ var CloseIcon = function CloseIcon(props) {
177
+ return jsxRuntime.jsx("svg", {
178
+ ...props,
179
+ children: jsxRuntime.jsx("path", {
180
+ fillRule: "evenodd",
181
+ d: "m12 4.7-.7-.7L8 7.3 4.7 4l-.7.7L7.3 8 4 11.3l.7.7L8 8.7l3.3 3.3.7-.7L8.7 8 12 4.7Z",
182
+ fill: "currentColor"
183
+ })
184
+ });
185
+ };
186
+ CloseIcon.defaultProps = {
187
+ xmlns: "http://www.w3.org/2000/svg",
188
+ width: "16",
189
+ height: "16"
190
+ };
176
191
 
177
192
  function Header(props) {
178
193
  const {
@@ -917,7 +932,8 @@ const CodeEditor$1 = compat.forwardRef((props, ref) => {
917
932
  tooltipContainer,
918
933
  enableGutters,
919
934
  hostLanguage,
920
- singleLine
935
+ singleLine,
936
+ lineWrap: true
921
937
  });
922
938
  setEditor(editor);
923
939
  return () => {
@@ -954,7 +970,7 @@ const CodeEditor$1 = compat.forwardRef((props, ref) => {
954
970
  title: "Open pop-up editor",
955
971
  class: "bio-properties-panel-open-feel-popup",
956
972
  onClick: () => onPopupOpen('feelers'),
957
- children: jsxRuntime.jsx(ExternalLinkIcon, {})
973
+ children: jsxRuntime.jsx(PopupIcon, {})
958
974
  })]
959
975
  });
960
976
  });
@@ -1324,6 +1340,9 @@ function Title(props) {
1324
1340
  draggable,
1325
1341
  emit = () => {},
1326
1342
  title,
1343
+ showCloseButton = false,
1344
+ closeButtonTooltip = 'Close popup',
1345
+ onClose,
1327
1346
  ...rest
1328
1347
  } = props;
1329
1348
 
@@ -1394,7 +1413,12 @@ function Title(props) {
1394
1413
  }), jsxRuntime.jsx("div", {
1395
1414
  class: "bio-properties-panel-popup__title",
1396
1415
  children: title
1397
- }), children]
1416
+ }), children, showCloseButton && jsxRuntime.jsx("button", {
1417
+ title: closeButtonTooltip,
1418
+ class: "bio-properties-panel-popup__close",
1419
+ onClick: onClose,
1420
+ children: jsxRuntime.jsx(CloseIcon, {})
1421
+ })]
1398
1422
  });
1399
1423
  }
1400
1424
  function Body(props) {
@@ -1612,6 +1636,9 @@ function FeelPopupComponent(props) {
1612
1636
  children: [jsxRuntime.jsxs(Popup.Title, {
1613
1637
  title: title,
1614
1638
  emit: emit,
1639
+ showCloseButton: true,
1640
+ closeButtonTooltip: "Save and close",
1641
+ onClose: onClose,
1615
1642
  draggable: true,
1616
1643
  children: [type === 'feel' && jsxRuntime.jsxs("a", {
1617
1644
  href: "https://docs.camunda.io/docs/components/modeler/feel/what-is-feel/",
@@ -1653,14 +1680,6 @@ function FeelPopupComponent(props) {
1653
1680
  tooltipContainer: tooltipContainer
1654
1681
  })]
1655
1682
  })
1656
- }), jsxRuntime.jsx(Popup.Footer, {
1657
- children: jsxRuntime.jsx("button", {
1658
- type: "button",
1659
- onClick: () => onClose(),
1660
- title: "Close pop-up editor",
1661
- class: "bio-properties-panel-feel-popup__close-btn",
1662
- children: "Close"
1663
- })
1664
1683
  })]
1665
1684
  });
1666
1685
  }
@@ -3050,6 +3069,28 @@ function HeaderButton(props) {
3050
3069
  });
3051
3070
  }
3052
3071
 
3072
+ /**
3073
+ * @typedef { {
3074
+ * [key: string]: string;
3075
+ * } } TranslateReplacements
3076
+ */
3077
+
3078
+ /**
3079
+ * A simple translation stub to be used for multi-language support.
3080
+ * Can be easily replaced with a more sophisticated solution.
3081
+ *
3082
+ * @param {string} template to interpolate
3083
+ * @param {TranslateReplacements} [replacements] a map with substitutes
3084
+ *
3085
+ * @return {string} the translated string
3086
+ */
3087
+ function translateFallback(template, replacements) {
3088
+ replacements = replacements || {};
3089
+ return template.replace(/{([^}]+)}/g, function (_, key) {
3090
+ return replacements[key] || '{' + key + '}';
3091
+ });
3092
+ }
3093
+
3053
3094
  function CollapsibleEntry(props) {
3054
3095
  const {
3055
3096
  element,
@@ -3057,7 +3098,8 @@ function CollapsibleEntry(props) {
3057
3098
  id,
3058
3099
  label,
3059
3100
  open: shouldOpen,
3060
- remove
3101
+ remove,
3102
+ translate = translateFallback
3061
3103
  } = props;
3062
3104
  const [open, setOpen] = hooks.useState(shouldOpen);
3063
3105
  const toggleOpen = () => setOpen(!open);
@@ -3073,9 +3115,7 @@ function CollapsibleEntry(props) {
3073
3115
  }
3074
3116
  }, [onShow, setOpen])
3075
3117
  };
3076
-
3077
- // todo(pinussilvestrus): translate once we have a translate mechanism for the core
3078
- const placeholderLabel = '<empty>';
3118
+ const placeholderLabel = translate('<empty>');
3079
3119
  return jsxRuntime.jsxs("div", {
3080
3120
  "data-entry-id": id,
3081
3121
  class: classnames('bio-properties-panel-collapsible-entry', open ? 'open' : ''),
@@ -3088,14 +3128,14 @@ function CollapsibleEntry(props) {
3088
3128
  children: label || placeholderLabel
3089
3129
  }), jsxRuntime.jsx("button", {
3090
3130
  type: "button",
3091
- title: "Toggle list item",
3131
+ title: translate('Toggle list item'),
3092
3132
  class: "bio-properties-panel-arrow bio-properties-panel-collapsible-entry-arrow",
3093
3133
  children: jsxRuntime.jsx(ArrowIcon, {
3094
3134
  class: open ? 'bio-properties-panel-arrow-down' : 'bio-properties-panel-arrow-right'
3095
3135
  })
3096
3136
  }), remove ? jsxRuntime.jsx("button", {
3097
3137
  type: "button",
3098
- title: "Delete item",
3138
+ title: translate('Delete item'),
3099
3139
  class: "bio-properties-panel-remove-entry",
3100
3140
  onClick: remove,
3101
3141
  children: jsxRuntime.jsx(DeleteIcon, {})
@@ -3123,7 +3163,8 @@ function CollapsibleEntry(props) {
3123
3163
  function ListItem(props) {
3124
3164
  const {
3125
3165
  autoFocusEntry,
3126
- autoOpen
3166
+ autoOpen,
3167
+ translate = translateFallback
3127
3168
  } = props;
3128
3169
 
3129
3170
  // focus specified entry on auto open
@@ -3145,7 +3186,8 @@ function ListItem(props) {
3145
3186
  class: "bio-properties-panel-list-item",
3146
3187
  children: jsxRuntime.jsx(CollapsibleEntry, {
3147
3188
  ...props,
3148
- open: autoOpen
3189
+ open: autoOpen,
3190
+ translate: translate
3149
3191
  })
3150
3192
  });
3151
3193
  }
@@ -3162,7 +3204,8 @@ function ListGroup(props) {
3162
3204
  id,
3163
3205
  items,
3164
3206
  label,
3165
- shouldOpen = true
3207
+ shouldOpen = true,
3208
+ translate = translateFallback
3166
3209
  } = props;
3167
3210
  hooks.useEffect(() => {
3168
3211
  if (props.shouldSort != undefined) {
@@ -3264,20 +3307,22 @@ function ListGroup(props) {
3264
3307
  class: "bio-properties-panel-group-header-buttons",
3265
3308
  children: [add ? jsxRuntime.jsxs("button", {
3266
3309
  type: "button",
3267
- title: "Create new list item",
3310
+ title: translate('Create new list item'),
3268
3311
  class: "bio-properties-panel-group-header-button bio-properties-panel-add-entry",
3269
3312
  onClick: handleAddClick,
3270
3313
  children: [jsxRuntime.jsx(CreateIcon, {}), !hasItems ? jsxRuntime.jsx("span", {
3271
3314
  class: "bio-properties-panel-add-entry-label",
3272
- children: "Create"
3315
+ children: translate('Create')
3273
3316
  }) : null]
3274
3317
  }) : null, hasItems ? jsxRuntime.jsx("div", {
3275
- title: `List contains ${items.length} item${items.length != 1 ? 's' : ''}`,
3318
+ title: translate(`List contains {numOfItems} item${items.length != 1 ? 's' : ''}`, {
3319
+ numOfItems: items.length
3320
+ }),
3276
3321
  class: classnames('bio-properties-panel-list-badge', hasError ? 'bio-properties-panel-list-badge--error' : ''),
3277
3322
  children: items.length
3278
3323
  }) : null, hasItems ? jsxRuntime.jsx("button", {
3279
3324
  type: "button",
3280
- title: "Toggle section",
3325
+ title: translate('Toggle section'),
3281
3326
  class: "bio-properties-panel-group-header-button bio-properties-panel-arrow",
3282
3327
  children: jsxRuntime.jsx(ArrowIcon, {
3283
3328
  class: open ? 'bio-properties-panel-arrow-down' : 'bio-properties-panel-arrow-right'
@@ -3304,7 +3349,8 @@ function ListGroup(props) {
3304
3349
  autoOpen: autoOpen,
3305
3350
  element: element,
3306
3351
  index: index,
3307
- key: id
3352
+ key: id,
3353
+ translate: translate
3308
3354
  });
3309
3355
  })
3310
3356
  })
@@ -4309,6 +4355,7 @@ var index = {
4309
4355
 
4310
4356
  exports.ArrowIcon = ArrowIcon;
4311
4357
  exports.CheckboxEntry = CheckboxEntry;
4358
+ exports.CloseIcon = CloseIcon;
4312
4359
  exports.CollapsibleEntry = CollapsibleEntry;
4313
4360
  exports.CreateIcon = CreateIcon;
4314
4361
  exports.DebounceInputModule = index$1;