@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
@@ -0,0 +1,68 @@
1
+ import { TQorusForm } from '@qoretechnologies/ts-toolkit';
2
+ export type TRecordType = 'search' | 'search-single' | 'create' | 'update' | 'delete';
3
+ export type TRealRecordType = 'read' | 'create' | 'update' | 'delete';
4
+ export type TProviderTypeSupports = {
5
+ [key in `supports_${TRealRecordType}`]?: boolean;
6
+ };
7
+ export type TProviderTypeArgs = {
8
+ [key in `${TRecordType}_args`]?: TQorusForm | TQorusForm[];
9
+ };
10
+ /**
11
+ * A data-provider selection, in the shape the form holds it.
12
+ *
13
+ * The `supports_*` flags say which record operations the selected provider can
14
+ * perform; validation reads them to decide whether a provider is a legitimate
15
+ * target for the operation the field was configured for.
16
+ */
17
+ export interface IProviderType extends TProviderTypeSupports, TProviderTypeArgs {
18
+ type: string;
19
+ name: string;
20
+ path?: string;
21
+ options?: TQorusForm;
22
+ subtype?: 'request' | 'response';
23
+ hasApiContext?: boolean;
24
+ optionsChanged?: boolean;
25
+ searchOptionsChanged?: boolean;
26
+ desc?: string;
27
+ use_args?: boolean;
28
+ args?: any;
29
+ up?: boolean;
30
+ supports_request?: boolean;
31
+ supports_messages?: 'ASYNC' | 'SYNC' | 'NONE';
32
+ supports_observable?: boolean;
33
+ transaction_management?: boolean;
34
+ record_requires_search_options?: boolean;
35
+ create_args_freeform?: TQorusForm[];
36
+ is_api_call?: boolean;
37
+ search_options?: TQorusForm;
38
+ descriptions?: string[];
39
+ message_id?: string;
40
+ message?: {
41
+ type: string;
42
+ value: any;
43
+ };
44
+ }
45
+ /**
46
+ * A provider value as an object, from either representation a caller may hold.
47
+ *
48
+ * A provider reaches the form either already expanded into `IProviderType`, or
49
+ * as the flat path string the server stores — `"factory/db{driver=pgsql}/table"`
50
+ * or the plain `"type/name/path"`. Returns `null` for anything that is neither,
51
+ * so a caller reports an invalid value rather than reading fields off nothing.
52
+ */
53
+ export declare const maybeBuildOptionProvider: (provider: unknown) => IProviderType | null;
54
+ /**
55
+ * An FSM variable action — which variable, and what is done to it.
56
+ *
57
+ * The provider half is `Partial<IProviderType>` because the action's own
58
+ * `action_type` decides which provider fields have to be there; validation
59
+ * re-runs the matching provider validator over the merged value rather than
60
+ * duplicating those rules here.
61
+ */
62
+ export type TVariableActionValue = {
63
+ var_type: 'globalvar' | 'localvar' | 'autovar';
64
+ var_name: string;
65
+ transaction_action?: 'commit' | 'rollback' | 'begin-transaction';
66
+ action_type?: 'search' | 'search-single' | 'update' | 'create' | 'delete' | 'transaction' | 'send-message' | 'apicall';
67
+ } & Partial<IProviderType>;
68
+ //# sourceMappingURL=providerValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providerValue.d.ts","sourceRoot":"","sources":["../../src/helpers/providerValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,eAAe,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACtF,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GA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AAE,GAAG,CAAC;KACZ,CAAC;CACH;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,aAAc,OAAO,KAAG,aAAa,GAAG,IA4C5E,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,mBAAmB,CAAC;IACjE,WAAW,CAAC,EACR,QAAQ,GACR,eAAe,GACf,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,aAAa,GACb,cAAc,GACd,SAAS,CAAC;CACf,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.maybeBuildOptionProvider = void 0;
4
+ /**
5
+ * A provider value as an object, from either representation a caller may hold.
6
+ *
7
+ * A provider reaches the form either already expanded into `IProviderType`, or
8
+ * as the flat path string the server stores — `"factory/db{driver=pgsql}/table"`
9
+ * or the plain `"type/name/path"`. Returns `null` for anything that is neither,
10
+ * so a caller reports an invalid value rather than reading fields off nothing.
11
+ */
12
+ var maybeBuildOptionProvider = function (provider) {
13
+ if (!provider) {
14
+ return null;
15
+ }
16
+ if (typeof provider === 'object') {
17
+ return provider;
18
+ }
19
+ if (typeof provider !== 'string') {
20
+ return null;
21
+ }
22
+ if (provider.startsWith('factory')) {
23
+ var fixedProvider = provider.endsWith('/') ? provider : "".concat(provider, "/");
24
+ var factoryType = fixedProvider.split('/')[0];
25
+ var factoryName = fixedProvider.substring(fixedProvider.indexOf('/') + 1, fixedProvider.lastIndexOf('{'));
26
+ var options = fixedProvider.substring(fixedProvider.indexOf('{') + 1, fixedProvider.lastIndexOf('}'));
27
+ var optionsObject = options
28
+ .split(',')
29
+ .filter(Boolean)
30
+ .reduce(function (result, option) {
31
+ var _a = option.split('='), key = _a[0], value = _a[1];
32
+ result[key] = value;
33
+ return result;
34
+ }, {});
35
+ var result = {
36
+ type: factoryType,
37
+ name: factoryName,
38
+ path: fixedProvider.substring(fixedProvider.lastIndexOf('}/') + 2),
39
+ options: optionsObject,
40
+ };
41
+ if (provider.includes('?options_changed')) {
42
+ result.optionsChanged = true;
43
+ }
44
+ return result;
45
+ }
46
+ var _a = provider.split('/'), type = _a[0], name = _a[1], path = _a.slice(2);
47
+ return { type: type, name: name, path: path.join('/') };
48
+ };
49
+ exports.maybeBuildOptionProvider = maybeBuildOptionProvider;
50
+ //# sourceMappingURL=providerValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providerValue.js","sourceRoot":"","sources":["../../src/helpers/providerValue.ts"],"names":[],"mappings":";;;AAiDA;;;;;;;GAOG;AACI,IAAM,wBAAwB,GAAG,UAAC,QAAiB;IACxD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,QAAyB,CAAC;IACnC,CAAC;IACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QACnC,IAAM,aAAa,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAG,QAAQ,MAAG,CAAC;QAClE,IAAA,WAAW,GAAI,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,GAA5B,CAA6B;QAC/C,IAAM,WAAW,GAAG,aAAa,CAAC,SAAS,CACzC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAC9B,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,CAC/B,CAAC;QACF,IAAM,OAAO,GAAG,aAAa,CAAC,SAAS,CACrC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAC9B,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,CAC/B,CAAC;QACF,IAAM,aAAa,GAAG,OAAO;aAC1B,KAAK,CAAC,GAAG,CAAC;aACV,MAAM,CAAC,OAAO,CAAC;aACf,MAAM,CAAyB,UAAC,MAAM,EAAE,MAAM;YACvC,IAAA,KAAe,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAA/B,GAAG,QAAA,EAAE,KAAK,QAAqB,CAAC;YACvC,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACpB,OAAO,MAAM,CAAC;QAChB,CAAC,EAAE,EAAE,CAAC,CAAC;QACT,IAAM,MAAM,GAAkB;YAC5B,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAClE,OAAO,EAAE,aAAsC;SAChD,CAAC;QACF,IAAI,QAAQ,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAC1C,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC;QAC/B,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEK,IAAA,KAAwB,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAA1C,IAAI,QAAA,EAAE,IAAI,QAAA,EAAK,IAAI,cAAuB,CAAC;IAClD,OAAO,EAAE,IAAI,MAAA,EAAE,IAAI,MAAA,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC9C,CAAC,CAAC;AA5CW,QAAA,wBAAwB,4BA4CnC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Which string field types hold one line, and how to keep them that way.
3
+ *
4
+ * The server already draws this distinction and the IDE was throwing it away:
5
+ * a service's `name` is declared `ui_type: "string"` while its `description` is
6
+ * `ui_type: "long-string"` with `markdown: True` (see `ServiceMetadata.qc`).
7
+ * Every one of them — plus `email`, `uuid`, `hostname`, `ipv4`, `ipv6` and
8
+ * `phone` — rendered through the same growing textarea, so a technical name, a
9
+ * version and an IP address all accepted Enter.
10
+ *
11
+ * That is not a cosmetic problem. These values become YAML keys, class names,
12
+ * URLs and identifiers; a newline in one of them is invalid input that the form
13
+ * happily accepted and passed on, and the operator had no way to see it.
14
+ *
15
+ * The rule is the server's own contract, stated once here rather than guessed
16
+ * per field, and it is enforced in `LongString.tsx`.
17
+ *
18
+ * It lives in reqraft rather than in a consumer because the consumer is not the
19
+ * only renderer: qorus-ide fixed this in its OWN long-string field, and every
20
+ * form that goes through FormEngine — which is where an alert rule's Internal
21
+ * Name, Name and Short Description are — reaches THIS one instead. The fix was
22
+ * real and the field in front of the operator still took Enter.
23
+ */
24
+ /** True when a string field of this type holds a single line. */
25
+ export declare const isSingleLineStringType: (type?: string) => boolean;
26
+ /**
27
+ * Flattens any line break to a single space.
28
+ *
29
+ * A space rather than nothing, because the newline is usually where a word
30
+ * boundary was — pasting two lines into a name should read as two words, not
31
+ * one run-together one. CR, LF and CRLF all collapse to one space, and the
32
+ * result is trimmed of leading/trailing whitespace the break introduced.
33
+ */
34
+ export declare const flattenToSingleLine: (value: string) => string;
35
+ /** True when the value carries a line break this field should not hold. */
36
+ export declare const hasLineBreak: (value: string) => boolean;
37
+ //# sourceMappingURL=singleLineString.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"singleLineString.d.ts","sourceRoot":"","sources":["../../src/helpers/singleLineString.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAsBH,iEAAiE;AACjE,eAAO,MAAM,sBAAsB,UAAW,MAAM,KAAG,OACT,CAAC;AAE/C;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,UAAW,MAAM,KAAG,MACM,CAAC;AAE3D,2EAA2E;AAC3E,eAAO,MAAM,YAAY,UAAW,MAAM,KAAG,OAA8B,CAAC"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ /**
3
+ * Which string field types hold one line, and how to keep them that way.
4
+ *
5
+ * The server already draws this distinction and the IDE was throwing it away:
6
+ * a service's `name` is declared `ui_type: "string"` while its `description` is
7
+ * `ui_type: "long-string"` with `markdown: True` (see `ServiceMetadata.qc`).
8
+ * Every one of them — plus `email`, `uuid`, `hostname`, `ipv4`, `ipv6` and
9
+ * `phone` — rendered through the same growing textarea, so a technical name, a
10
+ * version and an IP address all accepted Enter.
11
+ *
12
+ * That is not a cosmetic problem. These values become YAML keys, class names,
13
+ * URLs and identifiers; a newline in one of them is invalid input that the form
14
+ * happily accepted and passed on, and the operator had no way to see it.
15
+ *
16
+ * The rule is the server's own contract, stated once here rather than guessed
17
+ * per field, and it is enforced in `LongString.tsx`.
18
+ *
19
+ * It lives in reqraft rather than in a consumer because the consumer is not the
20
+ * only renderer: qorus-ide fixed this in its OWN long-string field, and every
21
+ * form that goes through FormEngine — which is where an alert rule's Internal
22
+ * Name, Name and Short Description are — reaches THIS one instead. The fix was
23
+ * real and the field in front of the operator still took Enter.
24
+ */
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.hasLineBreak = exports.flattenToSingleLine = exports.isSingleLineStringType = void 0;
27
+ /**
28
+ * The string types that hold exactly one line — the ones routed to a textarea
29
+ * today.
30
+ *
31
+ * Listed explicitly rather than derived by excluding the document types,
32
+ * because the two directions fail very differently. Missing a single-line type
33
+ * here leaves it behaving as it does now — no worse. Wrongly treating a new
34
+ * DOCUMENT type as single-line would flatten a user's text as they typed it,
35
+ * which is data loss. So an unrecognised type stays multi-line.
36
+ */
37
+ var SINGLE_LINE_STRING_TYPES = new Set([
38
+ 'string',
39
+ 'email',
40
+ 'uuid',
41
+ 'hostname',
42
+ 'ipv4',
43
+ 'ipv6',
44
+ 'phone',
45
+ ]);
46
+ /** True when a string field of this type holds a single line. */
47
+ var isSingleLineStringType = function (type) {
48
+ return !!type && SINGLE_LINE_STRING_TYPES.has(type);
49
+ };
50
+ exports.isSingleLineStringType = isSingleLineStringType;
51
+ /**
52
+ * Flattens any line break to a single space.
53
+ *
54
+ * A space rather than nothing, because the newline is usually where a word
55
+ * boundary was — pasting two lines into a name should read as two words, not
56
+ * one run-together one. CR, LF and CRLF all collapse to one space, and the
57
+ * result is trimmed of leading/trailing whitespace the break introduced.
58
+ */
59
+ var flattenToSingleLine = function (value) {
60
+ return value.replace(/\r\n|\r|\n/g, ' ').replace(/ {2,}/g, ' ');
61
+ };
62
+ exports.flattenToSingleLine = flattenToSingleLine;
63
+ /** True when the value carries a line break this field should not hold. */
64
+ var hasLineBreak = function (value) { return /\r|\n/.test(value); };
65
+ exports.hasLineBreak = hasLineBreak;
66
+ //# sourceMappingURL=singleLineString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"singleLineString.js","sourceRoot":"","sources":["../../src/helpers/singleLineString.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAEH;;;;;;;;;GASG;AACH,IAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC;IACvC,QAAQ;IACR,OAAO;IACP,MAAM;IACN,UAAU;IACV,MAAM;IACN,MAAM;IACN,OAAO;CACR,CAAC,CAAC;AAEH,iEAAiE;AAC1D,IAAM,sBAAsB,GAAG,UAAC,IAAa;IAClD,OAAA,CAAC,CAAC,IAAI,IAAI,wBAAwB,CAAC,GAAG,CAAC,IAAI,CAAC;AAA5C,CAA4C,CAAC;AADlC,QAAA,sBAAsB,0BACY;AAE/C;;;;;;;GAOG;AACI,IAAM,mBAAmB,GAAG,UAAC,KAAa;IAC/C,OAAA,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;AAAxD,CAAwD,CAAC;AAD9C,QAAA,mBAAmB,uBAC2B;AAE3D,2EAA2E;AACpE,IAAM,YAAY,GAAG,UAAC,KAAa,IAAc,OAAA,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAnB,CAAmB,CAAC;AAA/D,QAAA,YAAY,gBAAmD"}
@@ -1,5 +1,15 @@
1
1
  import { IReqoreFormTemplates } from '@qoretechnologies/reqore/dist/components/Textarea';
