@bpmn-io/properties-panel 3.20.1 → 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.esm.js CHANGED
@@ -3048,6 +3048,28 @@ function HeaderButton(props) {
3048
3048
  });
3049
3049
  }
3050
3050
 
3051
+ /**
3052
+ * @typedef { {
3053
+ * [key: string]: string;
3054
+ * } } TranslateReplacements
3055
+ */
3056
+
3057
+ /**
3058
+ * A simple translation stub to be used for multi-language support.
3059
+ * Can be easily replaced with a more sophisticated solution.
3060
+ *
3061
+ * @param {string} template to interpolate
3062
+ * @param {TranslateReplacements} [replacements] a map with substitutes
3063
+ *
3064
+ * @return {string} the translated string
3065
+ */
3066
+ function translateFallback(template, replacements) {
3067
+ replacements = replacements || {};
3068
+ return template.replace(/{([^}]+)}/g, function (_, key) {
3069
+ return replacements[key] || '{' + key + '}';
3070
+ });
3071
+ }
3072
+
3051
3073
  function CollapsibleEntry(props) {
3052
3074
  const {
3053
3075
  element,
@@ -3055,7 +3077,8 @@ function CollapsibleEntry(props) {
3055
3077
  id,
3056
3078
  label,
3057
3079
  open: shouldOpen,
3058
- remove
3080
+ remove,
3081
+ translate = translateFallback
3059
3082
  } = props;
3060
3083
  const [open, setOpen] = useState(shouldOpen);
3061
3084
  const toggleOpen = () => setOpen(!open);
@@ -3071,9 +3094,7 @@ function CollapsibleEntry(props) {
3071
3094
  }
3072
3095
  }, [onShow, setOpen])
3073
3096
  };
3074
-
3075
- // todo(pinussilvestrus): translate once we have a translate mechanism for the core
3076
- const placeholderLabel = '<empty>';
3097
+ const placeholderLabel = translate('<empty>');
3077
3098
  return jsxs("div", {
3078
3099
  "data-entry-id": id,
3079
3100
  class: classnames('bio-properties-panel-collapsible-entry', open ? 'open' : ''),
@@ -3086,14 +3107,14 @@ function CollapsibleEntry(props) {
3086
3107
  children: label || placeholderLabel
3087
3108
  }), jsx("button", {
3088
3109
  type: "button",
3089
- title: "Toggle list item",
3110
+ title: translate('Toggle list item'),
3090
3111
  class: "bio-properties-panel-arrow bio-properties-panel-collapsible-entry-arrow",
3091
3112
  children: jsx(ArrowIcon, {
3092
3113
  class: open ? 'bio-properties-panel-arrow-down' : 'bio-properties-panel-arrow-right'
3093
3114
  })
3094
3115
  }), remove ? jsx("button", {
3095
3116
  type: "button",
3096
- title: "Delete item",
3117
+ title: translate('Delete item'),
3097
3118
  class: "bio-properties-panel-remove-entry",
3098
3119
  onClick: remove,
3099
3120
  children: jsx(DeleteIcon, {})
@@ -3121,7 +3142,8 @@ function CollapsibleEntry(props) {
3121
3142
  function ListItem(props) {
3122
3143
  const {
3123
3144
  autoFocusEntry,
3124
- autoOpen
3145
+ autoOpen,
3146
+ translate = translateFallback
3125
3147
  } = props;
3126
3148
 
3127
3149
  // focus specified entry on auto open
@@ -3143,7 +3165,8 @@ function ListItem(props) {
3143
3165
  class: "bio-properties-panel-list-item",
3144
3166
  children: jsx(CollapsibleEntry, {
3145
3167
  ...props,
3146
- open: autoOpen
3168
+ open: autoOpen,
3169
+ translate: translate
3147
3170
  })
3148
3171
  });
3149
3172
  }
@@ -3160,7 +3183,8 @@ function ListGroup(props) {
3160
3183
  id,
3161
3184
  items,
3162
3185
  label,
3163
- shouldOpen = true
3186
+ shouldOpen = true,
3187
+ translate = translateFallback
3164
3188
  } = props;
3165
3189
  useEffect(() => {
3166
3190
  if (props.shouldSort != undefined) {
@@ -3262,20 +3286,22 @@ function ListGroup(props) {
3262
3286
  class: "bio-properties-panel-group-header-buttons",
3263
3287
  children: [add ? jsxs("button", {
3264
3288
  type: "button",
3265
- title: "Create new list item",
3289
+ title: translate('Create new list item'),
3266
3290
  class: "bio-properties-panel-group-header-button bio-properties-panel-add-entry",
3267
3291
  onClick: handleAddClick,
3268
3292
  children: [jsx(CreateIcon, {}), !hasItems ? jsx("span", {
3269
3293
  class: "bio-properties-panel-add-entry-label",
3270
- children: "Create"
3294
+ children: translate('Create')
3271
3295
  }) : null]
3272
3296
  }) : null, hasItems ? jsx("div", {
3273
- title: `List contains ${items.length} item${items.length != 1 ? 's' : ''}`,
3297
+ title: translate(`List contains {numOfItems} item${items.length != 1 ? 's' : ''}`, {
3298
+ numOfItems: items.length
3299
+ }),
3274
3300
  class: classnames('bio-properties-panel-list-badge', hasError ? 'bio-properties-panel-list-badge--error' : ''),
3275
3301
  children: items.length
3276
3302
  }) : null, hasItems ? jsx("button", {
3277
3303
  type: "button",
3278
- title: "Toggle section",
3304
+ title: translate('Toggle section'),
3279
3305
  class: "bio-properties-panel-group-header-button bio-properties-panel-arrow",
3280
3306
  children: jsx(ArrowIcon, {
3281
3307
  class: open ? 'bio-properties-panel-arrow-down' : 'bio-properties-panel-arrow-right'
@@ -3302,7 +3328,8 @@ function ListGroup(props) {
3302
3328
  autoOpen: autoOpen,
3303
3329
  element: element,
3304
3330
  index: index,
3305
- key: id
3331
+ key: id,
3332
+ translate: translate
3306
3333
  });
3307
3334
  })
3308
3335
  })