@pdfme/ui 6.2.1-dev.13 → 6.2.1-dev.18

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/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")
@@ -215745,10 +215742,10 @@ var ButtonGroupWidget = (props) => {
215745
215742
  //#endregion
215746
215743
  //#region src/components/Designer/RightSidebar/DetailView/ColorWidget.tsx
215747
215744
  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);
215745
+ var HEX_COLOR_REGEXP = /^#(?:[0-9A-Fa-f]{3,4}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/;
215746
+ var FULL_HEX_COLOR_REGEXP = /^#(?:[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/;
215750
215747
  var ColorWidget = (props) => {
215751
- const { value, onChange, disabled, disabledAlpha = true, readOnly, className, style } = props;
215748
+ const { value, onChange, disabled, disabledAlpha = false, readOnly, className, style } = props;
215752
215749
  const [inputValue, setInputValue] = (0, import_react$9.useState)(value ?? "");
215753
215750
  (0, import_react$9.useEffect)(() => {
215754
215751
  setInputValue(value ?? "");
@@ -215758,8 +215755,15 @@ var ColorWidget = (props) => {
215758
215755
  children: value || ""
215759
215756
  });
215760
215757
  const commit = (next) => {
215758
+ onChange?.(next === "" ? void 0 : next);
215759
+ };
215760
+ const handleInputChange = (next) => {
215761
215761
  setInputValue(next);
215762
- if (isCommittableColor(next)) onChange?.(next === "" ? void 0 : next);
215762
+ if (next === "" || FULL_HEX_COLOR_REGEXP.test(next)) commit(next);
215763
+ };
215764
+ const handleInputCommit = () => {
215765
+ if (HEX_COLOR_REGEXP.test(inputValue)) commit(inputValue);
215766
+ else if (inputValue !== "") setInputValue(value ?? "");
215763
215767
  };
215764
215768
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Space$1.Compact, {
215765
215769
  style,
@@ -215769,13 +215773,19 @@ var ColorWidget = (props) => {
215769
215773
  disabled,
215770
215774
  disabledAlpha,
215771
215775
  format: "hex",
215772
- onChange: (color) => commit(color.toHexString())
215776
+ onChange: (color) => {
215777
+ const next = color.toHexString();
215778
+ setInputValue(next);
215779
+ commit(next);
215780
+ }
215773
215781
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input$4, {
215774
215782
  className,
215775
215783
  placeholder: DEFAULT_COLOR,
215776
215784
  disabled,
215777
215785
  value: inputValue,
215778
- onChange: (ev) => commit(ev.target.value)
215786
+ onChange: (ev) => handleInputChange(ev.target.value),
215787
+ onBlur: handleInputCommit,
215788
+ onPressEnter: handleInputCommit
215779
215789
  })]
215780
215790
  });
215781
215791
  };