@saasquatch/mint-components 2.1.8-21 → 2.1.8-22
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/cjs/sqm-share-link.cjs.entry.js +271 -0
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +1144 -588
- package/dist/cjs/useShareLink-1282123e.js +422 -0
- package/dist/cjs/useShareLink-3c22b1b9.js +448 -0
- package/dist/cjs/useShareLink-54e24928.js +448 -0
- package/dist/cjs/useShareLink-b664fbc7.js +450 -0
- package/dist/cjs/useShareLink-bf04b25c.js +450 -0
- package/dist/cjs/useShareLink-e8e2ae6d.js +448 -0
- package/dist/collection/components/sqm-share-link/sqm-share-link-view.js +2 -28
- package/dist/esm/sqm-share-link.entry.js +267 -0
- package/dist/esm/sqm-stencilbook.entry.js +3327 -2771
- package/dist/esm/useShareLink-023284f3.js +445 -0
- package/dist/esm/useShareLink-436e9cad.js +445 -0
- package/dist/esm/useShareLink-4ba01373.js +447 -0
- package/dist/esm/useShareLink-79056582.js +445 -0
- package/dist/esm/useShareLink-a3329e33.js +419 -0
- package/dist/esm/useShareLink-bc20ec4c.js +447 -0
- package/dist/esm-es5/sqm-share-link.entry.js +1 -0
- package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
- package/dist/esm-es5/useShareLink-023284f3.js +1 -0
- package/dist/esm-es5/useShareLink-436e9cad.js +1 -0
- package/dist/esm-es5/useShareLink-4ba01373.js +1 -0
- package/dist/esm-es5/useShareLink-79056582.js +1 -0
- package/dist/esm-es5/useShareLink-a3329e33.js +1 -0
- package/dist/esm-es5/useShareLink-bc20ec4c.js +1 -0
- package/dist/mint-components/sqm-share-link.entry.js +267 -0
- package/dist/mint-components/sqm-share-link.system.entry.js +1 -0
- package/dist/mint-components/sqm-stencilbook.entry.js +22106 -0
- package/dist/mint-components/sqm-stencilbook.system.entry.js +1 -0
- package/dist/mint-components/useShareLink-023284f3.js +445 -0
- package/dist/mint-components/useShareLink-1d7c9fd8.system.js +1 -0
- package/dist/mint-components/useShareLink-211e061c.system.js +1 -0
- package/dist/mint-components/useShareLink-2de7ffce.system.js +1 -0
- package/dist/mint-components/useShareLink-436e9cad.js +445 -0
- package/dist/mint-components/useShareLink-454939f5.system.js +1 -0
- package/dist/mint-components/useShareLink-4ba01373.js +447 -0
- package/dist/mint-components/useShareLink-79056582.js +445 -0
- package/dist/mint-components/useShareLink-a3329e33.js +419 -0
- package/dist/mint-components/useShareLink-bc20ec4c.js +447 -0
- package/dist/mint-components/useShareLink-c05fe151.system.js +1 -0
- package/dist/mint-components/useShareLink-cb5abd96.system.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __makeTemplateObject=this&&this.__makeTemplateObject||function(e,n){if(Object.defineProperty){Object.defineProperty(e,"raw",{value:n})}else{e.raw=n}return e};var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var n,t=1,a=arguments.length;t<a;t++){n=arguments[t];for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i))e[i]=n[i]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,n,t,a){function i(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,r){function o(e){try{s(a.next(e))}catch(e){r(e)}}function l(e){try{s(a["throw"](e))}catch(e){r(e)}}function s(e){e.done?t(e.value):i(e.value).then(o,l)}s((a=a.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},a,i,r,o;return o={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(e){return function(n){return s([e,n])}}function s(o){if(a)throw new TypeError("Generator is already executing.");while(t)try{if(a=1,i&&(r=o[0]&2?i["return"]:o[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;if(i=0,r)o=[o[0]&2,r.value];switch(o[0]){case 0:case 1:r=o;break;case 4:t.label++;return{value:o[1],done:false};case 5:t.label++;i=o[1];o=[0];continue;case 7:o=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(o[0]===6||o[0]===2)){t=0;continue}if(o[0]===3&&(!r||o[1]>r[0]&&o[1]<r[3])){t.label=o[1];break}if(o[0]===6&&t.label<r[1]){t.label=r[1];r=o;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(o);break}if(r[2])t.ops.pop();t.trys.pop();continue}o=n.call(e,t)}catch(e){o=[6,e];i=0}finally{a=r=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}};import{h}from"./index-d9876cd5.js";import{i as intl}from"./global-e1c1ff72.js";import{i as useState,k as useRef}from"./dom-context-hooks.module-8411297a.js";import{d as dist,H,J,B,F as Fn,w as wn,$ as $e,X as Xe,h as Qe}from"./index.module-60e4da3a.js";import{c as createStyleSheet}from"./JSS-8c381d8b.js";import{R as REFERRAL_CODES_NAMESPACE,S as SET_CODE_COPIED}from"./useReferralCodes-cff9a9dc.js";import{C as CopyTextView}from"./copy-text-view-c508f2e1.js";var vanillaStyle="\n :host {\n display: block;\n width: 100%;\n }\n";function ShareLinkView(e){var n=e.copyTextViewProps,t=e.customizeUrl,a=e.customizeLinkLabel,i=e.saveLabelText,r=e.cancelLabelText,o=e.isEditing,l=e.editValue,s=e.domainPrefix,d=e.editsRemaining,c=e.maxEdits,u=e.limitReached,v=e.validationError,p=e.isValidating,m=e.isSaving,f=e.characterLimit,g=e.minCharacters,C=e.charactersRemaining,_=e.editLimitText,E=e.editLimitReachedText,L=e.supportLinkText,k=e.customizeDisabled,b=e.customizeDisabledTooltip,T=e.onCustomizeClick,y=e.onEditValueChange,S=e.onSave,I=e.onCancel;var x={Container:{display:"flex",flexDirection:"column",gap:"var(--sl-spacing-xx-small)",width:"100%"},CustomizeLinkText:{margin:"0",fontSize:"var(--sl-font-size-small)",fontWeight:"600",cursor:"pointer",color:"var(--sl-color-neutral-900)",textAlign:"left",padding:"var(--sl-spacing-small)","&:hover":{textDecoration:"underline"}},CustomizeLinkDisabled:{margin:"0",fontSize:"var(--sl-font-size-small)",fontWeight:"600",color:"var(--sl-color-neutral-400)",cursor:"default",textAlign:"left",padding:"var(--sl-spacing-small)"},EditContainer:{display:"flex",flexDirection:"column",gap:"var(--sl-spacing-x-small)",width:"100%"},EditInputWrapper:{display:"flex",alignItems:"center",width:"100%",border:"var(--sqm-border-thickness, 1px) solid var(--sqm-input-border-color, #d1d5db)",borderRadius:"var(--sqm-border-radius-normal, 4px)",background:"var(--sqm-input-background, #fff)",overflow:"hidden","&:focus-within":{borderColor:"#999999",boxShadow:"0 0 0 var(--sl-focus-ring-width) var(--sl-input-focus-ring-color)"}},DomainPrefix:{padding:"0 0 0 var(--sl-spacing-medium)",fontSize:"var(--sl-font-size-medium)",color:"var(--sl-color-neutral-500)",whiteSpace:"nowrap",userSelect:"none",lineHeight:"var(--sl-input-height-medium)"},EditInput:{flex:"1",border:"none",outline:"none",padding:"0 var(--sl-spacing-medium) 0 0",fontSize:"var(--sl-font-size-medium)",fontFamily:"var(--sl-font-sans)",color:"var(--sl-input-color)",background:"transparent",lineHeight:"var(--sl-input-height-medium)",minWidth:"0"},EditLabel:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sl-color-neutral-500)"},HelperText:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sl-color-neutral-500)"},ErrorText:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sqm-danger-color-text, #dc2626)"},ActionRow:{display:"flex",gap:"var(--sl-spacing-medium)",alignItems:"center"},SaveButton:{cursor:"pointer",fontFamily:"var(--sl-font-sans)",fontSize:"var(--sl-font-size-small)",fontWeight:"600",padding:"var(--sl-spacing-x-small) var(--sl-spacing-medium)",borderRadius:"var(--sqm-border-radius-normal, 4px)",border:"1px solid var(--sl-color-neutral-900)",background:"var(--sl-color-neutral-900)",color:"#fff","&:disabled":{opacity:"0.5",cursor:"default"}},CancelButton:{margin:"0",fontSize:"var(--sl-font-size-small)",fontWeight:"600",cursor:"pointer",background:"none",border:"none",padding:"0",fontFamily:"var(--sl-font-sans)",color:"var(--sl-color-neutral-500)"},LimitReachedContainer:{display:"flex",alignItems:"center",gap:"var(--sl-spacing-x-small)"}};var R=createStyleSheet(x);var D=R.toString();var w=(v===null||v===void 0?void 0:v.code)==="EXISTING_CODE_CONFLICT"?"info":"warning";var A=C<=14;console.log(t,u,k,v,"customize URL state");if(o){return h("div",{class:R.classes.Container},h("style",{type:"text/css"},D,vanillaStyle),h("p",{class:R.classes.EditLabel},"Enter your link"),h("div",{class:R.classes.EditInputWrapper},h("span",{class:R.classes.DomainPrefix},s),h("input",{class:R.classes.EditInput,type:"text",value:l,onInput:function(e){return y(e.target.value)},onKeyDown:function(e){if(e.key==="/"||e.key==="@")e.preventDefault()},disabled:m,maxLength:f})),h("p",{class:R.classes.HelperText},_,A&&" Characters remaining: "+C),v&&h("sqm-form-message",{type:w,style:{paddingBottom:"var(--sl-spacing-xx-small)"}},h("p",{part:"alert-title"},v.title),v.description),p&&h("p",{class:R.classes.HelperText},"Validating..."),h("div",{class:R.classes.ActionRow},h("sl-button",{type:"primary",onClick:S,disabled:m||p||!!v||!l||l.length<g},m?"Saving...":i),h("sl-button",{type:"secondary",class:R.classes.CancelButton,onClick:I,disabled:m},r)))}return h("div",{class:R.classes.Container},h("style",{type:"text/css"},D,vanillaStyle),h(CopyTextView,Object.assign({},n)),t&&(k?h("sl-tooltip",{content:b,placement:"top",style:{display:"inline-block",width:"fit-content"}},h("p",{class:R.classes.CustomizeLinkDisabled},a)):h("div",{class:R.classes.LimitReachedContainer},h("p",{class:u?R.classes.CustomizeLinkDisabled:R.classes.CustomizeLinkText,onClick:u?undefined:T},a),t&&u&&h("p",{class:R.classes.HelperText},intl.formatMessage({id:"editLimitReached",defaultMessage:E},{supportLink:h("a",{target:"_blank",href:"https://help.impact.com/other/readme/get-help-and-support"},L)})))))}var MAX_EDITS=5;var CHARACTER_LIMIT=15;var MIN_CHARACTERS=3;var MessageLinkQuery=dist.gql(templateObject_1||(templateObject_1=__makeTemplateObject(["\n query ($programId: ID) {\n user: viewer {\n ... on User {\n shareLink(programId: $programId)\n }\n }\n }\n"],["\n query ($programId: ID) {\n user: viewer {\n ... on User {\n shareLink(programId: $programId)\n }\n }\n }\n"])));var WIDGET_ENGAGEMENT_EVENT=dist.gql(templateObject_2||(templateObject_2=__makeTemplateObject(["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"],["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"])));var ADD_SHARE_LINK_CODE=dist.gql(templateObject_3||(templateObject_3=__makeTemplateObject(["\n mutation ($addShareLinkCodeInput: AddShareLinkCodeInput!) {\n addShareLinkCode(addShareLinkCodeInput: $addShareLinkCodeInput) {\n linkCode {\n linkCode\n shortUrl\n referralCode {\n code\n }\n }\n }\n }\n"],["\n mutation ($addShareLinkCodeInput: AddShareLinkCodeInput!) {\n addShareLinkCode(addShareLinkCodeInput: $addShareLinkCodeInput) {\n linkCode {\n linkCode\n shortUrl\n referralCode {\n code\n }\n }\n }\n }\n"])));var VALIDATE_LINK_CODE=dist.gql(templateObject_4||(templateObject_4=__makeTemplateObject(["\n query validateLinkCode($linkCode: String!) {\n validateLinkCode(linkCode: $linkCode) {\n valid\n invalidReason\n }\n }\n"],["\n query validateLinkCode($linkCode: String!) {\n validateLinkCode(linkCode: $linkCode) {\n valid\n invalidReason\n }\n }\n"])));var GET_LINK_DOMAIN=dist.gql(templateObject_5||(templateObject_5=__makeTemplateObject(["\n query getLinkDomain {\n tenantSettings {\n primaryLinkDomain {\n host\n }\n }\n }\n"],["\n query getLinkDomain {\n tenantSettings {\n primaryLinkDomain {\n host\n }\n }\n }\n"])));var SHARE_LINK_EDIT_COUNT=dist.gql(templateObject_6||(templateObject_6=__makeTemplateObject(["\n query shareLinkEditCount {\n viewer {\n ... on User {\n shareLinkCodes {\n totalCount\n data {\n isVanity\n }\n }\n }\n }\n }\n"],["\n query shareLinkEditCount {\n viewer {\n ... on User {\n shareLinkCodes {\n totalCount\n data {\n isVanity\n }\n }\n }\n }\n }\n"])));function parseShareUrl(e){try{var n=new URL(e);return{url:n.origin+n.pathname,domain:n.origin+"/",path:n.pathname.slice(1)}}catch(n){return{url:e,domain:e,path:""}}}function useShareLink(e){var n,t,a,i,r,o,l;var s=e.programId,d=s===void 0?H():s;var c=J();var u=B();var v=Fn(REFERRAL_CODES_NAMESPACE);var p=wn(MessageLinkQuery,{programId:d},!(c===null||c===void 0?void 0:c.jwt)||!!e.linkOverride||(v===null||v===void 0?void 0:v.shareLink)!==undefined),m=p.data,f=p.refetch;var h=$e(WIDGET_ENGAGEMENT_EVENT)[0];var g=$e(SET_CODE_COPIED)[0];var C=$e(ADD_SHARE_LINK_CODE),_=C[0],E=C[1].loading;var L=Xe(VALIDATE_LINK_CODE)[0];var k=Qe().refresh;var b=wn(GET_LINK_DOMAIN,{},!(c===null||c===void 0?void 0:c.jwt)||!e.customizeUrl).data;var T=wn(SHARE_LINK_EDIT_COUNT,{},!(c===null||c===void 0?void 0:c.jwt)||!e.customizeUrl),y=T.data,S=T.refetch;var I=parseShareUrl((t=(v===null||v===void 0?void 0:v.shareLink)||((n=m===null||m===void 0?void 0:m.user)===null||n===void 0?void 0:n.shareLink))!==null&&t!==void 0?t:"..."),x=I.url,R=I.domain,D=I.path;var w=useState(false),A=w[0],O=w[1];var j=useState(false),z=j[0],N=j[1];var M=useState(""),V=M[0],q=M[1];var U=useState(null),$=U[0],P=U[1];var G=useState(false),F=G[0],K=G[1];var W=useRef(undefined);var X=((a=b===null||b===void 0?void 0:b.tenantSettings)===null||a===void 0?void 0:a.primaryLinkDomain)!=null;var Q=!X;var Y=(l=(o=(r=(i=y===null||y===void 0?void 0:y.viewer)===null||i===void 0?void 0:i.shareLinkCodes)===null||r===void 0?void 0:r.data)===null||o===void 0?void 0:o.filter((function(e){return e.isVanity})).length)!==null&&l!==void 0?l:0;var Z=Y;var ee=Math.max(0,MAX_EDITS-Z);var ne=ee<=0;function te(n){if(!n)return null;var t={EXISTING_CODE_CONFLICT:{code:"EXISTING_CODE_CONFLICT",title:e.existingCodeConflictErrorTitle,description:e.existingCodeConflictErrorDescription},INVALID_CHARACTER:{code:"INVALID_CHARACTER",title:e.invalidCharactersErrorTitle,description:e.invalidCharactersErrorDescription},BLOCKED_WORD:{code:"BLOCKED_WORD",title:e.profanityErrorTitle,description:e.profanityErrorDescription}};return t[n]}function ae(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){switch(n.label){case 0:if(!v)return[3,2];return[4,g({referralCode:v.referralCode})];case 1:n.sent();v.refresh();n.label=2;case 2:navigator.clipboard.writeText(x);O(true);setTimeout((function(){return O(false)}),e.tooltiplifespan);h({eventMeta:{programId:d,id:c===null||c===void 0?void 0:c.id,accountId:c===null||c===void 0?void 0:c.accountId,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:u,shareMedium:"DIRECT"}}});return[2]}}))}))}function ie(){if(ne||Q)return;N(true);q(Z===0?"":D);P(null)}function re(e){var n=this;var t=e.slice(0,CHARACTER_LIMIT);q(t);P(null);if(W.current)clearTimeout(W.current);if(!t||t.length<MIN_CHARACTERS){K(false);return}K(true);W.current=setTimeout((function(){return __awaiter(n,void 0,void 0,(function(){var e,n,a,i,r;return __generator(this,(function(o){switch(o.label){case 0:o.trys.push([0,2,,3]);return[4,L({linkCode:t})];case 1:a=o.sent();if(!((e=a===null||a===void 0?void 0:a.validateLinkCode)===null||e===void 0?void 0:e.valid)){i=(n=a===null||a===void 0?void 0:a.validateLinkCode)===null||n===void 0?void 0:n.invalidReason;console.log(i,"validation error reason from validateLinkCode query");P(te(i))}return[3,3];case 2:r=o.sent();return[3,3];case 3:K(false);return[2]}}))}))}),2e3)}function oe(){return __awaiter(this,void 0,void 0,(function(){var e,n,t,a;return __generator(this,(function(i){switch(i.label){case 0:if(!V||V.length<MIN_CHARACTERS||$||F)return[2];i.label=1;case 1:i.trys.push([1,4,,5]);return[4,_({addShareLinkCodeInput:{userId:c===null||c===void 0?void 0:c.id,accountId:c===null||c===void 0?void 0:c.accountId,programId:d,linkCode:V,makeShareLinkCodePrimaryForReferralCode:true}})];case 2:i.sent();N(false);return[4,Promise.all([f(),S()])];case 3:i.sent();k();return[3,5];case 4:t=i.sent();a=(e=t===null||t===void 0?void 0:t.extensions)===null||e===void 0?void 0:e.code;console.log(a,"errorCode from addSharelInkCodeMutation");P((n=te(a))!==null&&n!==void 0?n:{code:null,title:"Error",description:(t===null||t===void 0?void 0:t.message)||"Failed to save custom link. Please try again."});return[3,5];case 5:return[2]}}))}))}function le(){N(false);q("");P(null);K(false)}console.log($,"validation error state");return{copyTextViewProps:__assign(__assign({},e),{onClick:ae,open:A,copyString:x}),customizeUrl:e.customizeUrl,customizeLinkLabel:e.customizeLinkLabel,saveLabelText:e.saveLabelText,cancelLabelText:e.cancelLabelText,isEditing:z,editValue:V,domainPrefix:R,editsRemaining:ee,maxEdits:MAX_EDITS,limitReached:ne,validationError:$,isValidating:F,isSaving:E,characterLimit:CHARACTER_LIMIT,minCharacters:MIN_CHARACTERS,charactersRemaining:CHARACTER_LIMIT-V.length,editLimitText:e.editLimitText,editLimitReachedText:e.editLimitReachedText,supportLinkText:e.supportLinkText,customizeDisabled:Q,customizeDisabledTooltip:e.customizeDisabledTooltip,onCustomizeClick:ie,onEditValueChange:re,onSave:oe,onCancel:le}}export{ShareLinkView as S,useShareLink as u};var templateObject_1,templateObject_2,templateObject_3,templateObject_4,templateObject_5,templateObject_6;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __makeTemplateObject=this&&this.__makeTemplateObject||function(e,n){if(Object.defineProperty){Object.defineProperty(e,"raw",{value:n})}else{e.raw=n}return e};var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var n,t=1,a=arguments.length;t<a;t++){n=arguments[t];for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i))e[i]=n[i]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,n,t,a){function i(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,r){function o(e){try{s(a.next(e))}catch(e){r(e)}}function l(e){try{s(a["throw"](e))}catch(e){r(e)}}function s(e){e.done?t(e.value):i(e.value).then(o,l)}s((a=a.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},a,i,r,o;return o={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(e){return function(n){return s([e,n])}}function s(o){if(a)throw new TypeError("Generator is already executing.");while(t)try{if(a=1,i&&(r=o[0]&2?i["return"]:o[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;if(i=0,r)o=[o[0]&2,r.value];switch(o[0]){case 0:case 1:r=o;break;case 4:t.label++;return{value:o[1],done:false};case 5:t.label++;i=o[1];o=[0];continue;case 7:o=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(o[0]===6||o[0]===2)){t=0;continue}if(o[0]===3&&(!r||o[1]>r[0]&&o[1]<r[3])){t.label=o[1];break}if(o[0]===6&&t.label<r[1]){t.label=r[1];r=o;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(o);break}if(r[2])t.ops.pop();t.trys.pop();continue}o=n.call(e,t)}catch(e){o=[6,e];i=0}finally{a=r=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}};import{h}from"./index-d9876cd5.js";import{i as intl}from"./global-e1c1ff72.js";import{i as useState,k as useRef}from"./dom-context-hooks.module-8411297a.js";import{d as dist,H,J,B,F as Fn,w as wn,$ as $e,X as Xe,h as Qe}from"./index.module-60e4da3a.js";import{c as createStyleSheet}from"./JSS-8c381d8b.js";import{R as REFERRAL_CODES_NAMESPACE,S as SET_CODE_COPIED}from"./useReferralCodes-cff9a9dc.js";import{C as CopyTextView}from"./copy-text-view-c508f2e1.js";var vanillaStyle="\n :host {\n display: block;\n width: 100%;\n }\n";function ShareLinkView(e){var n=e.copyTextViewProps,t=e.customizeUrl,a=e.customizeLinkLabel,i=e.saveLabelText,r=e.cancelLabelText,o=e.isEditing,l=e.editValue,s=e.domainPrefix,d=e.editsRemaining,c=e.maxEdits,u=e.limitReached,v=e.validationError,m=e.isValidating,p=e.isSaving,f=e.characterLimit,g=e.minCharacters,C=e.charactersRemaining,_=e.editLimitText,E=e.editLimitReachedText,L=e.supportLinkText,k=e.customizeDisabled,b=e.customizeDisabledTooltip,T=e.onCustomizeClick,S=e.onEditValueChange,y=e.onSave,I=e.onCancel;var x={Container:{display:"flex",flexDirection:"column",gap:"var(--sl-spacing-xx-small)",width:"100%"},CustomizeLinkText:{margin:"0",fontSize:"var(--sl-font-size-small)",fontWeight:"600",cursor:"pointer",color:"var(--sl-color-neutral-900)",textAlign:"left",padding:"var(--sl-spacing-small)","&:hover":{textDecoration:"underline"}},CustomizeLinkDisabled:{margin:"0",fontSize:"var(--sl-font-size-small)",fontWeight:"600",color:"var(--sl-color-neutral-400)",cursor:"default",textAlign:"left",padding:"var(--sl-spacing-small)"},EditContainer:{display:"flex",flexDirection:"column",gap:"var(--sl-spacing-x-small)",width:"100%"},EditInputWrapper:{display:"flex",alignItems:"center",width:"100%",border:"var(--sqm-border-thickness, 1px) solid var(--sqm-input-border-color, #d1d5db)",borderRadius:"var(--sqm-border-radius-normal, 4px)",background:"var(--sqm-input-background, #fff)",overflow:"hidden","&:focus-within":{borderColor:"#999999",boxShadow:"0 0 0 var(--sl-focus-ring-width) var(--sl-input-focus-ring-color)"}},DomainPrefix:{padding:"0 0 0 var(--sl-spacing-medium)",fontSize:"var(--sl-font-size-medium)",color:"var(--sl-color-neutral-500)",whiteSpace:"nowrap",userSelect:"none",lineHeight:"var(--sl-input-height-medium)"},EditInput:{flex:"1",border:"none",outline:"none",padding:"0 var(--sl-spacing-medium) 0 0",fontSize:"var(--sl-font-size-medium)",fontFamily:"var(--sl-font-sans)",color:"var(--sl-input-color)",background:"transparent",lineHeight:"var(--sl-input-height-medium)",minWidth:"0"},EditLabel:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sl-color-neutral-500)"},HelperText:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sl-color-neutral-500)"},ErrorText:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sqm-danger-color-text, #dc2626)"},ActionRow:{display:"flex",gap:"var(--sl-spacing-medium)",alignItems:"center"},SaveButton:{cursor:"pointer",fontFamily:"var(--sl-font-sans)",fontSize:"var(--sl-font-size-small)",fontWeight:"600",padding:"var(--sl-spacing-x-small) var(--sl-spacing-medium)",borderRadius:"var(--sqm-border-radius-normal, 4px)",border:"1px solid var(--sl-color-neutral-900)",background:"var(--sl-color-neutral-900)",color:"#fff","&:disabled":{opacity:"0.5",cursor:"default"}},CancelButton:{margin:"0",fontSize:"var(--sl-font-size-small)",fontWeight:"600",cursor:"pointer",background:"none",border:"none",padding:"0",fontFamily:"var(--sl-font-sans)",color:"var(--sl-color-neutral-500)"},LimitReachedContainer:{display:"flex",alignItems:"center",gap:"var(--sl-spacing-x-small)"}};var R=createStyleSheet(x);var D=R.toString();var w=(v===null||v===void 0?void 0:v.code)==="EXISTING_CODE_CONFLICT"?"info":"warning";var A=C<=14;console.log(t,u,k,v,"customize URL state");if(o){return h("div",{class:R.classes.Container},h("style",{type:"text/css"},D,vanillaStyle),h("p",{class:R.classes.EditLabel},"Enter your link"),h("div",{class:R.classes.EditInputWrapper},h("span",{class:R.classes.DomainPrefix},s),h("input",{class:R.classes.EditInput,type:"text",value:l,onInput:function(e){return S(e.target.value)},onKeyDown:function(e){if(e.key==="/"||e.key==="@")e.preventDefault()},disabled:p,maxLength:f})),h("p",{class:R.classes.HelperText},_,A&&" Characters remaining: "+C),v&&h("sqm-form-message",{type:w,style:{paddingBottom:"var(--sl-spacing-xx-small)"}},h("p",{part:"alert-title"},v.title),v.description),m&&h("p",{class:R.classes.HelperText},"Validating..."),h("div",{class:R.classes.ActionRow},h("sl-button",{class:R.classes.SaveButton,onClick:y,disabled:p||m||!!v||!l||l.length<g},p?"Saving...":i),h("sl-button",{class:R.classes.CancelButton,onClick:I,disabled:p},r)))}return h("div",{class:R.classes.Container},h("style",{type:"text/css"},D,vanillaStyle),h(CopyTextView,Object.assign({},n)),t&&(k?h("sl-tooltip",{content:b,placement:"top",style:{display:"inline-block",width:"fit-content"}},h("p",{class:R.classes.CustomizeLinkDisabled},a)):h("div",{class:R.classes.LimitReachedContainer},h("p",{class:u?R.classes.CustomizeLinkDisabled:R.classes.CustomizeLinkText,onClick:u?undefined:T},a),t&&u&&h("p",{class:R.classes.HelperText},intl.formatMessage({id:"editLimitReached",defaultMessage:E},{supportLink:h("a",{target:"_blank",href:"https://help.impact.com/other/readme/get-help-and-support"},L)})))))}var MAX_EDITS=5;var CHARACTER_LIMIT=15;var MIN_CHARACTERS=3;var MessageLinkQuery=dist.gql(templateObject_1||(templateObject_1=__makeTemplateObject(["\n query ($programId: ID) {\n user: viewer {\n ... on User {\n shareLink(programId: $programId)\n }\n }\n }\n"],["\n query ($programId: ID) {\n user: viewer {\n ... on User {\n shareLink(programId: $programId)\n }\n }\n }\n"])));var WIDGET_ENGAGEMENT_EVENT=dist.gql(templateObject_2||(templateObject_2=__makeTemplateObject(["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"],["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"])));var ADD_SHARE_LINK_CODE=dist.gql(templateObject_3||(templateObject_3=__makeTemplateObject(["\n mutation ($addShareLinkCodeInput: AddShareLinkCodeInput!) {\n addShareLinkCode(addShareLinkCodeInput: $addShareLinkCodeInput) {\n linkCode {\n linkCode\n shortUrl\n referralCode {\n code\n }\n }\n }\n }\n"],["\n mutation ($addShareLinkCodeInput: AddShareLinkCodeInput!) {\n addShareLinkCode(addShareLinkCodeInput: $addShareLinkCodeInput) {\n linkCode {\n linkCode\n shortUrl\n referralCode {\n code\n }\n }\n }\n }\n"])));var VALIDATE_LINK_CODE=dist.gql(templateObject_4||(templateObject_4=__makeTemplateObject(["\n query validateLinkCode($linkCode: String!) {\n validateLinkCode(linkCode: $linkCode) {\n valid\n invalidReason\n }\n }\n"],["\n query validateLinkCode($linkCode: String!) {\n validateLinkCode(linkCode: $linkCode) {\n valid\n invalidReason\n }\n }\n"])));var GET_LINK_DOMAIN=dist.gql(templateObject_5||(templateObject_5=__makeTemplateObject(["\n query getLinkDomain {\n tenantSettings {\n primaryLinkDomain {\n host\n }\n }\n }\n"],["\n query getLinkDomain {\n tenantSettings {\n primaryLinkDomain {\n host\n }\n }\n }\n"])));var SHARE_LINK_EDIT_COUNT=dist.gql(templateObject_6||(templateObject_6=__makeTemplateObject(["\n query shareLinkEditCount {\n viewer {\n ... on User {\n shareLinkCodes {\n totalCount\n data {\n isVanity\n }\n }\n }\n }\n }\n"],["\n query shareLinkEditCount {\n viewer {\n ... on User {\n shareLinkCodes {\n totalCount\n data {\n isVanity\n }\n }\n }\n }\n }\n"])));function parseShareUrl(e){try{var n=new URL(e);return{url:n.origin+n.pathname,domain:n.origin+"/",path:n.pathname.slice(1)}}catch(n){return{url:e,domain:e,path:""}}}function useShareLink(e){var n,t,a,i,r,o,l;var s=e.programId,d=s===void 0?H():s;var c=J();var u=B();var v=Fn(REFERRAL_CODES_NAMESPACE);var m=wn(MessageLinkQuery,{programId:d},!(c===null||c===void 0?void 0:c.jwt)||!!e.linkOverride||(v===null||v===void 0?void 0:v.shareLink)!==undefined),p=m.data,f=m.refetch;var h=$e(WIDGET_ENGAGEMENT_EVENT)[0];var g=$e(SET_CODE_COPIED)[0];var C=$e(ADD_SHARE_LINK_CODE),_=C[0],E=C[1].loading;var L=Xe(VALIDATE_LINK_CODE)[0];var k=Qe().refresh;var b=wn(GET_LINK_DOMAIN,{},!(c===null||c===void 0?void 0:c.jwt)||!e.customizeUrl).data;var T=wn(SHARE_LINK_EDIT_COUNT,{},!(c===null||c===void 0?void 0:c.jwt)||!e.customizeUrl),S=T.data,y=T.refetch;var I=parseShareUrl((t=(v===null||v===void 0?void 0:v.shareLink)||((n=p===null||p===void 0?void 0:p.user)===null||n===void 0?void 0:n.shareLink))!==null&&t!==void 0?t:"..."),x=I.url,R=I.domain,D=I.path;var w=useState(false),A=w[0],O=w[1];var j=useState(false),z=j[0],N=j[1];var M=useState(""),V=M[0],q=M[1];var U=useState(null),$=U[0],P=U[1];var G=useState(false),F=G[0],K=G[1];var W=useRef(undefined);var X=((a=b===null||b===void 0?void 0:b.tenantSettings)===null||a===void 0?void 0:a.primaryLinkDomain)!=null;var Q=!X;var Y=(l=(o=(r=(i=S===null||S===void 0?void 0:S.viewer)===null||i===void 0?void 0:i.shareLinkCodes)===null||r===void 0?void 0:r.data)===null||o===void 0?void 0:o.filter((function(e){return e.isVanity})).length)!==null&&l!==void 0?l:0;var Z=Y;var ee=Math.max(0,MAX_EDITS-Z);var ne=ee<=0;function te(n){if(!n)return null;var t={EXISTING_CODE_CONFLICT:{code:"EXISTING_CODE_CONFLICT",title:e.existingCodeConflictErrorTitle,description:e.existingCodeConflictErrorDescription},INVALID_CHARACTER:{code:"INVALID_CHARACTER",title:e.invalidCharactersErrorTitle,description:e.invalidCharactersErrorDescription},BLOCKED_WORD:{code:"BLOCKED_WORD",title:e.profanityErrorTitle,description:e.profanityErrorDescription}};return t[n]}function ae(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){switch(n.label){case 0:if(!v)return[3,2];return[4,g({referralCode:v.referralCode})];case 1:n.sent();v.refresh();n.label=2;case 2:navigator.clipboard.writeText(x);O(true);setTimeout((function(){return O(false)}),e.tooltiplifespan);h({eventMeta:{programId:d,id:c===null||c===void 0?void 0:c.id,accountId:c===null||c===void 0?void 0:c.accountId,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:u,shareMedium:"DIRECT"}}});return[2]}}))}))}function ie(){if(ne||Q)return;N(true);q(Z===0?"":D);P(null)}function re(e){var n=this;var t=e.slice(0,CHARACTER_LIMIT);q(t);P(null);if(W.current)clearTimeout(W.current);if(!t||t.length<MIN_CHARACTERS){K(false);return}K(true);W.current=setTimeout((function(){return __awaiter(n,void 0,void 0,(function(){var e,n,a,i,r;return __generator(this,(function(o){switch(o.label){case 0:o.trys.push([0,2,,3]);return[4,L({linkCode:t})];case 1:a=o.sent();if(!((e=a===null||a===void 0?void 0:a.validateLinkCode)===null||e===void 0?void 0:e.valid)){i=(n=a===null||a===void 0?void 0:a.validateLinkCode)===null||n===void 0?void 0:n.invalidReason;console.log(i,"validation error reason from validateLinkCode query");P(te(i))}return[3,3];case 2:r=o.sent();return[3,3];case 3:K(false);return[2]}}))}))}),2e3)}function oe(){return __awaiter(this,void 0,void 0,(function(){var e,n,t,a;return __generator(this,(function(i){switch(i.label){case 0:if(!V||V.length<MIN_CHARACTERS||$||F)return[2];i.label=1;case 1:i.trys.push([1,4,,5]);return[4,_({addShareLinkCodeInput:{userId:c===null||c===void 0?void 0:c.id,accountId:c===null||c===void 0?void 0:c.accountId,programId:d,linkCode:V,makeShareLinkCodePrimaryForReferralCode:true}})];case 2:i.sent();N(false);return[4,Promise.all([f(),y()])];case 3:i.sent();k();return[3,5];case 4:t=i.sent();a=(e=t===null||t===void 0?void 0:t.extensions)===null||e===void 0?void 0:e.code;console.log(a,"errorCode from addSharelInkCodeMutation");P((n=te(a))!==null&&n!==void 0?n:{code:null,title:"Error",description:(t===null||t===void 0?void 0:t.message)||"Failed to save custom link. Please try again."});return[3,5];case 5:return[2]}}))}))}function le(){N(false);q("");P(null);K(false)}console.log($,"validation error state");return{copyTextViewProps:__assign(__assign({},e),{onClick:ae,open:A,copyString:x}),customizeUrl:e.customizeUrl,customizeLinkLabel:e.customizeLinkLabel,saveLabelText:e.saveLabelText,cancelLabelText:e.cancelLabelText,isEditing:z,editValue:V,domainPrefix:R,editsRemaining:ee,maxEdits:MAX_EDITS,limitReached:ne,validationError:$,isValidating:F,isSaving:E,characterLimit:CHARACTER_LIMIT,minCharacters:MIN_CHARACTERS,charactersRemaining:CHARACTER_LIMIT-V.length,editLimitText:e.editLimitText,editLimitReachedText:e.editLimitReachedText,supportLinkText:e.supportLinkText,customizeDisabled:Q,customizeDisabledTooltip:e.customizeDisabledTooltip,onCustomizeClick:ie,onEditValueChange:re,onSave:oe,onCancel:le}}export{ShareLinkView as S,useShareLink as u};var templateObject_1,templateObject_2,templateObject_3,templateObject_4,templateObject_5,templateObject_6;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __makeTemplateObject=this&&this.__makeTemplateObject||function(e,n){if(Object.defineProperty){Object.defineProperty(e,"raw",{value:n})}else{e.raw=n}return e};var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var n,t=1,a=arguments.length;t<a;t++){n=arguments[t];for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i))e[i]=n[i]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,n,t,a){function i(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,r){function o(e){try{s(a.next(e))}catch(e){r(e)}}function l(e){try{s(a["throw"](e))}catch(e){r(e)}}function s(e){e.done?t(e.value):i(e.value).then(o,l)}s((a=a.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},a,i,r,o;return o={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(e){return function(n){return s([e,n])}}function s(o){if(a)throw new TypeError("Generator is already executing.");while(t)try{if(a=1,i&&(r=o[0]&2?i["return"]:o[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;if(i=0,r)o=[o[0]&2,r.value];switch(o[0]){case 0:case 1:r=o;break;case 4:t.label++;return{value:o[1],done:false};case 5:t.label++;i=o[1];o=[0];continue;case 7:o=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(o[0]===6||o[0]===2)){t=0;continue}if(o[0]===3&&(!r||o[1]>r[0]&&o[1]<r[3])){t.label=o[1];break}if(o[0]===6&&t.label<r[1]){t.label=r[1];r=o;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(o);break}if(r[2])t.ops.pop();t.trys.pop();continue}o=n.call(e,t)}catch(e){o=[6,e];i=0}finally{a=r=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}};import{h}from"./index-d9876cd5.js";import{i as intl}from"./global-e1c1ff72.js";import{i as useState,k as useRef}from"./dom-context-hooks.module-8411297a.js";import{d as dist,H,J,B,F as Fn,w as wn,$ as $e,X as Xe,h as Qe}from"./index.module-60e4da3a.js";import{c as createStyleSheet}from"./JSS-8c381d8b.js";import{R as REFERRAL_CODES_NAMESPACE,S as SET_CODE_COPIED}from"./useReferralCodes-cff9a9dc.js";import{C as CopyTextView}from"./copy-text-view-c508f2e1.js";var vanillaStyle="\n :host {\n display: block;\n width: 100%;\n }\n";function ShareLinkView(e){var n=e.copyTextViewProps,t=e.customizeUrl,a=e.customizeLinkLabel,i=e.saveLabelText,r=e.cancelLabelText,o=e.isEditing,l=e.editValue,s=e.domainPrefix,d=e.editsRemaining,c=e.maxEdits,u=e.limitReached,v=e.validationError,p=e.isValidating,m=e.isSaving,f=e.characterLimit,g=e.minCharacters,C=e.charactersRemaining,_=e.editLimitText,E=e.editLimitReachedText,L=e.supportLinkText,k=e.customizeDisabled,b=e.customizeDisabledTooltip,T=e.onCustomizeClick,y=e.onEditValueChange,S=e.onSave,I=e.onCancel;var x={Container:{display:"flex",flexDirection:"column",gap:"var(--sl-spacing-xx-small)",width:"100%"},CustomizeLinkText:{margin:"0",fontSize:"var(--sl-font-size-small)",fontWeight:"600",cursor:"pointer",color:"var(--sl-color-neutral-900)",textAlign:"left",padding:"var(--sl-spacing-small)","&:hover":{textDecoration:"underline"}},CustomizeLinkDisabled:{margin:"0",fontSize:"var(--sl-font-size-small)",fontWeight:"600",color:"var(--sl-color-neutral-400)",cursor:"default",textAlign:"left",padding:"var(--sl-spacing-small)"},EditContainer:{display:"flex",flexDirection:"column",gap:"var(--sl-spacing-x-small)",width:"100%"},EditInputWrapper:{display:"flex",alignItems:"center",width:"100%",border:"var(--sqm-border-thickness, 1px) solid var(--sqm-input-border-color, #d1d5db)",borderRadius:"var(--sqm-border-radius-normal, 4px)",background:"var(--sqm-input-background, #fff)",overflow:"hidden","&:focus-within":{borderColor:"#999999",boxShadow:"0 0 0 var(--sl-focus-ring-width) var(--sl-input-focus-ring-color)"}},DomainPrefix:{padding:"0 0 0 var(--sl-spacing-medium)",fontSize:"var(--sl-font-size-medium)",color:"var(--sl-color-neutral-500)",whiteSpace:"nowrap",userSelect:"none",lineHeight:"var(--sl-input-height-medium)"},EditInput:{flex:"1",border:"none",outline:"none",padding:"0 var(--sl-spacing-medium) 0 0",fontSize:"var(--sl-font-size-medium)",fontFamily:"var(--sl-font-sans)",color:"var(--sl-input-color)",background:"transparent",lineHeight:"var(--sl-input-height-medium)",minWidth:"0"},EditLabel:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sl-color-neutral-500)"},HelperText:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sl-color-neutral-500)"},ErrorText:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sqm-danger-color-text, #dc2626)"},ActionRow:{display:"flex",gap:"var(--sl-spacing-medium)",alignItems:"center"},SaveButton:{cursor:"pointer",fontFamily:"var(--sl-font-sans)",fontSize:"var(--sl-font-size-small)",fontWeight:"600",padding:"var(--sl-spacing-x-small) var(--sl-spacing-medium)",borderRadius:"var(--sqm-border-radius-normal, 4px)",border:"1px solid var(--sl-color-neutral-900)",background:"var(--sl-color-neutral-900)",color:"#fff","&:disabled":{opacity:"0.5",cursor:"default"}},CancelButton:{margin:"0",fontSize:"var(--sl-font-size-small)",fontWeight:"600",cursor:"pointer",background:"none",border:"none",padding:"0",fontFamily:"var(--sl-font-sans)",color:"var(--sl-color-neutral-500)"},LimitReachedContainer:{display:"flex",alignItems:"center",gap:"var(--sl-spacing-x-small)"}};var R=createStyleSheet(x);var D=R.toString();var w=(v===null||v===void 0?void 0:v.code)==="EXISTING_CODE_CONFLICT"?"info":"warning";var A=C<=14;console.log(t,u,k,v,"customize URL state");if(o){return h("div",{class:R.classes.Container},h("style",{type:"text/css"},D,vanillaStyle),h("p",{class:R.classes.EditLabel},"Enter your link"),h("div",{class:R.classes.EditInputWrapper},h("span",{class:R.classes.DomainPrefix},s),h("input",{class:R.classes.EditInput,type:"text",value:l,onInput:function(e){return y(e.target.value)},onKeyDown:function(e){if(e.key==="/"||e.key==="@")e.preventDefault()},disabled:m,maxLength:f})),h("p",{class:R.classes.HelperText},_,A&&" Characters remaining: "+C),v&&h("sqm-form-message",{type:w,style:{paddingBottom:"var(--sl-spacing-xx-small)"}},h("p",{part:"alert-title"},v.title),v.description),p&&h("p",{class:R.classes.HelperText},"Validating..."),h("div",{class:R.classes.ActionRow},h("sl-button",{type:"primary",onClick:S,disabled:m||p||!!v||!l||l.length<g},m?"Saving...":i),h("sl-button",{type:"secondary",class:R.classes.CancelButton,onClick:I,disabled:m},r)))}return h("div",{class:R.classes.Container},h("style",{type:"text/css"},D,vanillaStyle),h(CopyTextView,Object.assign({},n)),t&&(k?h("sl-tooltip",{content:b,placement:"top",style:{display:"inline-block",width:"fit-content"}},h("p",{class:R.classes.CustomizeLinkDisabled},a)):h("div",{class:R.classes.LimitReachedContainer},h("p",{class:u?R.classes.CustomizeLinkDisabled:R.classes.CustomizeLinkText,onClick:u?undefined:T},a),t&&u&&h("p",{class:R.classes.HelperText},intl.formatMessage({id:"editLimitReached",defaultMessage:E},{supportLink:h("a",{target:"_blank",href:"https://help.impact.com/other/readme/get-help-and-support"},L)})))))}var MAX_EDITS=5;var CHARACTER_LIMIT=15;var MIN_CHARACTERS=3;var MessageLinkQuery=dist.gql(templateObject_1||(templateObject_1=__makeTemplateObject(["\n query ($programId: ID) {\n user: viewer {\n ... on User {\n shareLink(programId: $programId)\n }\n }\n }\n"],["\n query ($programId: ID) {\n user: viewer {\n ... on User {\n shareLink(programId: $programId)\n }\n }\n }\n"])));var WIDGET_ENGAGEMENT_EVENT=dist.gql(templateObject_2||(templateObject_2=__makeTemplateObject(["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"],["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"])));var ADD_SHARE_LINK_CODE=dist.gql(templateObject_3||(templateObject_3=__makeTemplateObject(["\n mutation ($addShareLinkCodeInput: AddShareLinkCodeInput!) {\n addShareLinkCode(addShareLinkCodeInput: $addShareLinkCodeInput) {\n linkCode {\n linkCode\n shortUrl\n referralCode {\n code\n }\n }\n }\n }\n"],["\n mutation ($addShareLinkCodeInput: AddShareLinkCodeInput!) {\n addShareLinkCode(addShareLinkCodeInput: $addShareLinkCodeInput) {\n linkCode {\n linkCode\n shortUrl\n referralCode {\n code\n }\n }\n }\n }\n"])));var VALIDATE_LINK_CODE=dist.gql(templateObject_4||(templateObject_4=__makeTemplateObject(["\n query validateLinkCode($linkCode: String!) {\n validateLinkCode(linkCode: $linkCode) {\n valid\n invalidReason\n }\n }\n"],["\n query validateLinkCode($linkCode: String!) {\n validateLinkCode(linkCode: $linkCode) {\n valid\n invalidReason\n }\n }\n"])));var GET_LINK_DOMAIN=dist.gql(templateObject_5||(templateObject_5=__makeTemplateObject(["\n query getLinkDomain {\n tenantSettings {\n primaryLinkDomain {\n host\n }\n }\n }\n"],["\n query getLinkDomain {\n tenantSettings {\n primaryLinkDomain {\n host\n }\n }\n }\n"])));var SHARE_LINK_EDIT_COUNT=dist.gql(templateObject_6||(templateObject_6=__makeTemplateObject(["\n query shareLinkEditCount {\n viewer {\n ... on User {\n shareLinkCodes {\n totalCount\n data {\n isVanity\n }\n }\n }\n }\n }\n"],["\n query shareLinkEditCount {\n viewer {\n ... on User {\n shareLinkCodes {\n totalCount\n data {\n isVanity\n }\n }\n }\n }\n }\n"])));function parseShareUrl(e){try{var n=new URL(e);return{url:n.origin+n.pathname,domain:n.origin+"/",path:n.pathname.slice(1)}}catch(n){return{url:e,domain:e,path:""}}}function useShareLink(e){var n,t,a,i,r,o,l;var s=e.programId,d=s===void 0?H():s;var c=J();var u=B();var v=Fn(REFERRAL_CODES_NAMESPACE);var p=wn(MessageLinkQuery,{programId:d},!(c===null||c===void 0?void 0:c.jwt)||!!e.linkOverride||(v===null||v===void 0?void 0:v.shareLink)!==undefined),m=p.data,f=p.refetch;var h=$e(WIDGET_ENGAGEMENT_EVENT)[0];var g=$e(SET_CODE_COPIED)[0];var C=$e(ADD_SHARE_LINK_CODE),_=C[0],E=C[1].loading;var L=Xe(VALIDATE_LINK_CODE)[0];var k=Qe().refresh;var b=wn(GET_LINK_DOMAIN,{},!(c===null||c===void 0?void 0:c.jwt)||!e.customizeUrl).data;var T=wn(SHARE_LINK_EDIT_COUNT,{},!(c===null||c===void 0?void 0:c.jwt)||!e.customizeUrl),y=T.data,S=T.refetch;var I=parseShareUrl((t=(v===null||v===void 0?void 0:v.shareLink)||((n=m===null||m===void 0?void 0:m.user)===null||n===void 0?void 0:n.shareLink))!==null&&t!==void 0?t:"..."),x=I.url,R=I.domain,D=I.path;var w=useState(false),A=w[0],O=w[1];var j=useState(false),z=j[0],N=j[1];var M=useState(""),V=M[0],q=M[1];var U=useState(null),$=U[0],P=U[1];var G=useState(false),F=G[0],K=G[1];var W=useRef(undefined);var X=((a=b===null||b===void 0?void 0:b.tenantSettings)===null||a===void 0?void 0:a.primaryLinkDomain)!=null;var Q=!X;var Y=(l=(o=(r=(i=y===null||y===void 0?void 0:y.viewer)===null||i===void 0?void 0:i.shareLinkCodes)===null||r===void 0?void 0:r.data)===null||o===void 0?void 0:o.filter((function(e){return e.isVanity})).length)!==null&&l!==void 0?l:0;var Z=Y;var ee=Math.max(0,MAX_EDITS-Z);var ne=ee<=0;function te(n){if(!n)return null;var t={EXISTING_CODE_CONFLICT:{code:"EXISTING_CODE_CONFLICT",title:e.existingCodeConflictErrorTitle,description:e.existingCodeConflictErrorDescription},INVALID_CHARACTER:{code:"INVALID_CHARACTER",title:e.invalidCharactersErrorTitle,description:e.invalidCharactersErrorDescription},BLOCKED_WORD:{code:"BLOCKED_WORD",title:e.profanityErrorTitle,description:e.profanityErrorDescription}};return t[n]}function ae(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){switch(n.label){case 0:if(!v)return[3,2];return[4,g({referralCode:v.referralCode})];case 1:n.sent();v.refresh();n.label=2;case 2:navigator.clipboard.writeText(x);O(true);setTimeout((function(){return O(false)}),e.tooltiplifespan);h({eventMeta:{programId:d,id:c===null||c===void 0?void 0:c.id,accountId:c===null||c===void 0?void 0:c.accountId,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:u,shareMedium:"DIRECT"}}});return[2]}}))}))}function ie(){if(ne||Q)return;N(true);q(Z===0?"":D);P(null)}function re(e){var n=this;var t=e.slice(0,CHARACTER_LIMIT);q(t);P(null);if(W.current)clearTimeout(W.current);if(!t||t.length<MIN_CHARACTERS){K(false);return}K(true);W.current=setTimeout((function(){return __awaiter(n,void 0,void 0,(function(){var e,n,a,i,r;return __generator(this,(function(o){switch(o.label){case 0:o.trys.push([0,2,,3]);return[4,L({linkCode:t})];case 1:a=o.sent();if(!((e=a===null||a===void 0?void 0:a.validateLinkCode)===null||e===void 0?void 0:e.valid)){i=(n=a===null||a===void 0?void 0:a.validateLinkCode)===null||n===void 0?void 0:n.invalidReason;console.log(i,"validation error reason from validateLinkCode query");P(te(i))}return[3,3];case 2:r=o.sent();return[3,3];case 3:K(false);return[2]}}))}))}),2e3)}function oe(){return __awaiter(this,void 0,void 0,(function(){var e,n,t,a;return __generator(this,(function(i){switch(i.label){case 0:if(!V||V.length<MIN_CHARACTERS||$||F)return[2];i.label=1;case 1:i.trys.push([1,4,,5]);return[4,_({addShareLinkCodeInput:{userId:c===null||c===void 0?void 0:c.id,accountId:c===null||c===void 0?void 0:c.accountId,programId:d,linkCode:V,makeShareLinkCodePrimaryForReferralCode:true}})];case 2:i.sent();N(false);return[4,Promise.all([f(),S()])];case 3:i.sent();k();return[3,5];case 4:t=i.sent();a=(e=t===null||t===void 0?void 0:t.extensions)===null||e===void 0?void 0:e.code;console.log(a,"errorCode from addSharelInkCodeMutation");P((n=te(a))!==null&&n!==void 0?n:{code:null,title:"Error",description:(t===null||t===void 0?void 0:t.message)||"Failed to save custom link. Please try again."});return[3,5];case 5:return[2]}}))}))}function le(){N(false);q("");P(null);K(false)}console.log($,"validation error state");return{copyTextViewProps:__assign(__assign({},e),{onClick:ae,open:A,copyString:x}),customizeUrl:e.customizeUrl,customizeLinkLabel:e.customizeLinkLabel,saveLabelText:e.saveLabelText,cancelLabelText:e.cancelLabelText,isEditing:z,editValue:V,domainPrefix:R,editsRemaining:ee,maxEdits:MAX_EDITS,limitReached:ne,validationError:$,isValidating:F,isSaving:E,characterLimit:CHARACTER_LIMIT,minCharacters:MIN_CHARACTERS,charactersRemaining:CHARACTER_LIMIT-V.length,editLimitText:e.editLimitText,editLimitReachedText:e.editLimitReachedText,supportLinkText:e.supportLinkText,customizeDisabled:Q,customizeDisabledTooltip:e.customizeDisabledTooltip,onCustomizeClick:ie,onEditValueChange:re,onSave:oe,onCancel:le}}export{ShareLinkView as S,useShareLink as u};var templateObject_1,templateObject_2,templateObject_3,templateObject_4,templateObject_5,templateObject_6;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __makeTemplateObject=this&&this.__makeTemplateObject||function(e,n){if(Object.defineProperty){Object.defineProperty(e,"raw",{value:n})}else{e.raw=n}return e};var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var n,t=1,a=arguments.length;t<a;t++){n=arguments[t];for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i))e[i]=n[i]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,n,t,a){function i(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,r){function o(e){try{s(a.next(e))}catch(e){r(e)}}function l(e){try{s(a["throw"](e))}catch(e){r(e)}}function s(e){e.done?t(e.value):i(e.value).then(o,l)}s((a=a.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},a,i,r,o;return o={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(e){return function(n){return s([e,n])}}function s(o){if(a)throw new TypeError("Generator is already executing.");while(t)try{if(a=1,i&&(r=o[0]&2?i["return"]:o[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;if(i=0,r)o=[o[0]&2,r.value];switch(o[0]){case 0:case 1:r=o;break;case 4:t.label++;return{value:o[1],done:false};case 5:t.label++;i=o[1];o=[0];continue;case 7:o=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(o[0]===6||o[0]===2)){t=0;continue}if(o[0]===3&&(!r||o[1]>r[0]&&o[1]<r[3])){t.label=o[1];break}if(o[0]===6&&t.label<r[1]){t.label=r[1];r=o;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(o);break}if(r[2])t.ops.pop();t.trys.pop();continue}o=n.call(e,t)}catch(e){o=[6,e];i=0}finally{a=r=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}};import{h}from"./index-d9876cd5.js";import{i as intl}from"./global-e1c1ff72.js";import{i as useState,k as useRef}from"./dom-context-hooks.module-8411297a.js";import{d as dist,H,J,B,F as Fn,w as wn,$ as $e,X as Xe,h as Qe}from"./index.module-60e4da3a.js";import{c as createStyleSheet}from"./JSS-8c381d8b.js";import{R as REFERRAL_CODES_NAMESPACE,S as SET_CODE_COPIED}from"./useReferralCodes-cff9a9dc.js";import{C as CopyTextView}from"./copy-text-view-c508f2e1.js";var vanillaStyle="\n :host {\n display: block;\n width: 100%;\n }\n";function ShareLinkView(e){var n=e.copyTextViewProps,t=e.customizeUrl,a=e.customizeLinkLabel,i=e.saveLabelText,r=e.cancelLabelText,o=e.isEditing,l=e.editValue,s=e.domainPrefix,d=e.editsRemaining,c=e.maxEdits,u=e.limitReached,v=e.validationError,p=e.isValidating,m=e.isSaving,f=e.characterLimit,g=e.minCharacters,C=e.charactersRemaining,_=e.editLimitText,E=e.editLimitReachedText,L=e.supportLinkText,k=e.customizeDisabled,b=e.customizeDisabledTooltip,T=e.onCustomizeClick,y=e.onEditValueChange,S=e.onSave,I=e.onCancel;var x={Container:{display:"flex",flexDirection:"column",gap:"var(--sl-spacing-xx-small)",width:"100%"},CustomizeLinkText:{margin:"0",fontSize:"var(--sl-font-size-small)",fontWeight:"600",cursor:"pointer",color:"var(--sl-color-neutral-900)",textAlign:"left",padding:"var(--sl-spacing-small)","&:hover":{textDecoration:"underline"}},CustomizeLinkDisabled:{margin:"0",fontSize:"var(--sl-font-size-small)",fontWeight:"600",color:"var(--sl-color-neutral-400)",cursor:"default",textAlign:"left",padding:"var(--sl-spacing-small)"},EditContainer:{display:"flex",flexDirection:"column",gap:"var(--sl-spacing-x-small)",width:"100%"},EditInputWrapper:{display:"flex",alignItems:"center",width:"100%",border:"var(--sqm-border-thickness, 1px) solid var(--sqm-input-border-color, #d1d5db)",borderRadius:"var(--sqm-border-radius-normal, 4px)",background:"var(--sqm-input-background, #fff)",overflow:"hidden","&:focus-within":{borderColor:"#999999",boxShadow:"0 0 0 var(--sl-focus-ring-width) var(--sl-input-focus-ring-color)"}},DomainPrefix:{padding:"0 0 0 var(--sl-spacing-medium)",fontSize:"var(--sl-font-size-medium)",color:"var(--sl-color-neutral-500)",whiteSpace:"nowrap",userSelect:"none",lineHeight:"var(--sl-input-height-medium)"},EditInput:{flex:"1",border:"none",outline:"none",padding:"0 var(--sl-spacing-medium) 0 0",fontSize:"var(--sl-font-size-medium)",fontFamily:"var(--sl-font-sans)",color:"var(--sl-input-color)",background:"transparent",lineHeight:"var(--sl-input-height-medium)",minWidth:"0"},EditLabel:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sl-color-neutral-500)"},HelperText:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sl-color-neutral-500)"},ErrorText:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sqm-danger-color-text, #dc2626)"},ActionRow:{display:"flex",gap:"var(--sl-spacing-medium)",alignItems:"center"},SaveButton:{cursor:"pointer",fontFamily:"var(--sl-font-sans)",fontSize:"var(--sl-font-size-small)",fontWeight:"600",padding:"var(--sl-spacing-x-small) var(--sl-spacing-medium)",borderRadius:"var(--sqm-border-radius-normal, 4px)",border:"1px solid var(--sl-color-neutral-900)",background:"var(--sl-color-neutral-900)",color:"#fff","&:disabled":{opacity:"0.5",cursor:"default"}},CancelButton:{margin:"0",fontSize:"var(--sl-font-size-small)",fontWeight:"600",cursor:"pointer",background:"none",border:"none",padding:"0",fontFamily:"var(--sl-font-sans)",color:"var(--sl-color-neutral-500)"},LimitReachedContainer:{display:"flex",alignItems:"center",gap:"var(--sl-spacing-x-small)"}};var R=createStyleSheet(x);var D=R.toString();var w=(v===null||v===void 0?void 0:v.code)==="EXISTING_CODE_CONFLICT"?"info":"warning";var A=C<=14;console.log(t,u,k,v,"customize URL state");if(o){return h("div",{class:R.classes.Container},h("style",{type:"text/css"},D,vanillaStyle),h("p",{class:R.classes.EditLabel},"Enter your link"),h("div",{class:R.classes.EditInputWrapper},h("span",{class:R.classes.DomainPrefix},s),h("sl-input",{class:R.classes.EditInput,type:"text",value:l,onInput:function(e){return y(e.target.value)},onKeyDown:function(e){if(e.key==="/"||e.key==="@")e.preventDefault()},disabled:m,maxLength:f})),h("p",{class:R.classes.HelperText},_,A&&" Characters remaining: "+C),v&&h("sqm-form-message",{type:w,style:{paddingBottom:"var(--sl-spacing-xx-small)"}},h("p",{part:"alert-title"},v.title),v.description),p&&h("p",{class:R.classes.HelperText},"Validating..."),h("div",{class:R.classes.ActionRow},h("sl-button",{type:"primary",onClick:S,disabled:m||p||!!v||!l||l.length<g},m?"Saving...":i),h("sl-button",{type:"secondary",class:R.classes.CancelButton,onClick:I,disabled:m},r)))}return h("div",{class:R.classes.Container},h("style",{type:"text/css"},D,vanillaStyle),h(CopyTextView,Object.assign({},n)),t&&(k?h("sl-tooltip",{content:b,placement:"top",style:{display:"inline-block",width:"fit-content"}},h("p",{class:R.classes.CustomizeLinkDisabled},a)):h("div",{class:R.classes.LimitReachedContainer},h("p",{class:u?R.classes.CustomizeLinkDisabled:R.classes.CustomizeLinkText,onClick:u?undefined:T},a),t&&u&&h("p",{class:R.classes.HelperText},intl.formatMessage({id:"editLimitReached",defaultMessage:E},{supportLink:h("a",{target:"_blank",href:"https://help.impact.com/other/readme/get-help-and-support"},L)})))))}var MAX_EDITS=5;var CHARACTER_LIMIT=15;var MIN_CHARACTERS=3;var MessageLinkQuery=dist.gql(templateObject_1||(templateObject_1=__makeTemplateObject(["\n query ($programId: ID) {\n user: viewer {\n ... on User {\n shareLink(programId: $programId)\n }\n }\n }\n"],["\n query ($programId: ID) {\n user: viewer {\n ... on User {\n shareLink(programId: $programId)\n }\n }\n }\n"])));var WIDGET_ENGAGEMENT_EVENT=dist.gql(templateObject_2||(templateObject_2=__makeTemplateObject(["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"],["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"])));var ADD_SHARE_LINK_CODE=dist.gql(templateObject_3||(templateObject_3=__makeTemplateObject(["\n mutation ($addShareLinkCodeInput: AddShareLinkCodeInput!) {\n addShareLinkCode(addShareLinkCodeInput: $addShareLinkCodeInput) {\n linkCode {\n linkCode\n shortUrl\n referralCode {\n code\n }\n }\n }\n }\n"],["\n mutation ($addShareLinkCodeInput: AddShareLinkCodeInput!) {\n addShareLinkCode(addShareLinkCodeInput: $addShareLinkCodeInput) {\n linkCode {\n linkCode\n shortUrl\n referralCode {\n code\n }\n }\n }\n }\n"])));var VALIDATE_LINK_CODE=dist.gql(templateObject_4||(templateObject_4=__makeTemplateObject(["\n query validateLinkCode($linkCode: String!) {\n validateLinkCode(linkCode: $linkCode) {\n valid\n invalidReason\n }\n }\n"],["\n query validateLinkCode($linkCode: String!) {\n validateLinkCode(linkCode: $linkCode) {\n valid\n invalidReason\n }\n }\n"])));var GET_LINK_DOMAIN=dist.gql(templateObject_5||(templateObject_5=__makeTemplateObject(["\n query getLinkDomain {\n tenantSettings {\n primaryLinkDomain {\n host\n }\n }\n }\n"],["\n query getLinkDomain {\n tenantSettings {\n primaryLinkDomain {\n host\n }\n }\n }\n"])));var SHARE_LINK_EDIT_COUNT=dist.gql(templateObject_6||(templateObject_6=__makeTemplateObject(["\n query shareLinkEditCount {\n viewer {\n ... on User {\n shareLinkCodes {\n totalCount\n data {\n isVanity\n }\n }\n }\n }\n }\n"],["\n query shareLinkEditCount {\n viewer {\n ... on User {\n shareLinkCodes {\n totalCount\n data {\n isVanity\n }\n }\n }\n }\n }\n"])));function parseShareUrl(e){try{var n=new URL(e);return{url:n.origin+n.pathname,domain:n.origin+"/",path:n.pathname.slice(1)}}catch(n){return{url:e,domain:e,path:""}}}function useShareLink(e){var n,t,a,i,r,o,l;var s=e.programId,d=s===void 0?H():s;var c=J();var u=B();var v=Fn(REFERRAL_CODES_NAMESPACE);var p=wn(MessageLinkQuery,{programId:d},!(c===null||c===void 0?void 0:c.jwt)||!!e.linkOverride||(v===null||v===void 0?void 0:v.shareLink)!==undefined),m=p.data,f=p.refetch;var h=$e(WIDGET_ENGAGEMENT_EVENT)[0];var g=$e(SET_CODE_COPIED)[0];var C=$e(ADD_SHARE_LINK_CODE),_=C[0],E=C[1].loading;var L=Xe(VALIDATE_LINK_CODE)[0];var k=Qe().refresh;var b=wn(GET_LINK_DOMAIN,{},!(c===null||c===void 0?void 0:c.jwt)||!e.customizeUrl).data;var T=wn(SHARE_LINK_EDIT_COUNT,{},!(c===null||c===void 0?void 0:c.jwt)||!e.customizeUrl),y=T.data,S=T.refetch;var I=parseShareUrl((t=(v===null||v===void 0?void 0:v.shareLink)||((n=m===null||m===void 0?void 0:m.user)===null||n===void 0?void 0:n.shareLink))!==null&&t!==void 0?t:"..."),x=I.url,R=I.domain,D=I.path;var w=useState(false),A=w[0],O=w[1];var j=useState(false),z=j[0],N=j[1];var M=useState(""),V=M[0],q=M[1];var U=useState(null),$=U[0],P=U[1];var G=useState(false),F=G[0],K=G[1];var W=useRef(undefined);var X=((a=b===null||b===void 0?void 0:b.tenantSettings)===null||a===void 0?void 0:a.primaryLinkDomain)!=null;var Q=!X;var Y=(l=(o=(r=(i=y===null||y===void 0?void 0:y.viewer)===null||i===void 0?void 0:i.shareLinkCodes)===null||r===void 0?void 0:r.data)===null||o===void 0?void 0:o.filter((function(e){return e.isVanity})).length)!==null&&l!==void 0?l:0;var Z=Y;var ee=Math.max(0,MAX_EDITS-Z);var ne=ee<=0;function te(n){if(!n)return null;var t={EXISTING_CODE_CONFLICT:{code:"EXISTING_CODE_CONFLICT",title:e.existingCodeConflictErrorTitle,description:e.existingCodeConflictErrorDescription},INVALID_CHARACTER:{code:"INVALID_CHARACTER",title:e.invalidCharactersErrorTitle,description:e.invalidCharactersErrorDescription},BLOCKED_WORD:{code:"BLOCKED_WORD",title:e.profanityErrorTitle,description:e.profanityErrorDescription}};return t[n]}function ae(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){switch(n.label){case 0:if(!v)return[3,2];return[4,g({referralCode:v.referralCode})];case 1:n.sent();v.refresh();n.label=2;case 2:navigator.clipboard.writeText(x);O(true);setTimeout((function(){return O(false)}),e.tooltiplifespan);h({eventMeta:{programId:d,id:c===null||c===void 0?void 0:c.id,accountId:c===null||c===void 0?void 0:c.accountId,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:u,shareMedium:"DIRECT"}}});return[2]}}))}))}function ie(){if(ne||Q)return;N(true);q(Z===0?"":D);P(null)}function re(e){var n=this;var t=e.slice(0,CHARACTER_LIMIT);q(t);P(null);if(W.current)clearTimeout(W.current);if(!t||t.length<MIN_CHARACTERS){K(false);return}K(true);W.current=setTimeout((function(){return __awaiter(n,void 0,void 0,(function(){var e,n,a,i,r;return __generator(this,(function(o){switch(o.label){case 0:o.trys.push([0,2,,3]);return[4,L({linkCode:t})];case 1:a=o.sent();if(!((e=a===null||a===void 0?void 0:a.validateLinkCode)===null||e===void 0?void 0:e.valid)){i=(n=a===null||a===void 0?void 0:a.validateLinkCode)===null||n===void 0?void 0:n.invalidReason;console.log(i,"validation error reason from validateLinkCode query");P(te(i))}return[3,3];case 2:r=o.sent();return[3,3];case 3:K(false);return[2]}}))}))}),2e3)}function oe(){return __awaiter(this,void 0,void 0,(function(){var e,n,t,a;return __generator(this,(function(i){switch(i.label){case 0:if(!V||V.length<MIN_CHARACTERS||$||F)return[2];i.label=1;case 1:i.trys.push([1,4,,5]);return[4,_({addShareLinkCodeInput:{userId:c===null||c===void 0?void 0:c.id,accountId:c===null||c===void 0?void 0:c.accountId,programId:d,linkCode:V,makeShareLinkCodePrimaryForReferralCode:true}})];case 2:i.sent();N(false);return[4,Promise.all([f(),S()])];case 3:i.sent();k();return[3,5];case 4:t=i.sent();a=(e=t===null||t===void 0?void 0:t.extensions)===null||e===void 0?void 0:e.code;console.log(a,"errorCode from addSharelInkCodeMutation");P((n=te(a))!==null&&n!==void 0?n:{code:null,title:"Error",description:(t===null||t===void 0?void 0:t.message)||"Failed to save custom link. Please try again."});return[3,5];case 5:return[2]}}))}))}function le(){N(false);q("");P(null);K(false)}console.log($,"validation error state");return{copyTextViewProps:__assign(__assign({},e),{onClick:ae,open:A,copyString:x}),customizeUrl:e.customizeUrl,customizeLinkLabel:e.customizeLinkLabel,saveLabelText:e.saveLabelText,cancelLabelText:e.cancelLabelText,isEditing:z,editValue:V,domainPrefix:R,editsRemaining:ee,maxEdits:MAX_EDITS,limitReached:ne,validationError:$,isValidating:F,isSaving:E,characterLimit:CHARACTER_LIMIT,minCharacters:MIN_CHARACTERS,charactersRemaining:CHARACTER_LIMIT-V.length,editLimitText:e.editLimitText,editLimitReachedText:e.editLimitReachedText,supportLinkText:e.supportLinkText,customizeDisabled:Q,customizeDisabledTooltip:e.customizeDisabledTooltip,onCustomizeClick:ie,onEditValueChange:re,onSave:oe,onCancel:le}}export{ShareLinkView as S,useShareLink as u};var templateObject_1,templateObject_2,templateObject_3,templateObject_4,templateObject_5,templateObject_6;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __makeTemplateObject=this&&this.__makeTemplateObject||function(e,n){if(Object.defineProperty){Object.defineProperty(e,"raw",{value:n})}else{e.raw=n}return e};var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var n,t=1,i=arguments.length;t<i;t++){n=arguments[t];for(var a in n)if(Object.prototype.hasOwnProperty.call(n,a))e[a]=n[a]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,n,t,i){function a(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,r){function o(e){try{s(i.next(e))}catch(e){r(e)}}function l(e){try{s(i["throw"](e))}catch(e){r(e)}}function s(e){e.done?t(e.value):a(e.value).then(o,l)}s((i=i.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,a,r,o;return o={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(e){return function(n){return s([e,n])}}function s(o){if(i)throw new TypeError("Generator is already executing.");while(t)try{if(i=1,a&&(r=o[0]&2?a["return"]:o[0]?a["throw"]||((r=a["return"])&&r.call(a),0):a.next)&&!(r=r.call(a,o[1])).done)return r;if(a=0,r)o=[o[0]&2,r.value];switch(o[0]){case 0:case 1:r=o;break;case 4:t.label++;return{value:o[1],done:false};case 5:t.label++;a=o[1];o=[0];continue;case 7:o=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(o[0]===6||o[0]===2)){t=0;continue}if(o[0]===3&&(!r||o[1]>r[0]&&o[1]<r[3])){t.label=o[1];break}if(o[0]===6&&t.label<r[1]){t.label=r[1];r=o;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(o);break}if(r[2])t.ops.pop();t.trys.pop();continue}o=n.call(e,t)}catch(e){o=[6,e];a=0}finally{i=r=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}};import{h}from"./index-d9876cd5.js";import{i as intl}from"./global-e1c1ff72.js";import{i as useState,k as useRef}from"./dom-context-hooks.module-8411297a.js";import{d as dist,H,J,B,F as Fn,w as wn,$ as $e,X as Xe,h as Qe}from"./index.module-60e4da3a.js";import{c as createStyleSheet}from"./JSS-8c381d8b.js";import{R as REFERRAL_CODES_NAMESPACE,S as SET_CODE_COPIED}from"./useReferralCodes-cff9a9dc.js";import{C as CopyTextView}from"./copy-text-view-c508f2e1.js";var vanillaStyle="\n :host {\n display: block;\n width: 100%;\n }\n";function ShareLinkView(e){var n=e.copyTextViewProps,t=e.customizeUrl,i=e.customizeLinkLabel,a=e.saveLabelText,r=e.cancelLabelText,o=e.isEditing,l=e.editValue,s=e.domainPrefix,d=e.editsRemaining,c=e.maxEdits,u=e.limitReached,v=e.validationError,p=e.isValidating,m=e.isSaving,f=e.characterLimit,C=e.minCharacters,g=e.charactersRemaining,_=e.editLimitText,E=e.editLimitReachedText,L=e.supportLinkText,k=e.customizeDisabled,b=e.customizeDisabledTooltip,T=e.onCustomizeClick,y=e.onEditValueChange,I=e.onSave,S=e.onCancel;var x={Container:{display:"flex",flexDirection:"column",gap:"var(--sl-spacing-xx-small)",width:"100%"},CustomizeLinkText:{margin:"0",fontSize:"var(--sl-font-size-small)",fontWeight:"600",cursor:"pointer",color:"var(--sl-color-neutral-900)",textAlign:"left",padding:"var(--sl-spacing-small)","&:hover":{textDecoration:"underline"}},CustomizeLinkDisabled:{margin:"0",fontSize:"var(--sl-font-size-small)",fontWeight:"600",color:"var(--sl-color-neutral-400)",cursor:"default",textAlign:"left",padding:"var(--sl-spacing-small)"},EditContainer:{display:"flex",flexDirection:"column",gap:"var(--sl-spacing-x-small)",width:"100%"},EditInputWrapper:{display:"flex",alignItems:"center",width:"100%",border:"var(--sqm-border-thickness, 1px) solid var(--sqm-input-border-color, #d1d5db)",borderRadius:"var(--sqm-border-radius-normal, 4px)",background:"var(--sqm-input-background, #fff)",overflow:"hidden","&:focus-within":{borderColor:"#999999",boxShadow:"0 0 0 var(--sl-focus-ring-width) var(--sl-input-focus-ring-color)"}},DomainPrefix:{padding:"0 0 0 var(--sl-spacing-medium)",fontSize:"var(--sl-font-size-medium)",color:"var(--sl-color-neutral-500)",whiteSpace:"nowrap",userSelect:"none",lineHeight:"var(--sl-input-height-medium)"},EditInput:{flex:"1",border:"none",outline:"none",padding:"0 var(--sl-spacing-medium) 0 0",fontSize:"var(--sl-font-size-medium)",fontFamily:"var(--sl-font-sans)",color:"var(--sl-input-color)",background:"transparent",lineHeight:"var(--sl-input-height-medium)",minWidth:"0"},EditLabel:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sl-color-neutral-500)"},HelperText:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sl-color-neutral-500)"},ErrorText:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sqm-danger-color-text, #dc2626)"},ActionRow:{display:"flex",gap:"var(--sl-spacing-medium)",alignItems:"center"},LimitReachedContainer:{display:"flex",alignItems:"center",gap:"var(--sl-spacing-x-small)"}};var R=createStyleSheet(x);var D=R.toString();var w=(v===null||v===void 0?void 0:v.code)==="EXISTING_CODE_CONFLICT"?"info":"warning";var A=g<=14;console.log(t,u,k,v,"customize URL state");if(o){return h("div",{class:R.classes.Container},h("style",{type:"text/css"},D,vanillaStyle),h("p",{class:R.classes.EditLabel},"Enter your link"),h("div",{class:R.classes.EditInputWrapper},h("span",{class:R.classes.DomainPrefix},s),h("input",{class:R.classes.EditInput,type:"text",value:l,onInput:function(e){return y(e.target.value)},onKeyDown:function(e){if(e.key==="/"||e.key==="@")e.preventDefault()},disabled:m,maxLength:f})),h("p",{class:R.classes.HelperText},_,A&&" Characters remaining: "+g),v&&h("sqm-form-message",{type:w,style:{paddingBottom:"var(--sl-spacing-xx-small)"}},h("p",{part:"alert-title"},v.title),v.description),p&&h("p",{class:R.classes.HelperText},"Validating..."),h("div",{class:R.classes.ActionRow},h("sl-button",{type:"primary",onClick:I,disabled:m||p||!!v||!l||l.length<C},m?"Saving...":a),h("sl-button",{type:"secondary",onClick:S,disabled:m},r)))}return h("div",{class:R.classes.Container},h("style",{type:"text/css"},D,vanillaStyle),h(CopyTextView,Object.assign({},n)),t&&(k?h("sl-tooltip",{content:b,placement:"top",style:{display:"inline-block",width:"fit-content"}},h("p",{class:R.classes.CustomizeLinkDisabled},i)):h("div",{class:R.classes.LimitReachedContainer},h("p",{class:u?R.classes.CustomizeLinkDisabled:R.classes.CustomizeLinkText,onClick:u?undefined:T},i),t&&u&&h("p",{class:R.classes.HelperText},intl.formatMessage({id:"editLimitReached",defaultMessage:E},{supportLink:h("a",{target:"_blank",href:"https://help.impact.com/other/readme/get-help-and-support"},L)})))))}var MAX_EDITS=5;var CHARACTER_LIMIT=15;var MIN_CHARACTERS=3;var MessageLinkQuery=dist.gql(templateObject_1||(templateObject_1=__makeTemplateObject(["\n query ($programId: ID) {\n user: viewer {\n ... on User {\n shareLink(programId: $programId)\n }\n }\n }\n"],["\n query ($programId: ID) {\n user: viewer {\n ... on User {\n shareLink(programId: $programId)\n }\n }\n }\n"])));var WIDGET_ENGAGEMENT_EVENT=dist.gql(templateObject_2||(templateObject_2=__makeTemplateObject(["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"],["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"])));var ADD_SHARE_LINK_CODE=dist.gql(templateObject_3||(templateObject_3=__makeTemplateObject(["\n mutation ($addShareLinkCodeInput: AddShareLinkCodeInput!) {\n addShareLinkCode(addShareLinkCodeInput: $addShareLinkCodeInput) {\n linkCode {\n linkCode\n shortUrl\n referralCode {\n code\n }\n }\n }\n }\n"],["\n mutation ($addShareLinkCodeInput: AddShareLinkCodeInput!) {\n addShareLinkCode(addShareLinkCodeInput: $addShareLinkCodeInput) {\n linkCode {\n linkCode\n shortUrl\n referralCode {\n code\n }\n }\n }\n }\n"])));var VALIDATE_LINK_CODE=dist.gql(templateObject_4||(templateObject_4=__makeTemplateObject(["\n query validateLinkCode($linkCode: String!) {\n validateLinkCode(linkCode: $linkCode) {\n valid\n invalidReason\n }\n }\n"],["\n query validateLinkCode($linkCode: String!) {\n validateLinkCode(linkCode: $linkCode) {\n valid\n invalidReason\n }\n }\n"])));var GET_LINK_DOMAIN=dist.gql(templateObject_5||(templateObject_5=__makeTemplateObject(["\n query getLinkDomain {\n tenantSettings {\n primaryLinkDomain {\n host\n }\n }\n }\n"],["\n query getLinkDomain {\n tenantSettings {\n primaryLinkDomain {\n host\n }\n }\n }\n"])));var SHARE_LINK_EDIT_COUNT=dist.gql(templateObject_6||(templateObject_6=__makeTemplateObject(["\n query shareLinkEditCount {\n viewer {\n ... on User {\n shareLinkCodes {\n totalCount\n data {\n isVanity\n }\n }\n }\n }\n }\n"],["\n query shareLinkEditCount {\n viewer {\n ... on User {\n shareLinkCodes {\n totalCount\n data {\n isVanity\n }\n }\n }\n }\n }\n"])));function parseShareUrl(e){try{var n=new URL(e);return{url:n.origin+n.pathname,domain:n.origin+"/",path:n.pathname.slice(1)}}catch(n){return{url:e,domain:e,path:""}}}function useShareLink(e){var n,t,i,a,r,o,l;var s=e.programId,d=s===void 0?H():s;var c=J();var u=B();var v=Fn(REFERRAL_CODES_NAMESPACE);var p=wn(MessageLinkQuery,{programId:d},!(c===null||c===void 0?void 0:c.jwt)||!!e.linkOverride||(v===null||v===void 0?void 0:v.shareLink)!==undefined),m=p.data,h=p.refetch;var f=$e(WIDGET_ENGAGEMENT_EVENT)[0];var C=$e(SET_CODE_COPIED)[0];var g=$e(ADD_SHARE_LINK_CODE),_=g[0],E=g[1].loading;var L=Xe(VALIDATE_LINK_CODE)[0];var k=Qe().refresh;var b=wn(GET_LINK_DOMAIN,{},!(c===null||c===void 0?void 0:c.jwt)||!e.customizeUrl).data;var T=wn(SHARE_LINK_EDIT_COUNT,{},!(c===null||c===void 0?void 0:c.jwt)||!e.customizeUrl),y=T.data,I=T.refetch;var S=parseShareUrl((t=(v===null||v===void 0?void 0:v.shareLink)||((n=m===null||m===void 0?void 0:m.user)===null||n===void 0?void 0:n.shareLink))!==null&&t!==void 0?t:"..."),x=S.url,R=S.domain,D=S.path;var w=useState(false),A=w[0],O=w[1];var j=useState(false),z=j[0],N=j[1];var M=useState(""),V=M[0],U=M[1];var q=useState(null),$=q[0],P=q[1];var G=useState(false),F=G[0],K=G[1];var W=useRef(undefined);var X=((i=b===null||b===void 0?void 0:b.tenantSettings)===null||i===void 0?void 0:i.primaryLinkDomain)!=null;var Q=!X;var Y=(l=(o=(r=(a=y===null||y===void 0?void 0:y.viewer)===null||a===void 0?void 0:a.shareLinkCodes)===null||r===void 0?void 0:r.data)===null||o===void 0?void 0:o.filter((function(e){return e.isVanity})).length)!==null&&l!==void 0?l:0;var Z=Y;var ee=Math.max(0,MAX_EDITS-Z);var ne=ee<=0;function te(n){if(!n)return null;var t={EXISTING_CODE_CONFLICT:{code:"EXISTING_CODE_CONFLICT",title:e.existingCodeConflictErrorTitle,description:e.existingCodeConflictErrorDescription},INVALID_CHARACTER:{code:"INVALID_CHARACTER",title:e.invalidCharactersErrorTitle,description:e.invalidCharactersErrorDescription},BLOCKED_WORD:{code:"BLOCKED_WORD",title:e.profanityErrorTitle,description:e.profanityErrorDescription}};return t[n]}function ie(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){switch(n.label){case 0:if(!v)return[3,2];return[4,C({referralCode:v.referralCode})];case 1:n.sent();v.refresh();n.label=2;case 2:navigator.clipboard.writeText(x);O(true);setTimeout((function(){return O(false)}),e.tooltiplifespan);f({eventMeta:{programId:d,id:c===null||c===void 0?void 0:c.id,accountId:c===null||c===void 0?void 0:c.accountId,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:u,shareMedium:"DIRECT"}}});return[2]}}))}))}function ae(){if(ne||Q)return;N(true);U(Z===0?"":D);P(null)}function re(e){var n=this;var t=e.slice(0,CHARACTER_LIMIT);U(t);P(null);if(W.current)clearTimeout(W.current);if(!t||t.length<MIN_CHARACTERS){K(false);return}K(true);W.current=setTimeout((function(){return __awaiter(n,void 0,void 0,(function(){var e,n,i,a,r;return __generator(this,(function(o){switch(o.label){case 0:o.trys.push([0,2,,3]);return[4,L({linkCode:t})];case 1:i=o.sent();if(!((e=i===null||i===void 0?void 0:i.validateLinkCode)===null||e===void 0?void 0:e.valid)){a=(n=i===null||i===void 0?void 0:i.validateLinkCode)===null||n===void 0?void 0:n.invalidReason;console.log(a,"validation error reason from validateLinkCode query");P(te(a))}return[3,3];case 2:r=o.sent();return[3,3];case 3:K(false);return[2]}}))}))}),2e3)}function oe(){return __awaiter(this,void 0,void 0,(function(){var e,n,t,i;return __generator(this,(function(a){switch(a.label){case 0:if(!V||V.length<MIN_CHARACTERS||$||F)return[2];a.label=1;case 1:a.trys.push([1,4,,5]);return[4,_({addShareLinkCodeInput:{userId:c===null||c===void 0?void 0:c.id,accountId:c===null||c===void 0?void 0:c.accountId,programId:d,linkCode:V,makeShareLinkCodePrimaryForReferralCode:true}})];case 2:a.sent();N(false);return[4,Promise.all([h(),I()])];case 3:a.sent();k();return[3,5];case 4:t=a.sent();i=(e=t===null||t===void 0?void 0:t.extensions)===null||e===void 0?void 0:e.code;console.log(i,"errorCode from addSharelInkCodeMutation");P((n=te(i))!==null&&n!==void 0?n:{code:null,title:"Error",description:(t===null||t===void 0?void 0:t.message)||"Failed to save custom link. Please try again."});return[3,5];case 5:return[2]}}))}))}function le(){N(false);U("");P(null);K(false)}console.log($,"validation error state");return{copyTextViewProps:__assign(__assign({},e),{onClick:ie,open:A,copyString:x}),customizeUrl:e.customizeUrl,customizeLinkLabel:e.customizeLinkLabel,saveLabelText:e.saveLabelText,cancelLabelText:e.cancelLabelText,isEditing:z,editValue:V,domainPrefix:R,editsRemaining:ee,maxEdits:MAX_EDITS,limitReached:ne,validationError:$,isValidating:F,isSaving:E,characterLimit:CHARACTER_LIMIT,minCharacters:MIN_CHARACTERS,charactersRemaining:CHARACTER_LIMIT-V.length,editLimitText:e.editLimitText,editLimitReachedText:e.editLimitReachedText,supportLinkText:e.supportLinkText,customizeDisabled:Q,customizeDisabledTooltip:e.customizeDisabledTooltip,onCustomizeClick:ae,onEditValueChange:re,onSave:oe,onCancel:le}}export{ShareLinkView as S,useShareLink as u};var templateObject_1,templateObject_2,templateObject_3,templateObject_4,templateObject_5,templateObject_6;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __makeTemplateObject=this&&this.__makeTemplateObject||function(e,n){if(Object.defineProperty){Object.defineProperty(e,"raw",{value:n})}else{e.raw=n}return e};var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var n,t=1,a=arguments.length;t<a;t++){n=arguments[t];for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i))e[i]=n[i]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,n,t,a){function i(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,r){function o(e){try{s(a.next(e))}catch(e){r(e)}}function l(e){try{s(a["throw"](e))}catch(e){r(e)}}function s(e){e.done?t(e.value):i(e.value).then(o,l)}s((a=a.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},a,i,r,o;return o={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(e){return function(n){return s([e,n])}}function s(o){if(a)throw new TypeError("Generator is already executing.");while(t)try{if(a=1,i&&(r=o[0]&2?i["return"]:o[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;if(i=0,r)o=[o[0]&2,r.value];switch(o[0]){case 0:case 1:r=o;break;case 4:t.label++;return{value:o[1],done:false};case 5:t.label++;i=o[1];o=[0];continue;case 7:o=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(o[0]===6||o[0]===2)){t=0;continue}if(o[0]===3&&(!r||o[1]>r[0]&&o[1]<r[3])){t.label=o[1];break}if(o[0]===6&&t.label<r[1]){t.label=r[1];r=o;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(o);break}if(r[2])t.ops.pop();t.trys.pop();continue}o=n.call(e,t)}catch(e){o=[6,e];i=0}finally{a=r=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}};import{h}from"./index-d9876cd5.js";import{i as intl}from"./global-e1c1ff72.js";import{i as useState,k as useRef}from"./dom-context-hooks.module-8411297a.js";import{d as dist,H,J,B,F as Fn,w as wn,$ as $e,X as Xe,h as Qe}from"./index.module-60e4da3a.js";import{c as createStyleSheet}from"./JSS-8c381d8b.js";import{R as REFERRAL_CODES_NAMESPACE,S as SET_CODE_COPIED}from"./useReferralCodes-cff9a9dc.js";import{C as CopyTextView}from"./copy-text-view-c508f2e1.js";var vanillaStyle="\n :host {\n display: block;\n width: 100%;\n }\n";function ShareLinkView(e){var n=e.copyTextViewProps,t=e.customizeUrl,a=e.customizeLinkLabel,i=e.saveLabelText,r=e.cancelLabelText,o=e.isEditing,l=e.editValue,s=e.domainPrefix,d=e.editsRemaining,c=e.maxEdits,u=e.limitReached,v=e.validationError,p=e.isValidating,m=e.isSaving,f=e.characterLimit,g=e.minCharacters,C=e.charactersRemaining,_=e.editLimitText,E=e.editLimitReachedText,L=e.supportLinkText,k=e.customizeDisabled,b=e.customizeDisabledTooltip,T=e.onCustomizeClick,y=e.onEditValueChange,S=e.onSave,I=e.onCancel;var x={Container:{display:"flex",flexDirection:"column",gap:"var(--sl-spacing-xx-small)",width:"100%"},CustomizeLinkText:{margin:"0",fontSize:"var(--sl-font-size-small)",fontWeight:"600",cursor:"pointer",color:"var(--sl-color-neutral-900)",textAlign:"left",padding:"var(--sl-spacing-small)","&:hover":{textDecoration:"underline"}},CustomizeLinkDisabled:{margin:"0",fontSize:"var(--sl-font-size-small)",fontWeight:"600",color:"var(--sl-color-neutral-400)",cursor:"default",textAlign:"left",padding:"var(--sl-spacing-small)"},EditContainer:{display:"flex",flexDirection:"column",gap:"var(--sl-spacing-x-small)",width:"100%"},EditInputWrapper:{display:"flex",alignItems:"center",width:"100%",border:"var(--sqm-border-thickness, 1px) solid var(--sqm-input-border-color, #d1d5db)",borderRadius:"var(--sqm-border-radius-normal, 4px)",background:"var(--sqm-input-background, #fff)",overflow:"hidden","&:focus-within":{borderColor:"#999999",boxShadow:"0 0 0 var(--sl-focus-ring-width) var(--sl-input-focus-ring-color)"}},DomainPrefix:{padding:"0 0 0 var(--sl-spacing-medium)",fontSize:"var(--sl-font-size-medium)",color:"var(--sl-color-neutral-500)",whiteSpace:"nowrap",userSelect:"none",lineHeight:"var(--sl-input-height-medium)"},EditInput:{flex:"1",border:"none",outline:"none",padding:"0 var(--sl-spacing-medium) 0 0",fontSize:"var(--sl-font-size-medium)",fontFamily:"var(--sl-font-sans)",color:"var(--sl-input-color)",background:"transparent",lineHeight:"var(--sl-input-height-medium)",minWidth:"0"},EditLabel:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sl-color-neutral-500)"},HelperText:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sl-color-neutral-500)"},ErrorText:{margin:"0",fontSize:"var(--sl-font-size-small)",color:"var(--sqm-danger-color-text, #dc2626)"},ActionRow:{display:"flex",gap:"var(--sl-spacing-medium)",alignItems:"center"},SaveButton:{cursor:"pointer",fontFamily:"var(--sl-font-sans)",fontSize:"var(--sl-font-size-small)",fontWeight:"600",padding:"var(--sl-spacing-x-small) var(--sl-spacing-medium)",borderRadius:"var(--sqm-border-radius-normal, 4px)",border:"1px solid var(--sl-color-neutral-900)",background:"var(--sl-color-neutral-900)",color:"#fff","&:disabled":{opacity:"0.5",cursor:"default"}},CancelButton:{margin:"0",fontSize:"var(--sl-font-size-small)",fontWeight:"600",cursor:"pointer",background:"none",border:"none",padding:"0",fontFamily:"var(--sl-font-sans)",color:"var(--sl-color-neutral-500)"},LimitReachedContainer:{display:"flex",alignItems:"center",gap:"var(--sl-spacing-x-small)"}};var R=createStyleSheet(x);var D=R.toString();var w=(v===null||v===void 0?void 0:v.code)==="EXISTING_CODE_CONFLICT"?"info":"warning";var A=C<=14;console.log(t,u,k,v,"customize URL state");if(o){return h("div",{class:R.classes.Container},h("style",{type:"text/css"},D,vanillaStyle),h("p",{class:R.classes.EditLabel},"Enter your link"),h("div",{class:R.classes.EditInputWrapper},h("span",{class:R.classes.DomainPrefix},s),h("sl-input",{type:"text",value:l,onInput:function(e){return y(e.target.value)},onKeyDown:function(e){if(e.key==="/"||e.key==="@")e.preventDefault()},disabled:m,maxLength:f})),h("p",{class:R.classes.HelperText},_,A&&" Characters remaining: "+C),v&&h("sqm-form-message",{type:w,style:{paddingBottom:"var(--sl-spacing-xx-small)"}},h("p",{part:"alert-title"},v.title),v.description),p&&h("p",{class:R.classes.HelperText},"Validating..."),h("div",{class:R.classes.ActionRow},h("sl-button",{type:"primary",onClick:S,disabled:m||p||!!v||!l||l.length<g},m?"Saving...":i),h("sl-button",{type:"secondary",class:R.classes.CancelButton,onClick:I,disabled:m},r)))}return h("div",{class:R.classes.Container},h("style",{type:"text/css"},D,vanillaStyle),h(CopyTextView,Object.assign({},n)),t&&(k?h("sl-tooltip",{content:b,placement:"top",style:{display:"inline-block",width:"fit-content"}},h("p",{class:R.classes.CustomizeLinkDisabled},a)):h("div",{class:R.classes.LimitReachedContainer},h("p",{class:u?R.classes.CustomizeLinkDisabled:R.classes.CustomizeLinkText,onClick:u?undefined:T},a),t&&u&&h("p",{class:R.classes.HelperText},intl.formatMessage({id:"editLimitReached",defaultMessage:E},{supportLink:h("a",{target:"_blank",href:"https://help.impact.com/other/readme/get-help-and-support"},L)})))))}var MAX_EDITS=5;var CHARACTER_LIMIT=15;var MIN_CHARACTERS=3;var MessageLinkQuery=dist.gql(templateObject_1||(templateObject_1=__makeTemplateObject(["\n query ($programId: ID) {\n user: viewer {\n ... on User {\n shareLink(programId: $programId)\n }\n }\n }\n"],["\n query ($programId: ID) {\n user: viewer {\n ... on User {\n shareLink(programId: $programId)\n }\n }\n }\n"])));var WIDGET_ENGAGEMENT_EVENT=dist.gql(templateObject_2||(templateObject_2=__makeTemplateObject(["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"],["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"])));var ADD_SHARE_LINK_CODE=dist.gql(templateObject_3||(templateObject_3=__makeTemplateObject(["\n mutation ($addShareLinkCodeInput: AddShareLinkCodeInput!) {\n addShareLinkCode(addShareLinkCodeInput: $addShareLinkCodeInput) {\n linkCode {\n linkCode\n shortUrl\n referralCode {\n code\n }\n }\n }\n }\n"],["\n mutation ($addShareLinkCodeInput: AddShareLinkCodeInput!) {\n addShareLinkCode(addShareLinkCodeInput: $addShareLinkCodeInput) {\n linkCode {\n linkCode\n shortUrl\n referralCode {\n code\n }\n }\n }\n }\n"])));var VALIDATE_LINK_CODE=dist.gql(templateObject_4||(templateObject_4=__makeTemplateObject(["\n query validateLinkCode($linkCode: String!) {\n validateLinkCode(linkCode: $linkCode) {\n valid\n invalidReason\n }\n }\n"],["\n query validateLinkCode($linkCode: String!) {\n validateLinkCode(linkCode: $linkCode) {\n valid\n invalidReason\n }\n }\n"])));var GET_LINK_DOMAIN=dist.gql(templateObject_5||(templateObject_5=__makeTemplateObject(["\n query getLinkDomain {\n tenantSettings {\n primaryLinkDomain {\n host\n }\n }\n }\n"],["\n query getLinkDomain {\n tenantSettings {\n primaryLinkDomain {\n host\n }\n }\n }\n"])));var SHARE_LINK_EDIT_COUNT=dist.gql(templateObject_6||(templateObject_6=__makeTemplateObject(["\n query shareLinkEditCount {\n viewer {\n ... on User {\n shareLinkCodes {\n totalCount\n data {\n isVanity\n }\n }\n }\n }\n }\n"],["\n query shareLinkEditCount {\n viewer {\n ... on User {\n shareLinkCodes {\n totalCount\n data {\n isVanity\n }\n }\n }\n }\n }\n"])));function parseShareUrl(e){try{var n=new URL(e);return{url:n.origin+n.pathname,domain:n.origin+"/",path:n.pathname.slice(1)}}catch(n){return{url:e,domain:e,path:""}}}function useShareLink(e){var n,t,a,i,r,o,l;var s=e.programId,d=s===void 0?H():s;var c=J();var u=B();var v=Fn(REFERRAL_CODES_NAMESPACE);var p=wn(MessageLinkQuery,{programId:d},!(c===null||c===void 0?void 0:c.jwt)||!!e.linkOverride||(v===null||v===void 0?void 0:v.shareLink)!==undefined),m=p.data,f=p.refetch;var h=$e(WIDGET_ENGAGEMENT_EVENT)[0];var g=$e(SET_CODE_COPIED)[0];var C=$e(ADD_SHARE_LINK_CODE),_=C[0],E=C[1].loading;var L=Xe(VALIDATE_LINK_CODE)[0];var k=Qe().refresh;var b=wn(GET_LINK_DOMAIN,{},!(c===null||c===void 0?void 0:c.jwt)||!e.customizeUrl).data;var T=wn(SHARE_LINK_EDIT_COUNT,{},!(c===null||c===void 0?void 0:c.jwt)||!e.customizeUrl),y=T.data,S=T.refetch;var I=parseShareUrl((t=(v===null||v===void 0?void 0:v.shareLink)||((n=m===null||m===void 0?void 0:m.user)===null||n===void 0?void 0:n.shareLink))!==null&&t!==void 0?t:"..."),x=I.url,R=I.domain,D=I.path;var w=useState(false),A=w[0],O=w[1];var j=useState(false),z=j[0],N=j[1];var M=useState(""),V=M[0],q=M[1];var U=useState(null),$=U[0],P=U[1];var G=useState(false),F=G[0],K=G[1];var W=useRef(undefined);var X=((a=b===null||b===void 0?void 0:b.tenantSettings)===null||a===void 0?void 0:a.primaryLinkDomain)!=null;var Q=!X;var Y=(l=(o=(r=(i=y===null||y===void 0?void 0:y.viewer)===null||i===void 0?void 0:i.shareLinkCodes)===null||r===void 0?void 0:r.data)===null||o===void 0?void 0:o.filter((function(e){return e.isVanity})).length)!==null&&l!==void 0?l:0;var Z=Y;var ee=Math.max(0,MAX_EDITS-Z);var ne=ee<=0;function te(n){if(!n)return null;var t={EXISTING_CODE_CONFLICT:{code:"EXISTING_CODE_CONFLICT",title:e.existingCodeConflictErrorTitle,description:e.existingCodeConflictErrorDescription},INVALID_CHARACTER:{code:"INVALID_CHARACTER",title:e.invalidCharactersErrorTitle,description:e.invalidCharactersErrorDescription},BLOCKED_WORD:{code:"BLOCKED_WORD",title:e.profanityErrorTitle,description:e.profanityErrorDescription}};return t[n]}function ae(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){switch(n.label){case 0:if(!v)return[3,2];return[4,g({referralCode:v.referralCode})];case 1:n.sent();v.refresh();n.label=2;case 2:navigator.clipboard.writeText(x);O(true);setTimeout((function(){return O(false)}),e.tooltiplifespan);h({eventMeta:{programId:d,id:c===null||c===void 0?void 0:c.id,accountId:c===null||c===void 0?void 0:c.accountId,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:u,shareMedium:"DIRECT"}}});return[2]}}))}))}function ie(){if(ne||Q)return;N(true);q(Z===0?"":D);P(null)}function re(e){var n=this;var t=e.slice(0,CHARACTER_LIMIT);q(t);P(null);if(W.current)clearTimeout(W.current);if(!t||t.length<MIN_CHARACTERS){K(false);return}K(true);W.current=setTimeout((function(){return __awaiter(n,void 0,void 0,(function(){var e,n,a,i,r;return __generator(this,(function(o){switch(o.label){case 0:o.trys.push([0,2,,3]);return[4,L({linkCode:t})];case 1:a=o.sent();if(!((e=a===null||a===void 0?void 0:a.validateLinkCode)===null||e===void 0?void 0:e.valid)){i=(n=a===null||a===void 0?void 0:a.validateLinkCode)===null||n===void 0?void 0:n.invalidReason;console.log(i,"validation error reason from validateLinkCode query");P(te(i))}return[3,3];case 2:r=o.sent();return[3,3];case 3:K(false);return[2]}}))}))}),2e3)}function oe(){return __awaiter(this,void 0,void 0,(function(){var e,n,t,a;return __generator(this,(function(i){switch(i.label){case 0:if(!V||V.length<MIN_CHARACTERS||$||F)return[2];i.label=1;case 1:i.trys.push([1,4,,5]);return[4,_({addShareLinkCodeInput:{userId:c===null||c===void 0?void 0:c.id,accountId:c===null||c===void 0?void 0:c.accountId,programId:d,linkCode:V,makeShareLinkCodePrimaryForReferralCode:true}})];case 2:i.sent();N(false);return[4,Promise.all([f(),S()])];case 3:i.sent();k();return[3,5];case 4:t=i.sent();a=(e=t===null||t===void 0?void 0:t.extensions)===null||e===void 0?void 0:e.code;console.log(a,"errorCode from addSharelInkCodeMutation");P((n=te(a))!==null&&n!==void 0?n:{code:null,title:"Error",description:(t===null||t===void 0?void 0:t.message)||"Failed to save custom link. Please try again."});return[3,5];case 5:return[2]}}))}))}function le(){N(false);q("");P(null);K(false)}console.log($,"validation error state");return{copyTextViewProps:__assign(__assign({},e),{onClick:ae,open:A,copyString:x}),customizeUrl:e.customizeUrl,customizeLinkLabel:e.customizeLinkLabel,saveLabelText:e.saveLabelText,cancelLabelText:e.cancelLabelText,isEditing:z,editValue:V,domainPrefix:R,editsRemaining:ee,maxEdits:MAX_EDITS,limitReached:ne,validationError:$,isValidating:F,isSaving:E,characterLimit:CHARACTER_LIMIT,minCharacters:MIN_CHARACTERS,charactersRemaining:CHARACTER_LIMIT-V.length,editLimitText:e.editLimitText,editLimitReachedText:e.editLimitReachedText,supportLinkText:e.supportLinkText,customizeDisabled:Q,customizeDisabledTooltip:e.customizeDisabledTooltip,onCustomizeClick:ie,onEditValueChange:re,onSave:oe,onCancel:le}}export{ShareLinkView as S,useShareLink as u};var templateObject_1,templateObject_2,templateObject_3,templateObject_4,templateObject_5,templateObject_6;
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { r as registerInstance, h as h$1 } from './index-d9876cd5.js';
|
|
2
|
+
import './global-e1c1ff72.js';
|
|
3
|
+
import { o as h, i as useState } from './dom-context-hooks.module-8411297a.js';
|
|
4
|
+
import { i as isDemo } from './index.module-60e4da3a.js';
|
|
5
|
+
import './GoogleFonts-e3a7f82a.js';
|
|
6
|
+
import './jss-preset-default.esm-c36417f8.js';
|
|
7
|
+
import './JSS-8c381d8b.js';
|
|
8
|
+
import './mixins-acc245cc.js';
|
|
9
|
+
import { g as getProps } from './utils-61821fb1.js';
|
|
10
|
+
import { c as cjs } from './cjs-e829b75b.js';
|
|
11
|
+
import './useReferralCodes-cff9a9dc.js';
|
|
12
|
+
import './copy-text-view-c508f2e1.js';
|
|
13
|
+
import { u as useShareLink, S as ShareLinkView } from './useShareLink-a3329e33.js';
|
|
14
|
+
|
|
15
|
+
const ShareLink = class {
|
|
16
|
+
constructor(hostRef) {
|
|
17
|
+
registerInstance(this, hostRef);
|
|
18
|
+
/**
|
|
19
|
+
* Shown inside a tooltip after someone has successfully copied the link to their clipboard
|
|
20
|
+
*
|
|
21
|
+
* @uiName Tooltip text
|
|
22
|
+
*/
|
|
23
|
+
this.tooltiptext = "Copied to Clipboard";
|
|
24
|
+
/**
|
|
25
|
+
* The number of milliseconds that the tooltip appears for
|
|
26
|
+
*
|
|
27
|
+
* @uiName Tooltip lifespan
|
|
28
|
+
*/
|
|
29
|
+
this.tooltiplifespan = 1000;
|
|
30
|
+
/**
|
|
31
|
+
* Change the text alignment
|
|
32
|
+
*
|
|
33
|
+
* @uiName Share link alignment
|
|
34
|
+
* @uiType string
|
|
35
|
+
* @uiEnum ["left", "center", "right"]
|
|
36
|
+
* @uiEnumNames ["Left", "Center", "Right"]
|
|
37
|
+
* @uiGroup Style
|
|
38
|
+
*/
|
|
39
|
+
this.textAlign = "left";
|
|
40
|
+
/**
|
|
41
|
+
* @uiName Copy button label
|
|
42
|
+
*/
|
|
43
|
+
this.copyButtonLabel = "Copy Link";
|
|
44
|
+
/**
|
|
45
|
+
* The type of the button that is used (primary or secondary).
|
|
46
|
+
* @uiName Button Type
|
|
47
|
+
* @uiType string
|
|
48
|
+
* @uiEnum ["primary", "secondary"]
|
|
49
|
+
* @uiEnumNames ["Primary", "Secondary"]
|
|
50
|
+
* @uiGroup Style
|
|
51
|
+
*/
|
|
52
|
+
this.buttonType = "primary";
|
|
53
|
+
/**
|
|
54
|
+
* Set the copy button style and placement
|
|
55
|
+
*
|
|
56
|
+
* @uiName Button style
|
|
57
|
+
* @uiType string
|
|
58
|
+
* @uiEnum ["icon", "button-outside", "button-below"]
|
|
59
|
+
* @uiEnumNames ["Icon", "Button outside", "Button below"]
|
|
60
|
+
* @uiGroup Style
|
|
61
|
+
*/
|
|
62
|
+
this.buttonStyle = "icon";
|
|
63
|
+
/**
|
|
64
|
+
* Enable users to customize their referral link
|
|
65
|
+
*
|
|
66
|
+
* @uiName Customize URL
|
|
67
|
+
* @uiType boolean
|
|
68
|
+
* @uiGroup Customize Vanity Link
|
|
69
|
+
* @requiredFlavor impact
|
|
70
|
+
*/
|
|
71
|
+
this.customizeUrl = false;
|
|
72
|
+
/**
|
|
73
|
+
* Text shown below the share link input to trigger customization
|
|
74
|
+
*
|
|
75
|
+
* @uiName Customize link label
|
|
76
|
+
* @uiType string
|
|
77
|
+
* @uiGroup Customize Vanity Link
|
|
78
|
+
* @requiredFlavor impact
|
|
79
|
+
*/
|
|
80
|
+
this.customizeLinkLabel = "Customize Link";
|
|
81
|
+
/**
|
|
82
|
+
* Text for the save button in editing mode
|
|
83
|
+
*
|
|
84
|
+
* @uiName Save button label
|
|
85
|
+
* @uiType string
|
|
86
|
+
* @uiGroup Customize Vanity Link
|
|
87
|
+
* @requiredFlavor impact
|
|
88
|
+
*/
|
|
89
|
+
this.saveLabelText = "Save";
|
|
90
|
+
/**
|
|
91
|
+
* Text for the cancel button in editing mode
|
|
92
|
+
*
|
|
93
|
+
* @uiName Cancel button label
|
|
94
|
+
* @uiType string
|
|
95
|
+
* @uiGroup Customize Vanity Link
|
|
96
|
+
* @requiredFlavor impact
|
|
97
|
+
*/
|
|
98
|
+
this.cancelLabelText = "Cancel";
|
|
99
|
+
/**
|
|
100
|
+
* Title text shown when the custom link is already taken
|
|
101
|
+
*
|
|
102
|
+
* @uiName Existing code conflict error title
|
|
103
|
+
* @uiType string
|
|
104
|
+
* @uiGroup Customize Vanity Link
|
|
105
|
+
* @requiredFlavor impact
|
|
106
|
+
*/
|
|
107
|
+
this.existingCodeConflictErrorTitle = "This link is already taken";
|
|
108
|
+
/**
|
|
109
|
+
* Description text shown when the custom link is already taken
|
|
110
|
+
*
|
|
111
|
+
* @uiName Existing code conflict error description
|
|
112
|
+
* @uiType string
|
|
113
|
+
* @uiGroup Customize Vanity Link
|
|
114
|
+
* @requiredFlavor impact
|
|
115
|
+
*/
|
|
116
|
+
this.existingCodeConflictErrorDescription = "Try adding numbers, a dash or underscore to create a unique link.";
|
|
117
|
+
/**
|
|
118
|
+
* Title text shown when the link contains invalid characters
|
|
119
|
+
*
|
|
120
|
+
* @uiName Invalid characters error title
|
|
121
|
+
* @uiType string
|
|
122
|
+
* @uiGroup Customize Vanity Link
|
|
123
|
+
* @requiredFlavor impact
|
|
124
|
+
*/
|
|
125
|
+
this.invalidCharactersErrorTitle = "Please use only letters, numbers, dashes and underscores";
|
|
126
|
+
/**
|
|
127
|
+
* Description text shown when the link contains invalid characters
|
|
128
|
+
*
|
|
129
|
+
* @uiName Invalid characters error description
|
|
130
|
+
* @uiType string
|
|
131
|
+
* @uiGroup Customize Vanity Link
|
|
132
|
+
* @requiredFlavor impact
|
|
133
|
+
*/
|
|
134
|
+
this.invalidCharactersErrorDescription = "Special characters can break the link when sharing.";
|
|
135
|
+
/**
|
|
136
|
+
* Title text shown when the link contains profanity
|
|
137
|
+
*
|
|
138
|
+
* @uiName Profanity error title
|
|
139
|
+
* @uiType string
|
|
140
|
+
* @uiGroup Customize Vanity Link
|
|
141
|
+
* @requiredFlavor impact
|
|
142
|
+
*/
|
|
143
|
+
this.profanityErrorTitle = "Please try a different link";
|
|
144
|
+
/**
|
|
145
|
+
* Description text shown when the link contains profanity
|
|
146
|
+
*
|
|
147
|
+
* @uiName Profanity error description
|
|
148
|
+
* @uiType string
|
|
149
|
+
* @uiGroup Customize Vanity Link
|
|
150
|
+
* @requiredFlavor impact
|
|
151
|
+
*/
|
|
152
|
+
this.profanityErrorDescription = "This link contains a restricted word.";
|
|
153
|
+
/**
|
|
154
|
+
* Text describing the edit limit
|
|
155
|
+
*
|
|
156
|
+
* @uiName Edit limit text
|
|
157
|
+
* @uiType string
|
|
158
|
+
* @uiGroup Customize Vanity Link
|
|
159
|
+
* @requiredFlavor impact
|
|
160
|
+
*/
|
|
161
|
+
this.editLimitText = "You can edit your link up to 5 times.";
|
|
162
|
+
/**
|
|
163
|
+
* Message shown when the edit limit has been reached. Use {supportLink} as a placeholder for the support link.
|
|
164
|
+
*
|
|
165
|
+
* @uiName Edit limit reached text
|
|
166
|
+
* @uiType string
|
|
167
|
+
* @uiGroup Customize Vanity Link
|
|
168
|
+
* @requiredFlavor impact
|
|
169
|
+
*/
|
|
170
|
+
this.editLimitReachedText = "5 edit limit reached. To make more changes, please contact {supportLink}.";
|
|
171
|
+
/**
|
|
172
|
+
* Display text for the support link in the edit limit reached message
|
|
173
|
+
*
|
|
174
|
+
* @uiName Support link text
|
|
175
|
+
* @uiType string
|
|
176
|
+
* @uiGroup Customize Vanity Link
|
|
177
|
+
* @requiredFlavor impact
|
|
178
|
+
*/
|
|
179
|
+
this.supportLinkText = "Support";
|
|
180
|
+
/**
|
|
181
|
+
* Tooltip text shown when link customization is disabled
|
|
182
|
+
*
|
|
183
|
+
* @uiName Customize disabled tooltip
|
|
184
|
+
* @uiType string
|
|
185
|
+
* @uiGroup Customize Vanity Link
|
|
186
|
+
* @requiredFlavor impact
|
|
187
|
+
*/
|
|
188
|
+
this.customizeDisabledTooltip = "Link customization is not available.";
|
|
189
|
+
h(this);
|
|
190
|
+
}
|
|
191
|
+
disconnectedCallback() { }
|
|
192
|
+
render() {
|
|
193
|
+
const thisProps = getProps(this);
|
|
194
|
+
const props = isDemo()
|
|
195
|
+
? useDemoShareLink(thisProps)
|
|
196
|
+
: useShareLink(thisProps);
|
|
197
|
+
return h$1(ShareLinkView, Object.assign({}, props));
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
function useDemoShareLink(props) {
|
|
201
|
+
var _a;
|
|
202
|
+
const [open, setOpen] = useState(false);
|
|
203
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
204
|
+
const [editValue, setEditValue] = useState("");
|
|
205
|
+
const copyString = "https://www.example.com/sharelink/abc";
|
|
206
|
+
const domainPrefix = "https://www.example.com/";
|
|
207
|
+
const baseProps = {
|
|
208
|
+
copyTextViewProps: {
|
|
209
|
+
copyString,
|
|
210
|
+
tooltiptext: props.tooltiptext,
|
|
211
|
+
textAlign: props.textAlign,
|
|
212
|
+
buttonStyle: props.buttonStyle,
|
|
213
|
+
backgroundColor: props.backgroundColor,
|
|
214
|
+
textColor: props.textColor,
|
|
215
|
+
borderRadius: props.borderRadius,
|
|
216
|
+
buttonType: props.buttonType,
|
|
217
|
+
copyButtonLabel: props.copyButtonLabel,
|
|
218
|
+
borderColor: props.borderColor,
|
|
219
|
+
open,
|
|
220
|
+
onClick: () => {
|
|
221
|
+
navigator.clipboard.writeText(copyString);
|
|
222
|
+
setOpen(true);
|
|
223
|
+
setTimeout(() => setOpen(false), props.tooltiplifespan);
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
customizeUrl: props.customizeUrl,
|
|
227
|
+
customizeLinkLabel: props.customizeLinkLabel,
|
|
228
|
+
saveLabelText: props.saveLabelText,
|
|
229
|
+
cancelLabelText: props.cancelLabelText,
|
|
230
|
+
isEditing,
|
|
231
|
+
editValue,
|
|
232
|
+
domainPrefix,
|
|
233
|
+
editsRemaining: 5,
|
|
234
|
+
maxEdits: 5,
|
|
235
|
+
limitReached: false,
|
|
236
|
+
validationError: null,
|
|
237
|
+
isValidating: false,
|
|
238
|
+
isSaving: false,
|
|
239
|
+
characterLimit: 15,
|
|
240
|
+
minCharacters: 3,
|
|
241
|
+
charactersRemaining: 15 - editValue.length,
|
|
242
|
+
editLimitText: props.editLimitText,
|
|
243
|
+
editLimitReachedText: props.editLimitReachedText,
|
|
244
|
+
supportLinkText: props.supportLinkText,
|
|
245
|
+
customizeDisabled: false,
|
|
246
|
+
customizeDisabledTooltip: (_a = props.customizeDisabledTooltip) !== null && _a !== void 0 ? _a : "Link customization is not available.",
|
|
247
|
+
onCustomizeClick: () => {
|
|
248
|
+
setIsEditing(true);
|
|
249
|
+
setEditValue("");
|
|
250
|
+
},
|
|
251
|
+
onEditValueChange: (value) => {
|
|
252
|
+
setEditValue(value);
|
|
253
|
+
},
|
|
254
|
+
onSave: () => {
|
|
255
|
+
setIsEditing(false);
|
|
256
|
+
},
|
|
257
|
+
onCancel: () => {
|
|
258
|
+
setIsEditing(false);
|
|
259
|
+
setEditValue("");
|
|
260
|
+
},
|
|
261
|
+
};
|
|
262
|
+
return cjs(baseProps, props.demoData || {}, {
|
|
263
|
+
arrayMerge: (_, a) => a,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export { ShareLink as sqm_share_link };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
System.register(["./index-6582b378.system.js","./global-41985914.system.js","./dom-context-hooks.module-d6e89c16.system.js","./index.module-c0971372.system.js","./GoogleFonts-eea308bc.system.js","./jss-preset-default.esm-62a04d6d.system.js","./JSS-840a8fea.system.js","./mixins-8c4521b7.system.js","./utils-b405e671.system.js","./cjs-f0ef8d23.system.js","./useReferralCodes-d014208c.system.js","./copy-text-view-7713c6c8.system.js","./useShareLink-454939f5.system.js"],(function(t){"use strict";var e,i,s,n,o,a,r,l,c;return{setters:[function(t){e=t.r;i=t.h},function(){},function(t){s=t.o;n=t.i},function(t){o=t.i},function(){},function(){},function(){},function(){},function(t){a=t.g},function(t){r=t.c},function(){},function(){},function(t){l=t.u;c=t.S}],execute:function(){var u=t("sqm_share_link",function(){function t(t){e(this,t);this.tooltiptext="Copied to Clipboard";this.tooltiplifespan=1e3;this.textAlign="left";this.copyButtonLabel="Copy Link";this.buttonType="primary";this.buttonStyle="icon";this.customizeUrl=false;this.customizeLinkLabel="Customize Link";this.saveLabelText="Save";this.cancelLabelText="Cancel";this.existingCodeConflictErrorTitle="This link is already taken";this.existingCodeConflictErrorDescription="Try adding numbers, a dash or underscore to create a unique link.";this.invalidCharactersErrorTitle="Please use only letters, numbers, dashes and underscores";this.invalidCharactersErrorDescription="Special characters can break the link when sharing.";this.profanityErrorTitle="Please try a different link";this.profanityErrorDescription="This link contains a restricted word.";this.editLimitText="You can edit your link up to 5 times.";this.editLimitReachedText="5 edit limit reached. To make more changes, please contact {supportLink}.";this.supportLinkText="Support";this.customizeDisabledTooltip="Link customization is not available.";s(this)}t.prototype.disconnectedCallback=function(){};t.prototype.render=function(){var t=a(this);var e=o()?d(t):l(t);return i(c,Object.assign({},e))};return t}());function d(t){var e;var i=n(false),s=i[0],o=i[1];var a=n(false),l=a[0],c=a[1];var u=n(""),d=u[0],m=u[1];var f="https://www.example.com/sharelink/abc";var p="https://www.example.com/";var h={copyTextViewProps:{copyString:f,tooltiptext:t.tooltiptext,textAlign:t.textAlign,buttonStyle:t.buttonStyle,backgroundColor:t.backgroundColor,textColor:t.textColor,borderRadius:t.borderRadius,buttonType:t.buttonType,copyButtonLabel:t.copyButtonLabel,borderColor:t.borderColor,open:s,onClick:function(){navigator.clipboard.writeText(f);o(true);setTimeout((function(){return o(false)}),t.tooltiplifespan)}},customizeUrl:t.customizeUrl,customizeLinkLabel:t.customizeLinkLabel,saveLabelText:t.saveLabelText,cancelLabelText:t.cancelLabelText,isEditing:l,editValue:d,domainPrefix:p,editsRemaining:5,maxEdits:5,limitReached:false,validationError:null,isValidating:false,isSaving:false,characterLimit:15,minCharacters:3,charactersRemaining:15-d.length,editLimitText:t.editLimitText,editLimitReachedText:t.editLimitReachedText,supportLinkText:t.supportLinkText,customizeDisabled:false,customizeDisabledTooltip:(e=t.customizeDisabledTooltip)!==null&&e!==void 0?e:"Link customization is not available.",onCustomizeClick:function(){c(true);m("")},onEditValueChange:function(t){m(t)},onSave:function(){c(false)},onCancel:function(){c(false);m("")}};return r(h,t.demoData||{},{arrayMerge:function(t,e){return e}})}}}}));
|