@progress/kendo-react-diagram 16.2.0-develop.2 → 16.2.0-develop.20

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.
@@ -11,40 +11,40 @@ import { useLocalization as Se } from "@progress/kendo-react-intl";
11
11
  import { TextEditingToolbar as xe } from "./TextEditingToolbar.mjs";
12
12
  import { ShapeEditingToolbar as ve } from "./ShapeEditingToolbar.mjs";
13
13
  import { ConnectionEditingToolbar as we } from "./ConnectionEditingToolbar.mjs";
14
- import { defaultTextToolbarTools as Ce, defaultMainToolbarTools as Pe, defaultShapeToolbarTools as ke, defaultConnectionToolbarTools as Ve } from "./default-toolbar-tools.mjs";
15
- import { getContextToolbarAnchors as X, isDiagramItemVisibleInViewport as Y, EditingUtils as Ae } from "@progress/kendo-diagram-common";
16
- import { MainToolbar as De } from "./MainToolbar.mjs";
17
- import { FloatingToolbarPopup as M } from "./FloatingToolbarPopup.mjs";
18
- import { toolbarPopupWrapClass as R } from "./utils.mjs";
19
- import { useDiagramEditorController as Me, useRegisteredSurfaceRef as N, DiagramEditorProvider as Re } from "./DiagramEditorContext.mjs";
20
- import { placeholder as Z, messages as Ne } from "../messages/index.mjs";
21
- const { pmDocToRTContent: Oe, rtContentToPM: Ke, schemaSpec: ze, styleEditor: Be, scheduleRafCall: ee, recalcVerticalAlign: te } = Ae, ne = new b.Schema(ze), Ie = Ke(b.Node, ne), { imageResizing: Fe } = oe;
14
+ import { defaultTextToolbarTools as Ce, defaultMainToolbarTools as Pe, defaultShapeToolbarTools as ke, defaultConnectionToolbarTools as De } from "./default-toolbar-tools.mjs";
15
+ import { getContextToolbarAnchors as X, isDiagramItemVisibleInViewport as Y, EditingUtils as Ve } from "@progress/kendo-diagram-common";
16
+ import { MainToolbar as Ae } from "./MainToolbar.mjs";
17
+ import { FloatingToolbarPopup as K } from "./FloatingToolbarPopup.mjs";
18
+ import { toolbarPopupWrapClass as z } from "./utils.mjs";
19
+ import { useDiagramEditorController as Me, useRegisteredSurfaceRef as B, DiagramEditorProvider as Ne } from "./DiagramEditorContext.mjs";
20
+ import { placeholder as Z, messages as Re } from "../messages/index.mjs";
21
+ const { pmDocToRTContent: Oe, rtContentToPM: Ke, schemaSpec: ze, styleEditor: Be, scheduleRafCall: ee, recalcVerticalAlign: te } = Ve, ne = new b.Schema(ze), Ie = Ke(b.Node, ne), { imageResizing: Fe } = oe;
22
22
  class Le extends b.EditorView {
23
23
  }
