@bikdotai/bik-component-library 0.0.853-beta.0 → 0.0.853

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 (145) hide show
  1. package/dist/cjs/components/agent-builder/AgentBuilder.js +1 -1
  2. package/dist/cjs/components/agent-builder/AgentBuilder.js.map +1 -1
  3. package/dist/cjs/components/agent-builder/components/AgentBuilderFooter.js +1 -1
  4. package/dist/cjs/components/agent-builder/components/AgentBuilderFooter.js.map +1 -1
  5. package/dist/cjs/components/agent-builder/components/AgentBuilderTopBar.js +1 -1
  6. package/dist/cjs/components/agent-builder/components/AgentBuilderTopBar.js.map +1 -1
  7. package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js +11 -11
  8. package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
  9. package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js +5 -5
  10. package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
  11. package/dist/cjs/components/agent-builder/components/GoLiveModal.js +1 -1
  12. package/dist/cjs/components/agent-builder/components/GoLiveModal.js.map +1 -1
  13. package/dist/cjs/components/agent-builder/components/MentionEditor.js +1 -7
  14. package/dist/cjs/components/agent-builder/components/MentionEditor.js.map +1 -1
  15. package/dist/cjs/components/agent-builder/components/MentionField.js +1 -1
  16. package/dist/cjs/components/agent-builder/components/MentionField.js.map +1 -1
  17. package/dist/cjs/components/agent-builder/components/MentionPicker.js +26 -53
  18. package/dist/cjs/components/agent-builder/components/MentionPicker.js.map +1 -1
  19. package/dist/cjs/components/agent-builder/components/RequireVerificationModal.js +1 -1
  20. package/dist/cjs/components/agent-builder/components/RequireVerificationModal.js.map +1 -1
  21. package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js +5 -6
  22. package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
  23. package/dist/cjs/components/agent-builder/components/SelectableListSection.js +1 -1
  24. package/dist/cjs/components/agent-builder/components/SelectableListSection.js.map +1 -1
  25. package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js +2 -2
  26. package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
  27. package/dist/cjs/components/agent-builder/constants/tools.js +1 -1
  28. package/dist/cjs/components/agent-builder/constants/tools.js.map +1 -1
  29. package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js +1 -1
  30. package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
  31. package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js +1 -1
  32. package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
  33. package/dist/cjs/components/agent-builder/utils/mentionSerialization.js +4 -4
  34. package/dist/cjs/components/agent-builder/utils/mentionSerialization.js.map +1 -1
  35. package/dist/cjs/components/agent-builder/utils/sourceIcons.js +1 -1
  36. package/dist/cjs/components/agent-builder/utils/sourceIcons.js.map +1 -1
  37. package/dist/cjs/components/agent-listing/AgentTableRow.js +1 -1
  38. package/dist/cjs/components/agent-listing/AgentTableRow.js.map +1 -1
  39. package/dist/cjs/components/agent-listing/AiAgentsEmptyState.js +1 -1
  40. package/dist/cjs/components/agent-listing/AiAgentsEmptyState.js.map +1 -1
  41. package/dist/cjs/components/variable-picker-v3/Content.js +1 -1
  42. package/dist/cjs/components/variable-picker-v3/Content.js.map +1 -1
  43. package/dist/cjs/components/zeroState/ZeroState.js +3 -3
  44. package/dist/cjs/components/zeroState/ZeroState.js.map +1 -1
  45. package/dist/cjs/editor/BikEditor.js +1 -1
  46. package/dist/cjs/editor/BikEditor.js.map +1 -1
  47. package/dist/cjs/editor/BikEditor.styles.js +21 -23
  48. package/dist/cjs/editor/BikEditor.styles.js.map +1 -1
  49. package/dist/cjs/editor/BikEditor.types.js.map +1 -1
  50. package/dist/cjs/editor/extensions/jsonHighlight/JsonHighlightExtension.js +3 -3
  51. package/dist/cjs/editor/extensions/jsonHighlight/JsonHighlightExtension.js.map +1 -1
  52. package/dist/cjs/editor/extensions/mention/MentionDropdown.js +1 -1
  53. package/dist/cjs/editor/extensions/mention/MentionDropdown.js.map +1 -1
  54. package/dist/cjs/editor/extensions/mention/MentionExtension.js +1 -1
  55. package/dist/cjs/editor/extensions/mention/MentionExtension.js.map +1 -1
  56. package/dist/cjs/index.js +1 -1
  57. package/dist/esm/components/add-variableV2/index.d.ts +0 -1
  58. package/dist/esm/components/agent-builder/AgentBuilder.js +127 -119
  59. package/dist/esm/components/agent-builder/AgentBuilder.js.map +1 -1
  60. package/dist/esm/components/agent-builder/AgentBuilder.model.d.ts +7 -10
  61. package/dist/esm/components/agent-builder/components/AgentBuilderFooter.d.ts +2 -0
  62. package/dist/esm/components/agent-builder/components/AgentBuilderFooter.js +29 -26
  63. package/dist/esm/components/agent-builder/components/AgentBuilderFooter.js.map +1 -1
  64. package/dist/esm/components/agent-builder/components/AgentBuilderTopBar.js +30 -29
  65. package/dist/esm/components/agent-builder/components/AgentBuilderTopBar.js.map +1 -1
  66. package/dist/esm/components/agent-builder/components/ConfigToolPanel.d.ts +0 -8
  67. package/dist/esm/components/agent-builder/components/ConfigToolPanel.js +136 -182
  68. package/dist/esm/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
  69. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.d.ts +9 -3
  70. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js +230 -222
  71. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
  72. package/dist/esm/components/agent-builder/components/GoLiveModal.js +11 -13
  73. package/dist/esm/components/agent-builder/components/GoLiveModal.js.map +1 -1
  74. package/dist/esm/components/agent-builder/components/MentionEditor.d.ts +0 -12
  75. package/dist/esm/components/agent-builder/components/MentionEditor.js +103 -144
  76. package/dist/esm/components/agent-builder/components/MentionEditor.js.map +1 -1
  77. package/dist/esm/components/agent-builder/components/MentionField.js +45 -48
  78. package/dist/esm/components/agent-builder/components/MentionField.js.map +1 -1
  79. package/dist/esm/components/agent-builder/components/MentionPicker.d.ts +1 -14
  80. package/dist/esm/components/agent-builder/components/MentionPicker.js +248 -292
  81. package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
  82. package/dist/esm/components/agent-builder/components/RequireVerificationModal.js +8 -8
  83. package/dist/esm/components/agent-builder/components/RequireVerificationModal.js.map +1 -1
  84. package/dist/esm/components/agent-builder/components/RestApiToolPanel.d.ts +0 -8
  85. package/dist/esm/components/agent-builder/components/RestApiToolPanel.js +172 -185
  86. package/dist/esm/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
  87. package/dist/esm/components/agent-builder/components/SelectableListSection.js +73 -69
  88. package/dist/esm/components/agent-builder/components/SelectableListSection.js.map +1 -1
  89. package/dist/esm/components/agent-builder/components/ToolInstructionsField.d.ts +0 -9
  90. package/dist/esm/components/agent-builder/components/ToolInstructionsField.js +48 -67
  91. package/dist/esm/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
  92. package/dist/esm/components/agent-builder/constants/tools.d.ts +21 -1
  93. package/dist/esm/components/agent-builder/constants/tools.js +33 -23
  94. package/dist/esm/components/agent-builder/constants/tools.js.map +1 -1
  95. package/dist/esm/components/agent-builder/context/AgentBuilderContext.d.ts +0 -7
  96. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js +96 -99
  97. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
  98. package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js +272 -261
  99. package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
  100. package/dist/esm/components/agent-builder/utils/mentionSerialization.d.ts +4 -14
  101. package/dist/esm/components/agent-builder/utils/mentionSerialization.js +36 -54
  102. package/dist/esm/components/agent-builder/utils/mentionSerialization.js.map +1 -1
  103. package/dist/esm/components/agent-builder/utils/sourceIcons.d.ts +6 -6
  104. package/dist/esm/components/agent-builder/utils/sourceIcons.js +21 -19
  105. package/dist/esm/components/agent-builder/utils/sourceIcons.js.map +1 -1
  106. package/dist/esm/components/agent-listing/AgentTableRow.js +26 -23
  107. package/dist/esm/components/agent-listing/AgentTableRow.js.map +1 -1
  108. package/dist/esm/components/agent-listing/AiAgentsEmptyState.js +3 -2
  109. package/dist/esm/components/agent-listing/AiAgentsEmptyState.js.map +1 -1
  110. package/dist/esm/components/variable-picker-v3/Content.js +15 -16
  111. package/dist/esm/components/variable-picker-v3/Content.js.map +1 -1
  112. package/dist/esm/components/zeroState/ZeroState.d.ts +2 -0
  113. package/dist/esm/components/zeroState/ZeroState.js +18 -17
  114. package/dist/esm/components/zeroState/ZeroState.js.map +1 -1
  115. package/dist/esm/editor/BikEditor.js +229 -222
  116. package/dist/esm/editor/BikEditor.js.map +1 -1
  117. package/dist/esm/editor/BikEditor.styles.js +14 -16
  118. package/dist/esm/editor/BikEditor.styles.js.map +1 -1
  119. package/dist/esm/editor/BikEditor.types.d.ts +0 -9
  120. package/dist/esm/editor/BikEditor.types.js.map +1 -1
  121. package/dist/esm/editor/extensions/jsonHighlight/JsonHighlightExtension.js +62 -60
  122. package/dist/esm/editor/extensions/jsonHighlight/JsonHighlightExtension.js.map +1 -1
  123. package/dist/esm/editor/extensions/mention/MentionDropdown.js +28 -28
  124. package/dist/esm/editor/extensions/mention/MentionDropdown.js.map +1 -1
  125. package/dist/esm/editor/extensions/mention/MentionExtension.js +19 -23
  126. package/dist/esm/editor/extensions/mention/MentionExtension.js.map +1 -1
  127. package/dist/esm/icons/index.d.ts +25 -25
  128. package/dist/esm/index.js +541 -543
  129. package/dist/esm/index.js.map +1 -1
  130. package/package.json +1 -1
  131. package/dist/cjs/components/add-variableV2/AddDataPill.js +0 -10
  132. package/dist/cjs/components/add-variableV2/AddDataPill.js.map +0 -1
  133. package/dist/cjs/components/agent-builder/components/VariableInlineField.js +0 -65
  134. package/dist/cjs/components/agent-builder/components/VariableInlineField.js.map +0 -1
  135. package/dist/cjs/components/agent-builder/components/VariableTriggerArea.js +0 -10
  136. package/dist/cjs/components/agent-builder/components/VariableTriggerArea.js.map +0 -1
  137. package/dist/esm/components/add-variableV2/AddDataPill.d.ts +0 -24
  138. package/dist/esm/components/add-variableV2/AddDataPill.js +0 -33
  139. package/dist/esm/components/add-variableV2/AddDataPill.js.map +0 -1
  140. package/dist/esm/components/agent-builder/components/VariableInlineField.d.ts +0 -26
  141. package/dist/esm/components/agent-builder/components/VariableInlineField.js +0 -149
  142. package/dist/esm/components/agent-builder/components/VariableInlineField.js.map +0 -1
  143. package/dist/esm/components/agent-builder/components/VariableTriggerArea.d.ts +0 -46
  144. package/dist/esm/components/agent-builder/components/VariableTriggerArea.js +0 -118
  145. package/dist/esm/components/agent-builder/components/VariableTriggerArea.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.853-beta.0",
