@licklist/design 0.44.523 → 0.44.524
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/events/event-venue-map/hooks/useImage.d.ts.map +1 -1
- package/dist/events/event-venue-map/hooks/useImage.js +1 -1
- package/dist/notification/email-template/control/EmailTemplateControl.d.ts.map +1 -1
- package/dist/notification/email-template/control/EmailTemplateControl.js +1 -1
- package/dist/styles/notification/Notification.scss +4 -0
- package/package.json +1 -1
- package/src/events/event-venue-map/hooks/useImage.tsx +17 -8
- package/src/notification/email-template/control/EmailTemplateControl.tsx +26 -1
- package/src/styles/notification/Notification.scss +4 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useImage.d.ts","sourceRoot":"","sources":["../../../../src/events/event-venue-map/hooks/useImage.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,eAAO,MAAM,QAAQ,QACd,MAAM;WACiB,MAAM;YAAU,MAAM;MACjD,CAAC,SAAS,GAAG,gBAAgB,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"useImage.d.ts","sourceRoot":"","sources":["../../../../src/events/event-venue-map/hooks/useImage.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,eAAO,MAAM,QAAQ,QACd,MAAM;WACiB,MAAM;YAAU,MAAM;MACjD,CAAC,SAAS,GAAG,gBAAgB,EAAE,mBAAmB,CAmFpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),i=require("react"),
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),i=require("react"),r=(e(i),e(require("lodash/round")));exports.useImage=function(e,a){var h=a.width,n=a.height,c=i.useRef(void 0),d=t.__read(i.useState({width:0,height:0}),2),u=d[0],l=d[1],s=function(){c.current=this,l({width:this.naturalWidth,height:this.naturalHeight})},o=i.useCallback((function(e){c.current=new window.Image,c.current.src=e,c.current.addEventListener("load",s)}),[]);i.useEffect((function(){return o(e),function(){c.current.removeEventListener("load",s),c.current=void 0}}),[e,o]);var g=i.useMemo((function(){if(!u.width||!u.height)return t.__assign({scaledWidth:1,scaledHeight:1,x:0,y:0,scale:1,widthScale:1,heightScale:1,imageScale:1,totalScaledWidth:0,totalScaledHeight:0},u);var e=h/u.width,i=n/u.height,a=Math.min(e,i),c=r(u.width*a,2),d=r(u.height*a,2),l=r(h/2-c/2,2),s=r(n/2-d/2,2),o=u.width/c,g=2*l+c,f=2*s+d;return t.__assign({scaledWidth:c,scaledHeight:d,x:l,y:s,scale:a,widthScale:e,heightScale:i,imageScale:o,totalScaledWidth:g,totalScaledHeight:f},u)}),[u,h,n]);return[c.current,g]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailTemplateControl.d.ts","sourceRoot":"","sources":["../../../../src/notification/email-template/control/EmailTemplateControl.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,OAAO,EACL,cAAc,EAEf,MAAM,sEAAsE,CAAC;AAG9E,OAAO,EAAE,UAAU,EAAE,MAAM,kEAAkE,CAAC;AAM9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wEAAwE,CAAC;AAM1G,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,YAAY,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,CAAC,EAAE,UAAU,EAAE,CAAC;IAClC,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACvC,4BAA4B,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,IAAI,KAAK,MAAM,CAAC;CAC3E;AAED,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"EmailTemplateControl.d.ts","sourceRoot":"","sources":["../../../../src/notification/email-template/control/EmailTemplateControl.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,OAAO,EACL,cAAc,EAEf,MAAM,sEAAsE,CAAC;AAG9E,OAAO,EAAE,UAAU,EAAE,MAAM,kEAAkE,CAAC;AAM9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wEAAwE,CAAC;AAM1G,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,YAAY,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,CAAC,EAAE,UAAU,EAAE,CAAC;IAClC,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACvC,4BAA4B,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,IAAI,KAAK,MAAM,CAAC;CAC3E;AAED,eAAO,MAAM,oBAAoB,2FAgbhC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),a=require("react"),n=e(a),l=require("react-i18next"),r=require("react-bootstrap"),i=require("react-hook-form"),o=require("../../../file-upload/FileUpload.js"),s=e(require("react-email-editor")),
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),a=require("react"),n=e(a),l=require("react-i18next"),r=require("react-bootstrap"),i=require("react-hook-form"),o=require("../../../file-upload/FileUpload.js"),s=e(require("react-email-editor")),m=require("@licklist/core/dist/DataMapper/Notification/TemplateOptionDataMapper"),c=require("@licklist/plugins/dist/hooks/Media/useAttachments"),u=require("@licklist/plugins/dist/hooks/Media/usePermanentImage"),d=require("@licklist/core/dist/DataMapper/Media/UploadPermanentImageDataMapper"),p=n.forwardRef((function(e,p){var g,f,v,E,h=e.setIsLoading,b=e.meta,_=e.options,y=void 0===_?[]:_,F=e.defaultAttachments,N=void 0===F?[]:F,D=e.notificationTypes,T=void 0===D?[]:D,C=e.getDefaultTemplateMetaByType,P=l.useTranslation(["Design"]).t,I=t.__read(a.useState(null),2),k=I[0],x=I[1],M=i.useFormContext(),O=M.register,q=M.setValue,R=M.formState.errors,V=M.getValues,A=M.watch,j=M.reset,w=t.__read(a.useState(!1),2),G=w[0],L=w[1],S=c.useAttachments(k),U=S.attachments,Y=S.handleAttachmentRemove,B=S.handleAttachmentUploading,J=S.isLoading,H=u.usePermanentImage(),z=H.permanentImages,K=H.handlePermanentImageRemove,Q=H.handlePermanentImageUploading,W=A("type"),X=A("id");a.useEffect((function(){var e;if(!X&&C&&W){var a=V(),n=C(W);j(t.__assign(t.__assign({},a),{meta:n})),null===(e=p.current)||void 0===e||e.loadDesign(JSON.parse(n))}}),[W]),a.useEffect((function(){q("attachmentMetadata",U)}),[U,q]),a.useEffect((function(){z.length&&q("imagesMetadata",z)}),[z,q]),a.useEffect((function(){if(N&&N.length>0){var e=V("attachments");x(e)}else x([])}),[N]),a.useEffect((function(){if(null==y?void 0:y.length){var e=y.find((function(e){return e.type===m.OPTION_TYPE.files_selector}));(null==e?void 0:e.selectedValue)&&L(!0)}}),[y]);return n.createElement(n.Fragment,null,n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col,controlId:"type",xs:!0,sm:12,md:8,lg:10,xl:12},n.createElement(r.Form.Label,null,P("type")),n.createElement(r.Form.Control,t.__assign({as:"select"},O("type",{required:P("Validation:fieldRequired",{attribute:P("type")})}),{name:"type",required:!0,isInvalid:Boolean(R.type),placeholder:P("Design:type"),disabled:!!X}),n.createElement("option",{value:""},P("Design:choose")),T.map((function(e){return n.createElement("option",{key:e,value:e},P("Design:".concat(e)))}))),n.createElement(r.Form.Control.Feedback,{type:"invalid"},null===(g=R.type)||void 0===g?void 0:g.message))),n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col,controlId:"formGroupName",xs:!0,sm:12,md:8,lg:10,xl:12},n.createElement(r.Form.Label,null,P("templateName")),n.createElement(r.Form.Control,t.__assign({},O("name",{maxLength:255,required:P("Validation:fieldRequired",{attribute:P("name")})}),{name:"name",required:!0,isInvalid:Boolean(R.name),placeholder:P("Design:templateName")})),n.createElement(r.Form.Control.Feedback,{type:"invalid"},null===(f=R.name)||void 0===f?void 0:f.message))),n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col,xs:!0,sm:12,md:8,lg:10,xl:12,controlId:"formGroupSubject"},n.createElement(r.Form.Label,null,P("subject")),n.createElement(r.Form.Control,t.__assign({},O("subject",{maxLength:255,required:P("Validation:fieldRequired",{attribute:P("subject")})}),{name:"subject",required:!0,isInvalid:Boolean(R.subject),placeholder:P("Design:subject")})),n.createElement(r.Form.Control.Feedback,{type:"invalid"},null===(v=R.subject)||void 0===v?void 0:v.message))),n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col},n.createElement(r.Form.Check,t.__assign({},O("isActive"),{name:"isActive",label:P("Design:active"),id:"formGroupIsActive",custom:!0})),n.createElement(r.Form.Check,t.__assign({},O("isDefault"),{name:"isDefault",label:P("Design:defaultTemplateForTheType"),id:"formGroupIsDefault",custom:!0})))),n.createElement(r.Row,{className:"mb-4"},n.createElement(r.Form.Group,{as:r.Col},n.createElement(r.Form.Label,null,P("Design:emailBody")),n.createElement("div",{className:"alert alert-warning",role:"alert"},"Due to the mail services limitations on the length of the email body that can be sent or received - maximum length is set to 65,535 characters."),n.createElement("div",{className:"email-editor ".concat(R.body&&"is-invalid")},n.createElement(s,{ref:p,onReady:function(){var e,a,n,l;h(!0),null===(e=p.current)||void 0===e||e.registerCallback("design:updated",(function(e){var t,a;null===(t=p.current)||void 0===t||t.editor.exportHtml((function(e){q("body",e.html),q("meta",JSON.stringify(e.design))})),"content:removed"===e.type&&"image"===(null===(a=e.item)||void 0===a?void 0:a.type)&&function(e){var t=e.item.values.src.url;if(!t.includes("unlayer")){var a=V("imagesMetadata");if(a){var n=a.find((function(e){return e.permanentUrl===t}));if(n)K(n.hash,d.PERMANENT_IMAGE_TYPE_TEMP);else{var l=t.split("/"),r=l[l.length-2];if(!r)return;K(r,d.PERMANENT_IMAGE_TYPE_PERMANENT)}}else{var i=t.split("/"),o=i[i.length-2];if(!o)return;K(o,d.PERMANENT_IMAGE_TYPE_PERMANENT)}}}(e)})),b&&(null===(a=p.current)||void 0===a||a.loadDesign(JSON.parse(b)),null===(n=p.current)||void 0===n||n.editor.exportHtml((function(e){q("body",e.html),q("meta",JSON.stringify(e.design))}))),h(!1),null===(l=p.current)||void 0===l||l.registerCallback("image",(function(e,a){return t.__awaiter(void 0,void 0,void 0,(function(){var n;return t.__generator(this,(function(t){switch(t.label){case 0:return[4,Q(e.attachments[0])];case 1:return n=t.sent(),a({progress:100,url:n.permanentUrl}),[2]}}))}))}))},style:{height:"50rem"}}),n.createElement("input",t.__assign({type:"hidden",name:"body"},O("body",{maxLength:{value:65535,message:P("Validation:fieldMaxLength",{attribute:P("body"),max:65535})}})))),n.createElement(r.Form.Control.Feedback,{type:"invalid"},null===(E=R.body)||void 0===E?void 0:E.message))),n.createElement(r.Row,null,n.createElement(o.FileUpload,{className:"ml-4 mr-4",allowedExtensions:["jpg","jpeg","png","txt","pdf","doc"],enablePreview:!0,allowMultiple:!0,defaultFiles:U,onFilesChange:function(e){B(e)},title:P("Design:attachments"),onFileRemove:function(e,t){return Y(String(e),t)},isLoading:J})),(null==y?void 0:y.length)>0&&n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col},y.map((function(e){if(e.type===m.OPTION_TYPE.checkbox)return n.createElement(r.Form.Check,t.__assign({},O("templateOptionValues.".concat(null==e?void 0:e.id,".value")),{type:"checkbox",label:P("Design:".concat(e.name)),id:e.name+e.id,defaultChecked:"true"===e.selectedValue,custom:!0}));if(e.type===m.OPTION_TYPE.files_selector){var a=JSON.parse(e.defaultValue),l=Object.values(a),i=Object.keys(a);return n.createElement(n.Fragment,null,n.createElement(r.Form.Check,{checked:G,name:"IsIncludePDF",onChange:function(){L(!G),q("templateOptionValues.".concat(e.id,".value"),"")},label:P("Design:includePDF"),id:"formGroupIsIncludePdf",custom:!0}),G&&n.createElement(n.Fragment,null,n.createElement(r.Form.Label,{className:"mt-4"},P("Design:includeFile")),n.createElement(r.Form.Control,t.__assign({as:"select"},O("templateOptionValues.".concat(e.id,".value")),{defaultValue:e.selectedValue||""}),n.createElement("option",{value:""},P("Design:choose")),i.map((function(e,t){return n.createElement("option",{value:String(e),key:String(e)},l[t])})))))}return e.type===m.OPTION_TYPE.days_reminder?n.createElement(n.Fragment,null,n.createElement(r.Form.Label,{className:"mt-4"},P("Design:".concat(e.name))),n.createElement(r.Form.Control,t.__assign({},O("templateOptionValues.".concat(null==e?void 0:e.id,".value")),{type:"number",placeholder:P("Design:".concat(e.name)),id:e.name+e.id,defaultValue:e.selectedValue||""})),n.createElement(r.Form.Text,null,e.description)):null})))))}));p.displayName="EmailTemplateControl",exports.EmailTemplateControl=p;
|
package/package.json
CHANGED
|
@@ -12,21 +12,30 @@ export const useImage = (
|
|
|
12
12
|
height: 0,
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
+
const setImageEventHandler = function setImageEventHandler(
|
|
16
|
+
this: HTMLImageElement
|
|
17
|
+
) {
|
|
18
|
+
imageRef.current = this;
|
|
19
|
+
|
|
20
|
+
setImageAttributes({
|
|
21
|
+
width: this.naturalWidth,
|
|
22
|
+
height: this.naturalHeight,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
15
26
|
const loadImage = useCallback((imageUrl?: string) => {
|
|
16
27
|
imageRef.current = new window.Image();
|
|
17
28
|
imageRef.current.src = imageUrl;
|
|
18
|
-
imageRef.current.addEventListener("load",
|
|
19
|
-
imageRef.current = this;
|
|
20
|
-
|
|
21
|
-
setImageAttributes({
|
|
22
|
-
width: this.naturalWidth,
|
|
23
|
-
height: this.naturalHeight,
|
|
24
|
-
});
|
|
25
|
-
});
|
|
29
|
+
imageRef.current.addEventListener("load", setImageEventHandler);
|
|
26
30
|
}, []);
|
|
27
31
|
|
|
28
32
|
useEffect(() => {
|
|
29
33
|
loadImage(url);
|
|
34
|
+
|
|
35
|
+
return () => {
|
|
36
|
+
imageRef.current.removeEventListener("load", setImageEventHandler);
|
|
37
|
+
imageRef.current = undefined;
|
|
38
|
+
};
|
|
30
39
|
}, [url, loadImage]);
|
|
31
40
|
|
|
32
41
|
const memoizedImageAttributes = useMemo(() => {
|
|
@@ -314,13 +314,38 @@ export const EmailTemplateControl = React.forwardRef(
|
|
|
314
314
|
<Row className="mb-4">
|
|
315
315
|
<Form.Group as={Col}>
|
|
316
316
|
<Form.Label>{t("Design:emailBody")}</Form.Label>
|
|
317
|
-
|
|
317
|
+
|
|
318
|
+
<div className="alert alert-warning" role="alert">
|
|
319
|
+
Due to the mail services limitations on the length of the email
|
|
320
|
+
body that can be sent or received - maximum length is set to
|
|
321
|
+
65,535 characters.
|
|
322
|
+
</div>
|
|
323
|
+
|
|
324
|
+
<div className={`email-editor ${errors.body && "is-invalid"}`}>
|
|
318
325
|
<EmailEditor
|
|
319
326
|
ref={ref}
|
|
320
327
|
onReady={onReadyEditor}
|
|
321
328
|
style={{ height: "50rem" }}
|
|
322
329
|
/>
|
|
330
|
+
|
|
331
|
+
<input
|
|
332
|
+
type="hidden"
|
|
333
|
+
name="body"
|
|
334
|
+
{...register("body", {
|
|
335
|
+
maxLength: {
|
|
336
|
+
value: 65535,
|
|
337
|
+
message: t("Validation:fieldMaxLength", {
|
|
338
|
+
attribute: t("body"),
|
|
339
|
+
max: 65535,
|
|
340
|
+
}) as string,
|
|
341
|
+
},
|
|
342
|
+
})}
|
|
343
|
+
/>
|
|
323
344
|
</div>
|
|
345
|
+
|
|
346
|
+
<Form.Control.Feedback type="invalid">
|
|
347
|
+
{errors.body?.message}
|
|
348
|
+
</Form.Control.Feedback>
|
|
324
349
|
</Form.Group>
|
|
325
350
|
</Row>
|
|
326
351
|
<Row>
|