@pdfme/ui 4.2.3-dev.3 → 4.2.3-dev.4
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.es.js
CHANGED
@@ -151864,60 +151864,61 @@ const FormRender = withProvider(FormCore, defaultWidgets), svgBaseProp = {
|
|
151864
151864
|
);
|
151865
151865
|
}) }) });
|
151866
151866
|
}, ButtonGroupWidget$1 = ButtonGroupWidget, { Text: Text$2 } = Typography$1, DetailView = (a) => {
|
151867
|
-
const { token: s } = theme.useToken(), { size: $, changeSchemas: _, deselectSchema: _e, activeSchema: tt
|
151868
|
-
reactExports.
|
151869
|
-
|
151870
|
-
|
151871
|
-
|
151872
|
-
|
151873
|
-
|
151874
|
-
|
151875
|
-
|
151867
|
+
const { token: s } = theme.useToken(), { size: $, changeSchemas: _, deselectSchema: _e, activeSchema: tt } = a, nt = useForm(), at = reactExports.useContext(I18nContext), ot = reactExports.useContext(PluginsRegistry), rt = reactExports.useContext(OptionsContext);
|
151868
|
+
reactExports.useEffect(() => {
|
151869
|
+
const dt = { ...tt };
|
151870
|
+
dt.x = dt.position.x, dt.y = dt.position.y, delete dt.position, nt.setValues(dt);
|
151871
|
+
}, [tt, nt]);
|
151872
|
+
const st = (dt) => {
|
151873
|
+
const gt = (mt, ct) => typeof mt == "object" ? JSON.stringify(mt) !== JSON.stringify(ct) : mt !== ct;
|
151874
|
+
let pt = [];
|
151875
|
+
for (let mt in dt) {
|
151876
|
+
if (["id", "content"].includes(mt))
|
151876
151877
|
continue;
|
151877
|
-
let
|
151878
|
-
["x", "y"].includes(
|
151878
|
+
let ct = dt[mt], vt = !1;
|
151879
|
+
["x", "y"].includes(mt) ? (vt = ct !== tt.position[mt], mt = "position." + mt) : vt = gt(ct, tt[mt]), vt && (ct === null && ["rotate", "opacity"].includes(mt) && (ct = void 0), pt.push({ key: mt, value: ct, schemaId: tt.id }));
|
151879
151880
|
}
|
151880
|
-
|
151881
|
-
|
151882
|
-
(
|
151883
|
-
))),
|
151881
|
+
pt.length && nt.validateFields().then(() => _(pt)).catch((mt) => {
|
151882
|
+
mt.errorFields.length && (pt = pt.filter((ct) => !mt.errorFields.find(
|
151883
|
+
(vt) => vt.name.includes(ct.key)
|
151884
|
+
))), pt.length && _(pt);
|
151884
151885
|
});
|
151885
|
-
},
|
151886
|
-
(
|
151887
|
-
),
|
151888
|
-
|
151886
|
+
}, lt = Object.values(ot).find(
|
151887
|
+
(dt) => (dt == null ? void 0 : dt.propPanel.defaultSchema.type) === tt.type
|
151888
|
+
), et = lt == null ? void 0 : lt.propPanel.schema;
|
151889
|
+
et || console.error(`[@pdfme/ui] No propPanel.schema for ${tt.type}.
|
151889
151890
|
Check this document: https://pdfme.com/docs/custom-schemas`);
|
151890
|
-
const
|
151891
|
-
label:
|
151892
|
-
value:
|
151893
|
-
})),
|
151891
|
+
const it = Object.entries(ot).map(([dt, gt]) => ({
|
151892
|
+
label: dt,
|
151893
|
+
value: gt == null ? void 0 : gt.propPanel.defaultSchema.type
|
151894
|
+
})), ut = lt.propPanel.defaultSchema, ft = {
|
151894
151895
|
type: "object",
|
151895
151896
|
column: 2,
|
151896
151897
|
properties: {
|
151897
151898
|
type: {
|
151898
|
-
title:
|
151899
|
+
title: at("type"),
|
151899
151900
|
type: "string",
|
151900
151901
|
widget: "select",
|
151901
|
-
props: { options:
|
151902
|
+
props: { options: it },
|
151902
151903
|
required: !0,
|
151903
151904
|
span: 12
|
151904
151905
|
},
|
151905
|
-
key: { title:
|
151906
|
+
key: { title: at("fieldName"), type: "string", required: !0, span: 12 },
|
151906
151907
|
"-": { type: "void", widget: "Divider" },
|
151907
|
-
align: { title:
|
151908
|
+
align: { title: at("align"), type: "void", widget: "AlignWidget" },
|
151908
151909
|
x: { title: "X", type: "number", widget: "inputNumber", required: !0, span: 8, min: 0 },
|
151909
151910
|
y: { title: "Y", type: "number", widget: "inputNumber", required: !0, span: 8, min: 0 },
|
151910
151911
|
rotate: {
|
151911
|
-
title:
|
151912
|
+
title: at("rotate"),
|
151912
151913
|
type: "number",
|
151913
151914
|
widget: "inputNumber",
|
151914
|
-
disabled: (
|
151915
|
+
disabled: (ut == null ? void 0 : ut.rotate) === void 0,
|
151915
151916
|
max: 360,
|
151916
151917
|
props: { min: 0 },
|
151917
151918
|
span: 8
|
151918
151919
|
},
|
151919
151920
|
width: {
|
151920
|
-
title:
|
151921
|
+
title: at("width"),
|
151921
151922
|
type: "number",
|
151922
151923
|
widget: "inputNumber",
|
151923
151924
|
required: !0,
|
@@ -151925,7 +151926,7 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
151925
151926
|
props: { min: 0 }
|
151926
151927
|
},
|
151927
151928
|
height: {
|
151928
|
-
title:
|
151929
|
+
title: at("height"),
|
151929
151930
|
type: "number",
|
151930
151931
|
widget: "inputNumber",
|
151931
151932
|
required: !0,
|
@@ -151933,52 +151934,52 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
151933
151934
|
props: { min: 0 }
|
151934
151935
|
},
|
151935
151936
|
opacity: {
|
151936
|
-
title:
|
151937
|
+
title: at("opacity"),
|
151937
151938
|
type: "number",
|
151938
151939
|
widget: "inputNumber",
|
151939
|
-
disabled: (
|
151940
|
+
disabled: (ut == null ? void 0 : ut.opacity) === void 0,
|
151940
151941
|
props: { step: 0.1, min: 0, max: 1 },
|
151941
151942
|
span: 8
|
151942
151943
|
}
|
151943
151944
|
}
|
151944
151945
|
};
|
151945
|
-
if (typeof
|
151946
|
-
const
|
151946
|
+
if (typeof et == "function") {
|
151947
|
+
const dt = et({
|
151947
151948
|
...a,
|
151948
|
-
options:
|
151949
|
+
options: rt,
|
151949
151950
|
theme: s,
|
151950
|
-
i18n:
|
151951
|
+
i18n: at
|
151951
151952
|
}) || {};
|
151952
|
-
|
151953
|
-
...
|
151954
|
-
...Object.keys(
|
151955
|
-
...
|
151953
|
+
ft.properties = {
|
151954
|
+
...ft.properties,
|
151955
|
+
...Object.keys(dt).length === 0 ? {} : { "--": { type: "void", widget: "Divider" } },
|
151956
|
+
...dt
|
151956
151957
|
};
|
151957
151958
|
} else {
|
151958
|
-
const
|
151959
|
-
|
151960
|
-
...
|
151961
|
-
...Object.keys(
|
151962
|
-
...
|
151959
|
+
const dt = et || {};
|
151960
|
+
ft.properties = {
|
151961
|
+
...ft.properties,
|
151962
|
+
...Object.keys(dt).length === 0 ? {} : { "--": { type: "void", widget: "Divider" } },
|
151963
|
+
...dt
|
151963
151964
|
};
|
151964
151965
|
}
|
151965
|
-
const
|
151966
|
-
AlignWidget: (
|
151966
|
+
const ht = {
|
151967
|
+
AlignWidget: (dt) => /* @__PURE__ */ jsxRuntimeExports.jsx(AlignWidget$1, { ...dt, ...a, options: rt }),
|
151967
151968
|
Divider: () => /* @__PURE__ */ jsxRuntimeExports.jsx(Divider$1, { style: { marginTop: s.marginXS, marginBottom: s.marginXS } }),
|
151968
|
-
ButtonGroup: (
|
151969
|
+
ButtonGroup: (dt) => /* @__PURE__ */ jsxRuntimeExports.jsx(ButtonGroupWidget$1, { ...dt, ...a, options: rt })
|
151969
151970
|
};
|
151970
|
-
for (const
|
151971
|
-
const
|
151972
|
-
Object.entries(
|
151973
|
-
|
151971
|
+
for (const dt of Object.values(ot)) {
|
151972
|
+
const gt = (dt == null ? void 0 : dt.propPanel.widgets) || {};
|
151973
|
+
Object.entries(gt).forEach(([pt, mt]) => {
|
151974
|
+
ht[pt] = (ct) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
151974
151975
|
WidgetRenderer$1,
|
151975
151976
|
{
|
151976
|
-
...
|
151977
|
+
...ct,
|
151977
151978
|
...a,
|
151978
|
-
options:
|
151979
|
+
options: rt,
|
151979
151980
|
theme: s,
|
151980
|
-
i18n:
|
151981
|
-
widget:
|
151981
|
+
i18n: at,
|
151982
|
+
widget: mt
|
151982
151983
|
}
|
151983
151984
|
);
|
151984
151985
|
});
|
@@ -151999,7 +152000,7 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
151999
152000
|
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(MenuOutlined$1, {})
|
152000
152001
|
}
|
152001
152002
|
),
|
152002
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Text$2, { strong: !0, style: { textAlign: "center", width: "100%" }, children:
|
152003
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Text$2, { strong: !0, style: { textAlign: "center", width: "100%" }, children: at("editField") })
|
152003
152004
|
] }),
|
152004
152005
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Divider$1, { style: { marginTop: s.marginXS, marginBottom: s.marginXS } }),
|
152005
152006
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
@@ -152013,10 +152014,10 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
152013
152014
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
152014
152015
|
FormRender,
|
152015
152016
|
{
|
152016
|
-
form:
|
152017
|
-
schema:
|
152018
|
-
widgets:
|
152019
|
-
watch: { "#":
|
152017
|
+
form: nt,
|
152018
|
+
schema: ft,
|
152019
|
+
widgets: ht,
|
152020
|
+
watch: { "#": st },
|
152020
152021
|
locale: "en-US"
|
152021
152022
|
}
|
152022
152023
|
)
|
@@ -162378,7 +162379,7 @@ const Guides$2 = Guides$1, guideStyle = (a, s, $, _) => ({
|
|
162378
162379
|
var rr, Yt;
|
162379
162380
|
if (!$t.active)
|
162380
162381
|
return;
|
162381
|
-
const Pt = $t.active, Dt = ot.current[dt].getBoundingClientRect(), Ut = ((rr = Pt.rect.current.initial) == null ? void 0 : rr.left) || 0, Vt = ((Yt = Pt.rect.current.initial) == null ? void 0 : Yt.top) || 0, Qt = Dt.left - Ut + scaleDragPosAdjustment(20, St), qt = Dt.top - Vt, Zt = ($t.delta.y - qt) / St, ar = ($t.delta.x - Qt) / St, Jt = { x: px2mm(Math.max(0, ar)), y: px2mm(Math.max(0, Zt)) };
|
162382
|
+
const Pt = $t.active, Dt = ot.current[dt].getBoundingClientRect(), Ut = ((rr = Pt.rect.current.initial) == null ? void 0 : rr.left) || 0, Vt = ((Yt = Pt.rect.current.initial) == null ? void 0 : Yt.top) || 0, Qt = Dt.left - Ut + scaleDragPosAdjustment(20, St), qt = Dt.top - Vt, Zt = ($t.delta.y - qt) / St, ar = ($t.delta.x - Qt) / St, Jt = { x: round(px2mm(Math.max(0, ar)), 2), y: round(px2mm(Math.max(0, Zt)), 2) };
|
162382
162383
|
kt({ ...Pt.data.current, position: Jt });
|
162383
162384
|
},
|
162384
162385
|
onDragStart: wt,
|
package/dist/index.umd.js
CHANGED
@@ -704,8 +704,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
704
704
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _iterableToArrayLimit$2(a,s){var $=a==null?null:typeof Symbol<"u"&&a[Symbol.iterator]||a["@@iterator"];if($!=null){var _,_e,tt,nt,at=[],ot=!0,rt=!1;try{if(tt=($=$.call(a)).next,s===0){if(Object($)!==$)return;ot=!1}else for(;!(ot=(_=tt.call($)).done)&&(at.push(_.value),at.length!==s);ot=!0);}catch(st){rt=!0,_e=st}finally{try{if(!ot&&$.return!=null&&(nt=$.return(),Object(nt)!==nt))return}finally{if(rt)throw _e}}return at}}function _arrayWithHoles$2(a){if(Array.isArray(a))return a}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray$2(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
705
705
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _unsupportedIterableToArray$2(a,s){if(a){if(typeof a=="string")return _arrayLikeToArray$2(a,s);var $=Object.prototype.toString.call(a).slice(8,-1);if($==="Object"&&a.constructor&&($=a.constructor.name),$==="Map"||$==="Set")return Array.from(a);if($==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test($))return _arrayLikeToArray$2(a,s)}}function _iterableToArray(a){if(typeof Symbol<"u"&&a[Symbol.iterator]!=null||a["@@iterator"]!=null)return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray$2(a)}function _arrayLikeToArray$2(a,s){(s==null||s>a.length)&&(s=a.length);for(var $=0,_=new Array(s);$<s;$++)_[$]=a[$];return _}var TabPaneContent=function a(s){var $=s.renderCore,_=s.name,_e=s.schema,tt=s.rootPath;return reactExports.useMemo(function(){return React$a.createElement("div",{style:{flex:1}},$({schema:_e,parentPath:[_],rootPath:[].concat(_toConsumableArray(tt),[_])}))},[JSON.stringify(s)])},TabList=function a(s){var $=s.schema,_=s.fields,_e=s.rootPath,tt=s.renderCore,nt=s.readOnly,at=s.delConfirmProps,ot=s.tabName,rt=s.hideDelete,st=s.hideAdd,lt=s.addItem,et=s.removeItem,it=s.tabItemProps,ut=it===void 0?{}:it,ft=s.activeKey,ht=__rest$3(s,["schema","fields","rootPath","renderCore","readOnly","delConfirmProps","tabName","hideDelete","hideAdd","addItem","removeItem","tabItemProps","activeKey"]),dt=reactExports.useState("0"),gt=_slicedToArray$2(dt,2),pt=gt[0],mt=gt[1],ct=reactExports.useContext(ThemeConfigProvider.ConfigContext),vt=translation(ct);reactExports.useEffect(function(){mt(ft||"0")},[ft]);var At=function(Bt){return ot instanceof Array?ot[Bt]||Bt+1:"".concat(ot||vt("item")," ").concat(Bt+1)},xt=function(Bt){et(Bt),mt("".concat(Bt>1?Bt-1:0))},bt=function(Bt,Ot){if(Ot==="add"&&(!$.max||_.length<$.max)&&!nt&&!st){lt();var Tt=_.length;mt("".concat(Tt))}},Et=function(Bt){return!nt&&!rt?React$a.createElement(_Popconfirm,Object.assign({onConfirm:function(){return xt(Bt)}},at),React$a.createElement(default_1$3,null)):React$a.createElement(React$a.Fragment,null)};return React$a.createElement(_Tabs,Object.assign({className:"fr-tab-list",type:"editable-card"},ht,{onChange:mt,activeKey:"".concat(pt),onEdit:bt,hideAdd:nt||st}),_.map(function(St){var Bt=St.key,Ot=St.name;return React$a.createElement(_Tabs.TabPane,Object.assign({key:Bt,className:"fr-list-item"},ut,{tab:At(Ot),closeIcon:Et(Ot)}),React$a.createElement(TabPaneContent,{name:Ot,rootPath:_e,schema:$,renderCore:tt}))}))};function _typeof(a){"@babel/helpers - typeof";return _typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},_typeof(a)}function _defineProperty(a,s,$){return s=_toPropertyKey(s),s in a?Object.defineProperty(a,s,{value:$,enumerable:!0,configurable:!0,writable:!0}):a[s]=$,a}function _toPropertyKey(a){var s=_toPrimitive(a,"string");return _typeof(s)==="symbol"?s:String(s)}function _toPrimitive(a,s){if(_typeof(a)!=="object"||a===null)return a;var $=a[Symbol.toPrimitive];if($!==void 0){var _=$.call(a,s||"default");if(_typeof(_)!=="object")return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(a)}const index=function(a){var s=a.schema;return React$a.createElement("div",{className:classnames("fr-void-title",_defineProperty({},s==null?void 0:s.className,!!(s!=null&&s.className)))},s.title)};var ErrorSchema=function a(s){var $=reactExports.useContext(ThemeConfigProvider.ConfigContext),_=translation($);return React$a.createElement("div",null,React$a.createElement("div",{style:{color:"red"}},_("schema_not_match")),React$a.createElement("div",null,JSON.stringify(s)))};const defaultWidgets=Object.freeze(Object.defineProperty({__proto__:null,Card:BoxCard,CardList,Checkbox,Checkboxes:Checkboxes$1,Collapse:BoxCollapse,Color,DatePicker,DateRange:DateRange$1,DrawerList:TableList,ErrorSchema,Html:html,ImageInput:ImageInput$1,Input,InputNumber,LineTitle:FLineTitle,MultiSelect,PercentSlider,Radio,Rate:index$2,Select:MultiSelect,SimpleList,Slider,SubInline:BoxSubInline,Switch,TabList,TableList:TableList$1,TextArea:TextArea$1,TimePicker,TimeRange,TreeSelect,Upload:FrUpload,UrlInput:UrlInput$1,VirtualList,VoidTitle:index},Symbol.toStringTag,{value:"Module"}));function _slicedToArray$1(a,s){return _arrayWithHoles$1(a)||_iterableToArrayLimit$1(a,s)||_unsupportedIterableToArray$1(a,s)||_nonIterableRest$1()}function _nonIterableRest$1(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
706
706
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _unsupportedIterableToArray$1(a,s){if(a){if(typeof a=="string")return _arrayLikeToArray$1(a,s);var $=Object.prototype.toString.call(a).slice(8,-1);if($==="Object"&&a.constructor&&($=a.constructor.name),$==="Map"||$==="Set")return Array.from(a);if($==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test($))return _arrayLikeToArray$1(a,s)}}function _arrayLikeToArray$1(a,s){(s==null||s>a.length)&&(s=a.length);for(var $=0,_=new Array(s);$<s;$++)_[$]=a[$];return _}function _iterableToArrayLimit$1(a,s){var $=a==null?null:typeof Symbol<"u"&&a[Symbol.iterator]||a["@@iterator"];if($!=null){var _,_e,tt,nt,at=[],ot=!0,rt=!1;try{if(tt=($=$.call(a)).next,s===0){if(Object($)!==$)return;ot=!1}else for(;!(ot=(_=tt.call($)).done)&&(at.push(_.value),at.length!==s);ot=!0);}catch(st){rt=!0,_e=st}finally{try{if(!ot&&$.return!=null&&(nt=$.return(),Object(nt)!==nt))return}finally{if(rt)throw _e}}return at}}function _arrayWithHoles$1(a){if(Array.isArray(a))return a}function flattenSchema(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0,$=arguments.length>2?arguments[2]:void 0,_=arguments.length>3?arguments[3]:void 0,_e=_||{},tt=_cloneDeep(a)||{},nt=s||"#";tt.$id||(tt.$id=nt);var at=[];return isObjType(tt)&&(sortProperties(Object.entries(tt.properties)).forEach(function(ot){var rt=_slicedToArray$1(ot,2),st=rt[0],lt=rt[1],et=isListType(lt)?st+"[]":st,it=nt==="#"?et:nt+"."+et;at.push(it),flattenSchema(lt,it,nt,_e)}),tt.properties={}),isListType(tt)&&(sortProperties(Object.entries(tt.items.properties)).forEach(function(ot){var rt=_slicedToArray$1(ot,2),st=rt[0],lt=rt[1],et=isListType(lt)?st+"[]":st,it=nt==="#"?et:nt+"."+et;at.push(it),flattenSchema(lt,it,nt,_e)}),tt.items.properties={}),tt.type&&(_e[nt]={parent:$,schema:tt,children:at}),_e}function _slicedToArray(a,s){return _arrayWithHoles(a)||_iterableToArrayLimit(a,s)||_unsupportedIterableToArray(a,s)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
707
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _unsupportedIterableToArray(a,s){if(a){if(typeof a=="string")return _arrayLikeToArray(a,s);var $=Object.prototype.toString.call(a).slice(8,-1);if($==="Object"&&a.constructor&&($=a.constructor.name),$==="Map"||$==="Set")return Array.from(a);if($==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test($))return _arrayLikeToArray(a,s)}}function _arrayLikeToArray(a,s){(s==null||s>a.length)&&(s=a.length);for(var $=0,_=new Array(s);$<s;$++)_[$]=a[$];return _}function _iterableToArrayLimit(a,s){var $=a==null?null:typeof Symbol<"u"&&a[Symbol.iterator]||a["@@iterator"];if($!=null){var _,_e,tt,nt,at=[],ot=!0,rt=!1;try{if(tt=($=$.call(a)).next,s===0){if(Object($)!==$)return;ot=!1}else for(;!(ot=(_=tt.call($)).done)&&(at.push(_.value),at.length!==s);ot=!0);}catch(st){rt=!0,_e=st}finally{try{if(!ot&&$.return!=null&&(nt=$.return(),Object(nt)!==nt))return}finally{if(rt)throw _e}}return at}}function _arrayWithHoles(a){if(Array.isArray(a))return a}var updateSchemaByPath=function a(s,$,_){var _e=getSchemaFullPath(s,_),tt=_get(_,_e,{}),nt=isFunction$2($)?$(tt):$,at=Object.assign(Object.assign({},tt),nt);nt.props&&(at.props=Object.assign(Object.assign({},tt==null?void 0:tt.props),nt.props)),_set(_,_e,at)},getFieldName=function a(s){if(s){if(typeof s=="boolean")return s;var $=[];return isArray$3(s)&&($=s.map(function(_){return _.split(".").map(function(_e){return isNaN(Number(_e))?_e:_e*1})})),$=s.split(".").map(function(_){return isNaN(Number(_))?_:_*1}),$=$.map(function(_){return typeof _=="string"&&(_==null?void 0:_.indexOf("["))===0&&(_==null?void 0:_.indexOf("]"))===(_==null?void 0:_.length)-1?Number(_.substring(1,_.length-1)):_}),$}},useForm=function a(){var s=Form$3.useForm(),$=_slicedToArray(s,1),_=$[0],_e=reactExports.useRef({}),tt=reactExports.useRef(),nt=reactExports.useRef({}),at=reactExports.useRef({});_.getFieldError;var ot=_.getFieldsError,rt=_.getFieldInstance,st=_.setFieldsValue,lt=_.setFields,et=_.scrollToField,it=_.isFieldsTouched,ut=_.isFieldTouched,ft=_.isFieldValidating,ht=_.resetFields,dt=_.validateFields,gt=__rest$3(_,["getFieldError","getFieldsError","getFieldInstance","setFieldsValue","setFields","scrollToField","isFieldsTouched","isFieldTouched","isFieldValidating","resetFields","validateFields"]),pt=gt,mt=function(At){var xt=tt.current.setState;xt||setTimeout(function(){xt({schema:nt.current,flattenSchema:_e.current})},0),xt(At)},ct=function(At){_e.current=flattenSchema(At)||{},nt.current=At,mt({schema:At,flattenSchema:_e.current})};return pt.setSchema=function(vt){var At=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(isObject$6(vt)){if(At){ct(vt);return}var xt=cloneDeep(nt.current);Object.keys(vt||{}).forEach(function(bt){updateSchemaByPath(bt,vt[bt],xt)}),ct(xt)}},pt.setSchemaByPath=function(vt,At){if(!(!hasFuncProperty(At)&&_isMatch(At,pt.getSchemaByPath(vt)))){var xt=cloneDeep(nt.current);updateSchemaByPath(vt,At,xt),ct(xt)}},pt.setValues=function(vt){var At=parseBindToValues(vt,_e.current);st(At)},pt.getValues=function(vt,At){var xt,bt=cloneDeep(_.getFieldsValue(getFieldName(vt),At)),Et=((xt=tt.current)===null||xt===void 0?void 0:xt.getState())||{},St=Et.removeHiddenData;return St&&(bt=filterValuesHidden(bt,_e.current)),bt=filterValuesUndefined(bt),parseValuesToBind(bt,_e.current)},pt.getValueByPath=function(vt){var At=getFieldName(vt);return _.getFieldValue(At)},pt.setValueByPath=function(vt,At){if(!_.setFieldValue){var xt=_.getFieldsValue();_set(xt,vt,At),pt.setValues(xt);return}var bt=getFieldName(vt);_.setFieldValue(bt,At);try{JSON.stringify(_.getFieldValue(bt))!==JSON.stringify(At)&&_.setFieldValue(bt,At)}catch{}},pt.getSchemaByPath=function(vt){typeof vt!="string"&&console.warn("请输入正确的路径");var At=getSchemaFullPath(vt,nt.current);return _get(nt.current,At)},pt.getSchema=function(){return nt.current},pt.setErrorFields=function(vt){var At=transformFieldsData(vt,getFieldName);At&<(At)},pt.removeErrorField=function(vt){lt([{name:getFieldName(vt),errors:[]}])},pt.getFieldError=function(vt){var At=getFieldName(vt);return _.getFieldError(At)},pt.getFieldsError=function(vt){var At=getFieldName(vt);return ot(At)},pt.getFieldInstance=function(vt){var At=getFieldName(vt);return rt(At)},pt.getHiddenValues=function(){var vt=pt.getValues(),At=pt.getValues(!0),xt={},bt=function Et(St,Bt,Ot){Object.keys(St).forEach(function(Tt){var wt=St[Tt],Ct=Ot?"".concat(Ot,".").concat(Tt):Tt;if(!Bt.hasOwnProperty(Tt)){_set(xt,Ct,wt);return}isObject$6(wt)&&Et(wt,Bt[Tt],Ct),isArray$3(wt)&&wt.map(function(It,yt){Et(It,_get(Bt,"".concat(Tt,"[").concat(yt,"]"),[]),"".concat(Ct,"[").concat(yt,"]"))})})};return bt(At,vt,null),xt},pt.setFields=function(vt){var At=transformFieldsData(vt,getFieldName);At&<(At)},pt.__initStore=function(vt){tt.current=vt},pt.scrollToPath=function(vt){for(var At=getFieldName(vt),xt=arguments.length,bt=new Array(xt>1?xt-1:0),Et=1;Et<xt;Et++)bt[Et-1]=arguments[Et];et.apply(void 0,[At].concat(bt))},pt.isFieldsTouched=function(vt,At){var xt=(vt||[]).map(function(bt){return getFieldName(bt)});return it(xt,At)},pt.isFieldTouched=function(vt){var At=getFieldName(vt);return ut(At)},pt.isFieldValidating=function(vt){var At=getFieldName(vt);return ft(At)},pt.resetFields=function(vt){var At=(vt||[]).map(function(xt){return getFieldName(xt)});At.length>0?ht(At):ht()},pt.validateFields=function(vt){var At=(vt||[]).map(function(xt){return getFieldName(xt)});return At.length>0?dt(At):dt()},pt.getFlattenSchema=function(vt){var At;return vt?(At=_e.current)===null||At===void 0?void 0:At[vt]:_e.current},pt.onItemChange=pt.setValueByPath,pt.setFieldRef=function(vt,At){vt&&(at.current[vt]=At)},pt.getFieldRef=function(vt){return at.current[vt]},pt};const FormRender=withProvider(FormCore,defaultWidgets),svgBaseProp={style:{width:"90%",height:"90%"},xmlns:"http://www.w3.org/2000/svg",enableBackground:"new 0 0 24 24",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#000000"},createSvgIcon=a=>jsxRuntimeExports.jsxs("svg",{...svgBaseProp,children:[jsxRuntimeExports.jsx("rect",{fill:"none",height:"24",width:"24"}),a]}),createButtonConfig=(a,s,$)=>({id:a,icon:createSvgIcon(s),onClick:$}),AlignWidget=a=>{const{activeElements:s,changeSchemas:$,schemas:_,pageSize:_e,schema:tt}=a,nt=rt=>{const st=s.map(ct=>ct.id),lt=_.filter(ct=>st.includes(ct.id)),et=["left","center","right"].includes(rt),it=et?"x":"y",ut=et?"width":"height",ft=lt.length===1,ht=_e[ut],dt=ft?0:Math.min(...lt.map(ct=>ct.position[it])),gt=ft?ht:Math.max(...lt.map(ct=>ct.position[it]+ct[ut]));let pt=dt,mt=ct=>0;["center","middle"].includes(rt)?(pt=(dt+gt)/2,mt=ct=>ct/2):["right","bottom"].includes(rt)&&(pt=gt,mt=ct=>ct),$(lt.map(ct=>({key:`position.${it}`,value:round(pt-mt(ct[ut]),2),schemaId:ct.id})))},at=rt=>{const st=s.map(At=>At.id),lt=_.filter(At=>st.includes(At.id)),et=rt==="vertical",it=et?"y":"x",ut=et?"height":"width",ft=Math.min(...lt.map(At=>At.position[it])),ht=Math.max(...lt.map(At=>At.position[it]+At[ut]));if(lt.length<3)return;const dt=ft,gt=ht-ft,pt=lt.reduce((At,xt)=>At+xt[ut],0),ct=(gt-pt)/(lt.length-1);let vt=0;$(lt.map((At,xt)=>{vt+=xt===0?0:lt[xt-1][ut]+ct;const bt=round(dt+vt,2);return{key:`position.${it}`,value:bt,schemaId:At.id}}))},ot=[createButtonConfig("left",jsxRuntimeExports.jsx("path",{d:"M4,22H2V2h2V22z M22,7H6v3h16V7z M16,14H6v3h10V14z"}),()=>nt("left")),createButtonConfig("center",jsxRuntimeExports.jsx("polygon",{points:"11,2 13,2 13,7 21,7 21,10 13,10 13,14 18,14 18,17 13,17 13,22 11,22 11,17 6,17 6,14 11,14 11,10 3,10 3,7 11,7"}),()=>nt("center")),createButtonConfig("right",jsxRuntimeExports.jsx("path",{d:"M20,2h2v20h-2V2z M2,10h16V7H2V10z M8,17h10v-3H8V17z"}),()=>nt("right")),createButtonConfig("top",jsxRuntimeExports.jsx("path",{d:"M22,2v2H2V2H22z M7,22h3V6H7V22z M14,16h3V6h-3V16z"}),()=>nt("top")),createButtonConfig("middle",jsxRuntimeExports.jsx("polygon",{points:"22,11 17,11 17,6 14,6 14,11 10,11 10,3 7,3 7,11 1.84,11 1.84,13 7,13 7,21 10,21 10,13 14,13 14,18 17,18 17,13 22,13"}),()=>nt("middle")),createButtonConfig("bottom",jsxRuntimeExports.jsx("path",{d:"M22,22H2v-2h20V22z M10,2H7v16h3V2z M17,8h-3v10h3V8z"}),()=>nt("bottom")),createButtonConfig("vertical",jsxRuntimeExports.jsx("path",{d:"M22,2v2H2V2H22z M7,10.5v3h10v-3H7z M2,20v2h20v-2H2z"}),()=>at("vertical")),createButtonConfig("horizontal",jsxRuntimeExports.jsx("path",{d:"M4,22H2V2h2V22z M22,2h-2v20h2V2z M13.5,7h-3v10h3V7z"}),()=>at("horizontal"))];return jsxRuntimeExports.jsx(Form$3.Item,{label:tt.title,children:jsxRuntimeExports.jsx(Button$2.Group,{children:ot.map(rt=>jsxRuntimeExports.jsx(Button$2,{style:{padding:7},disabled:s.length<=2&&["vertical","horizontal"].includes(rt.id),...rt},rt.id))})})},AlignWidget$1=AlignWidget,WidgetRenderer=a=>{const{widget:s,...$}=a,_=reactExports.useRef(null);return reactExports.useEffect(()=>(_.current&&(_.current.innerHTML="",s({...$,rootElement:_.current})),()=>{_.current&&(_.current.innerHTML="")}),[a.activeSchema]),jsxRuntimeExports.jsx("div",{ref:_})},WidgetRenderer$1=WidgetRenderer,ButtonGroupWidget=a=>{const{activeElements:s,changeSchemas:$,schemas:_,schema:_e}=a,tt=ot=>{const rt=ot.key,st=ot.type,lt=s.map(it=>it.id),et=_.filter(it=>lt.includes(it.id));$(et.map(it=>{const ut=it[rt]??!1,ft=st==="boolean"?!ut:ot.value;return{key:rt,value:ft,schemaId:it.id}}))},nt=ot=>{const rt=ot.key,st=ot.type;let lt=!1;const et=s.map(ut=>ut.id);return _.filter(ut=>et.includes(ut.id)).forEach(ut=>{lt=st==="boolean"?ut[rt]??!1:ut[rt]===ot.value}),lt},at=ot=>{const rt=`data:image/svg+xml;utf8,${encodeURIComponent(ot)}`;return jsxRuntimeExports.jsx("img",{width:17,height:17,src:rt})};return jsxRuntimeExports.jsx(Form$3.Item,{children:jsxRuntimeExports.jsx(Button$2.Group,{children:_e.buttons.map((ot,rt)=>{const st=nt(ot);return jsxRuntimeExports.jsx(Button$2,{type:st?"primary":void 0,ghost:st,onClick:()=>tt(ot),style:{padding:7,zIndex:st?2:0},icon:at(ot.icon)},rt)})})})},ButtonGroupWidget$1=ButtonGroupWidget,{Text:Text$2}=Typography$1,DetailView=a=>{const{token:s}=theme.useToken(),{size:$,changeSchemas:_,deselectSchema:_e,activeSchema:tt,activeElements:nt}=a,at=useForm(),ot=reactExports.useContext(I18nContext),rt=reactExports.useContext(PluginsRegistry),st=reactExports.useContext(OptionsContext);reactExports.useState({});const lt={...tt};lt.x=lt.position.x,lt.y=lt.position.y,delete lt.position,at.setValues(lt);const et=pt=>{const mt=(vt,At)=>typeof vt=="object"?JSON.stringify(vt)!==JSON.stringify(At):vt!==At;let ct=[];for(let vt in pt){if(["id","content"].includes(vt))continue;let At=pt[vt],xt=!1;["x","y"].includes(vt)?(xt=At!==tt.position[vt],vt="position."+vt):xt=mt(At,tt[vt]),xt&&(At===null&&["rotate","opacity"].includes(vt)&&(At=void 0),ct.push({key:vt,value:At,schemaId:tt.id}))}ct.length&&at.validateFields().then(()=>_(ct)).catch(vt=>{vt.errorFields.length&&(ct=ct.filter(At=>!vt.errorFields.find(xt=>xt.name.includes(At.key)))),ct.length&&_(ct)})},it=Object.values(rt).find(pt=>(pt==null?void 0:pt.propPanel.defaultSchema.type)===tt.type),ut=it==null?void 0:it.propPanel.schema;ut||console.error(`[@pdfme/ui] No propPanel.schema for ${tt.type}.
|
708
|
-
Check this document: https://pdfme.com/docs/custom-schemas`);const
|
707
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _unsupportedIterableToArray(a,s){if(a){if(typeof a=="string")return _arrayLikeToArray(a,s);var $=Object.prototype.toString.call(a).slice(8,-1);if($==="Object"&&a.constructor&&($=a.constructor.name),$==="Map"||$==="Set")return Array.from(a);if($==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test($))return _arrayLikeToArray(a,s)}}function _arrayLikeToArray(a,s){(s==null||s>a.length)&&(s=a.length);for(var $=0,_=new Array(s);$<s;$++)_[$]=a[$];return _}function _iterableToArrayLimit(a,s){var $=a==null?null:typeof Symbol<"u"&&a[Symbol.iterator]||a["@@iterator"];if($!=null){var _,_e,tt,nt,at=[],ot=!0,rt=!1;try{if(tt=($=$.call(a)).next,s===0){if(Object($)!==$)return;ot=!1}else for(;!(ot=(_=tt.call($)).done)&&(at.push(_.value),at.length!==s);ot=!0);}catch(st){rt=!0,_e=st}finally{try{if(!ot&&$.return!=null&&(nt=$.return(),Object(nt)!==nt))return}finally{if(rt)throw _e}}return at}}function _arrayWithHoles(a){if(Array.isArray(a))return a}var updateSchemaByPath=function a(s,$,_){var _e=getSchemaFullPath(s,_),tt=_get(_,_e,{}),nt=isFunction$2($)?$(tt):$,at=Object.assign(Object.assign({},tt),nt);nt.props&&(at.props=Object.assign(Object.assign({},tt==null?void 0:tt.props),nt.props)),_set(_,_e,at)},getFieldName=function a(s){if(s){if(typeof s=="boolean")return s;var $=[];return isArray$3(s)&&($=s.map(function(_){return _.split(".").map(function(_e){return isNaN(Number(_e))?_e:_e*1})})),$=s.split(".").map(function(_){return isNaN(Number(_))?_:_*1}),$=$.map(function(_){return typeof _=="string"&&(_==null?void 0:_.indexOf("["))===0&&(_==null?void 0:_.indexOf("]"))===(_==null?void 0:_.length)-1?Number(_.substring(1,_.length-1)):_}),$}},useForm=function a(){var s=Form$3.useForm(),$=_slicedToArray(s,1),_=$[0],_e=reactExports.useRef({}),tt=reactExports.useRef(),nt=reactExports.useRef({}),at=reactExports.useRef({});_.getFieldError;var ot=_.getFieldsError,rt=_.getFieldInstance,st=_.setFieldsValue,lt=_.setFields,et=_.scrollToField,it=_.isFieldsTouched,ut=_.isFieldTouched,ft=_.isFieldValidating,ht=_.resetFields,dt=_.validateFields,gt=__rest$3(_,["getFieldError","getFieldsError","getFieldInstance","setFieldsValue","setFields","scrollToField","isFieldsTouched","isFieldTouched","isFieldValidating","resetFields","validateFields"]),pt=gt,mt=function(At){var xt=tt.current.setState;xt||setTimeout(function(){xt({schema:nt.current,flattenSchema:_e.current})},0),xt(At)},ct=function(At){_e.current=flattenSchema(At)||{},nt.current=At,mt({schema:At,flattenSchema:_e.current})};return pt.setSchema=function(vt){var At=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(isObject$6(vt)){if(At){ct(vt);return}var xt=cloneDeep(nt.current);Object.keys(vt||{}).forEach(function(bt){updateSchemaByPath(bt,vt[bt],xt)}),ct(xt)}},pt.setSchemaByPath=function(vt,At){if(!(!hasFuncProperty(At)&&_isMatch(At,pt.getSchemaByPath(vt)))){var xt=cloneDeep(nt.current);updateSchemaByPath(vt,At,xt),ct(xt)}},pt.setValues=function(vt){var At=parseBindToValues(vt,_e.current);st(At)},pt.getValues=function(vt,At){var xt,bt=cloneDeep(_.getFieldsValue(getFieldName(vt),At)),Et=((xt=tt.current)===null||xt===void 0?void 0:xt.getState())||{},St=Et.removeHiddenData;return St&&(bt=filterValuesHidden(bt,_e.current)),bt=filterValuesUndefined(bt),parseValuesToBind(bt,_e.current)},pt.getValueByPath=function(vt){var At=getFieldName(vt);return _.getFieldValue(At)},pt.setValueByPath=function(vt,At){if(!_.setFieldValue){var xt=_.getFieldsValue();_set(xt,vt,At),pt.setValues(xt);return}var bt=getFieldName(vt);_.setFieldValue(bt,At);try{JSON.stringify(_.getFieldValue(bt))!==JSON.stringify(At)&&_.setFieldValue(bt,At)}catch{}},pt.getSchemaByPath=function(vt){typeof vt!="string"&&console.warn("请输入正确的路径");var At=getSchemaFullPath(vt,nt.current);return _get(nt.current,At)},pt.getSchema=function(){return nt.current},pt.setErrorFields=function(vt){var At=transformFieldsData(vt,getFieldName);At&<(At)},pt.removeErrorField=function(vt){lt([{name:getFieldName(vt),errors:[]}])},pt.getFieldError=function(vt){var At=getFieldName(vt);return _.getFieldError(At)},pt.getFieldsError=function(vt){var At=getFieldName(vt);return ot(At)},pt.getFieldInstance=function(vt){var At=getFieldName(vt);return rt(At)},pt.getHiddenValues=function(){var vt=pt.getValues(),At=pt.getValues(!0),xt={},bt=function Et(St,Bt,Ot){Object.keys(St).forEach(function(Tt){var wt=St[Tt],Ct=Ot?"".concat(Ot,".").concat(Tt):Tt;if(!Bt.hasOwnProperty(Tt)){_set(xt,Ct,wt);return}isObject$6(wt)&&Et(wt,Bt[Tt],Ct),isArray$3(wt)&&wt.map(function(It,yt){Et(It,_get(Bt,"".concat(Tt,"[").concat(yt,"]"),[]),"".concat(Ct,"[").concat(yt,"]"))})})};return bt(At,vt,null),xt},pt.setFields=function(vt){var At=transformFieldsData(vt,getFieldName);At&<(At)},pt.__initStore=function(vt){tt.current=vt},pt.scrollToPath=function(vt){for(var At=getFieldName(vt),xt=arguments.length,bt=new Array(xt>1?xt-1:0),Et=1;Et<xt;Et++)bt[Et-1]=arguments[Et];et.apply(void 0,[At].concat(bt))},pt.isFieldsTouched=function(vt,At){var xt=(vt||[]).map(function(bt){return getFieldName(bt)});return it(xt,At)},pt.isFieldTouched=function(vt){var At=getFieldName(vt);return ut(At)},pt.isFieldValidating=function(vt){var At=getFieldName(vt);return ft(At)},pt.resetFields=function(vt){var At=(vt||[]).map(function(xt){return getFieldName(xt)});At.length>0?ht(At):ht()},pt.validateFields=function(vt){var At=(vt||[]).map(function(xt){return getFieldName(xt)});return At.length>0?dt(At):dt()},pt.getFlattenSchema=function(vt){var At;return vt?(At=_e.current)===null||At===void 0?void 0:At[vt]:_e.current},pt.onItemChange=pt.setValueByPath,pt.setFieldRef=function(vt,At){vt&&(at.current[vt]=At)},pt.getFieldRef=function(vt){return at.current[vt]},pt};const FormRender=withProvider(FormCore,defaultWidgets),svgBaseProp={style:{width:"90%",height:"90%"},xmlns:"http://www.w3.org/2000/svg",enableBackground:"new 0 0 24 24",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#000000"},createSvgIcon=a=>jsxRuntimeExports.jsxs("svg",{...svgBaseProp,children:[jsxRuntimeExports.jsx("rect",{fill:"none",height:"24",width:"24"}),a]}),createButtonConfig=(a,s,$)=>({id:a,icon:createSvgIcon(s),onClick:$}),AlignWidget=a=>{const{activeElements:s,changeSchemas:$,schemas:_,pageSize:_e,schema:tt}=a,nt=rt=>{const st=s.map(ct=>ct.id),lt=_.filter(ct=>st.includes(ct.id)),et=["left","center","right"].includes(rt),it=et?"x":"y",ut=et?"width":"height",ft=lt.length===1,ht=_e[ut],dt=ft?0:Math.min(...lt.map(ct=>ct.position[it])),gt=ft?ht:Math.max(...lt.map(ct=>ct.position[it]+ct[ut]));let pt=dt,mt=ct=>0;["center","middle"].includes(rt)?(pt=(dt+gt)/2,mt=ct=>ct/2):["right","bottom"].includes(rt)&&(pt=gt,mt=ct=>ct),$(lt.map(ct=>({key:`position.${it}`,value:round(pt-mt(ct[ut]),2),schemaId:ct.id})))},at=rt=>{const st=s.map(At=>At.id),lt=_.filter(At=>st.includes(At.id)),et=rt==="vertical",it=et?"y":"x",ut=et?"height":"width",ft=Math.min(...lt.map(At=>At.position[it])),ht=Math.max(...lt.map(At=>At.position[it]+At[ut]));if(lt.length<3)return;const dt=ft,gt=ht-ft,pt=lt.reduce((At,xt)=>At+xt[ut],0),ct=(gt-pt)/(lt.length-1);let vt=0;$(lt.map((At,xt)=>{vt+=xt===0?0:lt[xt-1][ut]+ct;const bt=round(dt+vt,2);return{key:`position.${it}`,value:bt,schemaId:At.id}}))},ot=[createButtonConfig("left",jsxRuntimeExports.jsx("path",{d:"M4,22H2V2h2V22z M22,7H6v3h16V7z M16,14H6v3h10V14z"}),()=>nt("left")),createButtonConfig("center",jsxRuntimeExports.jsx("polygon",{points:"11,2 13,2 13,7 21,7 21,10 13,10 13,14 18,14 18,17 13,17 13,22 11,22 11,17 6,17 6,14 11,14 11,10 3,10 3,7 11,7"}),()=>nt("center")),createButtonConfig("right",jsxRuntimeExports.jsx("path",{d:"M20,2h2v20h-2V2z M2,10h16V7H2V10z M8,17h10v-3H8V17z"}),()=>nt("right")),createButtonConfig("top",jsxRuntimeExports.jsx("path",{d:"M22,2v2H2V2H22z M7,22h3V6H7V22z M14,16h3V6h-3V16z"}),()=>nt("top")),createButtonConfig("middle",jsxRuntimeExports.jsx("polygon",{points:"22,11 17,11 17,6 14,6 14,11 10,11 10,3 7,3 7,11 1.84,11 1.84,13 7,13 7,21 10,21 10,13 14,13 14,18 17,18 17,13 22,13"}),()=>nt("middle")),createButtonConfig("bottom",jsxRuntimeExports.jsx("path",{d:"M22,22H2v-2h20V22z M10,2H7v16h3V2z M17,8h-3v10h3V8z"}),()=>nt("bottom")),createButtonConfig("vertical",jsxRuntimeExports.jsx("path",{d:"M22,2v2H2V2H22z M7,10.5v3h10v-3H7z M2,20v2h20v-2H2z"}),()=>at("vertical")),createButtonConfig("horizontal",jsxRuntimeExports.jsx("path",{d:"M4,22H2V2h2V22z M22,2h-2v20h2V2z M13.5,7h-3v10h3V7z"}),()=>at("horizontal"))];return jsxRuntimeExports.jsx(Form$3.Item,{label:tt.title,children:jsxRuntimeExports.jsx(Button$2.Group,{children:ot.map(rt=>jsxRuntimeExports.jsx(Button$2,{style:{padding:7},disabled:s.length<=2&&["vertical","horizontal"].includes(rt.id),...rt},rt.id))})})},AlignWidget$1=AlignWidget,WidgetRenderer=a=>{const{widget:s,...$}=a,_=reactExports.useRef(null);return reactExports.useEffect(()=>(_.current&&(_.current.innerHTML="",s({...$,rootElement:_.current})),()=>{_.current&&(_.current.innerHTML="")}),[a.activeSchema]),jsxRuntimeExports.jsx("div",{ref:_})},WidgetRenderer$1=WidgetRenderer,ButtonGroupWidget=a=>{const{activeElements:s,changeSchemas:$,schemas:_,schema:_e}=a,tt=ot=>{const rt=ot.key,st=ot.type,lt=s.map(it=>it.id),et=_.filter(it=>lt.includes(it.id));$(et.map(it=>{const ut=it[rt]??!1,ft=st==="boolean"?!ut:ot.value;return{key:rt,value:ft,schemaId:it.id}}))},nt=ot=>{const rt=ot.key,st=ot.type;let lt=!1;const et=s.map(ut=>ut.id);return _.filter(ut=>et.includes(ut.id)).forEach(ut=>{lt=st==="boolean"?ut[rt]??!1:ut[rt]===ot.value}),lt},at=ot=>{const rt=`data:image/svg+xml;utf8,${encodeURIComponent(ot)}`;return jsxRuntimeExports.jsx("img",{width:17,height:17,src:rt})};return jsxRuntimeExports.jsx(Form$3.Item,{children:jsxRuntimeExports.jsx(Button$2.Group,{children:_e.buttons.map((ot,rt)=>{const st=nt(ot);return jsxRuntimeExports.jsx(Button$2,{type:st?"primary":void 0,ghost:st,onClick:()=>tt(ot),style:{padding:7,zIndex:st?2:0},icon:at(ot.icon)},rt)})})})},ButtonGroupWidget$1=ButtonGroupWidget,{Text:Text$2}=Typography$1,DetailView=a=>{const{token:s}=theme.useToken(),{size:$,changeSchemas:_,deselectSchema:_e,activeSchema:tt}=a,nt=useForm(),at=reactExports.useContext(I18nContext),ot=reactExports.useContext(PluginsRegistry),rt=reactExports.useContext(OptionsContext);reactExports.useEffect(()=>{const dt={...tt};dt.x=dt.position.x,dt.y=dt.position.y,delete dt.position,nt.setValues(dt)},[tt,nt]);const st=dt=>{const gt=(mt,ct)=>typeof mt=="object"?JSON.stringify(mt)!==JSON.stringify(ct):mt!==ct;let pt=[];for(let mt in dt){if(["id","content"].includes(mt))continue;let ct=dt[mt],vt=!1;["x","y"].includes(mt)?(vt=ct!==tt.position[mt],mt="position."+mt):vt=gt(ct,tt[mt]),vt&&(ct===null&&["rotate","opacity"].includes(mt)&&(ct=void 0),pt.push({key:mt,value:ct,schemaId:tt.id}))}pt.length&&nt.validateFields().then(()=>_(pt)).catch(mt=>{mt.errorFields.length&&(pt=pt.filter(ct=>!mt.errorFields.find(vt=>vt.name.includes(ct.key)))),pt.length&&_(pt)})},lt=Object.values(ot).find(dt=>(dt==null?void 0:dt.propPanel.defaultSchema.type)===tt.type),et=lt==null?void 0:lt.propPanel.schema;et||console.error(`[@pdfme/ui] No propPanel.schema for ${tt.type}.
|
708
|
+
Check this document: https://pdfme.com/docs/custom-schemas`);const it=Object.entries(ot).map(([dt,gt])=>({label:dt,value:gt==null?void 0:gt.propPanel.defaultSchema.type})),ut=lt.propPanel.defaultSchema,ft={type:"object",column:2,properties:{type:{title:at("type"),type:"string",widget:"select",props:{options:it},required:!0,span:12},key:{title:at("fieldName"),type:"string",required:!0,span:12},"-":{type:"void",widget:"Divider"},align:{title:at("align"),type:"void",widget:"AlignWidget"},x:{title:"X",type:"number",widget:"inputNumber",required:!0,span:8,min:0},y:{title:"Y",type:"number",widget:"inputNumber",required:!0,span:8,min:0},rotate:{title:at("rotate"),type:"number",widget:"inputNumber",disabled:(ut==null?void 0:ut.rotate)===void 0,max:360,props:{min:0},span:8},width:{title:at("width"),type:"number",widget:"inputNumber",required:!0,span:8,props:{min:0}},height:{title:at("height"),type:"number",widget:"inputNumber",required:!0,span:8,props:{min:0}},opacity:{title:at("opacity"),type:"number",widget:"inputNumber",disabled:(ut==null?void 0:ut.opacity)===void 0,props:{step:.1,min:0,max:1},span:8}}};if(typeof et=="function"){const dt=et({...a,options:rt,theme:s,i18n:at})||{};ft.properties={...ft.properties,...Object.keys(dt).length===0?{}:{"--":{type:"void",widget:"Divider"}},...dt}}else{const dt=et||{};ft.properties={...ft.properties,...Object.keys(dt).length===0?{}:{"--":{type:"void",widget:"Divider"}},...dt}}const ht={AlignWidget:dt=>jsxRuntimeExports.jsx(AlignWidget$1,{...dt,...a,options:rt}),Divider:()=>jsxRuntimeExports.jsx(Divider$1,{style:{marginTop:s.marginXS,marginBottom:s.marginXS}}),ButtonGroup:dt=>jsxRuntimeExports.jsx(ButtonGroupWidget$1,{...dt,...a,options:rt})};for(const dt of Object.values(ot)){const gt=(dt==null?void 0:dt.propPanel.widgets)||{};Object.entries(gt).forEach(([pt,mt])=>{ht[pt]=ct=>jsxRuntimeExports.jsx(WidgetRenderer$1,{...ct,...a,options:rt,theme:s,i18n:at,widget:mt})})}return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{style:{height:40,display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(Button$2,{style:{position:"absolute",zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},onClick:_e,icon:jsxRuntimeExports.jsx(MenuOutlined$1,{})}),jsxRuntimeExports.jsx(Text$2,{strong:!0,style:{textAlign:"center",width:"100%"},children:at("editField")})]}),jsxRuntimeExports.jsx(Divider$1,{style:{marginTop:s.marginXS,marginBottom:s.marginXS}}),jsxRuntimeExports.jsx("div",{style:{height:getSidebarContentHeight($.height),overflowY:"auto",overflowX:"hidden"},children:jsxRuntimeExports.jsx(FormRender,{form:nt,schema:ft,widgets:ht,watch:{"#":st},locale:"en-US"})})]})},propsAreUnchanged=(a,s)=>JSON.stringify(a.activeSchema)==JSON.stringify(s.activeSchema),DetailView$1=React$a.memo(DetailView,propsAreUnchanged),Sidebar=a=>{const{sidebarOpen:s,setSidebarOpen:$,activeElements:_,schemas:_e}=a,{token:tt}=theme.useToken(),nt=()=>_e.filter(ot=>_.map(rt=>rt.id).includes(ot.id)),at=()=>{const ot=nt();return ot[ot.length-1]};return jsxRuntimeExports.jsx("div",{style:{position:"absolute",right:0,zIndex:1,height:"100%",width:s?RIGHT_SIDEBAR_WIDTH:0},children:jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(Button$2,{style:{position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",top:"1rem",right:"1rem",zIndex:100},icon:s?jsxRuntimeExports.jsx(ArrowRightOutlined$1,{}):jsxRuntimeExports.jsx(ArrowLeftOutlined$1,{}),onClick:()=>$(!s)}),jsxRuntimeExports.jsx("div",{style:{width:RIGHT_SIDEBAR_WIDTH,height:"100%",display:s?"block":"none",top:0,right:0,position:"absolute",padding:"0.7rem 1rem",overflowY:"auto",fontFamily:"'Open Sans', sans-serif",boxSizing:"border-box",background:tt.colorBgLayout},children:jsxRuntimeExports.jsx("div",{children:nt().length===0?jsxRuntimeExports.jsx(ListView$1,{...a}):jsxRuntimeExports.jsx(DetailView$1,{...a,activeSchema:at()})})})]})})},RightSidebar=Sidebar,useRerenderDependencies=({plugin:a,value:s,mode:$,scale:_,schema:_e,options:tt})=>reactExports.useMemo(()=>a.uninterruptedEditMode&&$==="designer"?[$]:[s,$,_,JSON.stringify(_e),JSON.stringify(tt)],[s,$,_,_e,tt]),Wrapper=({children:a,outline:s,onChangeHoveringSchemaId:$,schema:_})=>jsxRuntimeExports.jsx("div",{title:_.key,onMouseEnter:()=>$&&$(_.id),onMouseLeave:()=>$&&$(null),className:SELECTABLE_CLASSNAME,id:_.id,style:{position:"absolute",cursor:_.readOnly?"initial":"pointer",height:_.height*ZOOM,width:_.width*ZOOM,top:_.position.y*ZOOM,left:_.position.x*ZOOM,transform:`rotate(${_.rotate??0}deg)`,opacity:_.opacity??1,outline:s},children:a}),Renderer=a=>{const s=reactExports.useContext(PluginsRegistry),$=reactExports.useContext(OptionsContext),_=reactExports.useContext(I18nContext),{token:_e}=theme.useToken(),{schema:tt,basePdf:nt,value:at,mode:ot,onChange:rt,stopEditing:st,tabIndex:lt,placeholder:et,scale:it}=a,ut=reactExports.useRef(null),ft=reactExports.useRef(new Map),ht=Object.values(s).find(gt=>(gt==null?void 0:gt.propPanel.defaultSchema.type)===tt.type);if(!ht||!ht.ui)return console.error(`[@pdfme/ui] Renderer for type ${tt.type} not found.
|
709
709
|
Check this document: https://pdfme.com/docs/custom-schemas`),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{});const dt=useRerenderDependencies({plugin:ht,value:at,mode:ot,scale:it,schema:tt,options:$});return reactExports.useEffect(()=>{if(ut.current&&tt.type){ut.current.innerHTML="";const gt=ht.ui;gt({key:tt.key,value:at,schema:tt,basePdf:nt,rootElement:ut.current,mode:ot,onChange:rt,stopEditing:st,tabIndex:lt,placeholder:et,options:$,theme:_e,i18n:_,pdfJs,_cache:ft.current})}return()=>{ut.current&&(ut.current.innerHTML="")}},dt),jsxRuntimeExports.jsx(Wrapper,{...a,children:jsxRuntimeExports.jsx("div",{style:{height:"100%",width:"100%"},ref:ut})})},Renderer$1=Renderer,Draggable$1=a=>{const{scale:s,basePdf:$,plugin:_}=a,{token:_e}=theme.useToken(),tt=_.propPanel.defaultSchema,nt=useDraggable({id:tt.type,data:tt}),{listeners:at,setNodeRef:ot,attributes:rt,transform:st,isDragging:lt}=nt,et={transform:CSS$1.Translate.toString(st)};return jsxRuntimeExports.jsxs("div",{ref:ot,style:et,...at,...rt,children:[lt&&jsxRuntimeExports.jsx("div",{style:{transform:`scale(${s})`},children:jsxRuntimeExports.jsx(Renderer$1,{schema:{...tt,id:tt.type,key:tt.type},basePdf:$,value:tt.content||"",onChangeHoveringSchemaId:()=>{},mode:"viewer",outline:`1px solid ${_e.colorPrimary}`,scale:s},tt.type)}),jsxRuntimeExports.jsx("div",{style:{visibility:lt?"hidden":"visible"},children:a.children})]})},LeftSidebar=({height:a,scale:s,basePdf:$})=>{const{token:_}=theme.useToken(),_e=reactExports.useContext(PluginsRegistry),tt=reactExports.useContext(OptionsContext),[nt,at]=reactExports.useState(!1);return reactExports.useEffect(()=>{const ot=()=>{nt&&at(!1)};return document.addEventListener("mouseup",ot),()=>{document.removeEventListener("mouseup",ot)}},[nt]),jsxRuntimeExports.jsx("div",{style:{left:0,right:0,position:"absolute",zIndex:1,height:a,width:45,background:_.colorBgLayout,textAlign:"center",overflow:nt?"visible":"auto"},children:Object.entries(_e).map(([ot,rt])=>{var lt;if(!(rt!=null&&rt.propPanel.defaultSchema))return null;const st=((lt=tt.icons)==null?void 0:lt[rt.propPanel.defaultSchema.type])??rt.icon;return jsxRuntimeExports.jsx(Draggable$1,{scale:s,basePdf:$,plugin:rt,children:jsxRuntimeExports.jsx(Button$2,{title:ot,onMouseDown:()=>{at(!0)},style:{width:35,height:35,marginTop:"0.25rem",padding:"0.25rem"},children:st?jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:st}}):jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:ot})})},ot)})})},LeftSidebar$1=LeftSidebar,Paper=a=>{const{paperRefs:s,scale:$,size:_,schemasList:_e,pageSizes:tt,backgrounds:nt,renderPaper:at,renderSchema:ot,hasRulers:rt}=a,st=reactExports.useContext(FontContext),lt=rt?RULER_HEIGHT:0;return tt.length!==nt.length||tt.length!==_e.length?null:jsxRuntimeExports.jsx("div",{style:{transform:`scale(${$})`,transformOrigin:"top left",height:$,width:$},children:nt.map((et,it)=>{const ut=tt[it],ft={width:ut.width*ZOOM,height:ut.height*ZOOM},ht=ft.width*$+lt<_.width?`${(_.width/$-ft.width)/2}px`:`${lt}px`;let dt=it>0?(lt+PAGE_GAP)*(it+1):lt;return rt||(dt+=PAGE_GAP*2),jsxRuntimeExports.jsxs("div",{ref:gt=>{gt&&(s.current[it]=gt)},onMouseDown:gt=>{gt.currentTarget===gt.target&&document&&document.hasFocus()&&document.activeElement instanceof HTMLElement&&document.activeElement.blur()},style:{fontFamily:`'${getFallbackFontName(st)}'`,top:`${dt}px`,left:ht,position:"relative",backgroundImage:`url(${et})`,backgroundSize:`${ft.width}px ${ft.height}px`,...ft},children:[at&&at({paperSize:ft,index:it}),_e[it].map((gt,pt)=>jsxRuntimeExports.jsx("div",{children:ot({schema:gt,index:it===0?pt:pt+_e[it-1].length})},gt.id))]},String(it)+JSON.stringify(ft))})})},Paper$1=Paper;var FUNCTION="function",OBJECT="object",STRING="string",UNDEFINED="undefined",doc=typeof document!==UNDEFINED&&document,OPEN_CLOSED_CHARACTERS=[{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"},{open:'\\"',close:'\\"'},{open:"\\'",close:"\\'"}],TINY_NUM$1=1e-7,DEFAULT_UNIT_PRESETS={cm:function(a){return a*96/2.54},mm:function(a){return a*96/254},in:function(a){return a*96},pt:function(a){return a*96/72},pc:function(a){return a*96/6},"%":function(a,s){return a*s/100},vw:function(a,s){return s===void 0&&(s=window.innerWidth),a/100*s},vh:function(a,s){return s===void 0&&(s=window.innerHeight),a/100*s},vmax:function(a,s){return s===void 0&&(s=Math.max(window.innerWidth,window.innerHeight)),a/100*s},vmin:function(a,s){return s===void 0&&(s=Math.min(window.innerWidth,window.innerHeight)),a/100*s}};/*! *****************************************************************************
|
710
710
|
Copyright (c) Microsoft Corporation.
|
711
711
|
|
@@ -1142,4 +1142,4 @@ canvas {
|
|
1142
1142
|
.adder.dragging {
|
1143
1143
|
display: block;
|
1144
1144
|
}
|
1145
|
-
`),GuidesElement=defaultStyled("div",GUIDES_CSS),Guides$1=function(a){__extends(s,a);function s(){var _=a!==null&&a.apply(this,arguments)||this;return _.state={guides:[]},_.scrollPos=0,_.guideElements=[],_.onDragStart=function(_e){var tt=_e.datas,nt=_e.inputEvent,at=_.props.onDragStart;addClass(tt.target,DRAGGING),_.onDrag(_e),at(__assign({},_e,{dragElement:tt.target})),nt.stopPropagation(),nt.preventDefault()},_.onDrag=function(_e){var tt=_.movePos(_e);return _.props.onDrag(__assign({},_e,{dragElement:_e.datas.target})),tt},_.onDragEnd=function(_e){var tt=_e.datas,nt=_e.isDouble,at=_e.distX,ot=_e.distY,rt=_.movePos(_e),st=_.state.guides,lt=_.props,et=lt.onChangeGuides,it=lt.zoom,ut=lt.displayDragPos,ft=lt.digit,ht=lt.lockGuides,dt=parseFloat((rt/it).toFixed(ft||0));if(ut&&(_.displayElement.style.cssText+="display: none;"),removeClass(tt.target,DRAGGING),_.props.onDragEnd(__assign({},_e,{dragElement:tt.target})),tt.fromRuler)rt>=_.scrollPos&&st.indexOf(dt)<0&&_.setState({guides:st.concat([dt])},function(){et({guides:_.state.guides,distX:at,distY:ot,isAdd:!0,isRemove:!1,isChange:!1})});else{var gt=tt.target.getAttribute("data-index"),pt=!1,mt=!1;if(st=st.slice(),nt||dt<_.scrollPos){if(ht&&(ht===!0||ht.indexOf("remove")>-1))return;st.splice(gt,1),pt=!0}else{if(st.indexOf(dt)>-1)return;if(ht&&(ht===!0||ht.indexOf("change")>-1))return;st[gt]=dt,mt=!0}_.setState({guides:st},function(){var ct=_.state.guides;et({distX:at,distY:ot,guides:ct,isAdd:!1,isChange:mt,isRemove:pt})})}},_}var $=s.prototype;return $.render=function(){var _=this.props,_e=_.className,tt=_.type,nt=_.zoom,at=_.style,ot=_.rulerStyle,rt=_.displayDragPos,st=_.cspNonce,lt=_.dragGuideStyle,et=_.portalContainer,it=this.props,ut=this.getTranslateName(),ft={};return PROPERTIES.forEach(function(ht){ht!=="style"&&(ft[ht]=it[ht])}),reactExports.createElement(GuidesElement,{ref:ref(this,"manager"),cspNonce:st,className:prefix("manager",tt)+" "+_e,portalContainer:et,style:at},reactExports.createElement("div",{className:prefix("guide-origin"),ref:ref(this,"originElement")}),reactExports.createElement(Ruler$1,__assign({ref:ref(this,"ruler"),style:ot},ft)),reactExports.createElement("div",{className:GUIDES,ref:ref(this,"guidesElement"),style:{transform:ut+"("+-this.scrollPos*nt+"px)"}},rt&&reactExports.createElement("div",{className:DISPLAY_DRAG,ref:ref(this,"displayElement"),style:lt}),reactExports.createElement("div",{className:ADDER,ref:ref(this,"adderElement")}),this.renderGuides()))},$.renderGuides=function(){var _=this,_e=this.props,tt=_e.type,nt=_e.zoom,at=_e.showGuides,ot=_e.guideStyle,rt=this.getTranslateName(),st=this.state.guides;if(this.guideElements=[],at)return st.map(function(lt,et){return reactExports.createElement("div",{className:prefix("guide",tt),ref:refs(_,"guideElements",et),key:et,"data-index":et,"data-pos":lt,style:__assign({},ot,{transform:rt+"("+lt*nt+"px) translateZ(0px)"})})})},$.componentDidMount=function(){var _=this;this.gesto=new Gesto(this.manager.getElement(),{container:document.body}).on("dragStart",function(_e){var tt=_.props,nt=tt.type,at=tt.zoom,ot=tt.lockGuides;if(ot===!0){_e.stop();return}var rt=_e.inputEvent,st=rt.target,lt=_e.datas,et=_.ruler.canvasElement,it=_.guidesElement,ut=nt==="horizontal",ft=_.originElement.getBoundingClientRect(),ht=getDistElementMatrix(_.manager.getElement()),dt=calculateMatrixDist(ht,[_e.clientX-ft.left,_e.clientY-ft.top]);dt[0]-=it.offsetLeft,dt[1]-=it.offsetTop,dt[ut?1:0]+=_.scrollPos*at,lt.offsetPos=dt,lt.matrix=ht;var gt=ot&&ot.indexOf("add")>-1,pt=ot&&ot.indexOf("remove")>-1,mt=ot&&ot.indexOf("change")>-1;if(st===et){if(gt){_e.stop();return}lt.fromRuler=!0,lt.target=_.adderElement}else if(hasClass(st,GUIDE)){if(pt&&mt){_e.stop();return}lt.target=st}else return _e.stop(),!1;_.onDragStart(_e)}).on("drag",this.onDrag).on("dragEnd",this.onDragEnd),this.setState({guides:this.props.defaultGuides||[]})},$.componentWillUnmount=function(){this.gesto.unset()},$.componentDidUpdate=function(_){_.defaultGuides!==this.props.defaultGuides&&this.setState({guides:this.props.defaultGuides||[]})},$.loadGuides=function(_){this.setState({guides:_})},$.getGuides=function(){return this.state.guides},$.scrollGuides=function(_){var _e=this.props.zoom,tt=this.guidesElement;this.scrollPos=_,tt.style.transform=this.getTranslateName()+"("+-_*_e+"px)";var nt=this.state.guides;this.guideElements.forEach(function(at,ot){at&&(at.style.display=-_+nt[ot]<0?"none":"block")})},$.resize=function(){this.ruler.resize()},$.scroll=function(_){this.ruler.scroll(_)},$.movePos=function(_){var _e=_.datas,tt=_.distX,nt=_.distY,at=this.props,ot=at.type,rt=at.zoom,st=at.snaps,lt=at.snapThreshold,et=at.displayDragPos,it=at.digit,ut=at.dragPosFormat||function(xt){return xt},ft=ot==="horizontal",ht=calculateMatrixDist(_e.matrix,[tt,nt]),dt=_e.offsetPos,gt=ht[0]+dt[0],pt=ht[1]+dt[1],mt=Math.round(ft?pt:gt),ct=parseFloat((mt/rt).toFixed(it||0)),vt=st.slice().sort(function(xt,bt){return Math.abs(ct-xt)-Math.abs(ct-bt)});if(vt.length&&Math.abs(vt[0]*rt-mt)<lt&&(ct=vt[0],mt=ct*rt),et){var At=ot==="horizontal"?[gt,mt]:[mt,pt];this.displayElement.style.cssText+="display: block;transform: translate(-50%, -50%) "+("translate("+At.map(function(xt){return xt+"px"}).join(", ")+")"),this.displayElement.innerHTML=""+ut(ct)}return _e.target.setAttribute("data-pos",ct),_e.target.style.transform=this.getTranslateName()+"("+mt+"px)",mt},$.getTranslateName=function(){return this.props.type==="horizontal"?"translateY":"translateX"},s.defaultProps={className:"",type:"horizontal",zoom:1,style:{},snapThreshold:5,snaps:[],digit:0,onChangeGuides:function(){},onDragStart:function(){},onDrag:function(){},onDragEnd:function(){},displayDragPos:!1,dragPosFormat:function(_){return _},defaultGuides:[],lockGuides:!1,showGuides:!0,guideStyle:{},dragGuideStyle:{},portalContainer:null},s}(reactExports.PureComponent);const Guides$2=Guides$1,guideStyle=(a,s,$,_)=>({position:"absolute",top:a,left:s,height:$,width:_,background:"#333333"}),_Guides=({paperSize:a,horizontalRef:s,verticalRef:$})=>jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"ruler-container",style:guideStyle(-RULER_HEIGHT,-RULER_HEIGHT,RULER_HEIGHT,RULER_HEIGHT)}),jsxRuntimeExports.jsx(Guides$2,{zoom:ZOOM,style:guideStyle(-RULER_HEIGHT,0,RULER_HEIGHT,a.width),type:"horizontal",ref:s}),jsxRuntimeExports.jsx(Guides$2,{zoom:ZOOM,style:guideStyle(0,-RULER_HEIGHT,a.height,RULER_HEIGHT),type:"vertical",ref:$})]}),Guides=_Guides,Mask=({width:a,height:s})=>jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:-RULER_HEIGHT,left:-RULER_HEIGHT,zIndex:100,width:a,height:s,background:theme.useToken().token.colorBgMask}}),Mask$1=Mask,getPaddingStyle=(a,s,$)=>{const _={position:"absolute",background:$,opacity:.25,pointerEvents:"none"};switch(a){case 0:_.top=0,_.height=`${s*ZOOM}px`,_.left=0,_.right=0;break;case 1:_.right=0,_.width=`${s*ZOOM}px`,_.top=0,_.bottom=0;break;case 2:_.bottom=0,_.height=`${s*ZOOM}px`,_.left=0,_.right=0;break;case 3:_.left=0,_.width=`${s*ZOOM}px`,_.top=0,_.bottom=0;break}return _},Padding=({basePdf:a})=>jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:isBlankPdf(a)&&a.padding.map((s,$)=>jsxRuntimeExports.jsx("div",{style:getPaddingStyle($,s,theme.useToken().token.colorError)},String($)))}),Padding$1=Padding,mm2px=a=>a*3.7795275591,DELETE_BTN_ID=uuid$6(),fmt4Num=a=>Number(a.replace("px","")),fmt=a=>round(fmt4Num(a)/ZOOM,2),isTopLeftResize=a=>a==="-1,-1"||a==="-1,0"||a==="0,-1",normalizeRotate=a=>(a%360+360)%360,DeleteButton=({activeElements:a})=>{const{token:s}=theme.useToken(),$=26,_=Math.min(...a.map(({style:tt})=>fmt4Num(tt.top))),_e=Math.max(...a.map(({style:tt})=>fmt4Num(tt.left)+fmt4Num(tt.width)))+10;return jsxRuntimeExports.jsx(Button$2,{id:DELETE_BTN_ID,style:{position:"absolute",zIndex:1,top:_,left:_e,width:$,height:$,padding:2,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:s.borderRadius,color:s.colorWhite,background:s.colorPrimary},children:jsxRuntimeExports.jsx(CloseOutlined$4,{style:{pointerEvents:"none"}})})},Canvas=(a,s)=>{const{basePdf:$,pageCursor:_,scale:_e,backgrounds:tt,pageSizes:nt,size:at,activeElements:ot,schemasList:rt,hoveringSchemaId:st,onEdit:lt,changeSchemas:et,removeSchemas:it,onChangeHoveringSchemaId:ut,paperRefs:ft,sidebarOpen:ht}=a,{token:dt}=theme.useToken(),gt=reactExports.useContext(PluginsRegistry),pt=reactExports.useRef([]),mt=reactExports.useRef([]),ct=reactExports.useRef(null),[vt,At]=reactExports.useState(!1),[xt,bt]=reactExports.useState(!1),Et=usePrevious(rt[_]),St=Lt=>{Lt.shiftKey&&At(!0)},Bt=Lt=>{(Lt.key==="Shift"||!Lt.shiftKey)&&At(!1),(Lt.key==="Escape"||Lt.key==="Esc")&&bt(!1)},Ot=reactExports.useCallback(()=>{window.addEventListener("keydown",St),window.addEventListener("keyup",Bt)},[]),Tt=reactExports.useCallback(()=>{window.removeEventListener("keydown",St),window.removeEventListener("keyup",Bt)},[]);reactExports.useEffect(()=>(Ot(),Tt),[Ot,Tt]),reactExports.useEffect(()=>{var Pt,Dt;if((Pt=ct.current)==null||Pt.updateRect(),!Et)return;const Lt=JSON.stringify(Et[_]||{}),$t=JSON.stringify(rt[_]||{});Lt===$t&&((Dt=ct.current)==null||Dt.updateRect())},[_,rt,Et]);const wt=({target:Lt,top:$t,left:Pt})=>{const{width:Dt,height:Ut}=Lt.style,Vt=fmt(Dt),Qt=fmt(Ut),qt=$t/ZOOM,Zt=Pt/ZOOM,{width:ar,height:Jt}=nt[_];let rr=0,Yt=0,Kt=0,nr=0;if(isBlankPdf($)){const[tr,ir,sr,cr]=$.padding;rr=tr*ZOOM,Yt=ir,Kt=sr,nr=cr*ZOOM}qt+Qt>Jt-Kt?Lt.style.top=`${(Jt-Qt-Kt)*ZOOM}px`:Lt.style.top=`${$t<rr?rr:$t}px`,Zt+Vt>ar-Yt?Lt.style.left=`${(ar-Vt-Yt)*ZOOM}px`:Lt.style.left=`${Pt<nr?nr:Pt}px`},Ct=({target:Lt})=>{const{top:$t,left:Pt}=Lt.style;et([{key:"position.y",value:fmt($t),schemaId:Lt.id},{key:"position.x",value:fmt(Pt),schemaId:Lt.id}])},It=({targets:Lt})=>{const $t=Lt.map(({style:{top:Pt,left:Dt},id:Ut})=>[{key:"position.y",value:fmt(Pt),schemaId:Ut},{key:"position.x",value:fmt(Dt),schemaId:Ut}]);et(flatten($t))},yt=({target:Lt,rotate:$t})=>{Lt.style.transform=`rotate(${$t}deg)`},Rt=({target:Lt})=>{const{transform:$t}=Lt.style,Pt=Number($t.replace("rotate(","").replace("deg)","")),Dt=normalizeRotate(Pt);et([{key:"rotate",value:Dt,schemaId:Lt.id}])},kt=({targets:Lt})=>{const $t=Lt.map(({style:{transform:Pt},id:Dt})=>{const Ut=Number(Pt.replace("rotate(","").replace("deg)",""));return[{key:"rotate",value:normalizeRotate(Ut),schemaId:Dt}]});et(flatten($t))},jt=({target:Lt})=>{const{id:$t,style:Pt}=Lt,{width:Dt,height:Ut,top:Vt,left:Qt}=Pt;et([{key:"position.x",value:fmt(Qt),schemaId:$t},{key:"position.y",value:fmt(Vt),schemaId:$t},{key:"width",value:fmt(Dt),schemaId:$t},{key:"height",value:fmt(Ut),schemaId:$t}]);const qt=rt[_].find(Zt=>Zt.id===$t);qt&&(qt.position.x=fmt(Qt),qt.position.y=fmt(Vt),qt.width=fmt(Dt),qt.height=fmt(Ut))},Ht=({targets:Lt})=>{const $t=Lt.map(({style:{width:Pt,height:Dt,top:Ut,left:Vt},id:Qt})=>[{key:"width",value:fmt(Pt),schemaId:Qt},{key:"height",value:fmt(Dt),schemaId:Qt},{key:"position.y",value:fmt(Ut),schemaId:Qt},{key:"position.x",value:fmt(Vt),schemaId:Qt}]);et(flatten($t))},Ft=({target:Lt,width:$t,height:Pt,direction:Dt})=>{if(!Lt)return;let Ut=0,Vt=0,Qt=0,qt=0;if(isBlankPdf($)){const[tr,ir,sr,cr]=$.padding;Ut=tr*ZOOM,Vt=mm2px(ir),Qt=mm2px(sr),qt=cr*ZOOM}const Zt=mm2px(nt[_].width),ar=mm2px(nt[_].height),Jt={width:`${$t}px`,height:`${Pt}px`},rr=Lt.style;let Yt=fmt4Num(rr.left)+(fmt4Num(rr.width)-$t),Kt=fmt4Num(rr.top)+(fmt4Num(rr.height)-Pt);Yt<qt&&(Yt=qt),Kt<Ut&&(Kt=Ut),Yt+$t>Zt-Vt&&(Jt.width=`${Zt-Vt-Yt}px`),Kt+Pt>ar-Qt&&(Jt.height=`${ar-Qt-Kt}px`);const nr=Dt.toString();isTopLeftResize(nr)?(Jt.top=`${Kt}px`,Jt.left=`${Yt}px`):nr==="1,-1"?Jt.top=`${Kt}px`:nr==="-1,1"&&(Jt.left=`${Yt}px`),Object.assign(rr,Jt)},_t=(Lt,$t)=>Lt[$t]&&Lt[$t].getGuides().map(Pt=>Pt*ZOOM),Nt=Lt=>{Lt.inputEvent.stopPropagation(),bt(!0)},Mt=reactExports.useMemo(()=>{const $t=(rt[_]||[]).filter(Ut=>ot.map(Vt=>Vt.id).includes(Ut.id)).map(Ut=>Ut.type),Pt=[...new Set($t)],Dt=Object.values(gt).map(Ut=>Ut==null?void 0:Ut.propPanel.defaultSchema);return Pt.every(Ut=>{var Vt;return((Vt=Dt.find(Qt=>Qt.type===Ut))==null?void 0:Vt.rotate)!==void 0})},[ot,_,rt,gt]);return jsxRuntimeExports.jsxs("div",{style:{position:"relative",overflow:"auto",marginRight:ht?RIGHT_SIDEBAR_WIDTH:0,...at},ref:s,children:[jsxRuntimeExports.jsx(Selecto,{container:ft.current[_],continueSelect:vt,onDragStart:Lt=>{var Dt,Ut;const{inputEvent:$t}=Lt,Pt=(Dt=ct.current)==null?void 0:Dt.isMoveableElement($t.target);($t.type==="touchstart"&&Lt.isTrusted||Pt)&&Lt.stop(),ft.current[_]===$t.target&<([]),((Ut=$t.target)==null?void 0:Ut.id)===DELETE_BTN_ID&&it(ot.map(Vt=>Vt.id))},onSelect:({added:Lt,removed:$t,selected:Pt,inputEvent:Dt})=>{const Ut=Dt.type==="mousedown";let Vt=Ut?Pt:[];!Ut&&Lt.length>0&&(Vt=ot.concat(Lt)),!Ut&&$t.length>0&&(Vt=ot.filter(Qt=>!$t.includes(Qt))),lt(Vt),Vt!=ot&&bt(!1),Dt.shiftKey||At(!1)}}),jsxRuntimeExports.jsx(Paper$1,{paperRefs:ft,scale:_e,size:at,schemasList:rt,pageSizes:nt,backgrounds:tt,hasRulers:!0,renderPaper:({index:Lt,paperSize:$t})=>jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[!xt&&ot.length>0&&_===Lt&&jsxRuntimeExports.jsx(DeleteButton,{activeElements:ot}),jsxRuntimeExports.jsx(Padding$1,{basePdf:$}),jsxRuntimeExports.jsx(Guides,{paperSize:$t,horizontalRef:Pt=>{Pt&&(mt.current[Lt]=Pt)},verticalRef:Pt=>{Pt&&(pt.current[Lt]=Pt)}}),_!==Lt?jsxRuntimeExports.jsx(Mask$1,{width:$t.width+RULER_HEIGHT,height:$t.height+RULER_HEIGHT}):!xt&&jsxRuntimeExports.jsx(Moveable,{ref:ct,target:ot,bounds:{left:0,top:0,bottom:$t.height,right:$t.width},horizontalGuidelines:_t(mt.current,Lt),verticalGuidelines:_t(pt.current,Lt),keepRatio:vt,rotatable:Mt,onDrag:wt,onDragEnd:Ct,onDragGroupEnd:It,onRotate:yt,onRotateEnd:Rt,onRotateGroupEnd:kt,onResize:Ft,onResizeEnd:jt,onResizeGroupEnd:Ht,onClick:Nt})]}),renderSchema:({schema:Lt})=>jsxRuntimeExports.jsx(Renderer$1,{schema:Lt,basePdf:$,value:Lt.content||"",onChangeHoveringSchemaId:ut,mode:xt&&ot.map($t=>$t.id).includes(Lt.id)?"designer":"viewer",onChange:$t=>{const Pt=Array.isArray($t)?$t:[$t];et(Pt.map(({key:Dt,value:Ut})=>({key:Dt,value:Ut,schemaId:Lt.id})))},stopEditing:()=>bt(!1),outline:`1px ${st===Lt.id?"solid":"dashed"} ${Lt.readOnly&&st!==Lt.id?"transparent":dt.colorPrimary}`,scale:_e},Lt.id)})]})},Canvas$1=reactExports.forwardRef(Canvas),Spinner=()=>jsxRuntimeExports.jsx(Spin$1,{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},indicator:jsxRuntimeExports.jsx(LoadingOutlined$1,{style:{fontSize:50},spin:!0})}),Spinner$1=Spinner,Root=({size:a,scale:s,children:$},_)=>{const _e=reactExports.useContext(FontContext);return reactExports.useEffect(()=>{if(!document||!document.fonts)return;const nt=Object.entries(_e).map(([at,{data:ot}])=>new FontFace(at,typeof ot=="string"?`url(${ot})`:ot,{display:"swap"})).filter(at=>!document.fonts.has(at));Promise.allSettled(nt.map(at=>at.load())).then(at=>{at.forEach(ot=>{ot.status==="fulfilled"&&document.fonts.add(ot.value)})})},[_e]),jsxRuntimeExports.jsx("div",{ref:_,style:{position:"relative",background:BACKGROUND_COLOR,...a},children:jsxRuntimeExports.jsx("div",{style:{margin:"0 auto",...a},children:s===0?jsxRuntimeExports.jsx(Spinner$1,{}):$})})},Root$1=reactExports.forwardRef(Root),ErrorScreen=({size:a,error:s})=>{const $=reactExports.useContext(I18nContext),{token:_}=theme.useToken();return jsxRuntimeExports.jsx("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",background:BACKGROUND_COLOR,...a},children:jsxRuntimeExports.jsx("div",{style:{width:300,margin:"0 auto",background:_.colorBgLayout},children:jsxRuntimeExports.jsx(Result$2,{icon:null,title:"ERROR",subTitle:$("errorOccurred"),extra:jsxRuntimeExports.jsx("span",{children:s.message})})})})},ErrorScreen$1=ErrorScreen,{Text:Text$1}=Typography$1,Zoom=({zoomLevel:a,setZoomLevel:s,style:$})=>{const nt=a-.25,at=a+.25;return jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(Button$2,{type:"text",disabled:.25>=nt,onClick:()=>s(nt),icon:jsxRuntimeExports.jsx(MinusOutlined$1,{style:{color:$.textStyle.color}})}),jsxRuntimeExports.jsxs(Text$1,{strong:!0,style:$.textStyle,children:[Math.round(a*100),"%"]}),jsxRuntimeExports.jsx(Button$2,{type:"text",disabled:2<at,onClick:()=>s(at),icon:jsxRuntimeExports.jsx(PlusOutlined$4,{style:{color:$.textStyle.color}})})]})},Pager=({pageCursor:a,pageNum:s,setPageCursor:$,style:_})=>jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(Button$2,{type:"text",disabled:a<=0,onClick:()=>$(a-1),children:jsxRuntimeExports.jsx(LeftOutlined$1,{style:{color:_.textStyle.color}})}),jsxRuntimeExports.jsxs(Text$1,{strong:!0,style:_.textStyle,children:[a+1,"/",s]}),jsxRuntimeExports.jsx(Button$2,{type:"text",disabled:a+1>=s,onClick:()=>$(a+1),children:jsxRuntimeExports.jsx(RightOutlined$1,{style:{color:_.textStyle.color}})})]}),ContextMenu=({items:a,style:s})=>jsxRuntimeExports.jsx(Dropdown$1,{menu:{items:a},placement:"top",arrow:!0,trigger:["click"],children:jsxRuntimeExports.jsx(Button$2,{type:"text",children:jsxRuntimeExports.jsx(EllipsisOutlined$1,{style:{color:s.textStyle.color}})})}),CtlBar=a=>{const{token:s}=theme.useToken(),$=reactExports.useContext(I18nContext),{size:_,pageCursor:_e,pageNum:tt,setPageCursor:nt,zoomLevel:at,setZoomLevel:ot,addPageAfter:rt,removePage:st}=a,lt=[];rt&<.push({key:"1",label:jsxRuntimeExports.jsx("div",{onClick:rt,children:$("addPageAfter")})}),st&&tt>1&&_e!==0&<.push({key:"2",label:jsxRuntimeExports.jsx("div",{onClick:st,children:$("removePage")})});const et=300,it=lt.length>0?50:0,ut=(tt>1?et:et/2)+it,ft={color:s.colorWhite,fontSize:s.fontSize,margin:s.marginXS};return jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:"auto",bottom:"6%",width:_.width},children:jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-evenly",position:"relative",zIndex:1,left:`calc(50% - ${ut/2}px)`,width:ut,height:40,boxSizing:"border-box",padding:s.paddingSM,borderRadius:s.borderRadius,backgroundColor:s.colorBgMask},children:[tt>1&&jsxRuntimeExports.jsx(Pager,{style:{textStyle:ft},pageCursor:_e,pageNum:tt,setPageCursor:nt}),jsxRuntimeExports.jsx(Zoom,{style:{textStyle:ft},zoomLevel:at,setZoomLevel:ot}),lt.length>0&&jsxRuntimeExports.jsx(ContextMenu,{items:lt,style:{textStyle:ft}})]})})},CtlBar$1=CtlBar,scaleDragPosAdjustment=(a,s)=>s>1?a*(s-1):s<1?a*-(1-s):0,TemplateEditor=({template:a,size:s,onSaveTemplate:$,onChangeTemplate:_,onPageCursorChange:_e})=>{const tt=reactExports.useRef([]),nt=reactExports.useRef([]),at=reactExports.useRef(null),ot=reactExports.useRef([]),rt=reactExports.useContext(I18nContext),st=reactExports.useContext(PluginsRegistry),[lt,et]=reactExports.useState(null),[it,ut]=reactExports.useState([]),[ft,ht]=reactExports.useState([[]]),[dt,gt]=reactExports.useState(0),[pt,mt]=reactExports.useState(1),[ct,vt]=reactExports.useState(!0),[At,xt]=reactExports.useState(null),{backgrounds:bt,pageSizes:Et,scale:St,error:Bt,refresh:Ot}=useUIPreProcessor({template:a,size:s,zoomLevel:pt}),Tt=$t=>{ut($t),et(null)},wt=()=>{ut([]),et(null)};useScrollPageCursor({ref:at,pageSizes:Et,scale:St,pageCursor:dt,onChangePageCursor:$t=>{gt($t),_e($t),wt()}});const Ct=reactExports.useCallback($t=>{nt.current=[],tt.current.push(cloneDeep$2(ft[dt]));const Pt=cloneDeep$2(ft);Pt[dt]=$t,ht(Pt),_(schemasList2template(Pt,a.basePdf))},[a,ft,dt,_]),It=reactExports.useCallback($t=>{Ct(ft[dt].filter(Pt=>!$t.includes(Pt.id))),wt()},[ft,dt,Ct]),yt=reactExports.useCallback($t=>{changeSchemas({objs:$t,schemas:ft[dt],basePdf:a.basePdf,pluginsRegistry:st,pageSize:Et[dt],commitSchemas:Ct})},[Ct,dt,ft,st,Et,a.basePdf]);useInitEvents({pageCursor:dt,pageSizes:Et,activeElements:it,template:a,schemasList:ft,changeSchemas:yt,commitSchemas:Ct,removeSchemas:It,onSaveTemplate:$,past:tt,future:nt,setSchemasList:ht,onEdit:Tt,onEditEnd:wt});const Rt=reactExports.useCallback(async $t=>{var Dt;const Pt=await template2SchemasList($t);ht(Pt),wt(),gt(0),(Dt=at.current)!=null&&Dt.scroll&&at.current.scroll({top:0,behavior:"smooth"})},[]),kt=$t=>{const[Pt,Dt,Ut,Vt]=isBlankPdf(a.basePdf)?a.basePdf.padding:[0,0,0,0],Qt=Et[dt],qt=(ar,Jt,rr)=>Math.min(Math.max(ar,Jt),rr),Zt={id:uuid$6(),key:`${rt("field")}${ft[dt].length+1}`,...$t,position:{x:qt(Vt,$t.position.x,Qt.width-Dt-$t.width),y:qt(Pt,$t.position.y,Qt.height-Ut-$t.height)}};if($t.position.y===0){const ar=ot.current[dt],Jt=ar?ar.getBoundingClientRect().top:0;Zt.position.y=Jt>0?Pt:Et[dt].height/2}Ct(ft[dt].concat(Zt)),setTimeout(()=>Tt([document.getElementById(Zt.id)]))},jt=$t=>{Ct($t)},Ht=$t=>{et($t)},Ft=async($t,Pt)=>{gt(Pt);const Dt=schemasList2template($t,a.basePdf);_(Dt),await Rt(Dt),Ot(Dt),setTimeout(()=>at.current&&(at.current.scrollTop=getPagesScrollTopByIndex(Et,Pt,St),0))},_t=()=>{if(dt===0||!window.confirm(rt("removePageConfirm")))return;const $t=cloneDeep$2(ft);$t.splice(dt,1),Ft($t,dt-1)},Nt=()=>{const $t=cloneDeep$2(ft);$t.splice(dt+1,0,[]),Ft($t,dt+1)};At!==a&&(xt(a),Rt(a));const Mt={width:ct?s.width-RIGHT_SIDEBAR_WIDTH:s.width,height:s.height};if(Bt)return jsxRuntimeExports.jsx(ErrorScreen$1,{size:s,error:Bt});const Lt=isBlankPdf(a.basePdf)?{addPageAfter:Nt,removePage:_t}:{};return jsxRuntimeExports.jsx(Root$1,{size:s,scale:St,children:jsxRuntimeExports.jsxs(DndContext,{onDragEnd:$t=>{var rr,Yt;if(!$t.active)return;const Pt=$t.active,Dt=ot.current[dt].getBoundingClientRect(),Ut=((rr=Pt.rect.current.initial)==null?void 0:rr.left)||0,Vt=((Yt=Pt.rect.current.initial)==null?void 0:Yt.top)||0,Qt=Dt.left-Ut+scaleDragPosAdjustment(20,St),qt=Dt.top-Vt,Zt=($t.delta.y-qt)/St,ar=($t.delta.x-Qt)/St,Jt={x:px2mm(Math.max(0,ar)),y:px2mm(Math.max(0,Zt))};kt({...Pt.data.current,position:Jt})},onDragStart:wt,children:[jsxRuntimeExports.jsx(CtlBar$1,{size:Mt,pageCursor:dt,pageNum:ft.length,setPageCursor:$t=>{at.current&&(at.current.scrollTop=getPagesScrollTopByIndex(Et,$t,St),gt($t),wt())},zoomLevel:pt,setZoomLevel:mt,...Lt}),jsxRuntimeExports.jsx(LeftSidebar$1,{height:at.current?at.current.clientHeight:0,scale:St,basePdf:a.basePdf}),jsxRuntimeExports.jsx(RightSidebar,{hoveringSchemaId:lt,onChangeHoveringSchemaId:Ht,height:at.current?at.current.clientHeight:0,size:s,pageSize:Et[dt]??[],activeElements:it,schemas:ft[dt]??[],changeSchemas:yt,onSortEnd:jt,onEdit:$t=>{const Pt=document.getElementById($t);Pt&&Tt([Pt])},onEditEnd:wt,deselectSchema:wt,sidebarOpen:ct,setSidebarOpen:vt}),jsxRuntimeExports.jsx(Canvas$1,{ref:at,paperRefs:ot,basePdf:a.basePdf,hoveringSchemaId:lt,onChangeHoveringSchemaId:Ht,height:s.height-RULER_HEIGHT*ZOOM,pageCursor:dt,scale:St,size:Mt,pageSizes:Et,backgrounds:bt,activeElements:it,schemasList:ft,changeSchemas:yt,removeSchemas:It,sidebarOpen:ct,onEdit:Tt})]})})},DesignerComponent=TemplateEditor,defaultTheme={token:{colorPrimary:"#38a0ff"},components:{Form:{fontSize:12,margin:8,marginLG:12,marginXS:4,padding:8,paddingLG:12,paddingXS:4,itemMarginBottom:4,verticalLabelPadding:"0 0 2px"}}},isObject=a=>a&&typeof a=="object"&&!Array.isArray(a),deepMerge=(a,s)=>{let $={...a};return isObject(a)&&isObject(s)&&Object.keys(s).forEach(_=>{isObject(s[_])?_ in a?$[_]=deepMerge(a[_],s[_]):Object.assign($,{[_]:s[_]}):Object.assign($,{[_]:s[_]})}),$},AppContextProvider=({children:a,lang:s,font:$,plugins:_,options:_e})=>{let tt=defaultTheme;_e.theme&&(tt=deepMerge(tt,_e.theme));let nt=getDict(s);return _e.labels&&(nt=deepMerge(nt,_e.labels)),jsxRuntimeExports.jsx(ThemeConfigProvider,{theme:tt,children:jsxRuntimeExports.jsx(I18nContext.Provider,{value:at=>i18n(at,nt),children:jsxRuntimeExports.jsx(FontContext.Provider,{value:$,children:jsxRuntimeExports.jsx(PluginsRegistry.Provider,{value:_,children:jsxRuntimeExports.jsx(OptionsContext.Provider,{value:_e,children:a})})})})})},AppContextProvider$1=AppContextProvider;class Designer extends BaseUIClass{constructor(s){super(s),this.pageCursor=0,checkDesignerProps(s)}saveTemplate(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.onSaveTemplateCallback&&this.onSaveTemplateCallback(this.template)}updateTemplate(s){if(checkTemplate(s),!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.template=cloneDeep$2(s),this.onChangeTemplateCallback&&this.onChangeTemplateCallback(s),this.render()}onSaveTemplate(s){this.onSaveTemplateCallback=s}onChangeTemplate(s){this.onChangeTemplateCallback=s}getPageCursor(){return this.pageCursor}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider$1,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(DesignerComponent,{template:this.template,onSaveTemplate:s=>{this.template=s,this.onSaveTemplateCallback&&this.onSaveTemplateCallback(s)},onChangeTemplate:s=>{this.template=s,this.template.pdfmeVersion=PDFME_VERSION,this.onChangeTemplateCallback&&this.onChangeTemplateCallback(s)},onPageCursorChange:s=>{this.pageCursor=s},size:this.size})}),this.domContainer)}}const Designer$1=Designer,{Text}=Typography$1,icons={left:LeftOutlined$1,right:RightOutlined$1,doubleLeft:DoubleLeftOutlined$1,doubleRight:DoubleRightOutlined$1},UnitButton=({type:a,onClick:s,disabled:$,textStyle:_})=>{const _e=icons[a];return jsxRuntimeExports.jsx(Button$2,{type:"text",onClick:s,disabled:$,children:jsxRuntimeExports.jsx(_e,{style:{color:_.color}})})},UnitPager=({size:a,unitCursor:s,unitNum:$,setUnitCursor:_})=>{if($<=1)return null;const{token:_e}=theme.useToken(),tt={pointerEvents:"initial",position:"sticky",zIndex:1,display:"flex",alignItems:"center",boxSizing:"border-box",height:40,padding:_e.paddingSM,borderRadius:_e.borderRadius,backgroundColor:_e.colorBgMask},nt={color:_e.colorWhite,fontSize:_e.fontSize,margin:_e.marginXS};return jsxRuntimeExports.jsx("div",{style:{position:"absolute",...a},children:jsxRuntimeExports.jsxs("div",{style:{position:"sticky",width:"100%",zIndex:1,top:`calc(50% - ${tt.height/2}px)`,display:"flex",alignItems:"center"},children:[s>0&&jsxRuntimeExports.jsxs("div",{style:{left:"1rem",marginLeft:"1rem",...tt},children:[jsxRuntimeExports.jsx(UnitButton,{type:"doubleLeft",onClick:()=>_(0),disabled:s<=0,textStyle:nt}),jsxRuntimeExports.jsx(UnitButton,{type:"left",onClick:()=>_(s-1),disabled:s<=0,textStyle:nt}),jsxRuntimeExports.jsxs(Text,{strong:!0,style:nt,children:[s+1,"/",$]})]}),s+1<$&&jsxRuntimeExports.jsxs("div",{style:{right:"1rem",marginLeft:"auto",marginRight:"1rem",...tt},children:[jsxRuntimeExports.jsxs(Text,{strong:!0,style:nt,children:[s+1,"/",$]}),jsxRuntimeExports.jsx(UnitButton,{type:"right",onClick:()=>_(s+1),disabled:s+1>=$,textStyle:nt}),jsxRuntimeExports.jsx(UnitButton,{type:"doubleRight",onClick:()=>_($-1),disabled:s+1>=$,textStyle:nt})]})]})})},UnitPager$1=UnitPager,_cache=new Map,Preview=({template:a,inputs:s,size:$,onChangeInput:_})=>{const{token:_e}=theme.useToken(),tt=reactExports.useContext(FontContext),nt=reactExports.useRef(null),at=reactExports.useRef([]),[ot,rt]=reactExports.useState(0),[st,lt]=reactExports.useState(0),[et,it]=reactExports.useState(1),[ut,ft]=reactExports.useState([[]]),{backgrounds:ht,pageSizes:dt,scale:gt,error:pt,refresh:mt}=useUIPreProcessor({template:a,size:$,zoomLevel:et}),ct=!!_,vt=s[ot],At=bt=>{getDynamicTemplate({template:bt,input:vt,options:{font:tt},_cache,modifyTemplate:St=>modifyTemplateForTable(St),getDynamicHeight:(St,Bt)=>Bt.schema.type!=="table"?Promise.resolve(Bt.schema.height):getDynamicHeightForTable(St,Bt)}).then(async St=>{const Bt=await template2SchemasList(St);ft(Bt),await mt(St)}).catch(St=>console.error("[@pdfme/ui] ",St))};reactExports.useEffect(()=>{ot>s.length-1&&rt(s.length-1),At(a)},[a,s,$]),useScrollPageCursor({ref:nt,pageSizes:dt,scale:gt,pageCursor:st,onChangePageCursor:lt});const xt=({key:bt,value:Et})=>_&&_({index:ot,key:bt,value:Et});return pt?jsxRuntimeExports.jsx(ErrorScreen$1,{size:$,error:pt}):jsxRuntimeExports.jsxs(Root$1,{size:$,scale:gt,children:[jsxRuntimeExports.jsx(CtlBar$1,{size:$,pageCursor:st,pageNum:ut.length,setPageCursor:bt=>{nt.current&&(nt.current.scrollTop=getPagesScrollTopByIndex(dt,bt,gt),lt(bt))},zoomLevel:et,setZoomLevel:it}),jsxRuntimeExports.jsx(UnitPager$1,{size:$,unitCursor:ot,unitNum:s.length,setUnitCursor:rt}),jsxRuntimeExports.jsx("div",{ref:nt,style:{...$,position:"relative",overflow:"auto"},children:jsxRuntimeExports.jsx(Paper$1,{paperRefs:at,scale:gt,size:$,schemasList:ut,pageSizes:dt,backgrounds:ht,renderSchema:({schema:bt,index:Et})=>{const{key:St,readOnly:Bt}=bt,Ot=Bt?String(bt.content)||"":String(vt&&vt[St]||"");return jsxRuntimeExports.jsx(Renderer$1,{schema:bt,basePdf:a.basePdf,value:Ot,mode:ct?"form":"viewer",placeholder:bt.content,tabIndex:Et+100,onChange:Tt=>{const wt=Array.isArray(Tt)?Tt:[Tt];let Ct=!1;wt.forEach(({key:It,value:yt})=>{if(It==="content"){const Rt=yt,kt=(vt==null?void 0:vt[St])||"";if(Rt===kt)return;xt({key:St,value:Rt}),bt.type==="table"&&(Ct=!0)}else{const Rt=ut[st].find(kt=>kt.id===bt.id);if(!Rt)return;Rt[It]=yt}}),Ct&&At(a),ft([...ut])},outline:ct&&!bt.readOnly?`1px dashed ${_e.colorPrimary}`:"transparent",scale:gt},bt.id)}})})]})},Preview$1=Preview;class Form extends PreviewUI{constructor(s){super(s)}onChangeInput(s){this.onChangeInputCallback=s}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider$1,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(Preview$1,{template:this.template,size:this.size,inputs:this.inputs,onChangeInput:s=>{const{index:$,value:_,key:_e}=s;this.onChangeInputCallback&&this.onChangeInputCallback({index:$,value:_,key:_e}),this.inputs&&this.inputs[$]&&this.inputs[$][_e]!==_&&(this.inputs[$][_e]=_,this.render())}})}),this.domContainer)}}const Form$1=Form;class Viewer extends PreviewUI{constructor(s){super(s)}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider$1,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(Preview$1,{template:this.template,size:this.size,inputs:this.inputs})}),this.domContainer)}}const Viewer$1=Viewer;exports.Designer=Designer$1,exports.Form=Form$1,exports.Viewer=Viewer$1,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
|
1145
|
+
`),GuidesElement=defaultStyled("div",GUIDES_CSS),Guides$1=function(a){__extends(s,a);function s(){var _=a!==null&&a.apply(this,arguments)||this;return _.state={guides:[]},_.scrollPos=0,_.guideElements=[],_.onDragStart=function(_e){var tt=_e.datas,nt=_e.inputEvent,at=_.props.onDragStart;addClass(tt.target,DRAGGING),_.onDrag(_e),at(__assign({},_e,{dragElement:tt.target})),nt.stopPropagation(),nt.preventDefault()},_.onDrag=function(_e){var tt=_.movePos(_e);return _.props.onDrag(__assign({},_e,{dragElement:_e.datas.target})),tt},_.onDragEnd=function(_e){var tt=_e.datas,nt=_e.isDouble,at=_e.distX,ot=_e.distY,rt=_.movePos(_e),st=_.state.guides,lt=_.props,et=lt.onChangeGuides,it=lt.zoom,ut=lt.displayDragPos,ft=lt.digit,ht=lt.lockGuides,dt=parseFloat((rt/it).toFixed(ft||0));if(ut&&(_.displayElement.style.cssText+="display: none;"),removeClass(tt.target,DRAGGING),_.props.onDragEnd(__assign({},_e,{dragElement:tt.target})),tt.fromRuler)rt>=_.scrollPos&&st.indexOf(dt)<0&&_.setState({guides:st.concat([dt])},function(){et({guides:_.state.guides,distX:at,distY:ot,isAdd:!0,isRemove:!1,isChange:!1})});else{var gt=tt.target.getAttribute("data-index"),pt=!1,mt=!1;if(st=st.slice(),nt||dt<_.scrollPos){if(ht&&(ht===!0||ht.indexOf("remove")>-1))return;st.splice(gt,1),pt=!0}else{if(st.indexOf(dt)>-1)return;if(ht&&(ht===!0||ht.indexOf("change")>-1))return;st[gt]=dt,mt=!0}_.setState({guides:st},function(){var ct=_.state.guides;et({distX:at,distY:ot,guides:ct,isAdd:!1,isChange:mt,isRemove:pt})})}},_}var $=s.prototype;return $.render=function(){var _=this.props,_e=_.className,tt=_.type,nt=_.zoom,at=_.style,ot=_.rulerStyle,rt=_.displayDragPos,st=_.cspNonce,lt=_.dragGuideStyle,et=_.portalContainer,it=this.props,ut=this.getTranslateName(),ft={};return PROPERTIES.forEach(function(ht){ht!=="style"&&(ft[ht]=it[ht])}),reactExports.createElement(GuidesElement,{ref:ref(this,"manager"),cspNonce:st,className:prefix("manager",tt)+" "+_e,portalContainer:et,style:at},reactExports.createElement("div",{className:prefix("guide-origin"),ref:ref(this,"originElement")}),reactExports.createElement(Ruler$1,__assign({ref:ref(this,"ruler"),style:ot},ft)),reactExports.createElement("div",{className:GUIDES,ref:ref(this,"guidesElement"),style:{transform:ut+"("+-this.scrollPos*nt+"px)"}},rt&&reactExports.createElement("div",{className:DISPLAY_DRAG,ref:ref(this,"displayElement"),style:lt}),reactExports.createElement("div",{className:ADDER,ref:ref(this,"adderElement")}),this.renderGuides()))},$.renderGuides=function(){var _=this,_e=this.props,tt=_e.type,nt=_e.zoom,at=_e.showGuides,ot=_e.guideStyle,rt=this.getTranslateName(),st=this.state.guides;if(this.guideElements=[],at)return st.map(function(lt,et){return reactExports.createElement("div",{className:prefix("guide",tt),ref:refs(_,"guideElements",et),key:et,"data-index":et,"data-pos":lt,style:__assign({},ot,{transform:rt+"("+lt*nt+"px) translateZ(0px)"})})})},$.componentDidMount=function(){var _=this;this.gesto=new Gesto(this.manager.getElement(),{container:document.body}).on("dragStart",function(_e){var tt=_.props,nt=tt.type,at=tt.zoom,ot=tt.lockGuides;if(ot===!0){_e.stop();return}var rt=_e.inputEvent,st=rt.target,lt=_e.datas,et=_.ruler.canvasElement,it=_.guidesElement,ut=nt==="horizontal",ft=_.originElement.getBoundingClientRect(),ht=getDistElementMatrix(_.manager.getElement()),dt=calculateMatrixDist(ht,[_e.clientX-ft.left,_e.clientY-ft.top]);dt[0]-=it.offsetLeft,dt[1]-=it.offsetTop,dt[ut?1:0]+=_.scrollPos*at,lt.offsetPos=dt,lt.matrix=ht;var gt=ot&&ot.indexOf("add")>-1,pt=ot&&ot.indexOf("remove")>-1,mt=ot&&ot.indexOf("change")>-1;if(st===et){if(gt){_e.stop();return}lt.fromRuler=!0,lt.target=_.adderElement}else if(hasClass(st,GUIDE)){if(pt&&mt){_e.stop();return}lt.target=st}else return _e.stop(),!1;_.onDragStart(_e)}).on("drag",this.onDrag).on("dragEnd",this.onDragEnd),this.setState({guides:this.props.defaultGuides||[]})},$.componentWillUnmount=function(){this.gesto.unset()},$.componentDidUpdate=function(_){_.defaultGuides!==this.props.defaultGuides&&this.setState({guides:this.props.defaultGuides||[]})},$.loadGuides=function(_){this.setState({guides:_})},$.getGuides=function(){return this.state.guides},$.scrollGuides=function(_){var _e=this.props.zoom,tt=this.guidesElement;this.scrollPos=_,tt.style.transform=this.getTranslateName()+"("+-_*_e+"px)";var nt=this.state.guides;this.guideElements.forEach(function(at,ot){at&&(at.style.display=-_+nt[ot]<0?"none":"block")})},$.resize=function(){this.ruler.resize()},$.scroll=function(_){this.ruler.scroll(_)},$.movePos=function(_){var _e=_.datas,tt=_.distX,nt=_.distY,at=this.props,ot=at.type,rt=at.zoom,st=at.snaps,lt=at.snapThreshold,et=at.displayDragPos,it=at.digit,ut=at.dragPosFormat||function(xt){return xt},ft=ot==="horizontal",ht=calculateMatrixDist(_e.matrix,[tt,nt]),dt=_e.offsetPos,gt=ht[0]+dt[0],pt=ht[1]+dt[1],mt=Math.round(ft?pt:gt),ct=parseFloat((mt/rt).toFixed(it||0)),vt=st.slice().sort(function(xt,bt){return Math.abs(ct-xt)-Math.abs(ct-bt)});if(vt.length&&Math.abs(vt[0]*rt-mt)<lt&&(ct=vt[0],mt=ct*rt),et){var At=ot==="horizontal"?[gt,mt]:[mt,pt];this.displayElement.style.cssText+="display: block;transform: translate(-50%, -50%) "+("translate("+At.map(function(xt){return xt+"px"}).join(", ")+")"),this.displayElement.innerHTML=""+ut(ct)}return _e.target.setAttribute("data-pos",ct),_e.target.style.transform=this.getTranslateName()+"("+mt+"px)",mt},$.getTranslateName=function(){return this.props.type==="horizontal"?"translateY":"translateX"},s.defaultProps={className:"",type:"horizontal",zoom:1,style:{},snapThreshold:5,snaps:[],digit:0,onChangeGuides:function(){},onDragStart:function(){},onDrag:function(){},onDragEnd:function(){},displayDragPos:!1,dragPosFormat:function(_){return _},defaultGuides:[],lockGuides:!1,showGuides:!0,guideStyle:{},dragGuideStyle:{},portalContainer:null},s}(reactExports.PureComponent);const Guides$2=Guides$1,guideStyle=(a,s,$,_)=>({position:"absolute",top:a,left:s,height:$,width:_,background:"#333333"}),_Guides=({paperSize:a,horizontalRef:s,verticalRef:$})=>jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"ruler-container",style:guideStyle(-RULER_HEIGHT,-RULER_HEIGHT,RULER_HEIGHT,RULER_HEIGHT)}),jsxRuntimeExports.jsx(Guides$2,{zoom:ZOOM,style:guideStyle(-RULER_HEIGHT,0,RULER_HEIGHT,a.width),type:"horizontal",ref:s}),jsxRuntimeExports.jsx(Guides$2,{zoom:ZOOM,style:guideStyle(0,-RULER_HEIGHT,a.height,RULER_HEIGHT),type:"vertical",ref:$})]}),Guides=_Guides,Mask=({width:a,height:s})=>jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:-RULER_HEIGHT,left:-RULER_HEIGHT,zIndex:100,width:a,height:s,background:theme.useToken().token.colorBgMask}}),Mask$1=Mask,getPaddingStyle=(a,s,$)=>{const _={position:"absolute",background:$,opacity:.25,pointerEvents:"none"};switch(a){case 0:_.top=0,_.height=`${s*ZOOM}px`,_.left=0,_.right=0;break;case 1:_.right=0,_.width=`${s*ZOOM}px`,_.top=0,_.bottom=0;break;case 2:_.bottom=0,_.height=`${s*ZOOM}px`,_.left=0,_.right=0;break;case 3:_.left=0,_.width=`${s*ZOOM}px`,_.top=0,_.bottom=0;break}return _},Padding=({basePdf:a})=>jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:isBlankPdf(a)&&a.padding.map((s,$)=>jsxRuntimeExports.jsx("div",{style:getPaddingStyle($,s,theme.useToken().token.colorError)},String($)))}),Padding$1=Padding,mm2px=a=>a*3.7795275591,DELETE_BTN_ID=uuid$6(),fmt4Num=a=>Number(a.replace("px","")),fmt=a=>round(fmt4Num(a)/ZOOM,2),isTopLeftResize=a=>a==="-1,-1"||a==="-1,0"||a==="0,-1",normalizeRotate=a=>(a%360+360)%360,DeleteButton=({activeElements:a})=>{const{token:s}=theme.useToken(),$=26,_=Math.min(...a.map(({style:tt})=>fmt4Num(tt.top))),_e=Math.max(...a.map(({style:tt})=>fmt4Num(tt.left)+fmt4Num(tt.width)))+10;return jsxRuntimeExports.jsx(Button$2,{id:DELETE_BTN_ID,style:{position:"absolute",zIndex:1,top:_,left:_e,width:$,height:$,padding:2,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:s.borderRadius,color:s.colorWhite,background:s.colorPrimary},children:jsxRuntimeExports.jsx(CloseOutlined$4,{style:{pointerEvents:"none"}})})},Canvas=(a,s)=>{const{basePdf:$,pageCursor:_,scale:_e,backgrounds:tt,pageSizes:nt,size:at,activeElements:ot,schemasList:rt,hoveringSchemaId:st,onEdit:lt,changeSchemas:et,removeSchemas:it,onChangeHoveringSchemaId:ut,paperRefs:ft,sidebarOpen:ht}=a,{token:dt}=theme.useToken(),gt=reactExports.useContext(PluginsRegistry),pt=reactExports.useRef([]),mt=reactExports.useRef([]),ct=reactExports.useRef(null),[vt,At]=reactExports.useState(!1),[xt,bt]=reactExports.useState(!1),Et=usePrevious(rt[_]),St=Lt=>{Lt.shiftKey&&At(!0)},Bt=Lt=>{(Lt.key==="Shift"||!Lt.shiftKey)&&At(!1),(Lt.key==="Escape"||Lt.key==="Esc")&&bt(!1)},Ot=reactExports.useCallback(()=>{window.addEventListener("keydown",St),window.addEventListener("keyup",Bt)},[]),Tt=reactExports.useCallback(()=>{window.removeEventListener("keydown",St),window.removeEventListener("keyup",Bt)},[]);reactExports.useEffect(()=>(Ot(),Tt),[Ot,Tt]),reactExports.useEffect(()=>{var Pt,Dt;if((Pt=ct.current)==null||Pt.updateRect(),!Et)return;const Lt=JSON.stringify(Et[_]||{}),$t=JSON.stringify(rt[_]||{});Lt===$t&&((Dt=ct.current)==null||Dt.updateRect())},[_,rt,Et]);const wt=({target:Lt,top:$t,left:Pt})=>{const{width:Dt,height:Ut}=Lt.style,Vt=fmt(Dt),Qt=fmt(Ut),qt=$t/ZOOM,Zt=Pt/ZOOM,{width:ar,height:Jt}=nt[_];let rr=0,Yt=0,Kt=0,nr=0;if(isBlankPdf($)){const[tr,ir,sr,cr]=$.padding;rr=tr*ZOOM,Yt=ir,Kt=sr,nr=cr*ZOOM}qt+Qt>Jt-Kt?Lt.style.top=`${(Jt-Qt-Kt)*ZOOM}px`:Lt.style.top=`${$t<rr?rr:$t}px`,Zt+Vt>ar-Yt?Lt.style.left=`${(ar-Vt-Yt)*ZOOM}px`:Lt.style.left=`${Pt<nr?nr:Pt}px`},Ct=({target:Lt})=>{const{top:$t,left:Pt}=Lt.style;et([{key:"position.y",value:fmt($t),schemaId:Lt.id},{key:"position.x",value:fmt(Pt),schemaId:Lt.id}])},It=({targets:Lt})=>{const $t=Lt.map(({style:{top:Pt,left:Dt},id:Ut})=>[{key:"position.y",value:fmt(Pt),schemaId:Ut},{key:"position.x",value:fmt(Dt),schemaId:Ut}]);et(flatten($t))},yt=({target:Lt,rotate:$t})=>{Lt.style.transform=`rotate(${$t}deg)`},Rt=({target:Lt})=>{const{transform:$t}=Lt.style,Pt=Number($t.replace("rotate(","").replace("deg)","")),Dt=normalizeRotate(Pt);et([{key:"rotate",value:Dt,schemaId:Lt.id}])},kt=({targets:Lt})=>{const $t=Lt.map(({style:{transform:Pt},id:Dt})=>{const Ut=Number(Pt.replace("rotate(","").replace("deg)",""));return[{key:"rotate",value:normalizeRotate(Ut),schemaId:Dt}]});et(flatten($t))},jt=({target:Lt})=>{const{id:$t,style:Pt}=Lt,{width:Dt,height:Ut,top:Vt,left:Qt}=Pt;et([{key:"position.x",value:fmt(Qt),schemaId:$t},{key:"position.y",value:fmt(Vt),schemaId:$t},{key:"width",value:fmt(Dt),schemaId:$t},{key:"height",value:fmt(Ut),schemaId:$t}]);const qt=rt[_].find(Zt=>Zt.id===$t);qt&&(qt.position.x=fmt(Qt),qt.position.y=fmt(Vt),qt.width=fmt(Dt),qt.height=fmt(Ut))},Ht=({targets:Lt})=>{const $t=Lt.map(({style:{width:Pt,height:Dt,top:Ut,left:Vt},id:Qt})=>[{key:"width",value:fmt(Pt),schemaId:Qt},{key:"height",value:fmt(Dt),schemaId:Qt},{key:"position.y",value:fmt(Ut),schemaId:Qt},{key:"position.x",value:fmt(Vt),schemaId:Qt}]);et(flatten($t))},Ft=({target:Lt,width:$t,height:Pt,direction:Dt})=>{if(!Lt)return;let Ut=0,Vt=0,Qt=0,qt=0;if(isBlankPdf($)){const[tr,ir,sr,cr]=$.padding;Ut=tr*ZOOM,Vt=mm2px(ir),Qt=mm2px(sr),qt=cr*ZOOM}const Zt=mm2px(nt[_].width),ar=mm2px(nt[_].height),Jt={width:`${$t}px`,height:`${Pt}px`},rr=Lt.style;let Yt=fmt4Num(rr.left)+(fmt4Num(rr.width)-$t),Kt=fmt4Num(rr.top)+(fmt4Num(rr.height)-Pt);Yt<qt&&(Yt=qt),Kt<Ut&&(Kt=Ut),Yt+$t>Zt-Vt&&(Jt.width=`${Zt-Vt-Yt}px`),Kt+Pt>ar-Qt&&(Jt.height=`${ar-Qt-Kt}px`);const nr=Dt.toString();isTopLeftResize(nr)?(Jt.top=`${Kt}px`,Jt.left=`${Yt}px`):nr==="1,-1"?Jt.top=`${Kt}px`:nr==="-1,1"&&(Jt.left=`${Yt}px`),Object.assign(rr,Jt)},_t=(Lt,$t)=>Lt[$t]&&Lt[$t].getGuides().map(Pt=>Pt*ZOOM),Nt=Lt=>{Lt.inputEvent.stopPropagation(),bt(!0)},Mt=reactExports.useMemo(()=>{const $t=(rt[_]||[]).filter(Ut=>ot.map(Vt=>Vt.id).includes(Ut.id)).map(Ut=>Ut.type),Pt=[...new Set($t)],Dt=Object.values(gt).map(Ut=>Ut==null?void 0:Ut.propPanel.defaultSchema);return Pt.every(Ut=>{var Vt;return((Vt=Dt.find(Qt=>Qt.type===Ut))==null?void 0:Vt.rotate)!==void 0})},[ot,_,rt,gt]);return jsxRuntimeExports.jsxs("div",{style:{position:"relative",overflow:"auto",marginRight:ht?RIGHT_SIDEBAR_WIDTH:0,...at},ref:s,children:[jsxRuntimeExports.jsx(Selecto,{container:ft.current[_],continueSelect:vt,onDragStart:Lt=>{var Dt,Ut;const{inputEvent:$t}=Lt,Pt=(Dt=ct.current)==null?void 0:Dt.isMoveableElement($t.target);($t.type==="touchstart"&&Lt.isTrusted||Pt)&&Lt.stop(),ft.current[_]===$t.target&<([]),((Ut=$t.target)==null?void 0:Ut.id)===DELETE_BTN_ID&&it(ot.map(Vt=>Vt.id))},onSelect:({added:Lt,removed:$t,selected:Pt,inputEvent:Dt})=>{const Ut=Dt.type==="mousedown";let Vt=Ut?Pt:[];!Ut&&Lt.length>0&&(Vt=ot.concat(Lt)),!Ut&&$t.length>0&&(Vt=ot.filter(Qt=>!$t.includes(Qt))),lt(Vt),Vt!=ot&&bt(!1),Dt.shiftKey||At(!1)}}),jsxRuntimeExports.jsx(Paper$1,{paperRefs:ft,scale:_e,size:at,schemasList:rt,pageSizes:nt,backgrounds:tt,hasRulers:!0,renderPaper:({index:Lt,paperSize:$t})=>jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[!xt&&ot.length>0&&_===Lt&&jsxRuntimeExports.jsx(DeleteButton,{activeElements:ot}),jsxRuntimeExports.jsx(Padding$1,{basePdf:$}),jsxRuntimeExports.jsx(Guides,{paperSize:$t,horizontalRef:Pt=>{Pt&&(mt.current[Lt]=Pt)},verticalRef:Pt=>{Pt&&(pt.current[Lt]=Pt)}}),_!==Lt?jsxRuntimeExports.jsx(Mask$1,{width:$t.width+RULER_HEIGHT,height:$t.height+RULER_HEIGHT}):!xt&&jsxRuntimeExports.jsx(Moveable,{ref:ct,target:ot,bounds:{left:0,top:0,bottom:$t.height,right:$t.width},horizontalGuidelines:_t(mt.current,Lt),verticalGuidelines:_t(pt.current,Lt),keepRatio:vt,rotatable:Mt,onDrag:wt,onDragEnd:Ct,onDragGroupEnd:It,onRotate:yt,onRotateEnd:Rt,onRotateGroupEnd:kt,onResize:Ft,onResizeEnd:jt,onResizeGroupEnd:Ht,onClick:Nt})]}),renderSchema:({schema:Lt})=>jsxRuntimeExports.jsx(Renderer$1,{schema:Lt,basePdf:$,value:Lt.content||"",onChangeHoveringSchemaId:ut,mode:xt&&ot.map($t=>$t.id).includes(Lt.id)?"designer":"viewer",onChange:$t=>{const Pt=Array.isArray($t)?$t:[$t];et(Pt.map(({key:Dt,value:Ut})=>({key:Dt,value:Ut,schemaId:Lt.id})))},stopEditing:()=>bt(!1),outline:`1px ${st===Lt.id?"solid":"dashed"} ${Lt.readOnly&&st!==Lt.id?"transparent":dt.colorPrimary}`,scale:_e},Lt.id)})]})},Canvas$1=reactExports.forwardRef(Canvas),Spinner=()=>jsxRuntimeExports.jsx(Spin$1,{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},indicator:jsxRuntimeExports.jsx(LoadingOutlined$1,{style:{fontSize:50},spin:!0})}),Spinner$1=Spinner,Root=({size:a,scale:s,children:$},_)=>{const _e=reactExports.useContext(FontContext);return reactExports.useEffect(()=>{if(!document||!document.fonts)return;const nt=Object.entries(_e).map(([at,{data:ot}])=>new FontFace(at,typeof ot=="string"?`url(${ot})`:ot,{display:"swap"})).filter(at=>!document.fonts.has(at));Promise.allSettled(nt.map(at=>at.load())).then(at=>{at.forEach(ot=>{ot.status==="fulfilled"&&document.fonts.add(ot.value)})})},[_e]),jsxRuntimeExports.jsx("div",{ref:_,style:{position:"relative",background:BACKGROUND_COLOR,...a},children:jsxRuntimeExports.jsx("div",{style:{margin:"0 auto",...a},children:s===0?jsxRuntimeExports.jsx(Spinner$1,{}):$})})},Root$1=reactExports.forwardRef(Root),ErrorScreen=({size:a,error:s})=>{const $=reactExports.useContext(I18nContext),{token:_}=theme.useToken();return jsxRuntimeExports.jsx("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",background:BACKGROUND_COLOR,...a},children:jsxRuntimeExports.jsx("div",{style:{width:300,margin:"0 auto",background:_.colorBgLayout},children:jsxRuntimeExports.jsx(Result$2,{icon:null,title:"ERROR",subTitle:$("errorOccurred"),extra:jsxRuntimeExports.jsx("span",{children:s.message})})})})},ErrorScreen$1=ErrorScreen,{Text:Text$1}=Typography$1,Zoom=({zoomLevel:a,setZoomLevel:s,style:$})=>{const nt=a-.25,at=a+.25;return jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(Button$2,{type:"text",disabled:.25>=nt,onClick:()=>s(nt),icon:jsxRuntimeExports.jsx(MinusOutlined$1,{style:{color:$.textStyle.color}})}),jsxRuntimeExports.jsxs(Text$1,{strong:!0,style:$.textStyle,children:[Math.round(a*100),"%"]}),jsxRuntimeExports.jsx(Button$2,{type:"text",disabled:2<at,onClick:()=>s(at),icon:jsxRuntimeExports.jsx(PlusOutlined$4,{style:{color:$.textStyle.color}})})]})},Pager=({pageCursor:a,pageNum:s,setPageCursor:$,style:_})=>jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(Button$2,{type:"text",disabled:a<=0,onClick:()=>$(a-1),children:jsxRuntimeExports.jsx(LeftOutlined$1,{style:{color:_.textStyle.color}})}),jsxRuntimeExports.jsxs(Text$1,{strong:!0,style:_.textStyle,children:[a+1,"/",s]}),jsxRuntimeExports.jsx(Button$2,{type:"text",disabled:a+1>=s,onClick:()=>$(a+1),children:jsxRuntimeExports.jsx(RightOutlined$1,{style:{color:_.textStyle.color}})})]}),ContextMenu=({items:a,style:s})=>jsxRuntimeExports.jsx(Dropdown$1,{menu:{items:a},placement:"top",arrow:!0,trigger:["click"],children:jsxRuntimeExports.jsx(Button$2,{type:"text",children:jsxRuntimeExports.jsx(EllipsisOutlined$1,{style:{color:s.textStyle.color}})})}),CtlBar=a=>{const{token:s}=theme.useToken(),$=reactExports.useContext(I18nContext),{size:_,pageCursor:_e,pageNum:tt,setPageCursor:nt,zoomLevel:at,setZoomLevel:ot,addPageAfter:rt,removePage:st}=a,lt=[];rt&<.push({key:"1",label:jsxRuntimeExports.jsx("div",{onClick:rt,children:$("addPageAfter")})}),st&&tt>1&&_e!==0&<.push({key:"2",label:jsxRuntimeExports.jsx("div",{onClick:st,children:$("removePage")})});const et=300,it=lt.length>0?50:0,ut=(tt>1?et:et/2)+it,ft={color:s.colorWhite,fontSize:s.fontSize,margin:s.marginXS};return jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:"auto",bottom:"6%",width:_.width},children:jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-evenly",position:"relative",zIndex:1,left:`calc(50% - ${ut/2}px)`,width:ut,height:40,boxSizing:"border-box",padding:s.paddingSM,borderRadius:s.borderRadius,backgroundColor:s.colorBgMask},children:[tt>1&&jsxRuntimeExports.jsx(Pager,{style:{textStyle:ft},pageCursor:_e,pageNum:tt,setPageCursor:nt}),jsxRuntimeExports.jsx(Zoom,{style:{textStyle:ft},zoomLevel:at,setZoomLevel:ot}),lt.length>0&&jsxRuntimeExports.jsx(ContextMenu,{items:lt,style:{textStyle:ft}})]})})},CtlBar$1=CtlBar,scaleDragPosAdjustment=(a,s)=>s>1?a*(s-1):s<1?a*-(1-s):0,TemplateEditor=({template:a,size:s,onSaveTemplate:$,onChangeTemplate:_,onPageCursorChange:_e})=>{const tt=reactExports.useRef([]),nt=reactExports.useRef([]),at=reactExports.useRef(null),ot=reactExports.useRef([]),rt=reactExports.useContext(I18nContext),st=reactExports.useContext(PluginsRegistry),[lt,et]=reactExports.useState(null),[it,ut]=reactExports.useState([]),[ft,ht]=reactExports.useState([[]]),[dt,gt]=reactExports.useState(0),[pt,mt]=reactExports.useState(1),[ct,vt]=reactExports.useState(!0),[At,xt]=reactExports.useState(null),{backgrounds:bt,pageSizes:Et,scale:St,error:Bt,refresh:Ot}=useUIPreProcessor({template:a,size:s,zoomLevel:pt}),Tt=$t=>{ut($t),et(null)},wt=()=>{ut([]),et(null)};useScrollPageCursor({ref:at,pageSizes:Et,scale:St,pageCursor:dt,onChangePageCursor:$t=>{gt($t),_e($t),wt()}});const Ct=reactExports.useCallback($t=>{nt.current=[],tt.current.push(cloneDeep$2(ft[dt]));const Pt=cloneDeep$2(ft);Pt[dt]=$t,ht(Pt),_(schemasList2template(Pt,a.basePdf))},[a,ft,dt,_]),It=reactExports.useCallback($t=>{Ct(ft[dt].filter(Pt=>!$t.includes(Pt.id))),wt()},[ft,dt,Ct]),yt=reactExports.useCallback($t=>{changeSchemas({objs:$t,schemas:ft[dt],basePdf:a.basePdf,pluginsRegistry:st,pageSize:Et[dt],commitSchemas:Ct})},[Ct,dt,ft,st,Et,a.basePdf]);useInitEvents({pageCursor:dt,pageSizes:Et,activeElements:it,template:a,schemasList:ft,changeSchemas:yt,commitSchemas:Ct,removeSchemas:It,onSaveTemplate:$,past:tt,future:nt,setSchemasList:ht,onEdit:Tt,onEditEnd:wt});const Rt=reactExports.useCallback(async $t=>{var Dt;const Pt=await template2SchemasList($t);ht(Pt),wt(),gt(0),(Dt=at.current)!=null&&Dt.scroll&&at.current.scroll({top:0,behavior:"smooth"})},[]),kt=$t=>{const[Pt,Dt,Ut,Vt]=isBlankPdf(a.basePdf)?a.basePdf.padding:[0,0,0,0],Qt=Et[dt],qt=(ar,Jt,rr)=>Math.min(Math.max(ar,Jt),rr),Zt={id:uuid$6(),key:`${rt("field")}${ft[dt].length+1}`,...$t,position:{x:qt(Vt,$t.position.x,Qt.width-Dt-$t.width),y:qt(Pt,$t.position.y,Qt.height-Ut-$t.height)}};if($t.position.y===0){const ar=ot.current[dt],Jt=ar?ar.getBoundingClientRect().top:0;Zt.position.y=Jt>0?Pt:Et[dt].height/2}Ct(ft[dt].concat(Zt)),setTimeout(()=>Tt([document.getElementById(Zt.id)]))},jt=$t=>{Ct($t)},Ht=$t=>{et($t)},Ft=async($t,Pt)=>{gt(Pt);const Dt=schemasList2template($t,a.basePdf);_(Dt),await Rt(Dt),Ot(Dt),setTimeout(()=>at.current&&(at.current.scrollTop=getPagesScrollTopByIndex(Et,Pt,St),0))},_t=()=>{if(dt===0||!window.confirm(rt("removePageConfirm")))return;const $t=cloneDeep$2(ft);$t.splice(dt,1),Ft($t,dt-1)},Nt=()=>{const $t=cloneDeep$2(ft);$t.splice(dt+1,0,[]),Ft($t,dt+1)};At!==a&&(xt(a),Rt(a));const Mt={width:ct?s.width-RIGHT_SIDEBAR_WIDTH:s.width,height:s.height};if(Bt)return jsxRuntimeExports.jsx(ErrorScreen$1,{size:s,error:Bt});const Lt=isBlankPdf(a.basePdf)?{addPageAfter:Nt,removePage:_t}:{};return jsxRuntimeExports.jsx(Root$1,{size:s,scale:St,children:jsxRuntimeExports.jsxs(DndContext,{onDragEnd:$t=>{var rr,Yt;if(!$t.active)return;const Pt=$t.active,Dt=ot.current[dt].getBoundingClientRect(),Ut=((rr=Pt.rect.current.initial)==null?void 0:rr.left)||0,Vt=((Yt=Pt.rect.current.initial)==null?void 0:Yt.top)||0,Qt=Dt.left-Ut+scaleDragPosAdjustment(20,St),qt=Dt.top-Vt,Zt=($t.delta.y-qt)/St,ar=($t.delta.x-Qt)/St,Jt={x:round(px2mm(Math.max(0,ar)),2),y:round(px2mm(Math.max(0,Zt)),2)};kt({...Pt.data.current,position:Jt})},onDragStart:wt,children:[jsxRuntimeExports.jsx(CtlBar$1,{size:Mt,pageCursor:dt,pageNum:ft.length,setPageCursor:$t=>{at.current&&(at.current.scrollTop=getPagesScrollTopByIndex(Et,$t,St),gt($t),wt())},zoomLevel:pt,setZoomLevel:mt,...Lt}),jsxRuntimeExports.jsx(LeftSidebar$1,{height:at.current?at.current.clientHeight:0,scale:St,basePdf:a.basePdf}),jsxRuntimeExports.jsx(RightSidebar,{hoveringSchemaId:lt,onChangeHoveringSchemaId:Ht,height:at.current?at.current.clientHeight:0,size:s,pageSize:Et[dt]??[],activeElements:it,schemas:ft[dt]??[],changeSchemas:yt,onSortEnd:jt,onEdit:$t=>{const Pt=document.getElementById($t);Pt&&Tt([Pt])},onEditEnd:wt,deselectSchema:wt,sidebarOpen:ct,setSidebarOpen:vt}),jsxRuntimeExports.jsx(Canvas$1,{ref:at,paperRefs:ot,basePdf:a.basePdf,hoveringSchemaId:lt,onChangeHoveringSchemaId:Ht,height:s.height-RULER_HEIGHT*ZOOM,pageCursor:dt,scale:St,size:Mt,pageSizes:Et,backgrounds:bt,activeElements:it,schemasList:ft,changeSchemas:yt,removeSchemas:It,sidebarOpen:ct,onEdit:Tt})]})})},DesignerComponent=TemplateEditor,defaultTheme={token:{colorPrimary:"#38a0ff"},components:{Form:{fontSize:12,margin:8,marginLG:12,marginXS:4,padding:8,paddingLG:12,paddingXS:4,itemMarginBottom:4,verticalLabelPadding:"0 0 2px"}}},isObject=a=>a&&typeof a=="object"&&!Array.isArray(a),deepMerge=(a,s)=>{let $={...a};return isObject(a)&&isObject(s)&&Object.keys(s).forEach(_=>{isObject(s[_])?_ in a?$[_]=deepMerge(a[_],s[_]):Object.assign($,{[_]:s[_]}):Object.assign($,{[_]:s[_]})}),$},AppContextProvider=({children:a,lang:s,font:$,plugins:_,options:_e})=>{let tt=defaultTheme;_e.theme&&(tt=deepMerge(tt,_e.theme));let nt=getDict(s);return _e.labels&&(nt=deepMerge(nt,_e.labels)),jsxRuntimeExports.jsx(ThemeConfigProvider,{theme:tt,children:jsxRuntimeExports.jsx(I18nContext.Provider,{value:at=>i18n(at,nt),children:jsxRuntimeExports.jsx(FontContext.Provider,{value:$,children:jsxRuntimeExports.jsx(PluginsRegistry.Provider,{value:_,children:jsxRuntimeExports.jsx(OptionsContext.Provider,{value:_e,children:a})})})})})},AppContextProvider$1=AppContextProvider;class Designer extends BaseUIClass{constructor(s){super(s),this.pageCursor=0,checkDesignerProps(s)}saveTemplate(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.onSaveTemplateCallback&&this.onSaveTemplateCallback(this.template)}updateTemplate(s){if(checkTemplate(s),!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.template=cloneDeep$2(s),this.onChangeTemplateCallback&&this.onChangeTemplateCallback(s),this.render()}onSaveTemplate(s){this.onSaveTemplateCallback=s}onChangeTemplate(s){this.onChangeTemplateCallback=s}getPageCursor(){return this.pageCursor}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider$1,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(DesignerComponent,{template:this.template,onSaveTemplate:s=>{this.template=s,this.onSaveTemplateCallback&&this.onSaveTemplateCallback(s)},onChangeTemplate:s=>{this.template=s,this.template.pdfmeVersion=PDFME_VERSION,this.onChangeTemplateCallback&&this.onChangeTemplateCallback(s)},onPageCursorChange:s=>{this.pageCursor=s},size:this.size})}),this.domContainer)}}const Designer$1=Designer,{Text}=Typography$1,icons={left:LeftOutlined$1,right:RightOutlined$1,doubleLeft:DoubleLeftOutlined$1,doubleRight:DoubleRightOutlined$1},UnitButton=({type:a,onClick:s,disabled:$,textStyle:_})=>{const _e=icons[a];return jsxRuntimeExports.jsx(Button$2,{type:"text",onClick:s,disabled:$,children:jsxRuntimeExports.jsx(_e,{style:{color:_.color}})})},UnitPager=({size:a,unitCursor:s,unitNum:$,setUnitCursor:_})=>{if($<=1)return null;const{token:_e}=theme.useToken(),tt={pointerEvents:"initial",position:"sticky",zIndex:1,display:"flex",alignItems:"center",boxSizing:"border-box",height:40,padding:_e.paddingSM,borderRadius:_e.borderRadius,backgroundColor:_e.colorBgMask},nt={color:_e.colorWhite,fontSize:_e.fontSize,margin:_e.marginXS};return jsxRuntimeExports.jsx("div",{style:{position:"absolute",...a},children:jsxRuntimeExports.jsxs("div",{style:{position:"sticky",width:"100%",zIndex:1,top:`calc(50% - ${tt.height/2}px)`,display:"flex",alignItems:"center"},children:[s>0&&jsxRuntimeExports.jsxs("div",{style:{left:"1rem",marginLeft:"1rem",...tt},children:[jsxRuntimeExports.jsx(UnitButton,{type:"doubleLeft",onClick:()=>_(0),disabled:s<=0,textStyle:nt}),jsxRuntimeExports.jsx(UnitButton,{type:"left",onClick:()=>_(s-1),disabled:s<=0,textStyle:nt}),jsxRuntimeExports.jsxs(Text,{strong:!0,style:nt,children:[s+1,"/",$]})]}),s+1<$&&jsxRuntimeExports.jsxs("div",{style:{right:"1rem",marginLeft:"auto",marginRight:"1rem",...tt},children:[jsxRuntimeExports.jsxs(Text,{strong:!0,style:nt,children:[s+1,"/",$]}),jsxRuntimeExports.jsx(UnitButton,{type:"right",onClick:()=>_(s+1),disabled:s+1>=$,textStyle:nt}),jsxRuntimeExports.jsx(UnitButton,{type:"doubleRight",onClick:()=>_($-1),disabled:s+1>=$,textStyle:nt})]})]})})},UnitPager$1=UnitPager,_cache=new Map,Preview=({template:a,inputs:s,size:$,onChangeInput:_})=>{const{token:_e}=theme.useToken(),tt=reactExports.useContext(FontContext),nt=reactExports.useRef(null),at=reactExports.useRef([]),[ot,rt]=reactExports.useState(0),[st,lt]=reactExports.useState(0),[et,it]=reactExports.useState(1),[ut,ft]=reactExports.useState([[]]),{backgrounds:ht,pageSizes:dt,scale:gt,error:pt,refresh:mt}=useUIPreProcessor({template:a,size:$,zoomLevel:et}),ct=!!_,vt=s[ot],At=bt=>{getDynamicTemplate({template:bt,input:vt,options:{font:tt},_cache,modifyTemplate:St=>modifyTemplateForTable(St),getDynamicHeight:(St,Bt)=>Bt.schema.type!=="table"?Promise.resolve(Bt.schema.height):getDynamicHeightForTable(St,Bt)}).then(async St=>{const Bt=await template2SchemasList(St);ft(Bt),await mt(St)}).catch(St=>console.error("[@pdfme/ui] ",St))};reactExports.useEffect(()=>{ot>s.length-1&&rt(s.length-1),At(a)},[a,s,$]),useScrollPageCursor({ref:nt,pageSizes:dt,scale:gt,pageCursor:st,onChangePageCursor:lt});const xt=({key:bt,value:Et})=>_&&_({index:ot,key:bt,value:Et});return pt?jsxRuntimeExports.jsx(ErrorScreen$1,{size:$,error:pt}):jsxRuntimeExports.jsxs(Root$1,{size:$,scale:gt,children:[jsxRuntimeExports.jsx(CtlBar$1,{size:$,pageCursor:st,pageNum:ut.length,setPageCursor:bt=>{nt.current&&(nt.current.scrollTop=getPagesScrollTopByIndex(dt,bt,gt),lt(bt))},zoomLevel:et,setZoomLevel:it}),jsxRuntimeExports.jsx(UnitPager$1,{size:$,unitCursor:ot,unitNum:s.length,setUnitCursor:rt}),jsxRuntimeExports.jsx("div",{ref:nt,style:{...$,position:"relative",overflow:"auto"},children:jsxRuntimeExports.jsx(Paper$1,{paperRefs:at,scale:gt,size:$,schemasList:ut,pageSizes:dt,backgrounds:ht,renderSchema:({schema:bt,index:Et})=>{const{key:St,readOnly:Bt}=bt,Ot=Bt?String(bt.content)||"":String(vt&&vt[St]||"");return jsxRuntimeExports.jsx(Renderer$1,{schema:bt,basePdf:a.basePdf,value:Ot,mode:ct?"form":"viewer",placeholder:bt.content,tabIndex:Et+100,onChange:Tt=>{const wt=Array.isArray(Tt)?Tt:[Tt];let Ct=!1;wt.forEach(({key:It,value:yt})=>{if(It==="content"){const Rt=yt,kt=(vt==null?void 0:vt[St])||"";if(Rt===kt)return;xt({key:St,value:Rt}),bt.type==="table"&&(Ct=!0)}else{const Rt=ut[st].find(kt=>kt.id===bt.id);if(!Rt)return;Rt[It]=yt}}),Ct&&At(a),ft([...ut])},outline:ct&&!bt.readOnly?`1px dashed ${_e.colorPrimary}`:"transparent",scale:gt},bt.id)}})})]})},Preview$1=Preview;class Form extends PreviewUI{constructor(s){super(s)}onChangeInput(s){this.onChangeInputCallback=s}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider$1,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(Preview$1,{template:this.template,size:this.size,inputs:this.inputs,onChangeInput:s=>{const{index:$,value:_,key:_e}=s;this.onChangeInputCallback&&this.onChangeInputCallback({index:$,value:_,key:_e}),this.inputs&&this.inputs[$]&&this.inputs[$][_e]!==_&&(this.inputs[$][_e]=_,this.render())}})}),this.domContainer)}}const Form$1=Form;class Viewer extends PreviewUI{constructor(s){super(s)}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider$1,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(Preview$1,{template:this.template,size:this.size,inputs:this.inputs})}),this.domContainer)}}const Viewer$1=Viewer;exports.Designer=Designer$1,exports.Form=Form$1,exports.Viewer=Viewer$1,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import FormRender, { useForm } from 'form-render';
|
2
|
-
import React, { useContext, useEffect
|
2
|
+
import React, { useContext, useEffect } from 'react';
|
3
3
|
import type { ChangeSchemaItem, Dict, SchemaForUI, PropPanelWidgetProps, PropPanelSchema } from '@pdfme/common';
|
4
4
|
import type { SidebarProps } from '../../../../types';
|
5
5
|
import { MenuOutlined } from '@ant-design/icons';
|
@@ -14,7 +14,7 @@ import { InternalNamePath, ValidateErrorEntity } from "rc-field-form/es/interfac
|
|
14
14
|
const { Text } = Typography;
|
15
15
|
|
16
16
|
type DetailViewProps = Pick<SidebarProps,
|
17
|
-
|
17
|
+
'size' | 'schemas' | 'pageSize' | 'changeSchemas' | 'activeElements' | 'deselectSchema'
|
18
18
|
> & {
|
19
19
|
activeSchema: SchemaForUI;
|
20
20
|
};
|
@@ -22,23 +22,23 @@ type DetailViewProps = Pick<SidebarProps,
|
|
22
22
|
const DetailView = (props: DetailViewProps) => {
|
23
23
|
const { token } = theme.useToken();
|
24
24
|
|
25
|
-
const { size, changeSchemas, deselectSchema, activeSchema
|
25
|
+
const { size, changeSchemas, deselectSchema, activeSchema } = props;
|
26
26
|
const form = useForm();
|
27
27
|
|
28
28
|
const i18n = useContext(I18nContext);
|
29
29
|
const pluginsRegistry = useContext(PluginsRegistry);
|
30
30
|
const options = useContext(OptionsContext);
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
useEffect(() => {
|
33
|
+
const values: any = { ...activeSchema };
|
34
|
+
// [position] Change the nested position object into a flat, as a three-column layout is difficult to implement
|
35
|
+
values.x = values.position.x;
|
36
|
+
values.y = values.position.y;
|
37
|
+
delete values.position;
|
38
|
+
form.setValues(values);
|
39
|
+
|
40
|
+
}, [activeSchema, form]);
|
35
41
|
|
36
|
-
const values: any = { ...activeSchema };
|
37
|
-
// [position] Change the nested position object into a flat, as a three-column layout is difficult to implement
|
38
|
-
values.x = values.position.x;
|
39
|
-
values.y = values.position.y;
|
40
|
-
delete values.position;
|
41
|
-
form.setValues(values);
|
42
42
|
|
43
43
|
const handleWatch = (formSchema: any) => {
|
44
44
|
const formAndSchemaValuesDiffer = (formValue: any, schemaValue: any): boolean => {
|
@@ -67,7 +67,7 @@ const DetailView = (props: DetailViewProps) => {
|
|
67
67
|
// FIXME memo: https://github.com/pdfme/pdfme/pull/367#issuecomment-1857468274
|
68
68
|
if (value === null && ['rotate', 'opacity'].includes(key)) value = undefined;
|
69
69
|
|
70
|
-
changes.push({key, value, schemaId: activeSchema.id});
|
70
|
+
changes.push({ key, value, schemaId: activeSchema.id });
|
71
71
|
}
|
72
72
|
}
|
73
73
|
|
@@ -76,11 +76,11 @@ const DetailView = (props: DetailViewProps) => {
|
|
76
76
|
form.validateFields()
|
77
77
|
.then(() => changeSchemas(changes))
|
78
78
|
.catch((reason: ValidateErrorEntity) => {
|
79
|
-
if (reason.errorFields.length)
|
79
|
+
if (reason.errorFields.length) {
|
80
80
|
changes = changes.filter((change: ChangeSchemaItem) => !reason.errorFields.find((field: {
|
81
|
-
|
82
|
-
|
83
|
-
|
81
|
+
name: InternalNamePath;
|
82
|
+
errors: string[];
|
83
|
+
}) => field.name.includes(change.key)
|
84
84
|
));
|
85
85
|
}
|
86
86
|
if (changes.length) {
|
@@ -181,10 +181,12 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
181
181
|
};
|
182
182
|
}
|
183
183
|
|
184
|
-
const allWidgets:
|
184
|
+
const allWidgets: {
|
185
|
+
[key: string]: (props: PropPanelWidgetProps) => React.JSX.Element;
|
186
|
+
} = {
|
185
187
|
AlignWidget: (p) => <AlignWidget {...p} {...props} options={options} />,
|
186
188
|
Divider: () => (
|
187
|
-
|
189
|
+
<Divider style={{ marginTop: token.marginXS, marginBottom: token.marginXS }} />
|
188
190
|
),
|
189
191
|
ButtonGroup: (p) => <ButtonGroupWidget {...p} {...props} options={options} />,
|
190
192
|
};
|
@@ -192,14 +194,14 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
192
194
|
const widgets = plugin?.propPanel.widgets || {};
|
193
195
|
Object.entries(widgets).forEach(([widgetKey, widgetValue]) => {
|
194
196
|
allWidgets[widgetKey] = (p) => (
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
197
|
+
<WidgetRenderer
|
198
|
+
{...p}
|
199
|
+
{...props}
|
200
|
+
options={options}
|
201
|
+
theme={token}
|
202
|
+
i18n={i18n as (key: keyof Dict | string) => string}
|
203
|
+
widget={widgetValue}
|
204
|
+
/>
|
203
205
|
);
|
204
206
|
});
|
205
207
|
}
|
@@ -19,6 +19,7 @@ import { I18nContext, PluginsRegistry } from '../../contexts';
|
|
19
19
|
import {
|
20
20
|
schemasList2template,
|
21
21
|
uuid,
|
22
|
+
round,
|
22
23
|
cloneDeep,
|
23
24
|
template2SchemasList,
|
24
25
|
getPagesScrollTopByIndex,
|
@@ -51,7 +52,7 @@ const TemplateEditor = ({
|
|
51
52
|
onSaveTemplate: (t: Template) => void;
|
52
53
|
onChangeTemplate: (t: Template) => void;
|
53
54
|
} & {
|
54
|
-
onChangeTemplate: (t: Template) => void
|
55
|
+
onChangeTemplate: (t: Template) => void
|
55
56
|
onPageCursorChange: (newPageCursor: number) => void
|
56
57
|
}) => {
|
57
58
|
const past = useRef<SchemaForUI[][]>([]);
|
@@ -253,7 +254,7 @@ const TemplateEditor = ({
|
|
253
254
|
const moveY = (event.delta.y - canvasTopOffsetFromPageCorner) / scale;
|
254
255
|
const moveX = (event.delta.x - canvasLeftOffsetFromPageCorner) / scale;
|
255
256
|
|
256
|
-
const position = { x: px2mm(Math.max(0, moveX)), y: px2mm(Math.max(0, moveY)) }
|
257
|
+
const position = { x: round(px2mm(Math.max(0, moveX)), 2), y: round(px2mm(Math.max(0, moveY)), 2) }
|
257
258
|
|
258
259
|
addSchema({ ...(active.data.current as Schema), position });
|
259
260
|
}}
|
package/src/helper.ts
CHANGED