@qoretechnologies/reqraft 0.10.46-pr.95.ge595a13 → 0.10.46

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.
Files changed (147) hide show
  1. package/.claude/CLAUDE.md +12 -0
  2. package/.tasks/INDEX.md +1 -0
  3. package/.tasks/TEMPLATE_TOKEN_GRAMMAR.md +72 -0
  4. package/dist/components/composer/Composer.d.ts.map +1 -1
  5. package/dist/components/composer/Composer.js +5 -1
  6. package/dist/components/composer/Composer.js.map +1 -1
  7. package/dist/components/form/engine/CompactRow.d.ts +14 -0
  8. package/dist/components/form/engine/CompactRow.d.ts.map +1 -1
  9. package/dist/components/form/engine/CompactRow.js +199 -41
  10. package/dist/components/form/engine/CompactRow.js.map +1 -1
  11. package/dist/components/form/engine/CompactToolbar.d.ts.map +1 -1
  12. package/dist/components/form/engine/CompactToolbar.js +72 -72
  13. package/dist/components/form/engine/CompactToolbar.js.map +1 -1
  14. package/dist/components/form/engine/FormEngine.d.ts +65 -1
  15. package/dist/components/form/engine/FormEngine.d.ts.map +1 -1
  16. package/dist/components/form/engine/FormEngine.js +276 -108
  17. package/dist/components/form/engine/FormEngine.js.map +1 -1
  18. package/dist/components/form/engine/_structuredData/SchemaDataView.d.ts.map +1 -1
  19. package/dist/components/form/engine/_structuredData/SchemaDataView.js +55 -13
  20. package/dist/components/form/engine/_structuredData/SchemaDataView.js.map +1 -1
  21. package/dist/components/form/engine/_structuredData/structuredData.d.ts +15 -0
  22. package/dist/components/form/engine/_structuredData/structuredData.d.ts.map +1 -1
  23. package/dist/components/form/engine/_structuredData/structuredData.js +22 -1
  24. package/dist/components/form/engine/_structuredData/structuredData.js.map +1 -1
  25. package/dist/components/form/engine/compactRowStyles.d.ts.map +1 -1
  26. package/dist/components/form/engine/compactRowStyles.js +15 -3
  27. package/dist/components/form/engine/compactRowStyles.js.map +1 -1
  28. package/dist/components/form/engine/compactToolbarContext.d.ts +8 -0
  29. package/dist/components/form/engine/compactToolbarContext.d.ts.map +1 -1
  30. package/dist/components/form/engine/compactToolbarContext.js.map +1 -1
  31. package/dist/components/form/engine/readFirst.d.ts +24 -0
  32. package/dist/components/form/engine/readFirst.d.ts.map +1 -1
  33. package/dist/components/form/engine/readFirst.js +84 -6
  34. package/dist/components/form/engine/readFirst.js.map +1 -1
  35. package/dist/components/form/fields/Field.d.ts.map +1 -1
  36. package/dist/components/form/fields/Field.js +1 -1
  37. package/dist/components/form/fields/Field.js.map +1 -1
  38. package/dist/components/form/fields/allowed-values/AllowedValues.d.ts +12 -2
  39. package/dist/components/form/fields/allowed-values/AllowedValues.d.ts.map +1 -1
  40. package/dist/components/form/fields/allowed-values/AllowedValues.js +16 -6
  41. package/dist/components/form/fields/allowed-values/AllowedValues.js.map +1 -1
  42. package/dist/components/form/fields/auto/AutoFormField.d.ts.map +1 -1
  43. package/dist/components/form/fields/auto/AutoFormField.js +64 -14
  44. package/dist/components/form/fields/auto/AutoFormField.js.map +1 -1
  45. package/dist/components/form/fields/long-string/LongString.d.ts +9 -1
  46. package/dist/components/form/fields/long-string/LongString.d.ts.map +1 -1
  47. package/dist/components/form/fields/long-string/LongString.js +25 -4
  48. package/dist/components/form/fields/long-string/LongString.js.map +1 -1
  49. package/dist/components/form/fields/template/ExampleValueModal.d.ts +29 -0
  50. package/dist/components/form/fields/template/ExampleValueModal.d.ts.map +1 -0
  51. package/dist/components/form/fields/template/ExampleValueModal.js +122 -0
  52. package/dist/components/form/fields/template/ExampleValueModal.js.map +1 -0
  53. package/dist/components/form/fields/template/ReadOnlyTemplateTag.d.ts.map +1 -1
  54. package/dist/components/form/fields/template/ReadOnlyTemplateTag.js +3 -3
  55. package/dist/components/form/fields/template/ReadOnlyTemplateTag.js.map +1 -1
  56. package/dist/components/form/fields/template/TemplateField.d.ts.map +1 -1
  57. package/dist/components/form/fields/template/TemplateField.js +81 -27
  58. package/dist/components/form/fields/template/TemplateField.js.map +1 -1
  59. package/dist/components/form/fields/template/__fixtures__/longExampleValue.d.ts +2 -0
  60. package/dist/components/form/fields/template/__fixtures__/longExampleValue.d.ts.map +1 -0
  61. package/dist/components/form/fields/template/__fixtures__/longExampleValue.js +9 -0
  62. package/dist/components/form/fields/template/__fixtures__/longExampleValue.js.map +1 -0
  63. package/dist/components/form/index.d.ts +1 -0
  64. package/dist/components/form/index.d.ts.map +1 -1
  65. package/dist/components/form/index.js +1 -0
  66. package/dist/components/form/index.js.map +1 -1
  67. package/dist/components/searchFilterBar/SearchFilterBar.d.ts +12 -1
  68. package/dist/components/searchFilterBar/SearchFilterBar.d.ts.map +1 -1
  69. package/dist/components/searchFilterBar/SearchFilterBar.js +2 -2
  70. package/dist/components/searchFilterBar/SearchFilterBar.js.map +1 -1
  71. package/dist/components/ticketThread/TicketThread.d.ts.map +1 -1
  72. package/dist/components/ticketThread/TicketThread.js +1 -1
  73. package/dist/components/ticketThread/TicketThread.js.map +1 -1
  74. package/dist/helpers/common.d.ts +8 -1
  75. package/dist/helpers/common.d.ts.map +1 -1
  76. package/dist/helpers/common.js +9 -1
  77. package/dist/helpers/common.js.map +1 -1
  78. package/dist/helpers/expressions.d.ts.map +1 -1
  79. package/dist/helpers/expressions.js +15 -2
  80. package/dist/helpers/expressions.js.map +1 -1
  81. package/dist/helpers/optionUiTypes.d.ts +30 -0
  82. package/dist/helpers/optionUiTypes.d.ts.map +1 -0
  83. package/dist/helpers/optionUiTypes.js +156 -0
  84. package/dist/helpers/optionUiTypes.js.map +1 -0
  85. package/dist/helpers/options.d.ts +19 -0
  86. package/dist/helpers/options.d.ts.map +1 -1
  87. package/dist/helpers/options.js +25 -1
  88. package/dist/helpers/options.js.map +1 -1
  89. package/dist/helpers/providerValue.d.ts +68 -0
  90. package/dist/helpers/providerValue.d.ts.map +1 -0
  91. package/dist/helpers/providerValue.js +50 -0
  92. package/dist/helpers/providerValue.js.map +1 -0
  93. package/dist/helpers/singleLineString.d.ts +37 -0
  94. package/dist/helpers/singleLineString.d.ts.map +1 -0
  95. package/dist/helpers/singleLineString.js +66 -0
  96. package/dist/helpers/singleLineString.js.map +1 -0
  97. package/dist/helpers/templates.d.ts +100 -0
  98. package/dist/helpers/templates.d.ts.map +1 -1
  99. package/dist/helpers/templates.js +237 -4
  100. package/dist/helpers/templates.js.map +1 -1
  101. package/dist/helpers/validations.d.ts +103 -2
  102. package/dist/helpers/validations.d.ts.map +1 -1
  103. package/dist/helpers/validations.js +858 -91
  104. package/dist/helpers/validations.js.map +1 -1
  105. package/dist/index.d.ts +1 -1
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +2 -1
  108. package/dist/index.js.map +1 -1
  109. package/package.json +1 -1
  110. package/src/components/composer/Composer.tsx +7 -3
  111. package/src/components/form/engine/CompactRow.tsx +279 -33
  112. package/src/components/form/engine/CompactToolbar.tsx +105 -98
  113. package/src/components/form/engine/FormEngine.stories.tsx +995 -12
  114. package/src/components/form/engine/FormEngine.tsx +377 -94
  115. package/src/components/form/engine/_structuredData/SchemaDataView.stories.tsx +104 -0
  116. package/src/components/form/engine/_structuredData/SchemaDataView.tsx +158 -101
  117. package/src/components/form/engine/_structuredData/structuredData.ts +20 -0
  118. package/src/components/form/engine/compactRowStyles.ts +55 -1
  119. package/src/components/form/engine/compactToolbarContext.ts +8 -0
  120. package/src/components/form/engine/readFirst.ts +125 -35
  121. package/src/components/form/fields/Field.tsx +3 -1
  122. package/src/components/form/fields/allowed-values/AllowedValues.tsx +24 -2
  123. package/src/components/form/fields/array/ArrayAutoField.stories.tsx +81 -0
  124. package/src/components/form/fields/auto/AutoFormField.stories.tsx +47 -1
  125. package/src/components/form/fields/auto/AutoFormField.tsx +73 -11
  126. package/src/components/form/fields/long-string/LongString.tsx +46 -5
  127. package/src/components/form/fields/schema-definition/SchemaDefinitionField.stories.tsx +5 -0
  128. package/src/components/form/fields/template/ExampleValueModal.stories.tsx +114 -0
  129. package/src/components/form/fields/template/ExampleValueModal.tsx +99 -0
  130. package/src/components/form/fields/template/ReadOnlyTemplateTag.tsx +8 -4
  131. package/src/components/form/fields/template/TemplateField.stories.tsx +389 -1
  132. package/src/components/form/fields/template/TemplateField.tsx +100 -35
  133. package/src/components/form/fields/template/__fixtures__/longExampleValue.ts +7 -0
  134. package/src/components/form/index.tsx +1 -0
  135. package/src/components/searchFilterBar/SearchFilterBar.stories.tsx +62 -0
  136. package/src/components/searchFilterBar/SearchFilterBar.tsx +13 -0
  137. package/src/components/ticketThread/TicketThread.tsx +7 -0
  138. package/src/helpers/common.ts +11 -1
  139. package/src/helpers/expressions.ts +16 -2
  140. package/src/helpers/optionUiTypes.ts +161 -0
  141. package/src/helpers/options.ts +23 -0
  142. package/src/helpers/providerValue.ts +125 -0
  143. package/src/helpers/singleLineString.ts +61 -0
  144. package/src/helpers/templates.ts +272 -3
  145. package/src/helpers/validations.ts +1177 -109
  146. package/src/hooks/useWebSocket/useWebsocket.stories.tsx +23 -2
  147. package/src/index.tsx +1 -0