2
2
  import { TReqoreDropdownItem } from '@qoretechnologies/reqore/dist/components/Dropdown/list';
3
+ /**
4
+ * The DOM ceiling for a serialized example value in a picker item — a
5
+ * binary-carrying field's example (e.g. an email attachment body) can be an
6
+ * entire base64 file, and it must not enter the item wholesale. The VISUAL
7
+ * truncation is not this number: past the ceiling the item also gets a
8
+ * single-line-ellipsis description (`descriptionEffect.noWrap`), which cuts at
9
+ * the popover's ACTUAL rendered width — container-intrinsic, no breakpoints —
10
+ * paired with the "?" action that shows the full value.
11
+ */
12
+ export declare const TEMPLATE_EXAMPLE_PREVIEW_LENGTH = 150;
3
13
  /**
4
14
  * Shared template string utilities.
5
15
  * Used by both validations and TemplateField.
@@ -15,7 +25,97 @@ export declare const getTemplateTagStyle: (meta?: TTemplateMeta) => {
15
25
  export declare const isValueTemplate: (value: string) => boolean;
16
26
  export declare const getTemplateKey: (value: string) => string;
17
27
  export declare const getTemplateValue: (value: string) => string;
28
+ /**
29
+ * The canonical template-token grammar (twin of the IDE's
30
+ * `helpers/templateValue.ts` — keep the two in step). A token is
31
+ * `$<key>:<segment>(:<segment>)*` where the key may carry dashes
32
+ * (`-expr`) and every segment is either a plain word or a braced
33
+ * context reference — `{W2n….filename}` — whose content may hold dots,
34
+ * colons, spaces and dashes (`:{deep:test:list}`,
35
+ * `{id.Created by.name}`). `isValueTemplate` above stays deliberately
36
+ * LOOSER (starts with `$`, has `:`): it answers "does the user mean a
37
+ * template here" while typing; use the strict check below when a decision
38
+ * must not misfire on user-typed dollar-strings.
39
+ */
40
+ export declare const TEMPLATE_TOKEN_SOURCE = "\\$[A-Za-z_][\\w-]*(?::(?:\\{[^}]*\\}|[A-Za-z_][\\w-]*))+";
41
+ /** STRICT whole-value check: the entire string is one well-formed template
42
+ * token (`:{id.path}`, `:item`, …) — nothing before or after.
43
+ * `'$foo: hello'` passes the loose check but not this one. */
44
+ export declare const isCompleteTemplateToken: (value?: unknown) => value is string;
45
+ /** A complete token carrying at least one BRACED context segment —
46
+ * `$data:{W2n….filename}`, `$qore-expr:{1 + 2}`. These are machine-written
47
+ * references nobody types by hand, so a surface may render them as a picker
48
+ * chip. Plain word-path tokens (`$local:id`) stay typeable and belong in the
49
+ * template-offering input (build #123 review). Word segments cannot contain
50
+ * `{`, so `:{` inside a complete token always starts a braced segment. */
51
+ export declare const isBracedTemplateToken: (value?: unknown) => value is string;
52
+ /**
53
+ * The longest catalogue item whose path is a PREFIX of `value`, plus the part
54
+ * of the path it does not cover.
55
+ *
56
+ * A catalogue can only offer what the action's output type declares, so it
57
+ * stops at a list: `choices` is offered, `choices[0].message.content` is not —
58
+ * an operator hand-extends the path past the named field. Such a value has no
59
+ * item to match and used to render as its own raw token. Naming it by its
60
+ * nearest ancestor (`Choices[0].message.content`) keeps the chip readable
61
+ * without inventing a catalogue entry that does not exist.
62
+ *
63
+ * The match must break at a path boundary (`.` or `[`) so `choicesOther` is
64
+ * never named after `choices`, and the token keys must agree so a `$config:`
65
+ * item never names a `$data:` value.
66
+ */
67
+ export declare const findTemplateByPath: (templates: IReqoreFormTemplates, value: string) => {
68
+ item: TReqoreDropdownItem;
69
+ remainder: string;
70
+ } | undefined;
18
71
  export declare const findTemplate: (templates: IReqoreFormTemplates, value: string) => TReqoreDropdownItem | undefined;
