@pdfme/ui 6.1.8 → 6.1.9

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.
@@ -6,7 +6,9 @@ type RendererProps = Omit<UIRenderProps<Schema>, 'schema' | 'rootElement' | 'opt
6
6
  value: string;
7
7
  outline: string;
8
8
  onChangeHoveringSchemaId?: (id: string | null) => void;
9
+ onChangeActiveSchemaId?: (id: string | null) => void;
9
10
  scale: number;
11
+ isActive?: boolean;
10
12
  selectable?: boolean;
11
13
  };
12
14
  declare const Renderer: (props: RendererProps) => React.JSX.Element;
package/dist/index.js CHANGED
@@ -44411,7 +44411,7 @@ pp$3.currentThisScope = function() {
44411
44411
  if (scope.flags & (SCOPE_VAR | SCOPE_CLASS_FIELD_INIT | SCOPE_CLASS_STATIC_BLOCK) && !(scope.flags & SCOPE_ARROW)) return scope;
44412
44412
  }
44413
44413
  };
44414
- var Node = function Node(parser, pos, loc) {
44414
+ var Node$1 = function Node(parser, pos, loc) {
44415
44415
  this.type = "";
44416
44416
  this.start = pos;
44417
44417
  this.end = 0;
@@ -44421,10 +44421,10 @@ var Node = function Node(parser, pos, loc) {
44421
44421
  };
44422
44422
  var pp$2 = Parser.prototype;
44423
44423
  pp$2.startNode = function() {
44424
- return new Node(this, this.start, this.startLoc);
44424
+ return new Node$1(this, this.start, this.startLoc);
44425
44425
  };
44426
44426
  pp$2.startNodeAt = function(pos, loc) {
44427
- return new Node(this, pos, loc);
44427
+ return new Node$1(this, pos, loc);
44428
44428
  };
44429
44429
  function finishNodeAt(node, type, pos, loc) {
44430
44430
  node.type = type;
@@ -44440,7 +44440,7 @@ pp$2.finishNodeAt = function(node, type, pos, loc) {
44440
44440
  return finishNodeAt.call(this, node, type, pos, loc);
44441
44441
  };
44442
44442
  pp$2.copyNode = function(node) {
44443
- var newNode = new Node(this, node.start, this.startLoc);
44443
+ var newNode = new Node$1(this, node.start, this.startLoc);
44444
44444
  for (var prop in node) newNode[prop] = node[prop];
44445
44445
  return newNode;
44446
44446
  };
@@ -46006,7 +46006,7 @@ Parser.acorn = {
46006
46006
  Position,
46007
46007
  SourceLocation,
46008
46008
  getLineInfo,
46009
- Node,
46009
+ Node: Node$1,
46010
46010
  TokenType,
46011
46011
  tokTypes: types$1,
46012
46012
  keywordTypes: keywords,
@@ -46025,7 +46025,7 @@ function parseExpressionAt(input, pos, options) {
46025
46025
  }
46026
46026
  //#endregion
46027
46027
  //#region ../common/dist/index.js
46028
- var PDFME_VERSION = "6.1.8";
46028
+ var PDFME_VERSION = "6.1.9";
46029
46029
  var PAGE_SIZE_PRESETS = {
46030
46030
  A3: {
46031
46031
  width: 297,
@@ -190243,35 +190243,51 @@ var useRenderKey = (arg) => {
190243
190243
  plugin
190244
190244
  ]);
190245
190245
  };
190246
- var Wrapper = ({ children, outline, onChangeHoveringSchemaId, schema, selectable = true }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
190247
- title: schema.name,
190248
- onMouseEnter: () => onChangeHoveringSchemaId && onChangeHoveringSchemaId(schema.id),
190249
- onMouseLeave: () => onChangeHoveringSchemaId && onChangeHoveringSchemaId(null),
190250
- className: selectable ? SELECTABLE_CLASSNAME : "",
190251
- id: schema.id,
190252
- style: {
190253
- position: "absolute",
190254
- cursor: schema.readOnly ? "initial" : "pointer",
190255
- height: schema.height * ZOOM,
190256
- width: schema.width * ZOOM,
190257
- top: schema.position.y * ZOOM,
190258
- left: schema.position.x * ZOOM,
190259
- transform: `rotate(${schema.rotate ?? 0}deg)`,
190260
- opacity: schema.opacity ?? 1,
190261
- outline
190262
- },
190263
- children: [schema.required && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
190246
+ var Wrapper = ({ children, outline, onChangeHoveringSchemaId, onChangeActiveSchemaId, schema, mode, isActive = false, selectable = true }) => {
190247
+ const { token } = theme_default.useToken();
190248
+ const isFormEditable = mode === "form" && !schema.readOnly;
190249
+ const activateSchema = () => {
190250
+ if (isFormEditable) onChangeActiveSchemaId?.(schema.id);
190251
+ };
190252
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
190253
+ title: schema.name,
190254
+ onMouseEnter: () => onChangeHoveringSchemaId && onChangeHoveringSchemaId(schema.id),
190255
+ onMouseLeave: () => onChangeHoveringSchemaId && onChangeHoveringSchemaId(null),
190256
+ onPointerDownCapture: activateSchema,
190257
+ onClickCapture: activateSchema,
190258
+ onFocusCapture: activateSchema,
190259
+ onBlurCapture: (event) => {
190260
+ const nextTarget = event.relatedTarget;
190261
+ if (!(nextTarget instanceof Node) || !event.currentTarget.contains(nextTarget)) onChangeActiveSchemaId?.(null);
190262
+ },
190263
+ className: selectable ? SELECTABLE_CLASSNAME : "",
190264
+ id: schema.id,
190264
190265
  style: {
190265
- color: "red",
190266
190266
  position: "absolute",
190267
- top: -12,
190268
- left: -12,
190269
- fontSize: 18,
190270
- fontWeight: 700
190271
- },
190272
- children: "*"
190273
- }), children]
190274
- });
190267
+ cursor: schema.readOnly ? "initial" : "pointer",
190268
+ height: schema.height * ZOOM,
190269
+ width: schema.width * ZOOM,
190270
+ top: schema.position.y * ZOOM,
190271
+ left: schema.position.x * ZOOM,
190272
+ transform: `rotate(${schema.rotate ?? 0}deg)`,
190273
+ opacity: schema.opacity ?? 1,
190274
+ outline,
190275
+ boxShadow: isActive ? `0 0 0 2px ${token.colorPrimary}, 0 0 0 4px ${token.colorPrimaryBg}` : void 0,
190276
+ zIndex: isActive ? 1 : void 0
190277
+ },
190278
+ children: [schema.required && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
190279
+ style: {
190280
+ color: "red",
190281
+ position: "absolute",
190282
+ top: -12,
190283
+ left: -12,
190284
+ fontSize: 18,
190285
+ fontWeight: 700
190286
+ },
190287
+ children: "*"
190288
+ }), children]
190289
+ });
190290
+ };
190275
190291
  var Renderer = (props) => {
190276
190292
  const { schema, basePdf, value, mode, onChange, stopEditing, tabIndex, placeholder, scale } = props;
190277
190293
  const pluginsRegistry = (0, import_react$9.useContext)(PluginsRegistry);
@@ -212003,6 +212019,7 @@ var Preview = ({ template, inputs, size, onChangeInput, onPageChange }) => {
212003
212019
  const paperRefs = (0, import_react$9.useRef)([]);
212004
212020
  const [unitCursor, setUnitCursor] = (0, import_react$9.useState)(0);
212005
212021
  const [pageCursor, setPageCursor] = (0, import_react$9.useState)(0);
212022
+ const [activeSchemaId, setActiveSchemaId] = (0, import_react$9.useState)(null);
212006
212023
  const [schemasList, setSchemasList] = (0, import_react$9.useState)([[]]);
212007
212024
  const { backgrounds, pageSizes, baseScale, error, refresh } = useUIPreProcessor({
212008
212025
  template,
@@ -212076,6 +212093,9 @@ var Preview = ({ template, inputs, size, onChangeInput, onPageChange }) => {
212076
212093
  template,
212077
212094
  unitCursor
212078
212095
  ]);
212096
+ (0, import_react$9.useEffect)(() => {
212097
+ setActiveSchemaId(null);
212098
+ }, [unitCursor]);
212079
212099
  useScrollPageCursor({
212080
212100
  ref: containerRef,
212081
212101
  paperRefs,
@@ -212172,6 +212192,11 @@ var Preview = ({ template, inputs, size, onChangeInput, onPageChange }) => {
212172
212192
  }),
212173
212193
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
212174
212194
  ref: containerRef,
212195
+ onPointerDown: (event) => {
212196
+ if (!isForm) return;
212197
+ const target = event.target;
212198
+ if (!(target instanceof Element) || !target.closest(`.selectable`)) setActiveSchemaId(null);
212199
+ },
212175
212200
  style: {
212176
212201
  ...size,
212177
212202
  position: "relative",
@@ -212206,7 +212231,9 @@ var Preview = ({ template, inputs, size, onChangeInput, onPageChange }) => {
212206
212231
  handleOnChangeRenderer(Array.isArray(arg) ? arg : [arg], schema);
212207
212232
  },
212208
212233
  outline: isForm && !schema.readOnly ? `1px dashed ${token.colorPrimary}` : "transparent",
212209
- scale: renderScale
212234
+ scale: renderScale,
212235
+ isActive: isForm && activeSchemaId === schema.id,
212236
+ onChangeActiveSchemaId: isForm ? setActiveSchemaId : void 0
212210
212237
  }, schema.id);
212211
212238
  },
212212
212239
  renderPaper: ({ index }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StaticSchema, {