@saasquatch/mint-components 2.5.1-2 → 2.5.1-3
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-pagination_3.cjs.entry.js +11 -12
- package/dist/collection/components/sqm-pagination/sqm-pagination-view.js +7 -7
- package/dist/collection/components/sqm-referral-codes/sqm-referral-codes-view.js +4 -5
- package/dist/esm/sqm-pagination_3.entry.js +11 -12
- package/dist/esm-es5/sqm-pagination_3.entry.js +1 -1
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/p-b1c91d24.system.entry.js +1 -0
- package/dist/mint-components/p-bfb00685.system.js +1 -1
- package/dist/mint-components/p-d1ee0c72.entry.js +13 -0
- package/docs/docs.docx +0 -0
- package/package.json +1 -1
- package/dist/mint-components/p-1d0e6fd8.entry.js +0 -13
- package/dist/mint-components/p-b55e06b8.system.entry.js +0 -1
|
@@ -22,7 +22,7 @@ const style = {
|
|
|
22
22
|
width: "100%",
|
|
23
23
|
},
|
|
24
24
|
SkeletonContainer: {
|
|
25
|
-
width: "
|
|
25
|
+
width: "40px",
|
|
26
26
|
},
|
|
27
27
|
TextContainer: {
|
|
28
28
|
display: "flex",
|
|
@@ -39,13 +39,13 @@ function PaginationView(props) {
|
|
|
39
39
|
return index.h(index.Fragment, null);
|
|
40
40
|
return (index.h("span", { class: sheet.classes.Container, part: "sqm-base" },
|
|
41
41
|
index.h("style", { type: "text/css" }, styleString),
|
|
42
|
+
index.h("sl-button", { exportparts: `base: ${buttonType}button-base`, onClick: onPrev, part: "sqm-pagination-button", circle: true, disabled: currentPage === 1 },
|
|
43
|
+
index.h("sl-icon", { name: "chevron-left", label: "Previous Page" })),
|
|
42
44
|
!loading ? (index.h(index.Fragment, null,
|
|
43
|
-
index.h("
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
index.h("sl-
|
|
47
|
-
index.h("sl-icon", { name: "chevron-right", label: "Previous Page" })))) : (index.h("div", { class: sheet.classes.SkeletonContainer },
|
|
48
|
-
index.h("sl-skeleton", { width: "100px", height: "16px" })))));
|
|
45
|
+
index.h("div", { class: sheet.classes.TextContainer }, text.paginationText))) : (index.h("div", { class: sheet.classes.SkeletonContainer },
|
|
46
|
+
index.h("sl-skeleton", { height: "16px", width: "50%" }))),
|
|
47
|
+
index.h("sl-button", { exportparts: `base: ${buttonType}button-base`, onClick: onNext, part: "sqm-pagination-button", circle: true, disabled: currentPage === totalPages },
|
|
48
|
+
index.h("sl-icon", { name: "chevron-right", label: "Previous Page" }))));
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function usePagination(props) {
|
|
@@ -324,11 +324,11 @@ function ReferralCodesView(props) {
|
|
|
324
324
|
display: "flex",
|
|
325
325
|
flexDirection: "column",
|
|
326
326
|
gap: "var(--sl-spacing-small)",
|
|
327
|
-
width: "
|
|
327
|
+
width: "100%",
|
|
328
328
|
},
|
|
329
329
|
SkeletonOne: {
|
|
330
|
-
height: "
|
|
331
|
-
width: "
|
|
330
|
+
height: "36px",
|
|
331
|
+
width: "100%",
|
|
332
332
|
},
|
|
333
333
|
TitleText: {
|
|
334
334
|
fontSize: "var(--sl-font-size-large)",
|
|
@@ -351,7 +351,6 @@ function ReferralCodesView(props) {
|
|
|
351
351
|
}
|
|
352
352
|
if (states.loading) {
|
|
353
353
|
return (index.h("div", { class: sheet.classes.SkeletonContainer },
|
|
354
|
-
index.h("sl-skeleton", { class: sheet.classes.SkeletonOne }),
|
|
355
354
|
index.h("sl-skeleton", { class: sheet.classes.SkeletonOne })));
|
|
356
355
|
}
|
|
357
356
|
return (index.h("div", { class: sheet.classes.Wrapper },
|
|
@@ -364,7 +363,7 @@ function ReferralCodesView(props) {
|
|
|
364
363
|
styleString),
|
|
365
364
|
index.h("div", { class: sheet.classes.HeaderContainer },
|
|
366
365
|
index.h("h2", { class: sheet.classes.TitleText }, titleText),
|
|
367
|
-
!states.noCodes &&
|
|
366
|
+
!states.noCodes && slots.pagination),
|
|
368
367
|
getSlotContent(states)));
|
|
369
368
|
}
|
|
370
369
|
|
|
@@ -9,7 +9,7 @@ const style = {
|
|
|
9
9
|
width: "100%",
|
|
10
10
|
},
|
|
11
11
|
SkeletonContainer: {
|
|
12
|
-
width: "
|
|
12
|
+
width: "40px",
|
|
13
13
|
},
|
|
14
14
|
TextContainer: {
|
|
15
15
|
display: "flex",
|
|
@@ -26,11 +26,11 @@ export function PaginationView(props) {
|
|
|
26
26
|
return h(Fragment, null);
|
|
27
27
|
return (h("span", { class: sheet.classes.Container, part: "sqm-base" },
|
|
28
28
|
h("style", { type: "text/css" }, styleString),
|
|
29
|
+
h("sl-button", { exportparts: `base: ${buttonType}button-base`, onClick: onPrev, part: "sqm-pagination-button", circle: true, disabled: currentPage === 1 },
|
|
30
|
+
h("sl-icon", { name: "chevron-left", label: "Previous Page" })),
|
|
29
31
|
!loading ? (h(Fragment, null,
|
|
30
|
-
h("
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
h("sl-
|
|
34
|
-
h("sl-icon", { name: "chevron-right", label: "Previous Page" })))) : (h("div", { class: sheet.classes.SkeletonContainer },
|
|
35
|
-
h("sl-skeleton", { width: "100px", height: "16px" })))));
|
|
32
|
+
h("div", { class: sheet.classes.TextContainer }, text.paginationText))) : (h("div", { class: sheet.classes.SkeletonContainer },
|
|
33
|
+
h("sl-skeleton", { height: "16px", width: "50%" }))),
|
|
34
|
+
h("sl-button", { exportparts: `base: ${buttonType}button-base`, onClick: onNext, part: "sqm-pagination-button", circle: true, disabled: currentPage === totalPages },
|
|
35
|
+
h("sl-icon", { name: "chevron-right", label: "Previous Page" }))));
|
|
36
36
|
}
|
|
@@ -36,11 +36,11 @@ export function ReferralCodesView(props) {
|
|
|
36
36
|
display: "flex",
|
|
37
37
|
flexDirection: "column",
|
|
38
38
|
gap: "var(--sl-spacing-small)",
|
|
39
|
-
width: "
|
|
39
|
+
width: "100%",
|
|
40
40
|
},
|
|
41
41
|
SkeletonOne: {
|
|
42
|
-
height: "
|
|
43
|
-
width: "
|
|
42
|
+
height: "36px",
|
|
43
|
+
width: "100%",
|
|
44
44
|
},
|
|
45
45
|
TitleText: {
|
|
46
46
|
fontSize: "var(--sl-font-size-large)",
|
|
@@ -63,7 +63,6 @@ export function ReferralCodesView(props) {
|
|
|
63
63
|
}
|
|
64
64
|
if (states.loading) {
|
|
65
65
|
return (h("div", { class: sheet.classes.SkeletonContainer },
|
|
66
|
-
h("sl-skeleton", { class: sheet.classes.SkeletonOne }),
|
|
67
66
|
h("sl-skeleton", { class: sheet.classes.SkeletonOne })));
|
|
68
67
|
}
|
|
69
68
|
return (h("div", { class: sheet.classes.Wrapper },
|
|
@@ -76,6 +75,6 @@ export function ReferralCodesView(props) {
|
|
|
76
75
|
styleString),
|
|
77
76
|
h("div", { class: sheet.classes.HeaderContainer },
|
|
78
77
|
h("h2", { class: sheet.classes.TitleText }, titleText),
|
|
79
|
-
!states.noCodes &&
|
|
78
|
+
!states.noCodes && slots.pagination),
|
|
80
79
|
getSlotContent(states)));
|
|
81
80
|
}
|
|
@@ -18,7 +18,7 @@ const style = {
|
|
|
18
18
|
width: "100%",
|
|
19
19
|
},
|
|
20
20
|
SkeletonContainer: {
|
|
21
|
-
width: "
|
|
21
|
+
width: "40px",
|
|
22
22
|
},
|
|
23
23
|
TextContainer: {
|
|
24
24
|
display: "flex",
|
|
@@ -35,13 +35,13 @@ function PaginationView(props) {
|
|
|
35
35
|
return h(Fragment, null);
|
|
36
36
|
return (h("span", { class: sheet.classes.Container, part: "sqm-base" },
|
|
37
37
|
h("style", { type: "text/css" }, styleString),
|
|
38
|
+
h("sl-button", { exportparts: `base: ${buttonType}button-base`, onClick: onPrev, part: "sqm-pagination-button", circle: true, disabled: currentPage === 1 },
|
|
39
|
+
h("sl-icon", { name: "chevron-left", label: "Previous Page" })),
|
|
38
40
|
!loading ? (h(Fragment, null,
|
|
39
|
-
h("
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
h("sl-
|
|
43
|
-
h("sl-icon", { name: "chevron-right", label: "Previous Page" })))) : (h("div", { class: sheet.classes.SkeletonContainer },
|
|
44
|
-
h("sl-skeleton", { width: "100px", height: "16px" })))));
|
|
41
|
+
h("div", { class: sheet.classes.TextContainer }, text.paginationText))) : (h("div", { class: sheet.classes.SkeletonContainer },
|
|
42
|
+
h("sl-skeleton", { height: "16px", width: "50%" }))),
|
|
43
|
+
h("sl-button", { exportparts: `base: ${buttonType}button-base`, onClick: onNext, part: "sqm-pagination-button", circle: true, disabled: currentPage === totalPages },
|
|
44
|
+
h("sl-icon", { name: "chevron-right", label: "Previous Page" }))));
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
function usePagination(props) {
|
|
@@ -320,11 +320,11 @@ function ReferralCodesView(props) {
|
|
|
320
320
|
display: "flex",
|
|
321
321
|
flexDirection: "column",
|
|
322
322
|
gap: "var(--sl-spacing-small)",
|
|
323
|
-
width: "
|
|
323
|
+
width: "100%",
|
|
324
324
|
},
|
|
325
325
|
SkeletonOne: {
|
|
326
|
-
height: "
|
|
327
|
-
width: "
|
|
326
|
+
height: "36px",
|
|
327
|
+
width: "100%",
|
|
328
328
|
},
|
|
329
329
|
TitleText: {
|
|
330
330
|
fontSize: "var(--sl-font-size-large)",
|
|
@@ -347,7 +347,6 @@ function ReferralCodesView(props) {
|
|
|
347
347
|
}
|
|
348
348
|
if (states.loading) {
|
|
349
349
|
return (h("div", { class: sheet.classes.SkeletonContainer },
|
|
350
|
-
h("sl-skeleton", { class: sheet.classes.SkeletonOne }),
|
|
351
350
|
h("sl-skeleton", { class: sheet.classes.SkeletonOne })));
|
|
352
351
|
}
|
|
353
352
|
return (h("div", { class: sheet.classes.Wrapper },
|
|
@@ -360,7 +359,7 @@ function ReferralCodesView(props) {
|
|
|
360
359
|
styleString),
|
|
361
360
|
h("div", { class: sheet.classes.HeaderContainer },
|
|
362
361
|
h("h2", { class: sheet.classes.TitleText }, titleText),
|
|
363
|
-
!states.noCodes &&
|
|
362
|
+
!states.noCodes && slots.pagination),
|
|
364
363
|
getSlotContent(states)));
|
|
365
364
|
}
|
|
366
365
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __makeTemplateObject=this&&this.__makeTemplateObject||function(e,t){if(Object.defineProperty){Object.defineProperty(e,"raw",{value:t})}else{e.raw=t}return e};var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r))e[r]=t[r]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,a,n){function r(e){return e instanceof a?e:new a((function(t){t(e)}))}return new(a||(a=Promise))((function(a,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function i(e){try{l(n["throw"](e))}catch(e){o(e)}}function l(e){e.done?a(e.value):r(e.value).then(s,i)}l((n=n.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var a={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,r,o,s;return s={next:i(0),throw:i(1),return:i(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function i(e){return function(t){return l([e,t])}}function l(s){if(n)throw new TypeError("Generator is already executing.");while(a)try{if(n=1,r&&(o=s[0]&2?r["return"]:s[0]?r["throw"]||((o=r["return"])&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;if(r=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:a.label++;return{value:s[1],done:false};case 5:a.label++;r=s[1];s=[0];continue;case 7:s=a.ops.pop();a.trys.pop();continue;default:if(!(o=a.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){a=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(s[0]===6&&a.label<o[1]){a.label=o[1];o=s;break}if(o&&a.label<o[2]){a.label=o[2];a.ops.push(s);break}if(o[2])a.ops.pop();a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e];r=0}finally{n=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{h,F as Fragment,r as registerInstance}from"./index-38ad4957.js";import{i as intl}from"./global-32d00a6e.js";import{n as h$1,k as useState}from"./dom-context-hooks.module-50442785.js";import{F as Fn,i as isDemo,d as dist,H,J,B,w as wn,$ as $e}from"./index.module-02cb914c.js";import{c as cjs}from"./cjs-bdfb4486.js";import{g as getProps}from"./utils-334c1e34.js";import{c as createStyleSheet}from"./JSS-67b5cff8.js";import{R as REFERRAL_CODES_PAGINATION_CONTEXT,a as REFERRAL_CODES_NAMESPACE,S as SET_CODE_COPIED,u as useReferralCodes}from"./useReferralCodes-acbe7b0a.js";import"./mixins-f750863a.js";import{C as CopyTextView}from"./copy-text-view-87259b11.js";var style={Container:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"var(--sl-spacing-small)",width:"100%"},SkeletonContainer:{width:"100px"},TextContainer:{display:"flex",gap:"var(--sl-spacing-xx-small)"}};var sheet=createStyleSheet(style);var styleString=sheet.toString();function PaginationView(e){var t=e.states,a=e.callbacks,n=e.text,r=e.buttonType;var o=a.onNext,s=a.onPrev;var i=t.currentPage,l=t.totalPages,c=t.loading;if(l===1)return h(Fragment,null);return h("span",{class:sheet.classes.Container,part:"sqm-base"},h("style",{type:"text/css"},styleString),!c?h(Fragment,null,h("sl-button",{exportparts:"base: "+r+"button-base",onClick:s,part:"sqm-pagination-button",circle:true,disabled:i===1},h("sl-icon",{name:"chevron-left",label:"Previous Page"})),h("div",{class:sheet.classes.TextContainer},n.paginationText),h("sl-button",{exportparts:"base: "+r+"button-base",onClick:o,part:"sqm-pagination-button",circle:true,disabled:i===l},h("sl-icon",{name:"chevron-right",label:"Previous Page"}))):h("div",{class:sheet.classes.SkeletonContainer},h("sl-skeleton",{width:"100px",height:"16px"})))}function usePagination(e){var t;var a=Fn(REFERRAL_CODES_PAGINATION_CONTEXT);var n=a.states.currentPage+1;var r=(t=a.states)===null||t===void 0?void 0:t.pageCount;return{states:{currentPage:n,totalPages:r,loading:a.states.loading},callbacks:{onNext:function(){var e,t;return(e=a.callbacks)===null||e===void 0?void 0:e.setCurrentPage(((t=a.states)===null||t===void 0?void 0:t.currentPage)+1)},onPrev:function(){var e,t;return(e=a.callbacks)===null||e===void 0?void 0:e.setCurrentPage(((t=a.states)===null||t===void 0?void 0:t.currentPage)-1)}},text:{paginationText:intl.formatMessage({id:"paginationText",defaultMessage:e.paginationText},{currentPage:n,totalPages:r})}}}var Pagination=function(){function e(e){registerInstance(this,e);this.ignored=true;this.paginationText="{currentPage} of {totalPages}";this.buttonType="secondary";h$1(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=isDemo()?useDemoPagination(getProps(this)):usePagination(getProps(this));return h(PaginationView,Object.assign({},e))};return e}();function useDemoPagination(e){var t=useState(1),a=t[0],n=t[1];return cjs({states:{currentPage:a,totalPages:5,loading:false},buttonType:e.buttonType,callbacks:{onNext:function(){return n(a+1)},onPrev:function(){return n(a-1)}},text:{paginationText:intl.formatMessage({id:"paginationText",defaultMessage:e.paginationText||"{currentPage} of {totalPages}"},{currentPage:a,totalPages:5})}},e.demoData||{},{arrayMerge:function(e,t){return t}})}var MessageLinkQuery=dist.gql(templateObject_1||(templateObject_1=__makeTemplateObject(["\n query getReferralCode($programId: ID) {\n user: viewer {\n ... on User {\n referralCode(programId: $programId)\n }\n }\n }\n"],["\n query getReferralCode($programId: ID) {\n user: viewer {\n ... on User {\n referralCode(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"])));function useReferralCode(e){var t,a;var n=e.programId,r=n===void 0?H():n;var o=J();var s=B();var i=Fn(REFERRAL_CODES_NAMESPACE);var l=wn(MessageLinkQuery,{programId:r},!(o===null||o===void 0?void 0:o.jwt)||(i===null||i===void 0?void 0:i.referralCode)!==undefined).data;var c=$e(WIDGET_ENGAGEMENT_EVENT)[0];var u=$e(SET_CODE_COPIED)[0];var d=(a=(i===null||i===void 0?void 0:i.referralCode)||((t=l===null||l===void 0?void 0:l.user)===null||t===void 0?void 0:t.referralCode))!==null&&a!==void 0?a:"...";var p=useState(false),f=p[0],g=p[1];function h(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:if(!i)return[3,2];return[4,u({referralCode:i.referralCode})];case 1:t.sent();i.refresh();t.label=2;case 2:navigator.clipboard.writeText(d);g(true);setTimeout((function(){return g(false)}),e.tooltiplifespan);c({eventMeta:{programId:r,id:o===null||o===void 0?void 0:o.id,accountId:o===null||o===void 0?void 0:o.accountId,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:s,shareMedium:"DIRECT"}}});return[2]}}))}))}return __assign(__assign({},e),{onClick:h,open:f,copyString:d,isCopied:i===null||i===void 0?void 0:i.isCopied,showNotificationText:e.showNotificationText&&!!(i===null||i===void 0?void 0:i.singleUse)})}var ReferralCode=function(){function e(e){registerInstance(this,e);this.tooltiptext="Copied to Clipboard";this.showNotificationText=false;this.notificationText="You've copied this code before";this.tooltiplifespan=1e3;this.textAlign="left";this.copyButtonLabel="Copy Code";this.buttonStyle="icon";this.buttonType="primary";h$1(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=getProps(this);var t=isDemo()?useDemoReferralCode(e):useReferralCode(e);return h(CopyTextView,Object.assign({},t))};return e}();function useDemoReferralCode(e){var t=useState(false),a=t[0],n=t[1];var r="REFERRALCODE001";return cjs({copyString:r,tooltiptext:e.tooltiptext,textAlign:e.textAlign,copyButtonLabel:e.copyButtonLabel,buttonStyle:e.buttonStyle,notificationText:e.notificationText,showNotificationText:e.showNotificationText,isCopied:e.showNotificationText,borderColor:e.borderColor,backgroundColor:e.backgroundColor,textColor:e.textColor,borderRadius:e.borderRadius,buttonType:e.buttonType,isUsed:false,rewardStatus:"AVAILABLE",open:a,onClick:function(){navigator.clipboard.writeText(r);n(true);setTimeout((function(){return n(false)}),e.tooltiplifespan)}},e.demoData||{},{arrayMerge:function(e,t){return t}})}function ReferralCodesView(e){var t=e.slots,a=e.titleText,n=e.states,r=e.textColor,o=r===void 0?"var(--sqm-text-subdued)":r;var s={Wrapper:{width:"100%",display:"flex",alignItems:"flex-start",justifyContent:"center",flexDirection:"column",gap:"var(--sl-spacing-large)",color:o},HeaderContainer:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},ShareCodeContainer:{width:"100%",display:"flex",alignItems:"flex-start",justifyContent:"center",flexDirection:"column"},ShareButtonContainer:{width:"100%",display:"flex",alignItems:"flex-start",justifyContent:"center",flexDirection:"column"},SkeletonContainer:{display:"flex",flexDirection:"column",gap:"var(--sl-spacing-small)",width:"50%"},SkeletonOne:{height:"16px",width:"50%"},TitleText:{fontSize:"var(--sl-font-size-large)",margin:"0"}};var i="\n :host {\n display: block;\n }\n :host([hidden]): {\n display: none;\n }\n ";var l=createStyleSheet(s);var c=l.toString();var u=function(e){if(e.noCodes){return t.empty}if(e.loading){return h("div",{class:l.classes.SkeletonContainer},h("sl-skeleton",{class:l.classes.SkeletonOne}),h("sl-skeleton",{class:l.classes.SkeletonOne}))}return h("div",{class:l.classes.Wrapper},h("div",{class:l.classes.ShareCodeContainer},t.shareCodes),h("div",{class:l.classes.ShareButtonContainer},t.shareButtons))};return h("div",{class:l.classes.Wrapper,part:"sqm-base"},h("style",{type:"text/css"},i,c),h("div",{class:l.classes.HeaderContainer},h("h2",{class:l.classes.TitleText},a),!n.noCodes&&!n.loading&&t.pagination),u(n))}var ReferralCodes=function(){function e(e){registerInstance(this,e);this.titleText="Start sharing";this.emptyStateHeaderText="Your new codes and links aren’t ready yet";this.emptyStateDescriptionText="Please contact our program support team to let them know you’re out of codes.";this.emptyStateImageUrl="https://res.cloudinary.com/saasquatch/image/upload/v1644360953/squatch-assets/empty_leaderboard2.png";h$1(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=getProps(this);var t=isDemo()?useDemoReferralCodes(e):useReferralCodes(e);var a={shareButtons:h("slot",{name:"shareButtons"}),shareCodes:h("slot",{name:"shareCodes"}),pagination:h("slot",{name:"pagination"}),empty:h(EmptySlot,{headerText:this.emptyStateHeaderText,descriptionText:this.emptyStateDescriptionText,imageUrl:this.emptyStateImageUrl})};var n=__assign(__assign({slots:a},t),{loading:t.states.loading,noCodes:t.states.noCodes});return h(ReferralCodesView,Object.assign({},n))};return e}();function EmptySlot(e){var t=e.headerText,a=e.descriptionText,n=e.imageUrl;return h("slot",{name:"empty"},h("sqm-empty",{emptyStateHeader:t,emptyStateText:a,emptyStateImage:n}))}function useDemoReferralCodes(e){return cjs({titleText:e.titleText,textColor:e.textColor,states:{noCodes:false,loading:false}},e.demoData||{},{arrayMerge:function(e,t){return t}})}export{Pagination as sqm_pagination,ReferralCode as sqm_referral_code,ReferralCodes as sqm_referral_codes};var templateObject_1,templateObject_2;
|
|
1
|
+
var __makeTemplateObject=this&&this.__makeTemplateObject||function(e,t){if(Object.defineProperty){Object.defineProperty(e,"raw",{value:t})}else{e.raw=t}return e};var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r))e[r]=t[r]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,a,n){function r(e){return e instanceof a?e:new a((function(t){t(e)}))}return new(a||(a=Promise))((function(a,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function i(e){try{l(n["throw"](e))}catch(e){o(e)}}function l(e){e.done?a(e.value):r(e.value).then(s,i)}l((n=n.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var a={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,r,o,s;return s={next:i(0),throw:i(1),return:i(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function i(e){return function(t){return l([e,t])}}function l(s){if(n)throw new TypeError("Generator is already executing.");while(a)try{if(n=1,r&&(o=s[0]&2?r["return"]:s[0]?r["throw"]||((o=r["return"])&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;if(r=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:a.label++;return{value:s[1],done:false};case 5:a.label++;r=s[1];s=[0];continue;case 7:s=a.ops.pop();a.trys.pop();continue;default:if(!(o=a.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){a=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(s[0]===6&&a.label<o[1]){a.label=o[1];o=s;break}if(o&&a.label<o[2]){a.label=o[2];a.ops.push(s);break}if(o[2])a.ops.pop();a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e];r=0}finally{n=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{h,F as Fragment,r as registerInstance}from"./index-38ad4957.js";import{i as intl}from"./global-32d00a6e.js";import{n as h$1,k as useState}from"./dom-context-hooks.module-50442785.js";import{F as Fn,i as isDemo,d as dist,H,J,B,w as wn,$ as $e}from"./index.module-02cb914c.js";import{c as cjs}from"./cjs-bdfb4486.js";import{g as getProps}from"./utils-334c1e34.js";import{c as createStyleSheet}from"./JSS-67b5cff8.js";import{R as REFERRAL_CODES_PAGINATION_CONTEXT,a as REFERRAL_CODES_NAMESPACE,S as SET_CODE_COPIED,u as useReferralCodes}from"./useReferralCodes-acbe7b0a.js";import"./mixins-f750863a.js";import{C as CopyTextView}from"./copy-text-view-87259b11.js";var style={Container:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"var(--sl-spacing-small)",width:"100%"},SkeletonContainer:{width:"40px"},TextContainer:{display:"flex",gap:"var(--sl-spacing-xx-small)"}};var sheet=createStyleSheet(style);var styleString=sheet.toString();function PaginationView(e){var t=e.states,a=e.callbacks,n=e.text,r=e.buttonType;var o=a.onNext,s=a.onPrev;var i=t.currentPage,l=t.totalPages,c=t.loading;if(l===1)return h(Fragment,null);return h("span",{class:sheet.classes.Container,part:"sqm-base"},h("style",{type:"text/css"},styleString),h("sl-button",{exportparts:"base: "+r+"button-base",onClick:s,part:"sqm-pagination-button",circle:true,disabled:i===1},h("sl-icon",{name:"chevron-left",label:"Previous Page"})),!c?h(Fragment,null,h("div",{class:sheet.classes.TextContainer},n.paginationText)):h("div",{class:sheet.classes.SkeletonContainer},h("sl-skeleton",{height:"16px",width:"50%"})),h("sl-button",{exportparts:"base: "+r+"button-base",onClick:o,part:"sqm-pagination-button",circle:true,disabled:i===l},h("sl-icon",{name:"chevron-right",label:"Previous Page"})))}function usePagination(e){var t;var a=Fn(REFERRAL_CODES_PAGINATION_CONTEXT);var n=a.states.currentPage+1;var r=(t=a.states)===null||t===void 0?void 0:t.pageCount;return{states:{currentPage:n,totalPages:r,loading:a.states.loading},callbacks:{onNext:function(){var e,t;return(e=a.callbacks)===null||e===void 0?void 0:e.setCurrentPage(((t=a.states)===null||t===void 0?void 0:t.currentPage)+1)},onPrev:function(){var e,t;return(e=a.callbacks)===null||e===void 0?void 0:e.setCurrentPage(((t=a.states)===null||t===void 0?void 0:t.currentPage)-1)}},text:{paginationText:intl.formatMessage({id:"paginationText",defaultMessage:e.paginationText},{currentPage:n,totalPages:r})}}}var Pagination=function(){function e(e){registerInstance(this,e);this.ignored=true;this.paginationText="{currentPage} of {totalPages}";this.buttonType="secondary";h$1(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=isDemo()?useDemoPagination(getProps(this)):usePagination(getProps(this));return h(PaginationView,Object.assign({},e))};return e}();function useDemoPagination(e){var t=useState(1),a=t[0],n=t[1];return cjs({states:{currentPage:a,totalPages:5,loading:false},buttonType:e.buttonType,callbacks:{onNext:function(){return n(a+1)},onPrev:function(){return n(a-1)}},text:{paginationText:intl.formatMessage({id:"paginationText",defaultMessage:e.paginationText||"{currentPage} of {totalPages}"},{currentPage:a,totalPages:5})}},e.demoData||{},{arrayMerge:function(e,t){return t}})}var MessageLinkQuery=dist.gql(templateObject_1||(templateObject_1=__makeTemplateObject(["\n query getReferralCode($programId: ID) {\n user: viewer {\n ... on User {\n referralCode(programId: $programId)\n }\n }\n }\n"],["\n query getReferralCode($programId: ID) {\n user: viewer {\n ... on User {\n referralCode(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"])));function useReferralCode(e){var t,a;var n=e.programId,r=n===void 0?H():n;var o=J();var s=B();var i=Fn(REFERRAL_CODES_NAMESPACE);var l=wn(MessageLinkQuery,{programId:r},!(o===null||o===void 0?void 0:o.jwt)||(i===null||i===void 0?void 0:i.referralCode)!==undefined).data;var c=$e(WIDGET_ENGAGEMENT_EVENT)[0];var u=$e(SET_CODE_COPIED)[0];var d=(a=(i===null||i===void 0?void 0:i.referralCode)||((t=l===null||l===void 0?void 0:l.user)===null||t===void 0?void 0:t.referralCode))!==null&&a!==void 0?a:"...";var p=useState(false),f=p[0],g=p[1];function h(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:if(!i)return[3,2];return[4,u({referralCode:i.referralCode})];case 1:t.sent();i.refresh();t.label=2;case 2:navigator.clipboard.writeText(d);g(true);setTimeout((function(){return g(false)}),e.tooltiplifespan);c({eventMeta:{programId:r,id:o===null||o===void 0?void 0:o.id,accountId:o===null||o===void 0?void 0:o.accountId,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:s,shareMedium:"DIRECT"}}});return[2]}}))}))}return __assign(__assign({},e),{onClick:h,open:f,copyString:d,isCopied:i===null||i===void 0?void 0:i.isCopied,showNotificationText:e.showNotificationText&&!!(i===null||i===void 0?void 0:i.singleUse)})}var ReferralCode=function(){function e(e){registerInstance(this,e);this.tooltiptext="Copied to Clipboard";this.showNotificationText=false;this.notificationText="You've copied this code before";this.tooltiplifespan=1e3;this.textAlign="left";this.copyButtonLabel="Copy Code";this.buttonStyle="icon";this.buttonType="primary";h$1(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=getProps(this);var t=isDemo()?useDemoReferralCode(e):useReferralCode(e);return h(CopyTextView,Object.assign({},t))};return e}();function useDemoReferralCode(e){var t=useState(false),a=t[0],n=t[1];var r="REFERRALCODE001";return cjs({copyString:r,tooltiptext:e.tooltiptext,textAlign:e.textAlign,copyButtonLabel:e.copyButtonLabel,buttonStyle:e.buttonStyle,notificationText:e.notificationText,showNotificationText:e.showNotificationText,isCopied:e.showNotificationText,borderColor:e.borderColor,backgroundColor:e.backgroundColor,textColor:e.textColor,borderRadius:e.borderRadius,buttonType:e.buttonType,isUsed:false,rewardStatus:"AVAILABLE",open:a,onClick:function(){navigator.clipboard.writeText(r);n(true);setTimeout((function(){return n(false)}),e.tooltiplifespan)}},e.demoData||{},{arrayMerge:function(e,t){return t}})}function ReferralCodesView(e){var t=e.slots,a=e.titleText,n=e.states,r=e.textColor,o=r===void 0?"var(--sqm-text-subdued)":r;var s={Wrapper:{width:"100%",display:"flex",alignItems:"flex-start",justifyContent:"center",flexDirection:"column",gap:"var(--sl-spacing-large)",color:o},HeaderContainer:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},ShareCodeContainer:{width:"100%",display:"flex",alignItems:"flex-start",justifyContent:"center",flexDirection:"column"},ShareButtonContainer:{width:"100%",display:"flex",alignItems:"flex-start",justifyContent:"center",flexDirection:"column"},SkeletonContainer:{display:"flex",flexDirection:"column",gap:"var(--sl-spacing-small)",width:"100%"},SkeletonOne:{height:"36px",width:"100%"},TitleText:{fontSize:"var(--sl-font-size-large)",margin:"0"}};var i="\n :host {\n display: block;\n }\n :host([hidden]): {\n display: none;\n }\n ";var l=createStyleSheet(s);var c=l.toString();var u=function(e){if(e.noCodes){return t.empty}if(e.loading){return h("div",{class:l.classes.SkeletonContainer},h("sl-skeleton",{class:l.classes.SkeletonOne}))}return h("div",{class:l.classes.Wrapper},h("div",{class:l.classes.ShareCodeContainer},t.shareCodes),h("div",{class:l.classes.ShareButtonContainer},t.shareButtons))};return h("div",{class:l.classes.Wrapper,part:"sqm-base"},h("style",{type:"text/css"},i,c),h("div",{class:l.classes.HeaderContainer},h("h2",{class:l.classes.TitleText},a),!n.noCodes&&t.pagination),u(n))}var ReferralCodes=function(){function e(e){registerInstance(this,e);this.titleText="Start sharing";this.emptyStateHeaderText="Your new codes and links aren’t ready yet";this.emptyStateDescriptionText="Please contact our program support team to let them know you’re out of codes.";this.emptyStateImageUrl="https://res.cloudinary.com/saasquatch/image/upload/v1644360953/squatch-assets/empty_leaderboard2.png";h$1(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=getProps(this);var t=isDemo()?useDemoReferralCodes(e):useReferralCodes(e);var a={shareButtons:h("slot",{name:"shareButtons"}),shareCodes:h("slot",{name:"shareCodes"}),pagination:h("slot",{name:"pagination"}),empty:h(EmptySlot,{headerText:this.emptyStateHeaderText,descriptionText:this.emptyStateDescriptionText,imageUrl:this.emptyStateImageUrl})};var n=__assign(__assign({slots:a},t),{loading:t.states.loading,noCodes:t.states.noCodes});return h(ReferralCodesView,Object.assign({},n))};return e}();function EmptySlot(e){var t=e.headerText,a=e.descriptionText,n=e.imageUrl;return h("slot",{name:"empty"},h("sqm-empty",{emptyStateHeader:t,emptyStateText:a,emptyStateImage:n}))}function useDemoReferralCodes(e){return cjs({titleText:e.titleText,textColor:e.textColor,states:{noCodes:false,loading:false}},e.demoData||{},{arrayMerge:function(e,t){return t}})}export{Pagination as sqm_pagination,ReferralCode as sqm_referral_code,ReferralCodes as sqm_referral_codes};var templateObject_1,templateObject_2;
|