@pdfme/ui 6.2.1-dev.13 → 6.2.1-dev.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.
package/dist/helper.d.ts CHANGED
@@ -14,6 +14,13 @@ export declare const stabilizeSchemaIds: <T extends {
14
14
  export declare const debounce: <T extends (...args: unknown[]) => unknown>(cb: T, wait?: number) => T;
15
15
  export declare const round: (number: number, precision: number) => number;
16
16
  export declare const flatten: <T>(arr: T[][]) => T[];
17
+ /**
18
+ * Single source of truth for whether a schema type supports rotation in the
19
+ * Designer (rotate handle on the canvas and rotate input in the detail view).
20
+ * A plugin opts out by omitting `rotate` from its propPanel.defaultSchema or
21
+ * setting it to `undefined` (e.g. `{ ...text.propPanel.defaultSchema, rotate: undefined }`).
22
+ */
23
+ export declare const isRotatableSchema: (defaultSchema?: Record<string, unknown>) => boolean;
17
24
  export declare const initShortCuts: (arg: {
18
25
  move: (command: 'up' | 'down' | 'left' | 'right', isShift: boolean) => void;
19
26
  remove: () => void;
package/dist/index.js CHANGED
@@ -85536,7 +85536,7 @@ var measureRichTextLineHeights = (lines, fontSize, lineHeight, fallbackFont) =>
85536
85536
  return lines.map((line, index) => pt2mm(getLineBoxHeightPt(fontSize, index === 0, line.runs.map((run) => run.fontKitFont), fallbackFont) * lineHeight));
85537
85537
  };
85538
85538
  //#endregion
85539
- //#region ../schemas/dist/dynamicTemplate-DkTVIMNr.js
85539
+ //#region ../schemas/dist/dynamicTemplate-BecnZ8Uf.js
85540
85540
  function _typeof$17(o) {
85541
85541
  "@babel/helpers - typeof";
85542
85542
  return _typeof$17 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -86035,7 +86035,7 @@ function createSingleTable(body, args) {
86035
86035
  _cache
86036
86036
  });
86037
86037
  }
86038
- var HEX_COLOR_PATTERN = "^#(?:[A-Fa-f0-9]{6})$";
86038
+ var HEX_COLOR_PATTERN = "^#(?:[A-Fa-f0-9]{3,4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$";
86039
86039
  var getBody$1 = (value) => {
86040
86040
  if (typeof value === "string") return JSON.parse(value || "[]");
86041
86041
  return value || [];
@@ -86113,7 +86113,7 @@ var getDynamicLayoutForTable = async (value, args) => {
86113
86113
  };
86114
86114
  };
86115
86115
  //#endregion
86116
- //#region ../schemas/dist/utils-BhkbT1F9.js
86116
+ //#region ../schemas/dist/utils-DUdv_Vvk.js
86117
86117
  var convertForPdfLayoutProps = ({ schema, pageHeight, applyRotateTranslate = true }) => {
86118
86118
  const { width: mmWidth, height: mmHeight, position, rotate, opacity } = schema;
86119
86119
  const { x: mmX, y: mmY } = position;
@@ -86416,7 +86416,7 @@ var Underline = [["path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }], ["line", {
86416
86416
  y2: "20"
86417
86417
  }]];
86418
86418
  //#endregion
86419
- //#region ../schemas/dist/builtins-BEweDprE.js
86419
+ //#region ../schemas/dist/builtins-BID2DSHc.js
86420
86420
  var addUriLinkAnnotation = (arg) => {
86421
86421
  const { pdfDoc, page, uri, rect, borderWidth = 0 } = arg;
86422
86422
  const safeUri = normalizeSafeLinkUri(uri);
@@ -87251,7 +87251,6 @@ var propPanel = {
87251
87251
  title: i18n("schemas.textColor"),
87252
87252
  type: "string",
87253
87253
  widget: "color",
87254
- props: { disabledAlpha: true },
87255
87254
  rules: [{
87256
87255
  pattern: HEX_COLOR_PATTERN,
87257
87256
  message: i18n("validation.hexColor")
@@ -87261,7 +87260,6 @@ var propPanel = {
87261
87260
  title: i18n("schemas.bgColor"),
87262
87261
  type: "string",
87263
87262
  widget: "color",
87264
- props: { disabledAlpha: true },
87265
87263
  rules: [{
87266
87264
  pattern: HEX_COLOR_PATTERN,
87267
87265
  message: i18n("validation.hexColor")
@@ -87271,7 +87269,6 @@ var propPanel = {
87271
87269
  title: i18n("schemas.borderColor"),
87272
87270
  type: "string",
87273
87271
  widget: "color",
87274
- props: { disabledAlpha: true },
87275
87272
  rules: [{
87276
87273
  pattern: HEX_COLOR_PATTERN,
87277
87274
  message: i18n("validation.hexColor")
@@ -87845,6 +87842,13 @@ var round$2 = (number, precision) => {
87845
87842
  return shift(Math.round(shift(number, precision, false)), precision, true);
87846
87843
  };
87847
87844
  var flatten = (arr) => [].concat(...arr);
87845
+ /**
87846
+ * Single source of truth for whether a schema type supports rotation in the
87847
+ * Designer (rotate handle on the canvas and rotate input in the detail view).
87848
+ * A plugin opts out by omitting `rotate` from its propPanel.defaultSchema or
87849
+ * setting it to `undefined` (e.g. `{ ...text.propPanel.defaultSchema, rotate: undefined }`).
87850
+ */
87851
+ var isRotatableSchema = (defaultSchema) => typeof defaultSchema?.rotate !== "undefined";
87848
87852
  var up = "up";
87849
87853
  var shiftUp = "shift+up";
87850
87854
  var down = "down";
@@ -215745,10 +215749,10 @@ var ButtonGroupWidget = (props) => {
215745
215749
  //#endregion
215746
215750
  //#region src/components/Designer/RightSidebar/DetailView/ColorWidget.tsx
215747
215751
  var DEFAULT_COLOR = "#000000";
215748
- var HEX_COLOR_REGEXP = /^#(?:[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/;
215749
- var isCommittableColor = (value) => value === "" || HEX_COLOR_REGEXP.test(value);
215752
+ var HEX_COLOR_REGEXP = /^#(?:[0-9A-Fa-f]{3,4}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/;
215753
+ var FULL_HEX_COLOR_REGEXP = /^#(?:[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/;
215750
215754
  var ColorWidget = (props) => {
215751
- const { value, onChange, disabled, disabledAlpha = true, readOnly, className, style } = props;
215755
+ const { value, onChange, disabled, disabledAlpha = false, readOnly, className, style } = props;
215752
215756
  const [inputValue, setInputValue] = (0, import_react$9.useState)(value ?? "");
215753
215757
  (0, import_react$9.useEffect)(() => {
215754
215758
  setInputValue(value ?? "");
@@ -215758,8 +215762,15 @@ var ColorWidget = (props) => {
215758
215762
  children: value || ""
215759
215763
  });
215760
215764
  const commit = (next) => {
215765
+ onChange?.(next === "" ? void 0 : next);
215766
+ };
215767
+ const handleInputChange = (next) => {
215761
215768
  setInputValue(next);
215762
- if (isCommittableColor(next)) onChange?.(next === "" ? void 0 : next);
215769
+ if (next === "" || FULL_HEX_COLOR_REGEXP.test(next)) commit(next);
215770
+ };
215771
+ const handleInputCommit = () => {
215772
+ if (HEX_COLOR_REGEXP.test(inputValue)) commit(inputValue);
215773
+ else if (inputValue !== "") setInputValue(value ?? "");
215763
215774
  };
215764
215775
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Space$1.Compact, {
215765
215776
  style,
@@ -215769,13 +215780,19 @@ var ColorWidget = (props) => {
215769
215780
  disabled,
215770
215781
  disabledAlpha,
215771
215782
  format: "hex",
215772
- onChange: (color) => commit(color.toHexString())
215783
+ onChange: (color) => {
215784
+ const next = color.toHexString();
215785
+ setInputValue(next);
215786
+ commit(next);
215787
+ }
215773
215788
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input$4, {
215774
215789
  className,
215775
215790
  placeholder: DEFAULT_COLOR,
215776
215791
  disabled,
215777
215792
  value: inputValue,
215778
- onChange: (ev) => commit(ev.target.value)
215793
+ onChange: (ev) => handleInputChange(ev.target.value),
215794
+ onBlur: handleInputCommit,
215795
+ onPressEnter: handleInputCommit
215779
215796
  })]
215780
215797
  });
215781
215798
  };
@@ -216080,7 +216097,7 @@ var DetailView = (props) => {
216080
216097
  title: typedI18n("rotate"),
216081
216098
  type: "number",
216082
216099
  widget: "inputNumber",
216083
- disabled: typeof defaultSchema.rotate === "undefined",
216100
+ disabled: !isRotatableSchema(defaultSchema),
216084
216101
  max: 360,
216085
216102
  props: { min: 0 },
216086
216103
  span: 6
@@ -236762,8 +236779,7 @@ var Canvas = (props, ref) => {
236762
236779
  if (plugin.propPanel.defaultSchema) defaultSchemas.push(plugin.propPanel.defaultSchema);
236763
236780
  });
236764
236781
  return uniqueSchemaTypes.every((type) => {
236765
- const matchingSchema = defaultSchemas.find((ds) => ds && "type" in ds && ds.type === type);
236766
- return matchingSchema && "rotate" in matchingSchema;
236782
+ return isRotatableSchema(defaultSchemas.find((ds) => ds && "type" in ds && ds.type === type));
236767
236783
  });
236768
236784
  }, [
236769
236785
  activeElements,