72
+ /**
73
+ * The one answer to "what is this reference called?", so a value reads the
74
+ * same in the picker chip, the read-only tag and the compact row's summary.
75
+ * Exact match first (aliases included), then the nearest catalogue ancestor
76
+ * for a hand-extended path, and finally the raw token — which is honest when
77
+ * the catalogue holds nothing that explains the value.
78
+ */
79
+ export declare const resolveTemplateLabel: (templates: IReqoreFormTemplates | undefined, value: string) => {
80
+ label: string;
81
+ item?: TReqoreDropdownItem;
82
+ };
83
+ /**
84
+ * What to call a reference when the catalogue explains nothing about it — the
85
+ * reference's own path, with the token wrapper stripped:
86
+ * `$data:{dc_ai_reply.choices[0].message.content}` reads as
87
+ * `dc_ai_reply.choices[0].message.content`.
88
+ *
89
+ * Surfaces exist with no catalogue at all (the Automation Hub template preview
90
+ * never fetches one), and there the raw token is the only thing left to show.
91
+ * Showing it as `$data:{…}` renders a value as code; showing the path renders
92
+ * it as a name, which is the honest floor.
93
+ */
94
+ export declare const getTemplateReferencePath: (value: string) => string;
95
+ /**
96
+ * The best available name for a reference, for a surface that must show
97
+ * something readable no matter what: the catalogue's name when it has one,
98
+ * otherwise the bare path. `resolveTemplateLabel` keeps falling back to the
99
+ * raw token, because a picker that cannot resolve a value should say exactly
100
+ * what the value is.
101
+ */
102
+ export declare const describeTemplateReference: (templates: IReqoreFormTemplates | undefined, value: string) => {
103
+ label: string;
104
+ item?: TReqoreDropdownItem;
105
+ };
106
+ export type TTemplateTextSegment = {
107
+ kind: 'text';
108
+ text: string;
109
+ } | {
110
+ kind: 'token';
111
+ text: string;
112
+ };
113
+ /**
114
+ * Splits prose that embeds template tokens into its literal and token parts —
115
+ * `trim("$data:{…}")` becomes `trim("`, the token, `")`. Used to chip the
116
+ * references inside a rendered expression instead of printing them raw.
117
+ */
118
+ export declare const splitTemplateTokens: (text?: string) => TTemplateTextSegment[];
19
119
  export declare const filterTemplatesByType: (templates?: IReqoreFormTemplates, fieldType?: string, hasArgSchema?: boolean) => IReqoreFormTemplates;
