@nyaruka/temba-components 0.160.0 → 0.160.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nyaruka/temba-components",
3
- "version": "0.160.0",
3
+ "version": "0.160.1",
4
4
  "description": "Web components to support rapidpro and related projects",
5
5
  "author": "Nyaruka <code@nyaruka.coim>",
6
6
  "main": "dist/index.js",
package/src/utils.ts CHANGED
@@ -1291,9 +1291,19 @@ export const generateDefaultCategoryName = (
1291
1291
 
1292
1292
  // Handle different operator types
1293
1293
  switch (operator) {
1294
- // Word/phrase operators - capitalize first letter of value
1294
+ // Word-list operators - the argument is a list of words, so only the
1295
+ // first word seeds the category name (e.g. "red maroon fire" -> "Red").
1296
+ // Trailing punctuation is stripped so comma-separated lists like
1297
+ // "red, blue, green" yield "Red" rather than "Red,".
1295
1298
  case 'has_any_word':
1296
- case 'has_all_words':
1299
+ case 'has_all_words': {
1300
+ const firstWord = cleanValue1
1301
+ .split(/\s+/)[0]
1302
+ .replace(/[^\p{L}\p{N}]+$/u, '');
1303
+ return firstWord ? capitalize(firstWord) : '';
1304
+ }
1305
+
1306
+ // Phrase operators - the argument is a single phrase, capitalize as-is
1297
1307
  case 'has_phrase':
1298
1308
  case 'has_only_phrase':
1299
1309
  case 'has_beginning':