3
+ "version": "0.0.853",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,10 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("../../assets/icons/plus.svg.js"),o=require("styled-components"),s=require("./AddVariableBox.styled.js"),n=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},r=n(o),c=({onOpen:t,label:d="Add data",...a})=>e.jsx(u,{type:"button","data-test":a["data-test"]??"add-data-pill",onMouseDown:l=>l.preventDefault(),onClick:t,children:e.jsxs("div",{className:"add",children:[e.jsx(i.default,{width:16,height:16,color:"white"}),e.jsx("div",{children:d})]})}),u=r.default(s.AddVariableStyled)`
2
- bottom: -30px;
3
- z-index: 20;
4
- white-space: nowrap;
5
-
6
- .add {
7
- gap: 4px;
8
- }
9
- `;exports.AddDataPill=c;
10
- //# sourceMappingURL=AddDataPill.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AddDataPill.js","sources":["../../../../src/components/add-variableV2/AddDataPill.tsx"],"sourcesContent":["import PlusIcon from '@src/assets/icons/plus.svg';\nimport React from 'react';\nimport styled from 'styled-components';\nimport { AddVariableStyled } from './AddVariableBox.styled';\n\ninterface AddDataPillProps {\n\t/** Open the reference / variable menu (same as typing `@` in the field). */\n\tonOpen: () => void;\n\t/**\n\t * Button text. \"Add data\" (default) where `@` opens the full reference menu\n\t * (tools / sub-agents / variables); pass \"Add variable\" where `@` opens the\n\t * variable picker directly.\n\t */\n\tlabel?: string;\n\t'data-test'?: string;\n}\n\n/**\n * The floating \"+ Add data\" affordance shown at a focused field's bottom-right\n * corner. Reuses the dashboard's standard Add-variable button styling\n * ({@link AddVariableStyled}, as used by `InputWithVariables`). The parent\n * anchors it: render inside a `position: relative` container.\n *\n * `onMouseDown` is swallowed so clicking never blurs the field — the pill is\n * typically shown only while the field has focus, and the menu inserts at the\n * field's caret.\n */\nexport const AddDataPill: React.FC<AddDataPillProps> = ({\n\tonOpen,\n\tlabel = 'Add data',\n\t...rest\n}) => (\n\t<PillStyled\n\t\ttype=\"button\"\n\t\tdata-test={rest['data-test'] ?? 'add-data-pill'}\n\t\tonMouseDown={(e) => e.preventDefault()}\n\t\tonClick={onOpen}\n\t>\n\t\t<div className=\"add\">\n\t\t\t{/* svgr strips svg dimensions — size explicitly or it renders huge. */}\n\t\t\t<PlusIcon width={16} height={16} color=\"white\" />\n\t\t\t<div>{label}</div>\n\t\t</div>\n\t</PillStyled>\n);\n\nconst PillStyled = styled(AddVariableStyled)`\n\tbottom: -30px;\n\tz-index: 20;\n\twhite-space: nowrap;\n\n\t.add {\n\t\tgap: 4px;\n\t}\n`;\n"],"names":["AddDataPill","onOpen","label","rest","jsx","PillStyled","e","jsxs","PlusIcon","styled","AddVariableStyled"],"mappings":"uSA2BaA,EAA0C,CAAC,CACvD,OAAAC,EACA,MAAAC,EAAQ,WACR,GAAGC,CACJ,IACCC,EAAAA,IAACC,EAAA,CACA,KAAK,SACL,YAAWF,EAAK,WAAW,GAAK,gBAChC,YAAcG,GAAMA,EAAE,eAAA,EACtB,QAASL,EAET,SAAAM,EAAAA,KAAC,MAAA,CAAI,UAAU,MAEd,SAAA,CAAAH,MAACI,EAAAA,SAAS,MAAO,GAAI,OAAQ,GAAI,MAAM,QAAQ,EAC/CJ,EAAAA,IAAC,OAAK,SAAAF,CAAA,CAAM,CAAA,CAAA,CACb,CAAA,CACD,EAGKG,EAAaI,EAAAA,QAAOC,mBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA"}
@@ -1,65 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),r=require("react"),p=require("styled-components"),x=require("../../TypographyStyle.js"),l=require("../../../constants/Theme.js"),o=require("../utils/mentionSerialization.js"),v=require("./MentionPicker.js"),k=require("./VariableTriggerArea.js"),S=require("../../../editor/BikEditor.js"),C=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},w=C(p),T=e=>o.variableTokenName(e).replace(/^variable:/,""),I=({value:e,onChange:c,label:h,placeholder:m,variablesData:n,...f})=>{const s=r.useRef(null),a=(n?.length??0)>0,u=r.useMemo(()=>o.buildVariableMentionItems(n),[n]),b=r.useMemo(()=>o.instructionsToEditorHtml(e,u),[a]),d=r.useCallback(t=>{s.current?.insertInlineContent(o.buildMentionHtml(t,`{{${t}}}`,"variable"))},[]),g=r.useCallback(t=>d(o.variableTokenName(t.actualValue)),[d]),y=r.useCallback(()=>{const t=s.current?.getJSON()??null;c(o.editorDocToInstructions(t,[]).replace(/\n+/g,""))},[c]);return i.jsxs(M,{children:[h&&i.jsx(x.TitleSmall,{color:l.COLORS.content.primary,children:h}),i.jsx(k.VariableTriggerArea,{variablesData:n,addDataButton:!0,skipNativeBoundaries:!0,onInsert:t=>d(T(t)),children:i.jsx(j,{$atHint:a,"data-test":f["data-test"],children:i.jsx(S.BikEditor,{ref:s,initialContent:b,placeholder:m,minHeight:"20px",maxHeight:"20px",style:{border:"none"},editorStyle:O,onSend:()=>{},sendShortcut:{key:"Enter"},mentions:{agents:u,removeTriggerOnDismiss:!0,renderDropdown:t=>i.jsx(v.MentionPicker,{...t,variablesData:n,onSelectVariable:g})},onChange:y},a?"v1":"v0")})})]})},O={padding:0,fontFamily:"Inter",fontSize:"14px",lineHeight:"20px"},M=w.default.div`
2
- display: flex;
3
- flex-direction: column;
4
- gap: 4px;
5
- width: 100%;
6
- /* In a flex row (header key/value pairs) share the space and allow
7
- shrinking below content width — long values scroll inside the field
8
- instead of widening the row / drawer. */
9
- flex: 1 1 0%;
10
- min-width: 0;
11
- `,j=w.default.div`
12
- /* No global reset in every host — without this, width:100% + padding
13
- overflows the drawer by the padding + border (the reported overflow). */
14
- box-sizing: border-box;
15
- display: flex;
16
- align-items: center;
17
- width: 100%;
18
- min-width: 0;
19
- overflow: hidden;
20
- padding: 6px 12px;
21
- background: ${l.COLORS.surface.standard};
22
- border: 1px solid ${l.COLORS.stroke.primary};
23
- border-radius: 4px;
24
-
25
- /* The editor root is width:100% — cap it so a long value scrolls inside
26
- the ProseMirror line rather than stretching the shell. */
27
- > div {
28
- width: 100%;
29
- min-width: 0;
30
- }
31
-
32
- &:focus-within {
33
- border-color: ${l.COLORS.stroke.brand};
34
- }
35
-
36
- /* While the (empty) field is focused, the placeholder switches to the @
37
- hint — only when a catalog makes @ do anything; unfocused (or without
38
- variables) it shows the field's own placeholder. */
39
- ${e=>e.$atHint&&p.css`
40
- .ProseMirror.ProseMirror-focused p.is-editor-empty:first-child::before {
41
- content: 'Enter text, type @ to add variable';
42
- }
43
- `}
44
-
45
- /* Keep the editor to one visual line; long values scroll horizontally the
46
- way a native input does. */
47
- .ProseMirror {
48
- width: 100%;
49
- max-width: 100%;
50
- white-space: nowrap;
51
- overflow-x: auto;
52
- overflow-y: hidden;
53
- word-break: normal;
54
- scrollbar-width: none;
55
-
56
- &::-webkit-scrollbar {
57
- display: none;
58
- }
59
- }
60
-
61
- .ProseMirror p {
62
- display: inline;
63
- }
64
- `;exports.VariableInlineField=I;
65
- //# sourceMappingURL=VariableInlineField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VariableInlineField.js","sources":["../../../../../src/components/agent-builder/components/VariableInlineField.tsx"],"sourcesContent":["import { BikEditor, BikEditorRef } from '@src/editor';\nimport React, { useCallback, useMemo, useRef } from 'react';\nimport styled, { css } from 'styled-components';\nimport { TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport type {\n\tVariableListInterfaceV3,\n\tVariableV3,\n} from '../../variable-picker-v3/model';\nimport {\n\tbuildMentionHtml,\n\tbuildVariableMentionItems,\n\teditorDocToInstructions,\n\tinstructionsToEditorHtml,\n\tvariableTokenName,\n} from '../utils/mentionSerialization';\nimport { MentionPicker } from './MentionPicker';\nimport { VariableTriggerArea } from './VariableTriggerArea';\n\ninterface VariableInlineFieldProps {\n\t/** Stored string, `{{variable:<name>}}` tokens inline (e.g. a URL). */\n\tvalue: string;\n\tonChange: (text: string) => void;\n\tlabel?: string;\n\tplaceholder?: string;\n\t/** Variable catalog. Absent / empty → behaves as a plain single-line input. */\n\tvariablesData?: VariableListInterfaceV3[];\n\t'data-test'?: string;\n}\n\n/** `{{variable:a.b}}` / `{{a.b}}` → `a.b`. */\nconst nameOf = (token: string): string =>\n\tvariableTokenName(token).replace(/^variable:/, '');\n\n/**\n * Single-line text field whose `{{variable:<name>}}` tokens render as the\n * SAME purple `{{<name>}}` chips as the Instructions / Guardrails editors —\n * BikEditor under the hood, styled like the small `Input`. Used for tool\n * params that mix free text with variables (Request URL, header values).\n *\n * `@` opens the variable panel: after whitespace / at the start via the\n * editor's native mention trigger, after URL/JSON delimiters (`https://@`)\n * via the {@link VariableTriggerArea} wrapper — both render the same\n * {@link MentionPicker}. Enter is swallowed (single-line), and any pasted\n * newlines are dropped on serialize.\n */\nexport const VariableInlineField: React.FC<VariableInlineFieldProps> = ({\n\tvalue,\n\tonChange,\n\tlabel,\n\tplaceholder,\n\tvariablesData,\n\t...rest\n}) => {\n\tconst editorRef = useRef<BikEditorRef>(null);\n\n\tconst hasVariables = (variablesData?.length ?? 0) > 0;\n\tconst mentionItems = useMemo(\n\t\t() => buildVariableMentionItems(variablesData),\n\t\t[variablesData],\n\t);\n\n\t// Initial HTML — the field is uncontrolled after mount (the drawers key\n\t// their fields per open), EXCEPT when the variable catalog first arrives\n\t// (async fetch): the editor re-mounts (keyed below) so stored\n\t// `{{variable:…}}` tokens become chips instead of staying literal text.\n\t// `value` is kept current by onChange, so the re-seed loses nothing.\n\tconst initialHtml = useMemo(\n\t\t() => instructionsToEditorHtml(value, mentionItems),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[hasVariables],\n\t);\n\n\t// Insert the purple `{{<name>}}` chip; serialization emits the stored\n\t// `{{variable:<name>}}` token (same path as the instructions editors).\n\t// Single construction site for BOTH trigger paths (native `@` suggestion\n\t// and the VariableTriggerArea wrapper) so the chip flavor can't diverge.\n\tconst insertChipByName = useCallback((name: string) => {\n\t\teditorRef.current?.insertInlineContent(\n\t\t\tbuildMentionHtml(name, `{{${name}}}`, 'variable'),\n\t\t);\n\t}, []);\n\tconst insertChip = useCallback(\n\t\t(variable: VariableV3) =>\n\t\t\tinsertChipByName(variableTokenName(variable.actualValue)),\n\t\t[insertChipByName],\n\t);\n\n\tconst emitChange = useCallback(() => {\n\t\tconst doc = editorRef.current?.getJSON() ?? null;\n\t\t// Single-line: pasted newlines have no meaning in a URL / header value.\n\t\tonChange(editorDocToInstructions(doc, []).replace(/\\n+/g, ''));\n\t}, [onChange]);\n\n\treturn (\n\t\t<FieldBlockCol>\n\t\t\t{label && <TitleSmall color={COLORS.content.primary}>{label}</TitleSmall>}\n\t\t\t<VariableTriggerArea\n\t\t\t\tvariablesData={variablesData}\n\t\t\t\taddDataButton\n\t\t\t\tskipNativeBoundaries\n\t\t\t\tonInsert={(token) => insertChipByName(nameOf(token))}\n\t\t\t>\n\t\t\t\t<InputShell $atHint={hasVariables} data-test={rest['data-test']}>\n\t\t\t\t\t<BikEditor\n\t\t\t\t\t\tkey={hasVariables ? 'v1' : 'v0'}\n\t\t\t\t\t\tref={editorRef}\n\t\t\t\t\t\tinitialContent={initialHtml}\n\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\tminHeight=\"20px\"\n\t\t\t\t\t\tmaxHeight=\"20px\"\n\t\t\t\t\t\tstyle={{ border: 'none' }}\n\t\t\t\t\t\teditorStyle={INLINE_EDITOR_STYLE}\n\t\t\t\t\t\t// Single-line: Enter is a no-op \"send\".\n\t\t\t\t\t\tonSend={() => undefined}\n\t\t\t\t\t\tsendShortcut={{ key: 'Enter' }}\n\t\t\t\t\t\tmentions={{\n\t\t\t\t\t\t\tagents: mentionItems,\n\t\t\t\t\t\t\tremoveTriggerOnDismiss: true,\n\t\t\t\t\t\t\trenderDropdown: (props) => (\n\t\t\t\t\t\t\t\t<MentionPicker\n\t\t\t\t\t\t\t\t\t{...props}\n\t\t\t\t\t\t\t\t\tvariablesData={variablesData}\n\t\t\t\t\t\t\t\t\tonSelectVariable={insertChip}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonChange={emitChange}\n\t\t\t\t\t/>\n\t\t\t\t</InputShell>\n\t\t\t</VariableTriggerArea>\n\t\t</FieldBlockCol>\n\t);\n};\n\nconst INLINE_EDITOR_STYLE: React.CSSProperties = {\n\tpadding: 0,\n\tfontFamily: 'Inter',\n\tfontSize: '14px',\n\tlineHeight: '20px',\n};\n\nconst FieldBlockCol = styled.div`\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 4px;\n\twidth: 100%;\n\t/* In a flex row (header key/value pairs) share the space and allow\n\t shrinking below content width — long values scroll inside the field\n\t instead of widening the row / drawer. */\n\tflex: 1 1 0%;\n\tmin-width: 0;\n`;\n\n// Mirrors the small Input's box (border, radius, padding, focus ring) around\n// the single-line editor.\nconst InputShell = styled.div<{ $atHint: boolean }>`\n\t/* No global reset in every host — without this, width:100% + padding\n\t overflows the drawer by the padding + border (the reported overflow). */\n\tbox-sizing: border-box;\n\tdisplay: flex;\n\talign-items: center;\n\twidth: 100%;\n\tmin-width: 0;\n\toverflow: hidden;\n\tpadding: 6px 12px;\n\tbackground: ${COLORS.surface.standard};\n\tborder: 1px solid ${COLORS.stroke.primary};\n\tborder-radius: 4px;\n\n\t/* The editor root is width:100% — cap it so a long value scrolls inside\n\t the ProseMirror line rather than stretching the shell. */\n\t> div {\n\t\twidth: 100%;\n\t\tmin-width: 0;\n\t}\n\n\t&:focus-within {\n\t\tborder-color: ${COLORS.stroke.brand};\n\t}\n\n\t/* While the (empty) field is focused, the placeholder switches to the @\n\t hint — only when a catalog makes @ do anything; unfocused (or without\n\t variables) it shows the field's own placeholder. */\n\t${(p) =>\n\t\tp.$atHint &&\n\t\tcss`\n\t\t\t.ProseMirror.ProseMirror-focused p.is-editor-empty:first-child::before {\n\t\t\t\tcontent: 'Enter text, type @ to add variable';\n\t\t\t}\n\t\t`}\n\n\t/* Keep the editor to one visual line; long values scroll horizontally the\n\t way a native input does. */\n\t.ProseMirror {\n\t\twidth: 100%;\n\t\tmax-width: 100%;\n\t\twhite-space: nowrap;\n\t\toverflow-x: auto;\n\t\toverflow-y: hidden;\n\t\tword-break: normal;\n\t\tscrollbar-width: none;\n\n\t\t&::-webkit-scrollbar {\n\t\t\tdisplay: none;\n\t\t}\n\t}\n\n\t.ProseMirror p {\n\t\tdisplay: inline;\n\t}\n`;\n"],"names":["nameOf","token","variableTokenName","VariableInlineField","value","onChange","label","placeholder","variablesData","rest","editorRef","useRef","hasVariables","mentionItems","useMemo","buildVariableMentionItems","initialHtml","instructionsToEditorHtml","insertChipByName","useCallback","name","buildMentionHtml","insertChip","variable","emitChange","doc","editorDocToInstructions","FieldBlockCol","TitleSmall","COLORS","jsx","VariableTriggerArea","InputShell","BikEditor","INLINE_EDITOR_STYLE","props","MentionPicker","styled","p","css"],"mappings":"mdA+BMA,EAAUC,GACfC,EAAAA,kBAAkBD,CAAK,EAAE,QAAQ,aAAc,EAAE,EAcrCE,EAA0D,CAAC,CACvE,MAAAC,EACA,SAAAC,EACA,MAAAC,EACA,YAAAC,EACA,cAAAC,EACA,GAAGC,CACJ,IAAM,CACL,MAAMC,EAAYC,EAAAA,OAA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C,GAAGD,EACJ,cAAA3B,EACA,iBAAkBc,CAAA,CAAA,CACnB,EAGF,SAAUE,CAAA,EAtBLZ,EAAe,KAAO,IAAA,CAuB5B,CACD,CAAA,CAAA,CACD,EACD,CAEF,EAEMsB,EAA2C,CAChD,QAAS,EACT,WAAY,QACZ,SAAU,OACV,WAAY,MACb,EAEMP,EAAgBU,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcvBL,EAAaK,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAUXR,EAAAA,OAAO,QAAQ,QAAQ;AAAA,qBACjBA,EAAAA,OAAO,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAWxBA,EAAAA,OAAO,OAAO,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAMjCS,GACFA,EAAE,SACFC,EAAAA;AAAAA;AAAAA;AAAAA;AAAAA,GAIC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA"}
@@ -1,10 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react/jsx-runtime"),i=require("react"),A=require("styled-components"),D=require("../../add-variableV2/AddDataPill.js"),P=require("../utils/mentionSerialization.js"),L=require("./MentionPicker.js"),M=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},y=M(A),E=t=>`{{variable:${P.variableTokenName(t.actualValue)}}}`,h=/[\s,;:/?&=({[<"']/,j=/[,;:/?&=({[<"']/,k=(t,u,d)=>{if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){const a=t.selectionStart??t.value.length,c=a===0,n=c?" ":t.value[a-1]??" ";return{ok:c?!d:u.test(n),caret:a}}const l=window.getSelection(),f=l?.anchorNode?.textContent??"",g=l?.anchorOffset??0,r=g===0,m=r?" ":f[g-1]??" ";return{ok:r?!d:u.test(m),caret:null}},q=({variablesData:t,onInsert:u,addDataButton:d,skipNativeBoundaries:l,onOpenChange:f,children:g})=>{const r=i.useRef(null),[m,a]=i.useState(!1),c=i.useRef(null),[n,x]=i.useState(null),b=(t?.length??0)>0,T=e=>{x(e),f?.(!0)},p=()=>{x(null),f?.(!1)},w=()=>{const e=r.current?.getBoundingClientRect();return{above:!!e&&window.innerHeight-e.bottom<385,alignRight:!!e&&window.innerWidth-e.left<360}},R=i.useCallback(e=>{if(!b||e.key!=="@")return;const o=k(e.target,l?j:h,!!l);o.ok&&(e.preventDefault(),e.stopPropagation(),T({caret:o.caret,...w()}))},[b]),S=()=>{const e=k(c.current,h,!1);T({caret:e.caret,...w()})};return i.useEffect(()=>{if(!n)return;const e=s=>{s.key==="Escape"&&(s.stopPropagation(),p())},o=s=>{r.current?.contains(s.target)||p()};return document.addEventListener("keydown",e,!0),document.addEventListener("mousedown",o),()=>{document.removeEventListener("keydown",e,!0),document.removeEventListener("mousedown",o)}},[n]),v.jsxs(F,{ref:r,onKeyDownCapture:R,onFocus:e=>{e.target.closest?.('[data-test="variable-trigger-panel"]')||(c.current=e.target,a(!0))},onBlur:()=>a(!1),children:[g,d&&b&&(m||n)&&v.jsx(D.AddDataPill,{label:"Add variable",onOpen:S}),n&&v.jsx($,{$above:n.above,$right:n.alignRight,"data-test":"variable-trigger-panel",onMouseDown:e=>{e.target.closest("input")||e.preventDefault()},children:v.jsx(L.MentionPicker,{items:[],query:"",activeIndex:-1,onSelect:()=>{},onClose:p,variablesData:t,onSelectVariable:e=>{p();const o=c.current,s=o instanceof HTMLInputElement||o instanceof HTMLTextAreaElement?o.selectionStart??n.caret:n.caret;u(E(e),s)}})})]})},F=y.default.div`
2
- position: relative;
3
- `,$=y.default.div`
4
- position: absolute;
5
- z-index: 1000;
6
- width: 344px;
7
- ${t=>t.$right?"right: 0;":"left: 0;"}
8
- ${t=>t.$above?"bottom: calc(100% + 4px);":"top: calc(100% + 4px);"}
9
- `;exports.VariableTriggerArea=q;exports.variableToken=E;
10
- //# sourceMappingURL=VariableTriggerArea.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VariableTriggerArea.js","sources":["../../../../../src/components/agent-builder/components/VariableTriggerArea.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { AddDataPill } from '../../add-variableV2/AddDataPill';\nimport type {\n\tVariableListInterfaceV3,\n\tVariableV3,\n} from '../../variable-picker-v3/model';\nimport { variableTokenName } from '../utils/mentionSerialization';\nimport { MentionPicker } from './MentionPicker';\n\n/** The persisted form of a picked variable (`{{variable:<name>}}`). */\nexport const variableToken = (variable: VariableV3): string =>\n\t`{{variable:${variableTokenName(variable.actualValue)}}}`;\n\n/**\n * Boundary test for the `@` trigger: an `@` typed at the start of the field or\n * after a separator opens the picker. The separator set covers URL and JSON\n * delimiters too (`https://@`, `Bearer=@`, `\"@`, `[@`) — an email address's `@`\n * always follows a letter / digit / dot, so `john@acme.com` still types\n * through untouched. Returns the caret index for input / textarea targets\n * (where the caller can splice the token in), null for contenteditable ones.\n */\n// Opening delimiters trigger; closing ones (`}` `)` `]` `>`) deliberately do\n// NOT — typing a literal `@` right after an inserted `{{token}}` (e.g.\n// `{{store_name}}@acme.com`) must stay literal.\nconst BOUNDARY = /[\\s,;:/?&=({[<\"']/;\n// The subset the editor's own `@` mention trigger does NOT handle (it only\n// fires after whitespace / at the start) — used by `skipNativeBoundaries`\n// fields so the two triggers never fire for the same keystroke.\nconst NON_NATIVE_BOUNDARY = /[,;:/?&=({[<\"']/;\n\nconst triggerContext = (\n\ttarget: EventTarget | null,\n\tboundary: RegExp,\n\tskipStart: boolean,\n): { ok: boolean; caret: number | null } => {\n\tif (\n\t\ttarget instanceof HTMLInputElement ||\n\t\ttarget instanceof HTMLTextAreaElement\n\t) {\n\t\tconst caret = target.selectionStart ?? target.value.length;\n\t\tconst atStart = caret === 0;\n\t\tconst prev = atStart ? ' ' : target.value[caret - 1] ?? ' ';\n\t\treturn { ok: atStart ? !skipStart : boundary.test(prev), caret };\n\t}\n\t// Rich editor (ProseMirror contenteditable): read the character before the\n\t// selection.\n\tconst sel = window.getSelection();\n\tconst text = sel?.anchorNode?.textContent ?? '';\n\tconst offset = sel?.anchorOffset ?? 0;\n\tconst atStart = offset === 0;\n\tconst prev = atStart ? ' ' : text[offset - 1] ?? ' ';\n\treturn { ok: atStart ? !skipStart : boundary.test(prev), caret: null };\n};\n\ninterface VariableTriggerAreaProps {\n\t/** Variable catalog. Absent / empty → the wrapper is inert (children only). */\n\tvariablesData?: VariableListInterfaceV3[];\n\t/**\n\t * Insert `token` into the wrapped field. `caret` is the character index the\n\t * `@` was typed at (input / textarea targets — splice the token in there);\n\t * null for rich-editor targets (insert at the editor's own cursor).\n\t */\n\tonInsert: (token: string, caret: number | null) => void;\n\t/**\n\t * Show the floating \"+ Add data\" pill while the wrapped field is focused.\n\t * Clicking it opens this same variable panel at the field's caret — the\n\t * button equivalent of typing `@`.\n\t */\n\taddDataButton?: boolean;\n\t/**\n\t * The wrapped field is a BikEditor whose OWN `@` mention trigger already\n\t * fires after whitespace / at the start — this wrapper then only handles\n\t * the delimiter boundaries the native trigger misses (`https://@`, `\"@`…),\n\t * so the two never open a panel for the same keystroke.\n\t */\n\tskipNativeBoundaries?: boolean;\n\t/**\n\t * Observes the panel's open state. Fields that commit on blur (the email\n\t * chips entry) use this to hold off while focus is bouncing through the\n\t * panel — blur-time focus targets are unreliable mid-transition.\n\t */\n\tonOpenChange?: (open: boolean) => void;\n\tchildren: React.ReactNode;\n}\n\n/**\n * Wraps any plain field (input / textarea / chips entry / BikEditor) and opens\n * the shared {@link VariablePicker} as a floating panel when `@` is typed at a\n * word boundary. The `@` keystroke itself is swallowed (never reaches the\n * field); picking a variable calls `onInsert` with the `{{variable:<name>}}`\n * token, and Escape / click-outside / the panel's ✕ just closes the panel.\n *\n * Purely presentational wrapper — it renders a `position: relative` block, so\n * the wrapped field must be happy inside a plain block container.\n */\nexport const VariableTriggerArea: React.FC<VariableTriggerAreaProps> = ({\n\tvariablesData,\n\tonInsert,\n\taddDataButton,\n\tskipNativeBoundaries,\n\tonOpenChange,\n\tchildren,\n}) => {\n\tconst containerRef = useRef<HTMLDivElement>(null);\n\t// Whether the wrapped field (any focusable inside) currently has focus, and\n\t// the element that had it — the pill inserts at that element's caret.\n\tconst [fieldFocused, setFieldFocused] = useState(false);\n\tconst lastFocusedRef = useRef<EventTarget | null>(null);\n\t// Non-null while the panel is open: where to put the token when picked, and\n\t// which way the panel flips to stay on screen (above when there's no room\n\t// below, right-aligned when the field sits too close to the right edge —\n\t// e.g. header-value inputs in the Rest API drawer).\n\tconst [trigger, setTrigger] = useState<{\n\t\tcaret: number | null;\n\t\tabove: boolean;\n\t\talignRight: boolean;\n\t} | null>(null);\n\n\tconst enabled = (variablesData?.length ?? 0) > 0;\n\n\tconst openPanel = (t: NonNullable<typeof trigger>) => {\n\t\tsetTrigger(t);\n\t\tonOpenChange?.(true);\n\t};\n\tconst closePanel = () => {\n\t\tsetTrigger(null);\n\t\tonOpenChange?.(false);\n\t};\n\n\t// Panel is ~344px wide / ~385px tall (the MentionPicker card in its\n\t// variables view, plus a little slack), anchored to the field's left edge —\n\t// flip above / right-align when it would spill past the viewport (avoids\n\t// the drawer growing scrollbars).\n\tconst placement = () => {\n\t\tconst rect = containerRef.current?.getBoundingClientRect();\n\t\treturn {\n\t\t\tabove: !!rect && window.innerHeight - rect.bottom < 385,\n\t\t\talignRight: !!rect && window.innerWidth - rect.left < 360,\n\t\t};\n\t};\n\n\tconst onKeyDownCapture = useCallback(\n\t\t(e: React.KeyboardEvent) => {\n\t\t\tif (!enabled || e.key !== '@') {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst ctx = triggerContext(\n\t\t\t\te.target,\n\t\t\t\tskipNativeBoundaries ? NON_NATIVE_BOUNDARY : BOUNDARY,\n\t\t\t\t!!skipNativeBoundaries,\n\t\t\t);\n\t\t\tif (!ctx.ok) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Swallow the `@` so the field's value stays untouched while picking.\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\topenPanel({ caret: ctx.caret, ...placement() });\n\t\t},\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[enabled],\n\t);\n\n\t// The pill's click — same panel, anchored at the focused field's caret (no\n\t// boundary rule: an explicit button click is always intentional).\n\tconst openFromButton = () => {\n\t\tconst ctx = triggerContext(lastFocusedRef.current, BOUNDARY, false);\n\t\topenPanel({ caret: ctx.caret, ...placement() });\n\t};\n\n\t// Escape / click-outside dismiss, active only while open.\n\tuseEffect(() => {\n\t\tif (!trigger) {\n\t\t\treturn;\n\t\t}\n\t\tconst onKey = (e: KeyboardEvent) => {\n\t\t\tif (e.key === 'Escape') {\n\t\t\t\te.stopPropagation();\n\t\t\t\tclosePanel();\n\t\t\t}\n\t\t};\n\t\tconst onDown = (e: MouseEvent) => {\n\t\t\tif (!containerRef.current?.contains(e.target as Node)) {\n\t\t\t\tclosePanel();\n\t\t\t}\n\t\t};\n\t\t// Capture phase so an Escape meant for the panel never also closes the\n\t\t// drawer underneath.\n\t\tdocument.addEventListener('keydown', onKey, true);\n\t\tdocument.addEventListener('mousedown', onDown);\n\t\treturn () => {\n\t\t\tdocument.removeEventListener('keydown', onKey, true);\n\t\t\tdocument.removeEventListener('mousedown', onDown);\n\t\t};\n\t}, [trigger]);\n\n\treturn (\n\t\t<TriggerWrap\n\t\t\tref={containerRef}\n\t\t\tonKeyDownCapture={onKeyDownCapture}\n\t\t\t// React's focus/blur bubble — this tracks any focusable child (the\n\t\t\t// input, a chips entry, the ProseMirror contenteditable).\n\t\t\tonFocus={(e) => {\n\t\t\t\t// Focus landing inside the floating panel (its search box) is not\n\t\t\t\t// the field — inserting at \"its caret\" would target the wrong input.\n\t\t\t\tif (\n\t\t\t\t\t(e.target as HTMLElement).closest?.(\n\t\t\t\t\t\t'[data-test=\"variable-trigger-panel\"]',\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlastFocusedRef.current = e.target;\n\t\t\t\tsetFieldFocused(true);\n\t\t\t}}\n\t\t\tonBlur={() => setFieldFocused(false)}\n\t\t>\n\t\t\t{children}\n\t\t\t{addDataButton && enabled && (fieldFocused || trigger) && (\n\t\t\t\t<AddDataPill label=\"Add variable\" onOpen={openFromButton} />\n\t\t\t)}\n\t\t\t{trigger && (\n\t\t\t\t<FloaterBox\n\t\t\t\t\t$above={trigger.above}\n\t\t\t\t\t$right={trigger.alignRight}\n\t\t\t\t\tdata-test=\"variable-trigger-panel\"\n\t\t\t\t\t// Keep the field focused while clicking rows (a blur mid-pick\n\t\t\t\t\t// would e.g. commit a half-typed email chip). The panel's own\n\t\t\t\t\t// inputs (search) still take focus normally.\n\t\t\t\t\tonMouseDown={(e) => {\n\t\t\t\t\t\tconst t = e.target as HTMLElement;\n\t\t\t\t\t\tif (!t.closest('input')) {\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{/* The EXACT panel the Instructions / Guardrails @ opens: with no\n\t\t\t\t\t tools / sub-agents, Variables is its sole category, so it\n\t\t\t\t\t renders the \"Variables\" header + variable list directly. */}\n\t\t\t\t\t<MentionPicker\n\t\t\t\t\t\titems={[]}\n\t\t\t\t\t\tquery=\"\"\n\t\t\t\t\t\tactiveIndex={-1}\n\t\t\t\t\t\tonSelect={() => undefined}\n\t\t\t\t\t\tonClose={closePanel}\n\t\t\t\t\t\tvariablesData={variablesData}\n\t\t\t\t\t\tonSelectVariable={(variable: VariableV3) => {\n\t\t\t\t\t\t\tclosePanel();\n\t\t\t\t\t\t\t// Re-read the caret at PICK time: the user may have clicked\n\t\t\t\t\t\t\t// elsewhere in the field since the `@` (the panel stays open\n\t\t\t\t\t\t\t// for clicks inside the wrapper), and an input keeps its\n\t\t\t\t\t\t\t// selection while unfocused — trigger.caret is the fallback.\n\t\t\t\t\t\t\tconst el = lastFocusedRef.current;\n\t\t\t\t\t\t\tconst caret =\n\t\t\t\t\t\t\t\tel instanceof HTMLInputElement ||\n\t\t\t\t\t\t\t\tel instanceof HTMLTextAreaElement\n\t\t\t\t\t\t\t\t\t? el.selectionStart ?? trigger.caret\n\t\t\t\t\t\t\t\t\t: trigger.caret;\n\t\t\t\t\t\t\tonInsert(variableToken(variable), caret);\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t</FloaterBox>\n\t\t\t)}\n\t\t</TriggerWrap>\n\t);\n};\n\nconst TriggerWrap = styled.div`\n\tposition: relative;\n`;\n\n// Floats under (or over) the wrapped field; the MentionPicker inside brings\n// its own card chrome (same as the Instructions / Guardrails @ menu). High\n// z-index: these fields live inside side-modal drawers.\nconst FloaterBox = styled.div<{ $above: boolean; $right: boolean }>`\n\tposition: absolute;\n\tz-index: 1000;\n\twidth: 344px;\n\t${(p) => (p.$right ? 'right: 0;' : 'left: 0;')}\n\t${(p) => (p.$above ? 'bottom: calc(100% + 4px);' : 'top: calc(100% + 4px);')}\n`;\n"],"names":["variableToken","variable","variableTokenName","BOUNDARY","NON_NATIVE_BOUNDARY","triggerContext","target","boundary","skipStart","caret","atStart","prev","sel","text","offset","VariableTriggerArea","variablesData","onInsert","addDataButton","skipNativeBoundaries","onOpenChange","children","containerRef","useRef","fieldFocused","setFieldFocused","useState","lastFocusedRef","trigger","setTrigger","enabled","openPanel","t","closePanel","placement","rect","onKeyDownCapture","useCallback","ctx","openFromButton","useEffect","onKey","e","onDown","jsxs","TriggerWrap","AddDataPill","jsx","FloaterBox","MentionPicker","el","styled","p"],"mappings":"qWAWaA,EAAiBC,GAC7B,cAAcC,EAAAA,kBAAkBD,EAAS,WAAW,CAAC,KAahDE,EAAW,oBAIXC,EAA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,YAAc,GAAM,CACT,EAAE,OACL,QAAQ,OAAO,GACrB,EAAE,eAAA,CAEJ,EAKA,SAAAmB,EAAAA,IAACE,EAAAA,cAAA,CACA,MAAO,CAAA,EACP,MAAM,GACN,YAAa,GACb,SAAU,IAAA,GACV,QAAShB,EACT,cAAAjB,EACA,iBAAmBf,GAAyB,CAC3CgC,EAAA,EAKA,MAAMiB,EAAKvB,EAAe,QACpBlB,EACLyC,aAAc,kBACdA,aAAc,oBACXA,EAAG,gBAAkBtB,EAAQ,MAC7BA,EAAQ,MACZX,EAASjB,EAAcC,CAAQ,EAAGQ,CAAK,CACxC,CAAA,CAAA,CACD,CAAA,CACD,CAAA,CAAA,CAIJ,EAEMoC,EAAcM,EAAAA,QAAO;AAAA;AAAA,EAOrBH,EAAaG,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA,GAItBC,GAAOA,EAAE,OAAS,YAAc,UAAW;AAAA,GAC3CA,GAAOA,EAAE,OAAS,4BAA8B,wBAAyB;AAAA"}
@@ -1,24 +0,0 @@
1
- import { default as React } from 'react';
2
- interface AddDataPillProps {
3
- /** Open the reference / variable menu (same as typing `@` in the field). */
4
- onOpen: () => void;
5
- /**
6
- * Button text. "Add data" (default) where `@` opens the full reference menu
7
- * (tools / sub-agents / variables); pass "Add variable" where `@` opens the
8
- * variable picker directly.
9
- */
10
- label?: string;
11
- 'data-test'?: string;
12
- }
13
- /**
14
- * The floating "+ Add data" affordance shown at a focused field's bottom-right
15
- * corner. Reuses the dashboard's standard Add-variable button styling
16
- * ({@link AddVariableStyled}, as used by `InputWithVariables`). The parent
17
- * anchors it: render inside a `position: relative` container.
18
- *
19
- * `onMouseDown` is swallowed so clicking never blurs the field — the pill is
20
- * typically shown only while the field has focus, and the menu inserts at the
21
- * field's caret.
22
- */
23
- export declare const AddDataPill: React.FC<AddDataPillProps>;
24
- export {};
@@ -1,33 +0,0 @@
1
- import { jsx as t, jsxs as i } from "react/jsx-runtime";
2
- import l from "../../assets/icons/plus.svg.js";
3
- import r from "styled-components";
4
- import { AddVariableStyled as p } from "./AddVariableBox.styled.js";
5
- const x = ({
6
- onOpen: d,
7
- label: a = "Add data",
8
- ...e
9
- }) => /* @__PURE__ */ t(
10
- s,
11
- {
12
- type: "button",
13
- "data-test": e["data-test"] ?? "add-data-pill",
14
- onMouseDown: (o) => o.preventDefault(),
15
- onClick: d,
16
- children: /* @__PURE__ */ i("div", { className: "add", children: [
17
- /* @__PURE__ */ t(l, { width: 16, height: 16, color: "white" }),
18
- /* @__PURE__ */ t("div", { children: a })
19
- ] })
20
- }
21
- ), s = r(p)`
22
- bottom: -30px;
23
- z-index: 20;
24
- white-space: nowrap;
25
-
26
- .add {
27
- gap: 4px;
28
- }
29
- `;
30
- export {
31
- x as AddDataPill
32
- };
33
- //# sourceMappingURL=AddDataPill.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AddDataPill.js","sources":["../../../../src/components/add-variableV2/AddDataPill.tsx"],"sourcesContent":["import PlusIcon from '@src/assets/icons/plus.svg';\nimport React from 'react';\nimport styled from 'styled-components';\nimport { AddVariableStyled } from './AddVariableBox.styled';\n\ninterface AddDataPillProps {\n\t/** Open the reference / variable menu (same as typing `@` in the field). */\n\tonOpen: () => void;\n\t/**\n\t * Button text. \"Add data\" (default) where `@` opens the full reference menu\n\t * (tools / sub-agents / variables); pass \"Add variable\" where `@` opens the\n\t * variable picker directly.\n\t */\n\tlabel?: string;\n\t'data-test'?: string;\n}\n\n/**\n * The floating \"+ Add data\" affordance shown at a focused field's bottom-right\n * corner. Reuses the dashboard's standard Add-variable button styling\n * ({@link AddVariableStyled}, as used by `InputWithVariables`). The parent\n * anchors it: render inside a `position: relative` container.\n *\n * `onMouseDown` is swallowed so clicking never blurs the field — the pill is\n * typically shown only while the field has focus, and the menu inserts at the\n * field's caret.\n */\nexport const AddDataPill: React.FC<AddDataPillProps> = ({\n\tonOpen,\n\tlabel = 'Add data',\n\t...rest\n}) => (\n\t<PillStyled\n\t\ttype=\"button\"\n\t\tdata-test={rest['data-test'] ?? 'add-data-pill'}\n\t\tonMouseDown={(e) => e.preventDefault()}\n\t\tonClick={onOpen}\n\t>\n\t\t<div className=\"add\">\n\t\t\t{/* svgr strips svg dimensions — size explicitly or it renders huge. */}\n\t\t\t<PlusIcon width={16} height={16} color=\"white\" />\n\t\t\t<div>{label}</div>\n\t\t</div>\n\t</PillStyled>\n);\n\nconst PillStyled = styled(AddVariableStyled)`\n\tbottom: -30px;\n\tz-index: 20;\n\twhite-space: nowrap;\n\n\t.add {\n\t\tgap: 4px;\n\t}\n`;\n"],"names":["AddDataPill","onOpen","label","rest","jsx","PillStyled","e","jsxs","PlusIcon","styled","AddVariableStyled"],"mappings":";;;;AA2BO,MAAMA,IAA0C,CAAC;AAAA,EACvD,QAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,GAAGC;AACJ,MACC,gBAAAC;AAAA,EAACC;AAAA,EAAA;AAAA,IACA,MAAK;AAAA,IACL,aAAWF,EAAK,WAAW,KAAK;AAAA,IAChC,aAAa,CAACG,MAAMA,EAAE,eAAA;AAAA,IACtB,SAASL;AAAA,IAET,UAAA,gBAAAM,EAAC,OAAA,EAAI,WAAU,OAEd,UAAA;AAAA,MAAA,gBAAAH,EAACI,KAAS,OAAO,IAAI,QAAQ,IAAI,OAAM,SAAQ;AAAA,MAC/C,gBAAAJ,EAAC,SAAK,UAAAF,EAAA,CAAM;AAAA,IAAA,EAAA,CACb;AAAA,EAAA;AACD,GAGKG,IAAaI,EAAOC,CAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
@@ -1,26 +0,0 @@
1
- import { default as React } from 'react';
2
- import { VariableListInterfaceV3 } from '../../variable-picker-v3/model';
3
- interface VariableInlineFieldProps {
4
- /** Stored string, `{{variable:<name>}}` tokens inline (e.g. a URL). */
5
- value: string;
6
- onChange: (text: string) => void;
7
- label?: string;
8
- placeholder?: string;
9
- /** Variable catalog. Absent / empty → behaves as a plain single-line input. */
10
- variablesData?: VariableListInterfaceV3[];
11
- 'data-test'?: string;
12
- }
13
- /**
14
- * Single-line text field whose `{{variable:<name>}}` tokens render as the
15
- * SAME purple `{{<name>}}` chips as the Instructions / Guardrails editors —
16
- * BikEditor under the hood, styled like the small `Input`. Used for tool
17
- * params that mix free text with variables (Request URL, header values).
18
- *
19
- * `@` opens the variable panel: after whitespace / at the start via the
20
- * editor's native mention trigger, after URL/JSON delimiters (`https://@`)
21
- * via the {@link VariableTriggerArea} wrapper — both render the same
22
- * {@link MentionPicker}. Enter is swallowed (single-line), and any pasted
23
- * newlines are dropped on serialize.
24
- */
25
- export declare const VariableInlineField: React.FC<VariableInlineFieldProps>;
26
- export {};
@@ -1,149 +0,0 @@
1
- import { jsxs as y, jsx as i } from "react/jsx-runtime";
2
- import { useRef as v, useMemo as p, useCallback as d } from "react";
3
- import m, { css as k } from "styled-components";
4
- import { TitleSmall as I } from "../../TypographyStyle.js";
5
- import { COLORS as r } from "../../../constants/Theme.js";
6
- import { buildVariableMentionItems as S, instructionsToEditorHtml as M, buildMentionHtml as T, variableTokenName as u, editorDocToInstructions as C } from "../utils/mentionSerialization.js";
7
- import { MentionPicker as H } from "./MentionPicker.js";
8
- import { VariableTriggerArea as E } from "./VariableTriggerArea.js";
9
- import { BikEditor as N } from "../../../editor/BikEditor.js";
10
- const $ = (t) => u(t).replace(/^variable:/, ""), J = ({
11
- value: t,
12
- onChange: a,
13
- label: h,
14
- placeholder: w,
15
- variablesData: o,
16
- ...f
17
- }) => {
18
- const n = v(null), l = (o?.length ?? 0) > 0, c = p(
19
- () => S(o),
20
- [o]
21
- ), g = p(
22
- () => M(t, c),
23
- // eslint-disable-next-line react-hooks/exhaustive-deps
24
- [l]
25
- ), s = d((e) => {
26
- n.current?.insertInlineContent(
27
- T(e, `{{${e}}}`, "variable")
28
- );
29
- }, []), b = d(
30
- (e) => s(u(e.actualValue)),
31
- [s]
32
- ), x = d(() => {
33
- const e = n.current?.getJSON() ?? null;
34
- a(C(e, []).replace(/\n+/g, ""));
35
- }, [a]);
36
- return /* @__PURE__ */ y(P, { children: [
37
- h && /* @__PURE__ */ i(I, { color: r.content.primary, children: h }),
38
- /* @__PURE__ */ i(
39
- E,
40
- {
41
- variablesData: o,
42
- addDataButton: !0,
43
- skipNativeBoundaries: !0,
44
- onInsert: (e) => s($(e)),
45
- children: /* @__PURE__ */ i(V, { $atHint: l, "data-test": f["data-test"], children: /* @__PURE__ */ i(
46
- N,
47
- {
48
- ref: n,
49
- initialContent: g,
50
- placeholder: w,
51
- minHeight: "20px",
52
- maxHeight: "20px",
53
- style: { border: "none" },
54
- editorStyle: O,
55
- onSend: () => {
56
- },
57
- sendShortcut: { key: "Enter" },
58
- mentions: {
59
- agents: c,
60
- removeTriggerOnDismiss: !0,
61
- renderDropdown: (e) => /* @__PURE__ */ i(
62
- H,
63
- {
64
- ...e,
65
- variablesData: o,
66
- onSelectVariable: b
67
- }
68
- )
69
- },
70
- onChange: x
71
- },
72
- l ? "v1" : "v0"
73
- ) })
74
- }
75
- )
76
- ] });
77
- }, O = {
78
- padding: 0,
79
- fontFamily: "Inter",
80
- fontSize: "14px",
81
- lineHeight: "20px"
82
- }, P = m.div`
83
- display: flex;
84
- flex-direction: column;
85
- gap: 4px;
86
- width: 100%;
87
- /* In a flex row (header key/value pairs) share the space and allow
88
- shrinking below content width — long values scroll inside the field
89
- instead of widening the row / drawer. */
90
- flex: 1 1 0%;
91
- min-width: 0;
92
- `, V = m.div`
93
- /* No global reset in every host — without this, width:100% + padding
94
- overflows the drawer by the padding + border (the reported overflow). */
95
- box-sizing: border-box;
96
- display: flex;
97
- align-items: center;
98
- width: 100%;
99
- min-width: 0;
100
- overflow: hidden;
101
- padding: 6px 12px;
102
- background: ${r.surface.standard};
103
- border: 1px solid ${r.stroke.primary};
104
- border-radius: 4px;
105
-
106
- /* The editor root is width:100% — cap it so a long value scrolls inside
107
- the ProseMirror line rather than stretching the shell. */
108
- > div {
109
- width: 100%;
110
- min-width: 0;
111
- }
112
-
113
- &:focus-within {
114
- border-color: ${r.stroke.brand};
115
- }
116
-
117
- /* While the (empty) field is focused, the placeholder switches to the @
118
- hint — only when a catalog makes @ do anything; unfocused (or without
119
- variables) it shows the field's own placeholder. */
120
- ${(t) => t.$atHint && k`
121
- .ProseMirror.ProseMirror-focused p.is-editor-empty:first-child::before {
122
- content: 'Enter text, type @ to add variable';
123
- }
124
- `}
125
-
126
- /* Keep the editor to one visual line; long values scroll horizontally the
127
- way a native input does. */
128
- .ProseMirror {
129
- width: 100%;
130
- max-width: 100%;
131
- white-space: nowrap;
132
- overflow-x: auto;
133
- overflow-y: hidden;
134
- word-break: normal;
135
- scrollbar-width: none;
136
-
137
- &::-webkit-scrollbar {
138
- display: none;
139
- }
140
- }
141
-
142
- .ProseMirror p {
143
- display: inline;
144
- }
145
- `;
146
- export {
147
- J as VariableInlineField
148
- };
149
- //# sourceMappingURL=VariableInlineField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VariableInlineField.js","sources":["../../../../../src/components/agent-builder/components/VariableInlineField.tsx"],"sourcesContent":["import { BikEditor, BikEditorRef } from '@src/editor';\nimport React, { useCallback, useMemo, useRef } from 'react';\nimport styled, { css } from 'styled-components';\nimport { TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport type {\n\tVariableListInterfaceV3,\n\tVariableV3,\n} from '../../variable-picker-v3/model';\nimport {\n\tbuildMentionHtml,\n\tbuildVariableMentionItems,\n\teditorDocToInstructions,\n\tinstructionsToEditorHtml,\n\tvariableTokenName,\n} from '../utils/mentionSerialization';\nimport { MentionPicker } from './MentionPicker';\nimport { VariableTriggerArea } from './VariableTriggerArea';\n\ninterface VariableInlineFieldProps {\n\t/** Stored string, `{{variable:<name>}}` tokens inline (e.g. a URL). */\n\tvalue: string;\n\tonChange: (text: string) => void;\n\tlabel?: string;\n\tplaceholder?: string;\n\t/** Variable catalog. Absent / empty → behaves as a plain single-line input. */\n\tvariablesData?: VariableListInterfaceV3[];\n\t'data-test'?: string;\n}\n\n/** `{{variable:a.b}}` / `{{a.b}}` → `a.b`. */\nconst nameOf = (token: string): string =>\n\tvariableTokenName(token).replace(/^variable:/, '');\n\n/**\n * Single-line text field whose `{{variable:<name>}}` tokens render as the\n * SAME purple `{{<name>}}` chips as the Instructions / Guardrails editors —\n * BikEditor under the hood, styled like the small `Input`. Used for tool\n * params that mix free text with variables (Request URL, header values).\n *\n * `@` opens the variable panel: after whitespace / at the start via the\n * editor's native mention trigger, after URL/JSON delimiters (`https://@`)\n * via the {@link VariableTriggerArea} wrapper — both render the same\n * {@link MentionPicker}. Enter is swallowed (single-line), and any pasted\n * newlines are dropped on serialize.\n */\nexport const VariableInlineField: React.FC<VariableInlineFieldProps> = ({\n\tvalue,\n\tonChange,\n\tlabel,\n\tplaceholder,\n\tvariablesData,\n\t...rest\n}) => {\n\tconst editorRef = useRef<BikEditorRef>(null);\n\n\tconst hasVariables = (variablesData?.length ?? 0) > 0;\n\tconst mentionItems = useMemo(\n\t\t() => buildVariableMentionItems(variablesData),\n\t\t[variablesData],\n\t);\n\n\t// Initial HTML — the field is uncontrolled after mount (the drawers key\n\t// their fields per open), EXCEPT when the variable catalog first arrives\n\t// (async fetch): the editor re-mounts (keyed below) so stored\n\t// `{{variable:…}}` tokens become chips instead of staying literal text.\n\t// `value` is kept current by onChange, so the re-seed loses nothing.\n\tconst initialHtml = useMemo(\n\t\t() => instructionsToEditorHtml(value, mentionItems),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[hasVariables],\n\t);\n\n\t// Insert the purple `{{<name>}}` chip; serialization emits the stored\n\t// `{{variable:<name>}}` token (same path as the instructions editors).\n\t// Single construction site for BOTH trigger paths (native `@` suggestion\n\t// and the VariableTriggerArea wrapper) so the chip flavor can't diverge.\n\tconst insertChipByName = useCallback((name: string) => {\n\t\teditorRef.current?.insertInlineContent(\n\t\t\tbuildMentionHtml(name, `{{${name}}}`, 'variable'),\n\t\t);\n\t}, []);\n\tconst insertChip = useCallback(\n\t\t(variable: VariableV3) =>\n\t\t\tinsertChipByName(variableTokenName(variable.actualValue)),\n\t\t[insertChipByName],\n\t);\n\n\tconst emitChange = useCallback(() => {\n\t\tconst doc = editorRef.current?.getJSON() ?? null;\n\t\t// Single-line: pasted newlines have no meaning in a URL / header value.\n\t\tonChange(editorDocToInstructions(doc, []).replace(/\\n+/g, ''));\n\t}, [onChange]);\n\n\treturn (\n\t\t<FieldBlockCol>\n\t\t\t{label && <TitleSmall color={COLORS.content.primary}>{label}</TitleSmall>}\n\t\t\t<VariableTriggerArea\n\t\t\t\tvariablesData={variablesData}\n\t\t\t\taddDataButton\n\t\t\t\tskipNativeBoundaries\n\t\t\t\tonInsert={(token) => insertChipByName(nameOf(token))}\n\t\t\t>\n\t\t\t\t<InputShell $atHint={hasVariables} data-test={rest['data-test']}>\n\t\t\t\t\t<BikEditor\n\t\t\t\t\t\tkey={hasVariables ? 'v1' : 'v0'}\n\t\t\t\t\t\tref={editorRef}\n\t\t\t\t\t\tinitialContent={initialHtml}\n\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\tminHeight=\"20px\"\n\t\t\t\t\t\tmaxHeight=\"20px\"\n\t\t\t\t\t\tstyle={{ border: 'none' }}\n\t\t\t\t\t\teditorStyle={INLINE_EDITOR_STYLE}\n\t\t\t\t\t\t// Single-line: Enter is a no-op \"send\".\n\t\t\t\t\t\tonSend={() => undefined}\n\t\t\t\t\t\tsendShortcut={{ key: 'Enter' }}\n\t\t\t\t\t\tmentions={{\n\t\t\t\t\t\t\tagents: mentionItems,\n\t\t\t\t\t\t\tremoveTriggerOnDismiss: true,\n\t\t\t\t\t\t\trenderDropdown: (props) => (\n\t\t\t\t\t\t\t\t<MentionPicker\n\t\t\t\t\t\t\t\t\t{...props}\n\t\t\t\t\t\t\t\t\tvariablesData={variablesData}\n\t\t\t\t\t\t\t\t\tonSelectVariable={insertChip}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonChange={emitChange}\n\t\t\t\t\t/>\n\t\t\t\t</InputShell>\n\t\t\t</VariableTriggerArea>\n\t\t</FieldBlockCol>\n\t);\n};\n\nconst INLINE_EDITOR_STYLE: React.CSSProperties = {\n\tpadding: 0,\n\tfontFamily: 'Inter',\n\tfontSize: '14px',\n\tlineHeight: '20px',\n};\n\nconst FieldBlockCol = styled.div`\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 4px;\n\twidth: 100%;\n\t/* In a flex row (header key/value pairs) share the space and allow\n\t shrinking below content width — long values scroll inside the field\n\t instead of widening the row / drawer. */\n\tflex: 1 1 0%;\n\tmin-width: 0;\n`;\n\n// Mirrors the small Input's box (border, radius, padding, focus ring) around\n// the single-line editor.\nconst InputShell = styled.div<{ $atHint: boolean }>`\n\t/* No global reset in every host — without this, width:100% + padding\n\t overflows the drawer by the padding + border (the reported overflow). */\n\tbox-sizing: border-box;\n\tdisplay: flex;\n\talign-items: center;\n\twidth: 100%;\n\tmin-width: 0;\n\toverflow: hidden;\n\tpadding: 6px 12px;\n\tbackground: ${COLORS.surface.standard};\n\tborder: 1px solid ${COLORS.stroke.primary};\n\tborder-radius: 4px;\n\n\t/* The editor root is width:100% — cap it so a long value scrolls inside\n\t the ProseMirror line rather than stretching the shell. */\n\t> div {\n\t\twidth: 100%;\n\t\tmin-width: 0;\n\t}\n\n\t&:focus-within {\n\t\tborder-color: ${COLORS.stroke.brand};\n\t}\n\n\t/* While the (empty) field is focused, the placeholder switches to the @\n\t hint — only when a catalog makes @ do anything; unfocused (or without\n\t variables) it shows the field's own placeholder. */\n\t${(p) =>\n\t\tp.$atHint &&\n\t\tcss`\n\t\t\t.ProseMirror.ProseMirror-focused p.is-editor-empty:first-child::before {\n\t\t\t\tcontent: 'Enter text, type @ to add variable';\n\t\t\t}\n\t\t`}\n\n\t/* Keep the editor to one visual line; long values scroll horizontally the\n\t way a native input does. */\n\t.ProseMirror {\n\t\twidth: 100%;\n\t\tmax-width: 100%;\n\t\twhite-space: nowrap;\n\t\toverflow-x: auto;\n\t\toverflow-y: hidden;\n\t\tword-break: normal;\n\t\tscrollbar-width: none;\n\n\t\t&::-webkit-scrollbar {\n\t\t\tdisplay: none;\n\t\t}\n\t}\n\n\t.ProseMirror p {\n\t\tdisplay: inline;\n\t}\n`;\n"],"names":["nameOf","token","variableTokenName","VariableInlineField","value","onChange","label","placeholder","variablesData","rest","editorRef","useRef","hasVariables","mentionItems","useMemo","buildVariableMentionItems","initialHtml","instructionsToEditorHtml","insertChipByName","useCallback","name","buildMentionHtml","insertChip","variable","emitChange","doc","editorDocToInstructions","FieldBlockCol","TitleSmall","COLORS","jsx","VariableTriggerArea","InputShell","BikEditor","INLINE_EDITOR_STYLE","props","MentionPicker","styled","p","css"],"mappings":";;;;;;;;;AA+BA,MAAMA,IAAS,CAACC,MACfC,EAAkBD,CAAK,EAAE,QAAQ,cAAc,EAAE,GAcrCE,IAA0D,CAAC;AAAA,EACvE,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,eAAAC;AAAA,EACA,GAAGC;AACJ,MAAM;AACL,QAAMC,IAAYC,EAAqB,IAAI,GAErCC,KAAgBJ,GAAe,UAAU,KAAK,GAC9CK,IAAeC;AAAA,IACpB,MAAMC,EAA0BP,CAAa;AAAA,IAC7C,CAACA,CAAa;AAAA,EAAA,GAQTQ,IAAcF;AAAA,IACnB,MAAMG,EAAyBb,GAAOS,CAAY;AAAA;AAAA,IAElD,CAACD,CAAY;AAAA,EAAA,GAORM,IAAmBC,EAAY,CAACC,MAAiB;AACtD,IAAAV,EAAU,SAAS;AAAA,MAClBW,EAAiBD,GAAM,KAAKA,CAAI,MAAM,UAAU;AAAA,IAAA;AAAA,EAElD,GAAG,CAAA,CAAE,GACCE,IAAaH;AAAA,IAClB,CAACI,MACAL,EAAiBhB,EAAkBqB,EAAS,WAAW,CAAC;AAAA,IACzD,CA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,UAAU;AAAA,EACV,YAAY;AACb,GAEMP,IAAgBU,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAcvBL,IAAaK,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAUXR,EAAO,QAAQ,QAAQ;AAAA,qBACjBA,EAAO,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAWxBA,EAAO,OAAO,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAMlC,CAACS,MACFA,EAAE,WACFC;AAAA;AAAA;AAAA;AAAA,GAIC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
@@ -1,46 +0,0 @@
1
- import { default as React } from 'react';
2
- import { VariableListInterfaceV3, VariableV3 } from '../../variable-picker-v3/model';
3
- /** The persisted form of a picked variable (`{{variable:<name>}}`). */
4
- export declare const variableToken: (variable: VariableV3) => string;
5
- interface VariableTriggerAreaProps {
6
- /** Variable catalog. Absent / empty → the wrapper is inert (children only). */
7
- variablesData?: VariableListInterfaceV3[];
8
- /**
9
- * Insert `token` into the wrapped field. `caret` is the character index the
10
- * `@` was typed at (input / textarea targets — splice the token in there);
11
- * null for rich-editor targets (insert at the editor's own cursor).
12
- */
13
- onInsert: (token: string, caret: number | null) => void;
14
- /**
15
- * Show the floating "+ Add data" pill while the wrapped field is focused.
16
- * Clicking it opens this same variable panel at the field's caret — the
17
- * button equivalent of typing `@`.
18
- */
19
- addDataButton?: boolean;
20
- /**
21
- * The wrapped field is a BikEditor whose OWN `@` mention trigger already
22
- * fires after whitespace / at the start — this wrapper then only handles
23
- * the delimiter boundaries the native trigger misses (`https://@`, `"@`…),
24
- * so the two never open a panel for the same keystroke.
25
- */
26
- skipNativeBoundaries?: boolean;
27
- /**
28
- * Observes the panel's open state. Fields that commit on blur (the email
29
- * chips entry) use this to hold off while focus is bouncing through the
30
- * panel — blur-time focus targets are unreliable mid-transition.
31
- */
32
- onOpenChange?: (open: boolean) => void;
33
- children: React.ReactNode;
34
- }
35
- /**
36
- * Wraps any plain field (input / textarea / chips entry / BikEditor) and opens
37
- * the shared {@link VariablePicker} as a floating panel when `@` is typed at a
38
- * word boundary. The `@` keystroke itself is swallowed (never reaches the
39
- * field); picking a variable calls `onInsert` with the `{{variable:<name>}}`
40
- * token, and Escape / click-outside / the panel's ✕ just closes the panel.
41
- *
42
- * Purely presentational wrapper — it renders a `position: relative` block, so
43
- * the wrapped field must be happy inside a plain block container.
44
- */
45
- export declare const VariableTriggerArea: React.FC<VariableTriggerAreaProps>;
46
- export {};
@@ -1,118 +0,0 @@
1
- import { jsxs as y, jsx as v } from "react/jsx-runtime";
2
- import { useRef as h, useState as T, useCallback as D, useEffect as F } from "react";
3
- import A from "styled-components";
4
- import { AddDataPill as S } from "../../add-variableV2/AddDataPill.js";
5
- import { variableTokenName as $ } from "../utils/mentionSerialization.js";
6
- import { MentionPicker as M } from "./MentionPicker.js";
7
- const N = (e) => `{{variable:${$(e.actualValue)}}}`, E = /[\s,;:/?&=({[<"']/, P = /[,;:/?&=({[<"']/, k = (e, l, u) => {
8
- if (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement) {
9
- const c = e.selectionStart ?? e.value.length, a = c === 0, n = a ? " " : e.value[c - 1] ?? " ";
10
- return { ok: a ? !u : l.test(n), caret: c };
11
- }
12
- const i = window.getSelection(), d = i?.anchorNode?.textContent ?? "", f = i?.anchorOffset ?? 0, r = f === 0, p = r ? " " : d[f - 1] ?? " ";
13
- return { ok: r ? !u : l.test(p), caret: null };
14
- }, U = ({
15
- variablesData: e,
16
- onInsert: l,
17
- addDataButton: u,
18
- skipNativeBoundaries: i,
19
- onOpenChange: d,
20
- children: f
21
- }) => {
22
- const r = h(null), [p, c] = T(!1), a = h(null), [n, b] = T(null), g = (e?.length ?? 0) > 0, x = (t) => {
23
- b(t), d?.(!0);
24
- }, m = () => {
25
- b(null), d?.(!1);
26
- }, w = () => {
27
- const t = r.current?.getBoundingClientRect();
28
- return {
29
- above: !!t && window.innerHeight - t.bottom < 385,
30
- alignRight: !!t && window.innerWidth - t.left < 360
31
- };
32
- }, L = D(
33
- (t) => {
34
- if (!g || t.key !== "@")
35
- return;
36
- const o = k(
37
- t.target,
38
- i ? P : E,
39
- !!i
40
- );
41
- o.ok && (t.preventDefault(), t.stopPropagation(), x({ caret: o.caret, ...w() }));
42
- },
43
- // eslint-disable-next-line react-hooks/exhaustive-deps
44
- [g]
45
- ), R = () => {
46
- const t = k(a.current, E, !1);
47
- x({ caret: t.caret, ...w() });
48
- };
49
- return F(() => {
50
- if (!n)
51
- return;
52
- const t = (s) => {
53
- s.key === "Escape" && (s.stopPropagation(), m());
54
- }, o = (s) => {
55
- r.current?.contains(s.target) || m();
56
- };
57
- return document.addEventListener("keydown", t, !0), document.addEventListener("mousedown", o), () => {
58
- document.removeEventListener("keydown", t, !0), document.removeEventListener("mousedown", o);
59
- };
60
- }, [n]), /* @__PURE__ */ y(
61
- B,
62
- {
63
- ref: r,
64
- onKeyDownCapture: L,
65
- onFocus: (t) => {
66
- t.target.closest?.(
67
- '[data-test="variable-trigger-panel"]'
68
- ) || (a.current = t.target, c(!0));
69
- },
70
- onBlur: () => c(!1),
71
- children: [
72
- f,
73
- u && g && (p || n) && /* @__PURE__ */ v(S, { label: "Add variable", onOpen: R }),
74
- n && /* @__PURE__ */ v(
75
- C,
76
- {
77
- $above: n.above,
78
- $right: n.alignRight,
79
- "data-test": "variable-trigger-panel",
80
- onMouseDown: (t) => {
81
- t.target.closest("input") || t.preventDefault();
82
- },
83
- children: /* @__PURE__ */ v(
84
- M,
85
- {
86
- items: [],
87
- query: "",
88
- activeIndex: -1,
89
- onSelect: () => {
90
- },
91
- onClose: m,
92
- variablesData: e,
93
- onSelectVariable: (t) => {
94
- m();
95
- const o = a.current, s = o instanceof HTMLInputElement || o instanceof HTMLTextAreaElement ? o.selectionStart ?? n.caret : n.caret;
96
- l(N(t), s);
97
- }
98
- }
99
- )
100
- }
101
- )
102
- ]
103
- }
104
- );
105
- }, B = A.div`
106
- position: relative;
107
- `, C = A.div`
108
- position: absolute;
109
- z-index: 1000;
110
- width: 344px;
111
- ${(e) => e.$right ? "right: 0;" : "left: 0;"}
112
- ${(e) => e.$above ? "bottom: calc(100% + 4px);" : "top: calc(100% + 4px);"}
113
- `;
114
- export {
115
- U as VariableTriggerArea,
116
- N as variableToken
117
- };
118
- //# sourceMappingURL=VariableTriggerArea.js.map