20
120
  interface ITemplateItemPayload {
21
121
  display_name?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/helpers/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AACzF,OAAO,EACL,mBAAmB,EAEpB,MAAM,wDAAwD,CAAC;AAIhE;;;GAGG;AAEH,MAAM,MAAM,aAAa,GAAG;IAAE,KAAK,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CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED,eAAO,MAAM,cAAc,eACb,iBAAiB,KAC5B,oBAAoB,GAAG,SAgJzB,CAAC"}
@@ -20,9 +20,22 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
20
20
  return to.concat(ar || Array.prototype.slice.call(from));
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.buildTemplates = exports.filterTemplatesByType = exports.findTemplate = exports.getTemplateValue = exports.getTemplateKey = exports.isValueTemplate = exports.getTemplateTagStyle = void 0;
23
+ exports.buildTemplates = exports.filterTemplatesByType = exports.splitTemplateTokens = exports.describeTemplateReference = exports.getTemplateReferencePath = exports.resolveTemplateLabel = exports.findTemplate = exports.findTemplateByPath = exports.isBracedTemplateToken = exports.isCompleteTemplateToken = exports.TEMPLATE_TOKEN_SOURCE = exports.getTemplateValue = exports.getTemplateKey = exports.isValueTemplate = exports.getTemplateTagStyle = exports.TEMPLATE_EXAMPLE_PREVIEW_LENGTH = void 0;
24
+ var reqore_1 = require("@qoretechnologies/reqore");
24
25
  var lodash_1 = require("lodash");
26
+ var react_1 = require("react");
27
+ var ExampleValueModal_1 = require("../components/form/fields/template/ExampleValueModal");
25
28
  var expressions_1 = require("./expressions");
29
+ /**
30
+ * The DOM ceiling for a serialized example value in a picker item — a
31
+ * binary-carrying field's example (e.g. an email attachment body) can be an
32
+ * entire base64 file, and it must not enter the item wholesale. The VISUAL
33
+ * truncation is not this number: past the ceiling the item also gets a
34
+ * single-line-ellipsis description (`descriptionEffect.noWrap`), which cuts at
35
+ * the popover's ACTUAL rendered width — container-intrinsic, no breakpoints —
36
+ * paired with the "?" action that shows the full value.
37
+ */
38
+ exports.TEMPLATE_EXAMPLE_PREVIEW_LENGTH = 150;
26
39
  var getTemplateTagStyle = function (meta) {
27
40
  if (meta === null || meta === void 0 ? void 0 : meta.isEventTrigger)
28
41
  return { intent: 'success' };
@@ -48,13 +61,119 @@ var getTemplateValue = function (value) {
48
61
  return value.substring(colonIndex + 1);
49
62
  };
50
63
  exports.getTemplateValue = getTemplateValue;
64
+ /**
65
+ * The canonical template-token grammar (twin of the IDE's
66
+ * `helpers/templateValue.ts` — keep the two in step). A token is
67
+ * `$<key>:<segment>(:<segment>)*` where the key may carry dashes
68
+ * (`-expr`) and every segment is either a plain word or a braced
69
+ * context reference — `{W2n….filename}` — whose content may hold dots,
70
+ * colons, spaces and dashes (`:{deep:test:list}`,
71
+ * `{id.Created by.name}`). `isValueTemplate` above stays deliberately
72
+ * LOOSER (starts with `$`, has `:`): it answers "does the user mean a
73
+ * template here" while typing; use the strict check below when a decision
74
+ * must not misfire on user-typed dollar-strings.
75
+ */
76
+ exports.TEMPLATE_TOKEN_SOURCE = '\\$[A-Za-z_][\\w-]*(?::(?:\\{[^}]*\\}|[A-Za-z_][\\w-]*))+';
77
+ var COMPLETE_TEMPLATE_TOKEN = new RegExp("^".concat(exports.TEMPLATE_TOKEN_SOURCE, "$"));
78
+ /** STRICT whole-value check: the entire string is one well-formed template
79
+ * token (`:{id.path}`, `:item`, …) — nothing before or after.
80
+ * `'$foo: hello'` passes the loose check but not this one. */
81
+ var isCompleteTemplateToken = function (value) {
82
+ return typeof value === 'string' && COMPLETE_TEMPLATE_TOKEN.test(value);
83
+ };
84
+ exports.isCompleteTemplateToken = isCompleteTemplateToken;
85
+ /** A complete token carrying at least one BRACED context segment —
86
+ * `$data:{W2n….filename}`, `$qore-expr:{1 + 2}`. These are machine-written
87
+ * references nobody types by hand, so a surface may render them as a picker
88
+ * chip. Plain word-path tokens (`$local:id`) stay typeable and belong in the
89
+ * template-offering input (build #123 review). Word segments cannot contain
90
+ * `{`, so `:{` inside a complete token always starts a braced segment. */
91
+ var isBracedTemplateToken = function (value) {
92
+ return (0, exports.isCompleteTemplateToken)(value) && value.includes(':{');
93
+ };
94
+ exports.isBracedTemplateToken = isBracedTemplateToken;
95
+ /**
96
+ * An FSM state carries TWO identities: the key it occupies in the `states`
97
+ * hash and its own `id`. The IDE gives both the same nanoid, so nothing
98
+ * authored there can tell them apart — but a template hand-writes numbered
99
+ * keys (`'1'`, `'2'`, …) over meaningful ids (`dc_ai_reply`), its saved
100
+ * `$data:{…}` references use the **id**, and the server's design-time
101
+ * catalogue spells its item values with the **key**. The two never match as
102
+ * text, so a template-derived Qog renders the raw token where a named chip
103
+ * belongs.
104
+ *
105
+ * The producer of the catalogue (the IDE, which is the side that holds the
106
+ * states) attaches the alternate spelling here rather than rewriting either
107
+ * side — a picked value must keep storing exactly what the catalogue says.
108
+ * Consuming it is therefore purely a display concern.
109
+ */
110
+ var matchesTemplateValue = function (item, value) {
111
+ var _a, _b;
112
+ return item.value === value ||
113
+ !!((_b = (_a = item.metadata) === null || _a === void 0 ? void 0 : _a.aliasValues) === null || _b === void 0 ? void 0 : _b.includes(value));
114
+ };
115
+ /** Splits `$data:{a.b.c}` into its key (`$data`) and inner path (`a.b.c`). */
116
+ var TEMPLATE_TOKEN_PATH = /^(\$[A-Za-z_][\w-]*):\{(.*)\}$/;
117
+ var getTokenPath = function (value) {
118
+ var match = typeof value === 'string' ? TEMPLATE_TOKEN_PATH.exec(value) : null;
119
+ return match ? { key: match[1], path: match[2] } : undefined;
120
+ };
121
+ /**
122
+ * The longest catalogue item whose path is a PREFIX of `value`, plus the part
123
+ * of the path it does not cover.
124
+ *
125
+ * A catalogue can only offer what the action's output type declares, so it
126
+ * stops at a list: `choices` is offered, `choices[0].message.content` is not —
127
+ * an operator hand-extends the path past the named field. Such a value has no
128
+ * item to match and used to render as its own raw token. Naming it by its
129
+ * nearest ancestor (`Choices[0].message.content`) keeps the chip readable
130
+ * without inventing a catalogue entry that does not exist.
131
+ *
132
+ * The match must break at a path boundary (`.` or `[`) so `choicesOther` is
133
+ * never named after `choices`, and the token keys must agree so a `$config:`
134
+ * item never names a `$data:` value.
135
+ */
136
+ var findTemplateByPath = function (templates, value) {
137
+ var ref = getTokenPath(value);
138
+ if (!ref)
139
+ return undefined;
140
+ var best;
141
+ var consider = function (item, candidate) {
142
+ var itemPath = getTokenPath(candidate);
143
+ if (!itemPath || itemPath.key !== ref.key || !ref.path.startsWith(itemPath.path)) {
144
+ return;
145
+ }
146
+ var boundary = ref.path[itemPath.path.length];
147
+ if (boundary !== '.' && boundary !== '[') {
148
+ return;
149
+ }
150
+ if (!best || itemPath.path.length > best.path.length) {
151
+ best = { item: item, path: itemPath.path, remainder: ref.path.slice(itemPath.path.length) };
152
+ }
153
+ };
154
+ var walk = function (items) {
155
+ items === null || items === void 0 ? void 0 : items.forEach(function (item) {
156
+ var _a, _b;
157
+ consider(item, item.value);
158
+ (_b = (_a = item.metadata) === null || _a === void 0 ? void 0 : _a.aliasValues) === null || _b === void 0 ? void 0 : _b.forEach(function (alias) {
159
+ return consider(item, alias);
160
+ });
161
+ if (item.items) {
162
+ walk(item.items);
163
+ }
164
+ });
165
+ };
166
+ walk(templates === null || templates === void 0 ? void 0 : templates.items);
167
+ return best ? { item: best.item, remainder: best.remainder } : undefined;
168
+ };
169
+ exports.findTemplateByPath = findTemplateByPath;
51
170
  var findTemplate = function (templates, value) {
52
171
  if (!value)
53
172
  return undefined;
54
173
  var result = undefined;
55
174
  var findItem = function (items) {
56
175
  items === null || items === void 0 ? void 0 : items.forEach(function (item) {
57
- if (item.value === value) {
176
+ if (matchesTemplateValue(item, value)) {
58
177
  result = item;
59
178
  return;
60
179
  }
@@ -67,6 +186,93 @@ var findTemplate = function (templates, value) {
67
186
  return result;
68
187
  };
69
188
  exports.findTemplate = findTemplate;
189
+ /**
190
+ * Joins a catalogue item's name to the part of the path it does not cover.
191
+ * A field step reads as a step (`Choices › message`), while an array index
192
+ * binds to the name it indexes (`Choices[0]`) rather than floating off it.
193
+ */
194
+ var composeExtendedLabel = function (label, remainder) {
195
+ return remainder.startsWith('.') ? "".concat(label, " \u203A ").concat(remainder.slice(1)) : "".concat(label).concat(remainder);
196
+ };
197
+ /**
198
+ * The one answer to "what is this reference called?", so a value reads the
199
+ * same in the picker chip, the read-only tag and the compact row's summary.
200
+ * Exact match first (aliases included), then the nearest catalogue ancestor
201
+ * for a hand-extended path, and finally the raw token — which is honest when
202
+ * the catalogue holds nothing that explains the value.
203
+ */
204
+ var resolveTemplateLabel = function (templates, value) {
205
+ if (!templates || !value) {
206
+ return { label: value };
207
+ }
208
+ var exact = (0, exports.findTemplate)(templates, value);
209
+ if (exact) {
210
+ return { label: exact.label || value, item: exact };
211
+ }
212
+ var extended = (0, exports.findTemplateByPath)(templates, value);
213
+ if (extended) {
214
+ return {
215
+ label: composeExtendedLabel(extended.item.label, extended.remainder),
216
+ item: extended.item,
217
+ };
218
+ }
219
+ return { label: value };
220
+ };
221
+ exports.resolveTemplateLabel = resolveTemplateLabel;
222
+ /**
223
+ * What to call a reference when the catalogue explains nothing about it — the
224
+ * reference's own path, with the token wrapper stripped:
225
+ * `$data:{dc_ai_reply.choices[0].message.content}` reads as
226
+ * `dc_ai_reply.choices[0].message.content`.
227
+ *
228
+ * Surfaces exist with no catalogue at all (the Automation Hub template preview
229
+ * never fetches one), and there the raw token is the only thing left to show.
230
+ * Showing it as `$data:{…}` renders a value as code; showing the path renders
231
+ * it as a name, which is the honest floor.
232
+ */
233
+ var getTemplateReferencePath = function (value) { var _a, _b; return (_b = (_a = getTokenPath(value)) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : value; };
234
+ exports.getTemplateReferencePath = getTemplateReferencePath;
235
+ /**
236
+ * The best available name for a reference, for a surface that must show
237
+ * something readable no matter what: the catalogue's name when it has one,
238
+ * otherwise the bare path. `resolveTemplateLabel` keeps falling back to the
239
+ * raw token, because a picker that cannot resolve a value should say exactly
240
+ * what the value is.
241
+ */
242
+ var describeTemplateReference = function (templates, value) {
243
+ var resolved = (0, exports.resolveTemplateLabel)(templates, value);
244
+ return resolved.item ? resolved : { label: (0, exports.getTemplateReferencePath)(value) };
245
+ };
246
+ exports.describeTemplateReference = describeTemplateReference;
247
+ var EMBEDDED_TEMPLATE_TOKEN = new RegExp(exports.TEMPLATE_TOKEN_SOURCE, 'g');
248
+ /**
249
+ * Splits prose that embeds template tokens into its literal and token parts —
250
+ * `trim("$data:{…}")` becomes `trim("`, the token, `")`. Used to chip the
251
+ * references inside a rendered expression instead of printing them raw.
252
+ */
253
+ var splitTemplateTokens = function (text) {
254
+ if (!text) {
255
+ return [];
256
+ }
257
+ var segments = [];
258
+ var lastIndex = 0;
259
+ // A fresh regex per call: a shared /g instance carries `lastIndex` between
260
+ // calls and would skip tokens on the second string it is given.
261
+ var pattern = new RegExp(EMBEDDED_TEMPLATE_TOKEN.source, 'g');
262
+ var match;
263
+ while ((match = pattern.exec(text)) !== null) {
264
+ if (match.index > lastIndex) {
265
+ segments.push({ kind: 'text', text: text.slice(lastIndex, match.index) });
266
+ }
267
+ segments.push({ kind: 'token', text: match[0] });
268
+ lastIndex = match.index + match[0].length;
269
+ }
270
+ if (lastIndex < text.length) {
271
+ segments.push({ kind: 'text', text: text.slice(lastIndex) });
272
+ }
273
+ return segments;
274
+ };
275
+ exports.splitTemplateTokens = splitTemplateTokens;
70
276
  // Ported verbatim from qorus-ide `helpers/functions.tsx` (FIELD_STACK_REPORT
71
277
  // batch) — the previous reqraft version used naive badge equality; the IDE
72
278
  // routes compatibility through `areQorusTypesCompatible` (int↔string coercion
@@ -126,11 +332,21 @@ var buildTemplates = function (templates) {
126
332
  if (items === void 0) { items = []; }
127
333
  return items.map(function (_a) {
128
334
  var itemDisplayName = _a.display_name, value = _a.value, example_value = _a.example_value, type = _a.type, childItems = _a.items, itemDataRole = _a.data_role;
335
+ var serializedExample = example_value !== undefined ? JSON.stringify(example_value) : undefined;
336
+ var exampleIsLong = serializedExample !== undefined &&
337
+ serializedExample.length > exports.TEMPLATE_EXAMPLE_PREVIEW_LENGTH;
129
338
  var item = {
130
339
  label: itemDisplayName,
131
- description: example_value
132
- ? "Example value: ".concat(JSON.stringify(example_value))
340
+ description: serializedExample
341
+ ? "Example value: ".concat(exampleIsLong
342
+ ? "".concat(serializedExample.slice(0, exports.TEMPLATE_EXAMPLE_PREVIEW_LENGTH), "\u2026")
343
+ : serializedExample)
133
344
  : undefined,
345
+ // Ellipsize ONLY where the "?" full-value affordance exists — for a
346
+ // short value an ellipsis would hide information with no way to
347
+ // reveal it. The single line cuts at the rendered width, so the
348
+ // preview adapts to any popover/panel width without breakpoints.
349
+ descriptionEffect: exampleIsLong ? { noWrap: true } : undefined,
134
350
  badge: type,
135
351
  metadata: {
136
352
  image: logo,
@@ -146,6 +362,23 @@ var buildTemplates = function (templates) {
146
362
  transparent: false,
147
363
  minimal: true,
148
364
  };
365
+ if (exampleIsLong) {
366
+ // Menu-item actions stop propagation, so the click never selects or
367
+ // expands the item. The modal rides reqore's global modal queue
368
+ // (rendered by the provider portal), so no host component is needed
369
+ // — the modals wrapper injects `isOpen`/`onClose` itself.
370
+ item.rightAction = {
371
+ icon: 'QuestionLine',
372
+ compact: true,
373
+ tooltip: 'Show the full example value',
374
+ onClick: function () {
375
+ reqore_1.modalStore.getState().addModal((0, react_1.createElement)(ExampleValueModal_1.ReqraftTemplateExampleValueModal, {
376
+ label: itemDisplayName,
377
+ value: serializedExample,
378
+ }));
379
+ },
380
+ };
381
+ }
149
382
  if (childItems === null || childItems === void 0 ? void 0 : childItems.length) {
150
383
  item.items = mapTemplates(childItems, app, action, logo, display_name, builtIn, isEventTrigger, dataRole);
151
384
  item.stackWithActions = false;