24
- class tt extends b.Node {
24
+ class ot extends b.Node {
25
25
  }
26
26
  const _e = '[tabindex]:not([tabindex="-1"]), button:not([disabled]), .k-dropdownlist, .k-colorpicker', Ue = (i) => {
27
- const r = i.content.firstChild;
28
- return i.childCount === 0 || !!(i.childCount === 1 && (r != null && r.inlineContent) && r.childCount === 0);
29
- }, ot = (i) => {
27
+ const l = i.content.firstChild;
28
+ return i.childCount === 0 || !!(i.childCount === 1 && (l != null && l.inlineContent) && l.childCount === 0);
29
+ }, $e = (i) => {
30
30
  var U, $;
31
- const { diagram: r, toolbars: se = {} } = i, O = {
31
+ const { diagram: l, toolbars: se = {} } = i, v = {
32
32
  position: "top",
33
33
  tools: Pe,
34
34
  shapes: i.shapes
35
- }, K = { tools: ke, shapes: i.shapes }, z = { tools: Ve }, B = {
35
+ }, w = { tools: ke, shapes: i.shapes }, C = { tools: De }, P = {
36
36
  tools: Ce,
37
37
  fontNames: i.fontTypes,
38
38
  fontSizes: i.fontSizes
39
39
  }, {
40
- diagram: v = O,
41
- shape: w = K,
42
- connection: C = z,
43
- text: P = B
44
- } = se, I = typeof v == "boolean" ? v ? O : { position: "top", tools: [] } : v, k = typeof w == "boolean" ? w ? K : { tools: [] } : w, V = typeof C == "boolean" ? C ? z : { tools: [] } : C, F = typeof P == "boolean" ? P ? B : { tools: [] } : P, { controller: n, snapshot: e } = Me(r), ie = N(n), le = N(n), L = N(n), _ = t.useRef(null), [p, A] = t.useState(null), T = t.useRef(null), [c, g] = t.useState(null), s = t.useRef(null), re = Se(), ae = e.editingSession ? `${e.editingSession.target.type}:${e.editingSession.target.id}` : null, ce = t.useCallback(
40
+ diagram: k = v,
41
+ shape: D = w,
42
+ connection: V = C,
43
+ text: A = P
44
+ } = se, I = typeof k == "boolean" ? k ? v : { position: "top", tools: [] } : { ...v, ...k }, M = typeof D == "boolean" ? D ? w : { tools: [] } : { ...w, ...D }, N = typeof V == "boolean" ? V ? C : { tools: [] } : { ...C, ...V }, F = typeof A == "boolean" ? A ? P : { tools: [] } : { ...P, ...A }, { controller: n, snapshot: e } = Me(l), ie = B(n), re = B(n), L = B(n), _ = t.useRef(null), [p, R] = t.useState(null), T = t.useRef(null), [c, g] = t.useState(null), s = t.useRef(null), le = Se(), ae = e.editingSession ? `${e.editingSession.target.type}:${e.editingSession.target.id}` : null, ce = t.useCallback(
45
45
  (o) => {
46
- var l;
47
- (l = s.current) == null || l.call(s), s.current = o && n ? n.registerSurface(o) : null;
46
+ var r;
47
+ (r = s.current) == null || r.call(s), s.current = o && n ? n.registerSurface(o) : null;
48
48
  },
49
49
  [n]
50
50
  ), ue = t.useCallback(
@@ -53,21 +53,21 @@ const _e = '[tabindex]:not([tabindex="-1"]), button:not([disabled]), .k-dropdown
53
53
  },
54
54
  [L]
55
55
  ), de = t.useCallback(() => {
56
- var l;
57
- const o = (l = _.current) == null ? void 0 : l.querySelector(_e);
56
+ var r;
57
+ const o = (r = _.current) == null ? void 0 : r.querySelector(_e);
58
58
  return o ? (o.focus({ preventScroll: !0 }), !0) : !1;
59
59
  }, []);
60
60
  t.useEffect(() => () => {
61
61
  var o;
62
62
  (o = s.current) == null || o.call(s), s.current = null;
63
63
  }, []), t.useLayoutEffect(() => {
64
- var l;
64
+ var r;
65
65
  if (!n || !e.editingSession) {
66
- A(null), T.current = null, g(null), n == null || n.setTextEditingAdapter(null), (l = s.current) == null || l.call(s), s.current = null;
66
+ R(null), T.current = null, g(null), n == null || n.setTextEditingAdapter(null), (r = s.current) == null || r.call(s), s.current = null;
67
67
  return;
68
68
  }
69
69
  const o = Ie(e.editingSession.item._contentVisual.options);
70
- return A(o), T.current = o, g(null), n.setTextEditingAdapter({
70
+ return R(o), T.current = o, g(null), n.setTextEditingAdapter({
71
71
  getCommitPayload: () => {
72
72
  const u = T.current;
73
73
  return u ? {
@@ -80,31 +80,31 @@ const _e = '[tabindex]:not([tabindex="-1"]), button:not([disabled]), .k-dropdown
80
80
  n.setTextEditingAdapter(null);
81
81
  };
82
82
  }, [n, ae, e.editingSession]);
83
- const me = e.editingSession ? e.editingSession.item._contentVisual.options : {}, d = e.selectedShape, m = e.selectedConnection, f = (U = r == null ? void 0 : r.element) != null ? U : null, E = t.useMemo(() => X(d, e.anchors.shape), [d, e.anchors.shape]), y = t.useMemo(() => X(m, e.anchors.connection), [m, e.anchors.connection]), fe = t.useMemo(() => !!(d && E.base && e.visibility.shape && k.tools.length > 0 && Y(d, f)), [
83
+ const me = e.editingSession ? e.editingSession.item._contentVisual.options : {}, d = e.selectedShape, m = e.selectedConnection, f = (U = l == null ? void 0 : l.element) != null ? U : null, E = t.useMemo(() => X(d, e.anchors.shape), [d, e.anchors.shape]), y = t.useMemo(() => X(m, e.anchors.connection), [m, e.anchors.connection]), fe = t.useMemo(() => !!(d && E.base && e.visibility.shape && M.tools.length > 0 && Y(d, f)), [
84
84
  d,
85
85
  E.base,
86
86
  e.visibility.shape,
87
- k.tools.length,
87
+ M.tools.length,
88
88
  f
89
- ]), be = t.useMemo(() => !!(m && y.base && e.visibility.connection && V.tools.length > 0 && Y(m, f)), [
89
+ ]), be = t.useMemo(() => !!(m && y.base && e.visibility.connection && N.tools.length > 0 && Y(m, f)), [
90
90
  m,
91
91
  y.base,
92
92
  e.visibility.connection,
93
- V.tools.length,
93
+ N.tools.length,
94
94
  f
95
95
  ]), pe = (o) => {
96
- A(o.value), T.current = o.value, c && g({ view: c.view });
96
+ R(o.value), T.current = o.value, c && g({ view: c.view });
97
97
  }, ge = (o) => {
98
98
  var j;
99
- const l = o.target;
100
- if (!e.editingSession || !l.element || !n || !p)
99
+ const r = o.target;
100
+ if (!e.editingSession || !r.element || !n || !p)
101
101
  return;
102
- const u = l.element;
102
+ const u = r.element;
103
103
  ce(u);
104
- const { item: S } = e.editingSession, q = S.name === "Shape" ? S._contentVisual.padding() : { top: 0, bottom: 0, left: 0, right: 0 }, D = o.dom, W = re.toLanguageString(Z, Ne[Z]);
104
+ const { item: S } = e.editingSession, q = S.name === "Shape" ? S._contentVisual.padding() : { top: 0, bottom: 0, left: 0, right: 0 }, O = o.dom, W = le.toLanguageString(Z, Re[Z]);
105
105
  let h;
106
106
  const Te = new b.Plugin({
107
- filterTransaction: (x) => (ee(te, [x.doc.attrs.alignment, D, q]), g({ view: h }), !0)
107
+ filterTransaction: (x) => (ee(te, [x.doc.attrs.alignment, O, q]), g({ view: h }), !0)
108
108
  }), Ee = b.EditorState.create({
109
109
  doc: p,
110
110
  schema: ne,
@@ -116,7 +116,7 @@ const _e = '[tabindex]:not([tabindex="-1"]), button:not([disabled]), .k-dropdown
116
116
  ]
117
117
  });
118
118
  return h = new Le(
119
- { mount: D },
119
+ { mount: O },
120
120
  {
121
121
  ...o.viewProps,
122
122
  state: Ee,
@@ -125,40 +125,40 @@ const _e = '[tabindex]:not([tabindex="-1"]), button:not([disabled]), .k-dropdown
125
125
  return a.key === "Escape" ? (n.handleKeyDown(a), a.defaultPrevented || ((H = (G = o.viewProps).handleKeyDown) == null ? void 0 : H.call(G, x, a)) === !0) : a.key === "F10" && a.altKey && de() ? (a.preventDefault(), !0) : (Q = (J = o.viewProps).handleKeyDown) == null ? void 0 : Q.call(J, x, a);
126
126
  }
127
127
  }
128
- ), Be(S, u, W), h.focus(), ee(te, [(j = S.options.content) == null ? void 0 : j.align, D, q]), g({ view: h }), h;
128
+ ), Be(S, u, W), h.focus(), ee(te, [(j = S.options.content) == null ? void 0 : j.align, O, q]), g({ view: h }), h;
129
129
  }, he = t.useCallback(
130
130
  (o) => {
131
131
  o.key !== "Tab" || o.shiftKey || c && (o.preventDefault(), c.view.focus());
132
132
  },
133
133
  [c]
134
134
  );
135
- return n ? /* @__PURE__ */ t.createElement(Re, { value: { controller: n, snapshot: e } }, /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement("div", { style: { position: "relative" } }, /* @__PURE__ */ t.createElement(
136
- De,
135
+ return n ? /* @__PURE__ */ t.createElement(Ne, { value: { controller: n, snapshot: e } }, /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement("div", { style: { position: "relative" } }, /* @__PURE__ */ t.createElement(
136
+ Ae,
137
137
  {
138
- diagram: r,
138
+ diagram: l,
139
139
  visible: e.visibility.main && I.tools.length > 0,
140
140
  ...I
141
141
  }
142
142
  ), /* @__PURE__ */ t.createElement(
143
- M,
143
+ K,
144
144
  {
145
145
  show: fe,
146
146
  baseAnchor: E.base,
147
147
  fallbackAnchor: E.fallback,
148
148
  boundaryElement: f
149
149
  },
150
- /* @__PURE__ */ t.createElement("div", { ref: ie, className: R }, /* @__PURE__ */ t.createElement(ve, { shape: d, ...k }))
150
+ /* @__PURE__ */ t.createElement("div", { ref: ie, className: z }, /* @__PURE__ */ t.createElement(ve, { shape: d, ...M }))
151
151
  ), /* @__PURE__ */ t.createElement(
152
- M,
152
+ K,
153
153
  {
154
154
  show: be,
155
155
  baseAnchor: y.base,
156
156
  fallbackAnchor: y.fallback,
157
157
  boundaryElement: f
158
158
  },
159
- /* @__PURE__ */ t.createElement("div", { ref: le, className: R }, /* @__PURE__ */ t.createElement(we, { connection: m, ...V }))
159
+ /* @__PURE__ */ t.createElement("div", { ref: re, className: z }, /* @__PURE__ */ t.createElement(we, { connection: m, ...N }))
160
160
  ), /* @__PURE__ */ t.createElement(
161
- M,
161
+ K,
162
162
  {
163
163
  show: !!(e.editingSession && c && p && e.anchors.textEditing && e.visibility.textEditing && F.tools.length > 0),
164
164
  baseAnchor: e.anchors.textEditing ? { left: e.anchors.textEditing.x, top: e.anchors.textEditing.y } : null
@@ -167,7 +167,7 @@ const _e = '[tabindex]:not([tabindex="-1"]), button:not([disabled]), .k-dropdown
167
167
  "div",
168
168
  {
169
169
  ref: ue,
170
- className: R,
170
+ className: z,
171
171
  onKeyDown: he
172
172
  },
173
173
  /* @__PURE__ */ t.createElement(
@@ -192,6 +192,7 @@ const _e = '[tabindex]:not([tabindex="-1"]), button:not([disabled]), .k-dropdown
192
192
  }
193
193
  ))) : null;
194
194
  };
195
+ $e.displayName = "KendoDiagramEditor";
195
196
  export {
196
- ot as DiagramEditor
197
+ $e as DiagramEditor
197
198
  };
@@ -17,5 +17,5 @@ interface MainToolbarProps extends MainToolbarOptions {
17
17
  visible?: boolean;
18
18
  }
19
19
  /** @hidden */
20
- export declare const MainToolbar: (props: MainToolbarProps) => React.ReactPortal | null;
20
+ export declare const MainToolbar: (props: MainToolbarProps) => React.JSX.Element | null;
21
21
  export {};
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("react"),B=require("react-dom"),a=require("@progress/kendo-react-buttons"),L=require("@progress/kendo-react-popup"),w=require("@progress/kendo-diagram-common"),u=require("@progress/kendo-svg-icons"),O=require("@progress/kendo-react-intl"),e=require("../messages/index.js"),j=require("./shapes-dropdown.js"),m=require("./utils.js"),f=require("./DiagramEditorContext.js");function U(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const s in n)if(s!=="default"){const p=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(t,s,p.get?p:{enumerable:!0,get:()=>n[s]})}}return t.default=n,Object.freeze(t)}const c=U(D),{floatingToolbarStyle:v}=w.EditingUtils.Data,S=2,z=10,N=n=>{const{diagram:t,tools:s,position:p="top",shapes:h,visible:d=!0}=n,{controller:i,snapshot:T}=f.useDiagramEditorContext(),P=f.useRegisteredSurfaceRef(i),k=f.useDiagramEditorPopupProps("main-toolbar"),r=T.activeTool,x=!!(t&&t.canUndo()),C=!!(t&&t.canRedo()),l=O.useLocalization();c.useEffect(()=>{if(!t)return;const{element:o}=t,y=o.ownerDocument.defaultView;if(!y||y.getComputedStyle(o).position!=="static")return;const M=o.style.position;return o.style.position="relative",()=>{o.style.position=M}},[t]);const g=c.useCallback(o=>{i.dispatch({type:"setActiveTool",tool:o})},[i]),I=o=>{g({type:"insert-shape",shape:o})},E={undo:{component:a.Button,props:{svgIcon:u.undoIcon,fillMode:"flat",onClick:()=>i.execute({type:"undo"}),disabled:!x,title:l.toLanguageString(e.editingUndo,e.messages[e.editingUndo])}},redo:{component:a.Button,props:{svgIcon:u.redoIcon,fillMode:"flat",onClick:()=>i.execute({type:"redo"}),disabled:!C,title:l.toLanguageString(e.editingRedo,e.messages[e.editingRedo])}},select:{component:a.Button,props:{svgIcon:u.pointerIcon,fillMode:"flat",onClick:()=>g({type:"select"}),togglable:!0,selected:r.type==="select",title:l.toLanguageString(e.editingSelect,e.messages[e.editingSelect])}},pan:{component:a.Button,props:{svgIcon:u.handIcon,fillMode:"flat",onClick:()=>g({type:"pan"}),togglable:!0,selected:r.type==="pan",title:l.toLanguageString(e.editingPan,e.messages[e.editingPan])}},text:{component:a.Button,props:{svgIcon:u.freeTextIcon,fillMode:"flat",onClick:()=>g({type:"insert-text"}),togglable:!0,selected:r.type==="insert-text",title:l.toLanguageString(e.editingText,e.messages[e.editingText])}},shape:{component:j.ShapeSelector,props:{onSelect:I,value:r.type==="insert-shape"?r.shape:null,active:r.type==="insert-shape",buttonTitle:l.toLanguageString(e.editingShape,e.messages[e.editingShape]),shapes:h,popupClass:m.mainToolbarPopupClass,overlayOwner:"main-toolbar"}},separator:{component:a.ToolbarSeparator,props:{}}},b=m.mapTools(s,E);if(!t||b.length===0)return null;const R={position:"absolute",left:0,right:0,top:p==="top"?S:void 0,bottom:p==="bottom"?S+z:void 0,display:"flex",justifyContent:"center",pointerEvents:"none",zIndex:1},q={opacity:d?1:0,visibility:d?"visible":"hidden",pointerEvents:d?"auto":"none",transition:d?"opacity 140ms ease":"opacity 140ms ease, visibility 0s linear 140ms",...v};return B.createPortal(c.createElement("div",{style:R,className:"k-animation-container k-animation-container-shown"},c.createElement("div",{ref:P,className:"k-popup k-diagram-top-toolbar-container",style:q,onPointerEnter:()=>i.handlePointerEnter(),onPointerLeave:()=>i.handlePointerLeave()},c.createElement(L.PopupPropsContext.Provider,{value:k},c.createElement(a.Toolbar,{fillMode:"flat",style:v,buttons:m.floatingToolbarButtons},b)))),t.element)};exports.MainToolbar=N;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react"),a=require("@progress/kendo-react-buttons"),y=require("@progress/kendo-react-popup"),E=require("@progress/kendo-diagram-common"),g=require("@progress/kendo-svg-icons"),w=require("@progress/kendo-react-intl"),e=require("../messages/index.js"),O=require("./shapes-dropdown.js"),m=require("./utils.js"),f=require("./DiagramEditorContext.js");function L(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const s in n)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(t,s,r.get?r:{enumerable:!0,get:()=>n[s]})}}return t.default=n,Object.freeze(t)}const i=L(B),{floatingToolbarStyle:S}=E.EditingUtils.Data,v=2,z=10,j={zIndex:1},U={type:"fade",openDuration:140,closeDuration:140},A=n=>{const{diagram:t,tools:s,position:r="top",shapes:h,visible:T=!0}=n,{controller:p,snapshot:P}=f.useDiagramEditorContext(),I=f.useRegisteredSurfaceRef(p),x=f.useDiagramEditorPopupProps("main-toolbar"),l=P.activeTool,C=!!(t&&t.canUndo()),M=!!(t&&t.canRedo()),c=w.useLocalization();i.useEffect(()=>{if(!t)return;const{element:o}=t,u=o.ownerDocument.defaultView;if(!u||u.getComputedStyle(o).position!=="static")return;const q=o.style.position;return o.style.position="relative",()=>{o.style.position=q}},[t]);const d=i.useCallback(o=>{p.dispatch({type:"setActiveTool",tool:o})},[p]),k=o=>{d({type:"insert-shape",shape:o})},R={undo:{component:a.Button,props:{svgIcon:g.undoIcon,fillMode:"flat",onClick:()=>p.execute({type:"undo"}),disabled:!C,title:c.toLanguageString(e.editingUndo,e.messages[e.editingUndo])}},redo:{component:a.Button,props:{svgIcon:g.redoIcon,fillMode:"flat",onClick:()=>p.execute({type:"redo"}),disabled:!M,title:c.toLanguageString(e.editingRedo,e.messages[e.editingRedo])}},select:{component:a.Button,props:{svgIcon:g.pointerIcon,fillMode:"flat",onClick:()=>d({type:"select"}),togglable:!0,selected:l.type==="select",title:c.toLanguageString(e.editingSelect,e.messages[e.editingSelect])}},pan:{component:a.Button,props:{svgIcon:g.handIcon,fillMode:"flat",onClick:()=>d({type:"pan"}),togglable:!0,selected:l.type==="pan",title:c.toLanguageString(e.editingPan,e.messages[e.editingPan])}},text:{component:a.Button,props:{svgIcon:g.freeTextIcon,fillMode:"flat",onClick:()=>d({type:"insert-text"}),togglable:!0,selected:l.type==="insert-text",title:c.toLanguageString(e.editingText,e.messages[e.editingText])}},shape:{component:O.ShapeSelector,props:{onSelect:k,value:l.type==="insert-shape"?l.shape:null,active:l.type==="insert-shape",buttonTitle:c.toLanguageString(e.editingShape,e.messages[e.editingShape]),shapes:h,popupClass:m.mainToolbarPopupClass,overlayOwner:"main-toolbar"}},separator:{component:a.ToolbarSeparator,props:{}}},D=i.useMemo(()=>{const o={horizontal:0,vertical:r==="top"?v:v+z},u={vertical:r,horizontal:"center"};return{anchorAlign:u,popupAlign:{...u},margin:o}},[r]),b=m.mapTools(s,R);return!t||b.length===0?null:i.createElement(y.Popup,{appendTo:t.element,show:T,animate:U,style:j,anchor:t.element,...D},i.createElement("div",{ref:I,style:S},i.createElement(y.PopupPropsContext.Provider,{value:x},i.createElement(a.Toolbar,{fillMode:"flat",style:S,buttons:m.floatingToolbarButtons},b))))};exports.MainToolbar=A;
@@ -5,139 +5,123 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import * as a from "react";
9
- import { createPortal as U } from "react-dom";
10
- import { Toolbar as z, ToolbarSeparator as A, Button as l } from "@progress/kendo-react-buttons";
11
- import { PopupPropsContext as N } from "@progress/kendo-react-popup";
8
+ import * as e from "react";
9
+ import { Toolbar as z, ToolbarSeparator as A, Button as s } from "@progress/kendo-react-buttons";
10
+ import { Popup as B, PopupPropsContext as U } from "@progress/kendo-react-popup";
12
11
  import { EditingUtils as O } from "@progress/kendo-diagram-common";
13
- import { freeTextIcon as W, handIcon as j, pointerIcon as V, redoIcon as q, undoIcon as F } from "@progress/kendo-svg-icons";
12
+ import { freeTextIcon as W, handIcon as V, pointerIcon as j, redoIcon as q, undoIcon as F } from "@progress/kendo-svg-icons";
14
13
  import { useLocalization as G } from "@progress/kendo-react-intl";
15
- import { editingShape as u, messages as r, editingText as g, editingPan as f, editingSelect as y, editingRedo as b, editingUndo as v } from "../messages/index.mjs";
14
+ import { editingShape as g, messages as i, editingText as m, editingPan as d, editingSelect as f, editingRedo as y, editingUndo as b } from "../messages/index.mjs";
16
15
  import { ShapeSelector as H } from "./shapes-dropdown.mjs";
17
- import { mapTools as J, floatingToolbarButtons as K, mainToolbarPopupClass as Q } from "./utils.mjs";
18
- import { useDiagramEditorContext as X, useRegisteredSurfaceRef as Y, useDiagramEditorPopupProps as Z } from "./DiagramEditorContext.mjs";
19
- const { floatingToolbarStyle: h } = O.Data, S = 2, _ = 10, pt = (T) => {
20
- const { diagram: t, tools: P, position: c = "top", shapes: x, visible: s = !0 } = T, { controller: e, snapshot: C } = X(), E = Y(e), I = Z("main-toolbar"), n = C.activeTool, k = !!(t && t.canUndo()), L = !!(t && t.canRedo()), i = G();
21
- a.useEffect(() => {
16
+ import { mapTools as J, floatingToolbarButtons as K, mainToolbarPopupClass as N } from "./utils.mjs";
17
+ import { useDiagramEditorContext as Q, useRegisteredSurfaceRef as X, useDiagramEditorPopupProps as Y } from "./DiagramEditorContext.mjs";
18
+ const { floatingToolbarStyle: h } = O.Data, v = 2, Z = 10, _ = { zIndex: 1 }, $ = { type: "fade", openDuration: 140, closeDuration: 140 }, po = (S) => {
19
+ const { diagram: t, tools: T, position: c = "top", shapes: I, visible: P = !0 } = S, { controller: r, snapshot: x } = Q(), C = X(r), M = Y("main-toolbar"), n = x.activeTool, E = !!(t && t.canUndo()), L = !!(t && t.canRedo()), a = G();
20
+ e.useEffect(() => {
22
21
  if (!t)
23
22
  return;
24
- const { element: o } = t, d = o.ownerDocument.defaultView;
25
- if (!d || d.getComputedStyle(o).position !== "static")
23
+ const { element: o } = t, l = o.ownerDocument.defaultView;
24
+ if (!l || l.getComputedStyle(o).position !== "static")
26
25
  return;
27
26
  const D = o.style.position;
28
27
  return o.style.position = "relative", () => {
29
28
  o.style.position = D;
30
29
  };
31
30
  }, [t]);
32
- const p = a.useCallback(
31
+ const p = e.useCallback(
33
32
  (o) => {
34
- e.dispatch({ type: "setActiveTool", tool: o });
33
+ r.dispatch({ type: "setActiveTool", tool: o });
35
34
  },
36
- [e]
37
- ), M = (o) => {
35
+ [r]
36
+ ), R = (o) => {
38
37
  p({ type: "insert-shape", shape: o });
39
- }, R = {
38
+ }, k = {
40
39
  undo: {
41
- component: l,
40
+ component: s,
42
41
  props: {
43
42
  svgIcon: F,
44
43
  fillMode: "flat",
45
- onClick: () => e.execute({ type: "undo" }),
46
- disabled: !k,
47
- title: i.toLanguageString(v, r[v])
44
+ onClick: () => r.execute({ type: "undo" }),
45
+ disabled: !E,
46
+ title: a.toLanguageString(b, i[b])
48
47
  }
49
48
  },
50
49
  redo: {
51
- component: l,
50
+ component: s,
52
51
  props: {
53
52
  svgIcon: q,
54
53
  fillMode: "flat",
55
- onClick: () => e.execute({ type: "redo" }),
54
+ onClick: () => r.execute({ type: "redo" }),
56
55
  disabled: !L,
57
- title: i.toLanguageString(b, r[b])
56
+ title: a.toLanguageString(y, i[y])
58
57
  }
59
58
  },
60
59
  select: {
61
- component: l,
60
+ component: s,
62
61
  props: {
63
- svgIcon: V,
62
+ svgIcon: j,
64
63
  fillMode: "flat",
65
64
  onClick: () => p({ type: "select" }),
66
65
  togglable: !0,
67
66
  selected: n.type === "select",
68
- title: i.toLanguageString(y, r[y])
67
+ title: a.toLanguageString(f, i[f])
69
68
  }
70
69
  },
71
70
  pan: {
72
- component: l,
71
+ component: s,
73
72
  props: {
74
- svgIcon: j,
73
+ svgIcon: V,
75
74
  fillMode: "flat",
76
75
  onClick: () => p({ type: "pan" }),
77
76
  togglable: !0,
78
77
  selected: n.type === "pan",
79
- title: i.toLanguageString(f, r[f])
78
+ title: a.toLanguageString(d, i[d])
80
79
  }
81
80
  },
82
81
  text: {
83
- component: l,
82
+ component: s,
84
83
  props: {
85
84
  svgIcon: W,
86
85
  fillMode: "flat",
87
86
  onClick: () => p({ type: "insert-text" }),
88
87
  togglable: !0,
89
88
  selected: n.type === "insert-text",
90
- title: i.toLanguageString(g, r[g])
89
+ title: a.toLanguageString(m, i[m])
91
90
  }
92
91
  },
93
92
  shape: {
94
93
  component: H,
95
94
  props: {
96
- onSelect: M,
95
+ onSelect: R,
97
96
  value: n.type === "insert-shape" ? n.shape : null,
98
97
  active: n.type === "insert-shape",
99
- buttonTitle: i.toLanguageString(u, r[u]),
100
- shapes: x,
101
- popupClass: Q,
98
+ buttonTitle: a.toLanguageString(g, i[g]),
99
+ shapes: I,
100
+ popupClass: N,
102
101
  overlayOwner: "main-toolbar"
103
102
  }
104
103
  },
105
104
  separator: { component: A, props: {} }
106
- }, m = J(P, R);
107
- if (!t || m.length === 0)
108
- return null;
109
- const w = {
110
- position: "absolute",
111
- left: 0,
112
- right: 0,
113
- top: c === "top" ? S : void 0,
114
- bottom: c === "bottom" ? S + _ : void 0,
115
- display: "flex",
116
- justifyContent: "center",
117
- pointerEvents: "none",
118
- zIndex: 1
119
- }, B = {
120
- opacity: s ? 1 : 0,
121
- visibility: s ? "visible" : "hidden",
122
- pointerEvents: s ? "auto" : "none",
123
- transition: s ? "opacity 140ms ease" : "opacity 140ms ease, visibility 0s linear 140ms",
124
- ...h
125
- };
126
- return U(
127
- /* @__PURE__ */ a.createElement("div", { style: w, className: "k-animation-container k-animation-container-shown" }, /* @__PURE__ */ a.createElement(
128
- "div",
129
- {
130
- ref: E,
131
- className: "k-popup k-diagram-top-toolbar-container",
132
- style: B,
133
- onPointerEnter: () => e.handlePointerEnter(),
134
- onPointerLeave: () => e.handlePointerLeave()
135
- },
136
- /* @__PURE__ */ a.createElement(N.Provider, { value: I }, /* @__PURE__ */ a.createElement(z, { fillMode: "flat", style: h, buttons: K }, m))
137
- )),
138
- t.element
105
+ }, w = e.useMemo(() => {
106
+ const o = {
107
+ horizontal: 0,
108
+ vertical: c === "top" ? v : v + Z
109
+ }, l = { vertical: c, horizontal: "center" };
110
+ return { anchorAlign: l, popupAlign: { ...l }, margin: o };
111
+ }, [c]), u = J(T, k);
112
+ return !t || u.length === 0 ? null : /* @__PURE__ */ e.createElement(
113
+ B,
114
+ {
115
+ appendTo: t.element,
116
+ show: P,
117
+ animate: $,
118
+ style: _,
119
+ anchor: t.element,
120
+ ...w
121
+ },
122
+ /* @__PURE__ */ e.createElement("div", { ref: C, style: h }, /* @__PURE__ */ e.createElement(U.Provider, { value: M }, /* @__PURE__ */ e.createElement(z, { fillMode: "flat", style: h, buttons: K }, u)))
139
123
  );
140
124
  };
141
125
  export {
142
- pt as MainToolbar
126
+ po as MainToolbar
143
127
  };
@@ -10,5 +10,5 @@ export type { ToolbarTools, FontTypeItem, FontSizeItem, ConnectionToolbarOptions
10
10
  /**
11
11
  * The props of the `DiagramEditor` component.
12
12
  */
13
- export interface DiagramEditorProps extends DiagramEditorOptions {
13
+ export interface DiagramEditorProps extends Omit<DiagramEditorOptions, 'diagram'> {
14
14
  }
package/utils/consts.d.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
+ import { ShapeRichTextContent, ConnectionRichTextContent } from '@progress/kendo-diagram-common';
8
9
  import { DiagramNavigationOptions, DiagramDataItem } from '../interfaces/index.js';
9
10
  import { ConnectionOptions } from '../interfaces/ConnectionTypes';
10
11
  import { ShapeOptions } from '../interfaces/ShapeTypes';
@@ -35,3 +36,7 @@ export declare const diagramDefaultProps: {
35
36
  zoomRate: number;
36
37
  role: string;
37
38
  };
39
+ /**
40
+ * The default content style for shapes and connections in the diagram for text editing.
41
+ */
42
+ export declare const diagramEditingContentDefaults: ShapeRichTextContent | ConnectionRichTextContent;
package/utils/consts.js CHANGED
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={enabled:!0,smallStep:1,largeStep:5},a={connections:[],shapes:[],editable:!0,pannable:{enabled:!0,showScrollbars:!0,autoHideScrollbars:!0},selectable:!0,zoom:1,zoomMax:2,zoomMin:.1,zoomRate:.1,role:"application"};exports.DEFAULT_NAVIGABLE_OPTIONS=e;exports.diagramDefaultProps=a;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@progress/kendo-diagram-common"),t={enabled:!0,smallStep:1,largeStep:5},a={connections:[],shapes:[],editable:!0,pannable:{enabled:!0,showScrollbars:!0,autoHideScrollbars:!0},selectable:!0,zoom:1,zoomMax:2,zoomMin:.1,zoomRate:.1,role:"application"},o={fontSize:16,fontFamily:e.EditingUtils.Data.fontNames[0].value};exports.DEFAULT_NAVIGABLE_OPTIONS=t;exports.diagramDefaultProps=a;exports.diagramEditingContentDefaults=o;
package/utils/consts.mjs CHANGED
@@ -5,7 +5,8 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- const e = { enabled: !0, smallStep: 1, largeStep: 5 }, o = {
8
+ import { EditingUtils as e } from "@progress/kendo-diagram-common";
9
+ const a = { enabled: !0, smallStep: 1, largeStep: 5 }, o = {
9
10
  connections: [],
10
11
  shapes: [],
11
12
  editable: !0,
@@ -20,8 +21,12 @@ const e = { enabled: !0, smallStep: 1, largeStep: 5 }, o = {
20
21
  zoomMin: 0.1,
21
22
  zoomRate: 0.1,
22
23
  role: "application"
24
+ }, l = {
25
+ fontSize: 16,
26
+ fontFamily: e.Data.fontNames[0].value
23
27
  };
24
28
  export {
25
- e as DEFAULT_NAVIGABLE_OPTIONS,
26
- o as diagramDefaultProps
29
+ a as DEFAULT_NAVIGABLE_OPTIONS,
30
+ o as diagramDefaultProps,
31
+ l as diagramEditingContentDefaults
27
32
  };