@ant-design/agentic-ui 2.29.43 → 2.29.45

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.
@@ -61,6 +61,7 @@ function _unsupported_iterable_to_array(o, minLen) {
61
61
  if (n === "Map" || n === "Set") return Array.from(n);
62
62
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
63
63
  }
64
+ import { CloseOutlined } from "@ant-design/icons";
64
65
  import { Info } from "@sofa-design/icons";
65
66
  import { ConfigProvider } from "antd";
66
67
  import classNames from "clsx";
@@ -71,32 +72,37 @@ import { Editor, Transforms } from "slate";
71
72
  import { ReactEditor } from "slate-react";
72
73
  import { useLocale } from "../../../../I18n";
73
74
  import { useEditorStore } from "../../store";
74
- import { getOffsetLeft } from "../../utils/dom";
75
75
  import { EditorUtils } from "../../utils/editorUtils";
76
76
  import { JINJA_PANEL_PREFIX_CLS, useJinjaTemplatePanelStyle } from "./style";
77
77
  import { getJinjaTemplateData, JINJA_DOC_LINK } from "./templates";
78
78
  var PANEL_MAX_HEIGHT = 320;
79
+ var PANEL_MIN_WIDTH = 240;
79
80
  function getPosition(nodeEl) {
80
81
  var rect = nodeEl.getBoundingClientRect();
81
- var left = getOffsetLeft(nodeEl, document.body) + 0;
82
- var top = rect.bottom + window.scrollY;
82
+ var viewportWidth = document.documentElement.clientWidth;
83
83
  var viewportHeight = document.documentElement.clientHeight;
84
84
  var spaceBelow = viewportHeight - rect.bottom;
85
- if (spaceBelow < PANEL_MAX_HEIGHT && rect.top > PANEL_MAX_HEIGHT) {
85
+ var spaceAbove = rect.top;
86
+ var left = rect.left;
87
+ left = Math.max(0, Math.min(left, viewportWidth - PANEL_MIN_WIDTH));
88
+ if (spaceBelow < PANEL_MAX_HEIGHT && spaceAbove > PANEL_MAX_HEIGHT) {
86
89
  return {
87
90
  left: left,
88
- bottom: viewportHeight - rect.top
91
+ bottom: Math.min(viewportHeight - rect.top, viewportHeight - PANEL_MAX_HEIGHT),
92
+ position: 'fixed'
89
93
  };
90
94
  }
95
+ var top = Math.min(rect.bottom, viewportHeight - PANEL_MAX_HEIGHT);
91
96
  return {
92
97
  left: left,
93
- top: top
98
+ top: top,
99
+ position: 'fixed'
94
100
  };
95
101
  }
96
102
  export var JinjaTemplatePanel = function JinjaTemplatePanel() {
97
103
  var _ref, _ref1, _ref2, _ref3;
98
104
  var _context_getPrefixCls;
99
- var _useEditorStore = useEditorStore(), markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef, openJinjaTemplate = _useEditorStore.openJinjaTemplate, setOpenJinjaTemplate = _useEditorStore.setOpenJinjaTemplate, jinjaAnchorPath = _useEditorStore.jinjaAnchorPath, setJinjaAnchorPath = _useEditorStore.setJinjaAnchorPath, editorProps = _useEditorStore.editorProps;
105
+ var _useEditorStore = useEditorStore(), markdownEditorRef = _useEditorStore.markdownEditorRef, openJinjaTemplate = _useEditorStore.openJinjaTemplate, setOpenJinjaTemplate = _useEditorStore.setOpenJinjaTemplate, jinjaAnchorPath = _useEditorStore.jinjaAnchorPath, setJinjaAnchorPath = _useEditorStore.setJinjaAnchorPath, editorProps = _useEditorStore.editorProps;
100
106
  var jinjaConfig = editorProps === null || editorProps === void 0 ? void 0 : editorProps.jinja;
101
107
  var templatePanelConfig = (jinjaConfig === null || jinjaConfig === void 0 ? void 0 : jinjaConfig.templatePanel) && _type_of(jinjaConfig.templatePanel) === 'object' ? jinjaConfig.templatePanel : undefined;
102
108
  var trigger = (_ref = templatePanelConfig === null || templatePanelConfig === void 0 ? void 0 : templatePanelConfig.trigger) !== null && _ref !== void 0 ? _ref : '{}';
@@ -113,7 +119,8 @@ export var JinjaTemplatePanel = function JinjaTemplatePanel() {
113
119
  var _useState1 = _sliced_to_array(useState(false), 2), loading = _useState1[0], setLoading = _useState1[1];
114
120
  var _useState2 = _sliced_to_array(useState(0), 2), activeIndex = _useState2[0], setActiveIndex = _useState2[1];
115
121
  var _useState3 = _sliced_to_array(useState({
116
- left: 0
122
+ left: 0,
123
+ position: 'fixed'
117
124
  }), 2), position = _useState3[0], setPosition = _useState3[1];
118
125
  var domRef = useRef(null);
119
126
  var context = React.useContext(ConfigProvider.ConfigContext);
@@ -177,7 +184,8 @@ export var JinjaTemplatePanel = function JinjaTemplatePanel() {
177
184
  }
178
185
  } catch (unused) {
179
186
  setPosition({
180
- left: 0
187
+ left: 0,
188
+ position: 'fixed'
181
189
  });
182
190
  }
183
191
  }, [
@@ -261,14 +269,16 @@ export var JinjaTemplatePanel = function JinjaTemplatePanel() {
261
269
  insertTemplate
262
270
  ]);
263
271
  useEffect(function() {
264
- var container = markdownContainerRef === null || markdownContainerRef === void 0 ? void 0 : markdownContainerRef.current;
265
- if (!container) return;
266
- container.addEventListener('keydown', keydown);
272
+ if (!openJinjaTemplate) return;
273
+ var handleKeydown = function handleKeydown(e) {
274
+ return keydown(e);
275
+ };
276
+ document.addEventListener('keydown', handleKeydown);
267
277
  return function() {
268
- return container.removeEventListener('keydown', keydown);
278
+ return document.removeEventListener('keydown', handleKeydown);
269
279
  };
270
280
  }, [
271
- markdownContainerRef,
281
+ openJinjaTemplate,
272
282
  keydown
273
283
  ]);
274
284
  useEffect(function() {
@@ -283,7 +293,7 @@ export var JinjaTemplatePanel = function JinjaTemplatePanel() {
283
293
  "aria-label": "Jinja template list",
284
294
  className: classNames(prefixCls, hashId),
285
295
  style: {
286
- position: 'absolute',
296
+ position: position.position,
287
297
  zIndex: 9999,
288
298
  left: position.left,
289
299
  top: position.top,
@@ -298,13 +308,25 @@ export var JinjaTemplatePanel = function JinjaTemplatePanel() {
298
308
  className: "".concat(prefixCls, "-header")
299
309
  }, /*#__PURE__*/ React.createElement("div", {
300
310
  className: "".concat(prefixCls, "-title")
301
- }, locale['jinja.panel.title']), docLink ? /*#__PURE__*/ React.createElement("div", {
311
+ }, locale['jinja.panel.title']), /*#__PURE__*/ React.createElement("div", {
312
+ className: "".concat(prefixCls, "-header-actions")
313
+ }, docLink ? /*#__PURE__*/ React.createElement("div", {
302
314
  className: "".concat(prefixCls, "-doc-link"),
303
315
  onClick: function onClick(e) {
304
316
  e.preventDefault();
305
317
  window.open(docLink, '_blank');
306
318
  }
307
- }, /*#__PURE__*/ React.createElement(Info, null), locale['jinja.panel.docLink']) : null), /*#__PURE__*/ React.createElement("div", {
319
+ }, /*#__PURE__*/ React.createElement(Info, null), locale['jinja.panel.docLink']) : null, /*#__PURE__*/ React.createElement("button", {
320
+ type: "button",
321
+ className: "".concat(prefixCls, "-close"),
322
+ onClick: function onClick(e) {
323
+ e.preventDefault();
324
+ e.stopPropagation();
325
+ close();
326
+ },
327
+ "aria-label": locale['jinja.panel.close'],
328
+ title: locale['jinja.panel.close']
329
+ }, /*#__PURE__*/ React.createElement(CloseOutlined, null)))), /*#__PURE__*/ React.createElement("div", {
308
330
  className: "".concat(prefixCls, "-list-box")
309
331
  }, loading ? /*#__PURE__*/ React.createElement("div", {
310
332
  style: {
@@ -76,7 +76,29 @@ var genJinjaPanelStyle = function genJinjaPanelStyle(token) {
76
76
  padding: '6px 12px',
77
77
  display: 'flex',
78
78
  alignItems: 'center',
79
- justifyContent: 'space-between'
79
+ justifyContent: 'space-between',
80
+ flexShrink: 0
81
+ },
82
+ '&-header-actions': {
83
+ display: 'flex',
84
+ alignItems: 'center',
85
+ gap: 8
86
+ },
87
+ '&-close': {
88
+ display: 'flex',
89
+ alignItems: 'center',
90
+ justifyContent: 'center',
91
+ padding: 4,
92
+ margin: -4,
93
+ border: 'none',
94
+ background: 'transparent',
95
+ cursor: 'pointer',
96
+ color: 'var(--color-gray-text-light, var(--ant-color-text-secondary))',
97
+ borderRadius: token.borderRadiusSM,
98
+ '&:hover': {
99
+ color: 'var(--color-gray-text-default, var(--ant-color-text))',
100
+ backgroundColor: token.colorFillTertiary
101
+ }
80
102
  },
81
103
  '&-title': {
82
104
  font: 'var(--font-text-body-emphasized-sm)',
@@ -231,6 +231,13 @@ export type CustomLeaf<T = Record<string, any>> = {
231
231
  jinjaVariable?: boolean;
232
232
  jinjaTag?: boolean;
233
233
  jinjaComment?: boolean;
234
+ jinjaKeyword?: boolean;
235
+ jinjaString?: boolean;
236
+ jinjaNumber?: boolean;
237
+ jinjaFilter?: boolean;
238
+ jinjaVariableName?: boolean;
239
+ jinjaPlaceholder?: boolean;
240
+ jinjaDelimiter?: boolean;
234
241
  selection?: BaseRange;
235
242
  id?: string;
236
243
  data?: Record<string, any>;
@@ -415,6 +415,7 @@ declare class ChartErrorBoundary extends React.Component<ChartErrorBoundaryProps
415
415
  'refine.optimizePrompt': string;
416
416
  'jinja.panel.title': string;
417
417
  'jinja.panel.docLink': string;
418
+ 'jinja.panel.close': string;
418
419
  'jinja.panel.noTemplates': string;
419
420
  'jinja.template.variableInterpolation.title': string;
420
421
  'jinja.template.variableInterpolation.description': string;
@@ -803,6 +804,7 @@ declare class ChartErrorBoundary extends React.Component<ChartErrorBoundaryProps
803
804
  'refine.optimizePrompt': string;
804
805
  'jinja.panel.title': string;
805
806
  'jinja.panel.docLink': string;
807
+ 'jinja.panel.close': string;
806
808
  'jinja.panel.noTemplates': string;
807
809
  'jinja.template.variableInterpolation.title': string;
808
810
  'jinja.template.variableInterpolation.description': string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/agentic-ui",
3
- "version": "2.29.43",
3
+ "version": "2.29.45",
4
4
  "description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
5
5
  "repository": "git@github.com:ant-design/agentic-ui.git",
6
6
  "license": "MIT",