@@ -1,11 +1,25 @@
1
+ import { modalStore } from '@qoretechnologies/reqore';
1
2
  import { IReqoreFormTemplates } from '@qoretechnologies/reqore/dist/components/Textarea';
2
3
  import {
3
4
  TReqoreDropdownItem,
4
5
  TReqoreDropdownItems,
5
6
  } from '@qoretechnologies/reqore/dist/components/Dropdown/list';
6
7
  import { cloneDeep, size } from 'lodash';
8
+ import { createElement } from 'react';
9
+ import { ReqraftTemplateExampleValueModal } from '../components/form/fields/template/ExampleValueModal';
7
10
  import { areQorusTypesCompatible } from './expressions';
8
11
 
12
+ /**
13
+ * The DOM ceiling for a serialized example value in a picker item — a
14
+ * binary-carrying field's example (e.g. an email attachment body) can be an
15
+ * entire base64 file, and it must not enter the item wholesale. The VISUAL
16
+ * truncation is not this number: past the ceiling the item also gets a
17
+ * single-line-ellipsis description (`descriptionEffect.noWrap`), which cuts at
18
+ * the popover's ACTUAL rendered width — container-intrinsic, no breakpoints —
19
+ * paired with the "?" action that shows the full value.
20
+ */
21
+ export const TEMPLATE_EXAMPLE_PREVIEW_LENGTH = 150;
22
+
9
23
  /**
10
24
  * Shared template string utilities.
11
25
  * Used by both validations and TemplateField.
@@ -38,6 +52,119 @@ export const getTemplateValue = (value: string): string => {
38
52
  return value.substring(colonIndex + 1);
39
53
  };
40
54
 
55
+ /**
56
+ * The canonical template-token grammar (twin of the IDE's
57
+ * `helpers/templateValue.ts` — keep the two in step). A token is
58
+ * `$<key>:<segment>(:<segment>)*` where the key may carry dashes
59
+ * (`-expr`) and every segment is either a plain word or a braced
60
+ * context reference — `{W2n….filename}` — whose content may hold dots,
61
+ * colons, spaces and dashes (`:{deep:test:list}`,
62
+ * `{id.Created by.name}`). `isValueTemplate` above stays deliberately
63
+ * LOOSER (starts with `$`, has `:`): it answers "does the user mean a
64
+ * template here" while typing; use the strict check below when a decision
65
+ * must not misfire on user-typed dollar-strings.
66
+ */
67
+ export const TEMPLATE_TOKEN_SOURCE =
68
+ '\\$[A-Za-z_][\\w-]*(?::(?:\\{[^}]*\\}|[A-Za-z_][\\w-]*))+';
69
+
70
+ const COMPLETE_TEMPLATE_TOKEN = new RegExp(`^${TEMPLATE_TOKEN_SOURCE}$`);
71
+
72
+ /** STRICT whole-value check: the entire string is one well-formed template
73
+ * token (`:{id.path}`, `:item`, …) — nothing before or after.
74
+ * `'$foo: hello'` passes the loose check but not this one. */
75
+ export const isCompleteTemplateToken = (value?: unknown): value is string =>
76
+ typeof value === 'string' && COMPLETE_TEMPLATE_TOKEN.test(value);
77
+
78
+ /** A complete token carrying at least one BRACED context segment —
79
+ * `$data:{W2n….filename}`, `$qore-expr:{1 + 2}`. These are machine-written
80
+ * references nobody types by hand, so a surface may render them as a picker
81
+ * chip. Plain word-path tokens (`$local:id`) stay typeable and belong in the
82
+ * template-offering input (build #123 review). Word segments cannot contain
83
+ * `{`, so `:{` inside a complete token always starts a braced segment. */
84
+ export const isBracedTemplateToken = (value?: unknown): value is string =>
85
+ isCompleteTemplateToken(value) && value.includes(':{');
86
+
87
+ /**
88
+ * An FSM state carries TWO identities: the key it occupies in the `states`
89
+ * hash and its own `id`. The IDE gives both the same nanoid, so nothing
90
+ * authored there can tell them apart — but a template hand-writes numbered
91
+ * keys (`'1'`, `'2'`, …) over meaningful ids (`dc_ai_reply`), its saved
92
+ * `$data:{…}` references use the **id**, and the server's design-time
93
+ * catalogue spells its item values with the **key**. The two never match as
94
+ * text, so a template-derived Qog renders the raw token where a named chip
95
+ * belongs.
96
+ *
97
+ * The producer of the catalogue (the IDE, which is the side that holds the
98
+ * states) attaches the alternate spelling here rather than rewriting either
99
+ * side — a picked value must keep storing exactly what the catalogue says.
100
+ * Consuming it is therefore purely a display concern.
101
+ */
102
+ const matchesTemplateValue = (item: TReqoreDropdownItem, value: string): boolean =>
103
+ item.value === value ||
104
+ !!(item.metadata as { aliasValues?: string[] } | undefined)?.aliasValues?.includes(value);
105
+
106
+ /** Splits `$data:{a.b.c}` into its key (`$data`) and inner path (`a.b.c`). */
107
+ const TEMPLATE_TOKEN_PATH = /^(\$[A-Za-z_][\w-]*):\{(.*)\}$/;
108
+
109
+ const getTokenPath = (value?: unknown): { key: string; path: string } | undefined => {
110
+ const match = typeof value === 'string' ? TEMPLATE_TOKEN_PATH.exec(value) : null;
111
+ return match ? { key: match[1], path: match[2] } : undefined;
112
+ };
113
+
114
+ /**
115
+ * The longest catalogue item whose path is a PREFIX of `value`, plus the part
116
+ * of the path it does not cover.
117
+ *
118
+ * A catalogue can only offer what the action's output type declares, so it
119
+ * stops at a list: `choices` is offered, `choices[0].message.content` is not —
120
+ * an operator hand-extends the path past the named field. Such a value has no
121
+ * item to match and used to render as its own raw token. Naming it by its
122
+ * nearest ancestor (`Choices[0].message.content`) keeps the chip readable
123
+ * without inventing a catalogue entry that does not exist.
124
+ *
125
+ * The match must break at a path boundary (`.` or `[`) so `choicesOther` is
126
+ * never named after `choices`, and the token keys must agree so a `$config:`
127
+ * item never names a `$data:` value.
128
+ */
129
+ export const findTemplateByPath = (
130
+ templates: IReqoreFormTemplates,
131
+ value: string
132
+ ): { item: TReqoreDropdownItem; remainder: string } | undefined => {
133
+ const ref = getTokenPath(value);
134
+ if (!ref) return undefined;
135
+
136
+ let best: { item: TReqoreDropdownItem; path: string; remainder: string } | undefined;
137
+
138
+ const consider = (item: TReqoreDropdownItem, candidate?: string) => {
139
+ const itemPath = getTokenPath(candidate);
140
+ if (!itemPath || itemPath.key !== ref.key || !ref.path.startsWith(itemPath.path)) {
141
+ return;
142
+ }
143
+ const boundary = ref.path[itemPath.path.length];
144
+ if (boundary !== '.' && boundary !== '[') {
145
+ return;
146
+ }
147
+ if (!best || itemPath.path.length > best.path.length) {
148
+ best = { item, path: itemPath.path, remainder: ref.path.slice(itemPath.path.length) };
149
+ }
150
+ };
151
+
152
+ const walk = (items?: TReqoreDropdownItems) => {
153
+ items?.forEach((item) => {
154
+ consider(item, item.value as string);
155
+ (item.metadata as { aliasValues?: string[] } | undefined)?.aliasValues?.forEach((alias) =>
156
+ consider(item, alias)
157
+ );
158
+ if (item.items) {
159
+ walk(item.items);
160
+ }
161
+ });
162
+ };
163
+
164
+ walk(templates?.items);
165
+ return best ? { item: best.item, remainder: best.remainder } : undefined;
166
+ };
167
+
41
168
  export const findTemplate = (
42
169
  templates: IReqoreFormTemplates,
43
170
  value: string
@@ -48,7 +175,7 @@ export const findTemplate = (
48
175
 
49
176
  const findItem = (items: TReqoreDropdownItems) => {
50
177
  items?.forEach((item) => {
51
- if (item.value === value) {
178
+ if (matchesTemplateValue(item, value)) {
52
179
  result = item;
53
180
  return;
54
181
  }
@@ -63,6 +190,113 @@ export const findTemplate = (
63
190
  return result;
64
191
  };
65
192
 
193
+ /**
194
+ * Joins a catalogue item's name to the part of the path it does not cover.
195
+ * A field step reads as a step (`Choices › message`), while an array index
196
+ * binds to the name it indexes (`Choices[0]`) rather than floating off it.
197
+ */
198
+ const composeExtendedLabel = (label: string, remainder: string): string =>
199
+ remainder.startsWith('.') ? `${label} › ${remainder.slice(1)}` : `${label}${remainder}`;
200
+
201
+ /**
202
+ * The one answer to "what is this reference called?", so a value reads the
203
+ * same in the picker chip, the read-only tag and the compact row's summary.
204
+ * Exact match first (aliases included), then the nearest catalogue ancestor
205
+ * for a hand-extended path, and finally the raw token — which is honest when
206
+ * the catalogue holds nothing that explains the value.
207
+ */
208
+ export const resolveTemplateLabel = (
209
+ templates: IReqoreFormTemplates | undefined,
210
+ value: string
211
+ ): { label: string; item?: TReqoreDropdownItem } => {
212
+ if (!templates || !value) {
213
+ return { label: value };
214
+ }
215
+
216
+ const exact = findTemplate(templates, value);
217
+ if (exact) {
218
+ return { label: (exact.label as string) || value, item: exact };
219
+ }
220
+
221
+ const extended = findTemplateByPath(templates, value);
222
+ if (extended) {
223
+ return {
224
+ label: composeExtendedLabel(extended.item.label as string, extended.remainder),
225
+ item: extended.item,
226
+ };
227
+ }
228
+
229
+ return { label: value };
230
+ };
231
+
232
+ /**
233
+ * What to call a reference when the catalogue explains nothing about it — the
234
+ * reference's own path, with the token wrapper stripped:
235
+ * `$data:{dc_ai_reply.choices[0].message.content}` reads as
236
+ * `dc_ai_reply.choices[0].message.content`.
237
+ *
238
+ * Surfaces exist with no catalogue at all (the Automation Hub template preview
239
+ * never fetches one), and there the raw token is the only thing left to show.
240
+ * Showing it as `$data:{…}` renders a value as code; showing the path renders
241
+ * it as a name, which is the honest floor.
242
+ */
243
+ export const getTemplateReferencePath = (value: string): string =>
244
+ getTokenPath(value)?.path ?? value;
245
+
246
+ /**
247
+ * The best available name for a reference, for a surface that must show
248
+ * something readable no matter what: the catalogue's name when it has one,
249
+ * otherwise the bare path. `resolveTemplateLabel` keeps falling back to the
250
+ * raw token, because a picker that cannot resolve a value should say exactly
251
+ * what the value is.
252
+ */
253
+ export const describeTemplateReference = (
254
+ templates: IReqoreFormTemplates | undefined,
255
+ value: string
256
+ ): { label: string; item?: TReqoreDropdownItem } => {
257
+ const resolved = resolveTemplateLabel(templates, value);
258
+ return resolved.item ? resolved : { label: getTemplateReferencePath(value) };
259
+ };
260
+
261
+ const EMBEDDED_TEMPLATE_TOKEN = new RegExp(TEMPLATE_TOKEN_SOURCE, 'g');
262
+
263
+ export type TTemplateTextSegment =
264
+ | { kind: 'text'; text: string }
265
+ | { kind: 'token'; text: string };
266
+
267
+ /**
268
+ * Splits prose that embeds template tokens into its literal and token parts —
269
+ * `trim("$data:{…}")` becomes `trim("`, the token, `")`. Used to chip the
270
+ * references inside a rendered expression instead of printing them raw.
271
+ */
272
+ export const splitTemplateTokens = (text?: string): TTemplateTextSegment[] => {
273
+ if (!text) {
274
+ return [];
275
+ }
276
+
277
+ const segments: TTemplateTextSegment[] = [];
278
+ let lastIndex = 0;
279
+
280
+ // A fresh regex per call: a shared /g instance carries `lastIndex` between
281
+ // calls and would skip tokens on the second string it is given.
282
+ const pattern = new RegExp(EMBEDDED_TEMPLATE_TOKEN.source, 'g');
283
+ let match: RegExpExecArray | null;
284
+
285
+ while ((match = pattern.exec(text)) !== null) {
286
+ if (match.index > lastIndex) {
287
+ segments.push({ kind: 'text', text: text.slice(lastIndex, match.index) });
288
+ }
289
+ segments.push({ kind: 'token', text: match[0] });
290
+ lastIndex = match.index + match[0].length;
291
+ }
292
+
293
+ if (lastIndex < text.length) {
294
+ segments.push({ kind: 'text', text: text.slice(lastIndex) });
295
+ }
296
+
297
+ return segments;
298
+ };
299
+
66
300
  // Ported verbatim from qorus-ide `helpers/functions.tsx` (FIELD_STACK_REPORT
67
301
  // batch) — the previous reqraft version used naive badge equality; the IDE
68
302
  // routes compatibility through `areQorusTypesCompatible` (int↔string coercion
@@ -192,11 +426,26 @@ export const buildTemplates = (
192
426
  items: childItems,
193
427
  data_role: itemDataRole,
194
428
  }): TReqoreDropdownItem => {
429
+ const serializedExample =
430
+ example_value !== undefined ? JSON.stringify(example_value) : undefined;
431
+ const exampleIsLong =
432
+ serializedExample !== undefined &&
433
+ serializedExample.length > TEMPLATE_EXAMPLE_PREVIEW_LENGTH;
434
+
195
435
  const item: TReqoreDropdownItem = {
196
436
  label: itemDisplayName,
197
- description: example_value
198
- ? `Example value: ${JSON.stringify(example_value)}`
437
+ description: serializedExample
438
+ ? `Example value: ${
439
+ exampleIsLong
440
+ ? `${serializedExample.slice(0, TEMPLATE_EXAMPLE_PREVIEW_LENGTH)}…`
441
+ : serializedExample
442
+ }`
199
443
  : undefined,
444
+ // Ellipsize ONLY where the "?" full-value affordance exists — for a
445
+ // short value an ellipsis would hide information with no way to
446
+ // reveal it. The single line cuts at the rendered width, so the
447
+ // preview adapts to any popover/panel width without breakpoints.
448
+ descriptionEffect: exampleIsLong ? { noWrap: true } : undefined,
200
449
  badge: type,
201
450
  metadata: {
202
451
  image: logo,
@@ -213,6 +462,26 @@ export const buildTemplates = (
213
462
  minimal: true,
214
463
  };
215
464
 
465
+ if (exampleIsLong) {
466
+ // Menu-item actions stop propagation, so the click never selects or
467
+ // expands the item. The modal rides reqore's global modal queue
468
+ // (rendered by the provider portal), so no host component is needed
469
+ // — the modals wrapper injects `isOpen`/`onClose` itself.
470
+ item.rightAction = {
471
+ icon: 'QuestionLine',
472
+ compact: true,
473
+ tooltip: 'Show the full example value',
474
+ onClick: () => {
475
+ modalStore.getState().addModal(
476
+ createElement(ReqraftTemplateExampleValueModal, {
477
+ label: itemDisplayName,
478
+ value: serializedExample,
479
+ })
480
+ );
481
+ },
482
+ };
483
+ }
484
+
216
485
  if (childItems?.length) {
217
486
  item.items = mapTemplates(
218
487
  childItems,