@saasquatch/mint-components 1.10.2-9 → 1.10.3-1
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/{ShadowViewAddon-721bb748.js → ShadowViewAddon-c3e91cee.js} +55 -30
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mint-components.cjs.js +1 -1
- package/dist/cjs/sqm-banking-info-form_16.cjs.entry.js +57 -33
- package/dist/cjs/sqm-big-stat_38.cjs.entry.js +64 -23
- package/dist/cjs/sqm-empty_4.cjs.entry.js +8 -1
- package/dist/cjs/{sqm-portal-container-view-5fb2ad49.js → sqm-portal-container-view-990a85a3.js} +1 -1
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +153 -30
- package/dist/collection/components/sqm-empty/EmptyState.stories.js +1 -1
- package/dist/collection/components/sqm-image/sqm-image-view.js +1 -1
- package/dist/collection/components/sqm-image/sqm-image.js +20 -0
- package/dist/collection/components/sqm-leaderboard/Leaderboard.stories.js +130 -24
- package/dist/collection/components/sqm-leaderboard/sqm-leaderboard-view.js +55 -29
- package/dist/collection/components/sqm-leaderboard/sqm-leaderboard.js +93 -29
- package/dist/collection/components/sqm-leaderboard/useLeaderboard.js +40 -4
- package/dist/collection/components/sqm-portal-container/PortalContainer.stories.js +12 -0
- package/dist/collection/components/sqm-portal-container/sqm-portal-container-view.js +1 -1
- package/dist/collection/components/sqm-portal-container/sqm-portal-container.js +37 -0
- package/dist/collection/components/tax-and-cash/sqm-banking-info-form/sqm-banking-info-form-view.js +2 -1
- package/dist/collection/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form-view.js +55 -32
- package/dist/esm/{ShadowViewAddon-31eb5b16.js → ShadowViewAddon-e012b2aa.js} +55 -30
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mint-components.js +1 -1
- package/dist/esm/sqm-banking-info-form_16.entry.js +57 -33
- package/dist/esm/sqm-big-stat_38.entry.js +64 -23
- package/dist/esm/sqm-empty_4.entry.js +8 -1
- package/dist/esm/{sqm-portal-container-view-ab89c6cc.js → sqm-portal-container-view-6c582684.js} +1 -1
- package/dist/esm/sqm-stencilbook.entry.js +153 -30
- package/dist/esm-es5/ShadowViewAddon-e012b2aa.js +1 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/mint-components.js +1 -1
- package/dist/esm-es5/sqm-banking-info-form_16.entry.js +1 -1
- package/dist/esm-es5/sqm-big-stat_38.entry.js +1 -1
- package/dist/esm-es5/sqm-empty_4.entry.js +1 -1
- package/dist/esm-es5/sqm-portal-container-view-6c582684.js +1 -0
- package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/{p-d6474614.js → p-10685090.js} +23 -23
- package/dist/mint-components/p-2ffefa3b.entry.js +223 -0
- package/dist/mint-components/{p-b45ba369.entry.js → p-31e810e9.entry.js} +2 -2
- package/dist/mint-components/p-5de21018.system.entry.js +1 -0
- package/dist/mint-components/p-7497a4f6.system.entry.js +1 -0
- package/dist/mint-components/{p-bf723ae9.entry.js → p-81689347.entry.js} +2 -2
- package/dist/mint-components/p-84361da0.system.entry.js +1 -0
- package/dist/mint-components/p-95771f79.system.js +1 -0
- package/dist/mint-components/p-9f0629ba.system.entry.js +1 -0
- package/dist/mint-components/{p-e704842c.js → p-c7fd9e16.js} +1 -1
- package/dist/mint-components/p-d8d2de11.entry.js +1 -0
- package/dist/mint-components/p-ed17e637.system.js +1 -1
- package/dist/mint-components/p-ed6ebd60.system.js +1 -0
- package/dist/types/components/sqm-image/sqm-image-view.d.ts +1 -0
- package/dist/types/components/sqm-image/sqm-image.d.ts +5 -0
- package/dist/types/components/sqm-leaderboard/Leaderboard.stories.d.ts +5 -1
- package/dist/types/components/sqm-leaderboard/sqm-leaderboard-view.d.ts +6 -4
- package/dist/types/components/sqm-leaderboard/sqm-leaderboard.d.ts +23 -6
- package/dist/types/components/sqm-leaderboard/useLeaderboard.d.ts +4 -2
- package/dist/types/components/sqm-portal-container/PortalContainer.stories.d.ts +1 -0
- package/dist/types/components/sqm-portal-container/sqm-portal-container-view.d.ts +1 -0
- package/dist/types/components/sqm-portal-container/sqm-portal-container.d.ts +7 -0
- package/dist/types/components.d.ts +64 -12
- package/docs/docs.docx +0 -0
- package/docs/raisins.json +1 -1
- package/grapesjs/grapesjs.js +1 -1
- package/package.json +2 -2
- package/dist/esm-es5/ShadowViewAddon-31eb5b16.js +0 -1
- package/dist/esm-es5/sqm-portal-container-view-ab89c6cc.js +0 -1
- package/dist/mint-components/p-0d39c815.system.entry.js +0 -1
- package/dist/mint-components/p-1fe65a36.entry.js +0 -1
- package/dist/mint-components/p-27bd5535.entry.js +0 -187
- package/dist/mint-components/p-34fd1229.system.entry.js +0 -1
- package/dist/mint-components/p-922578e4.system.js +0 -1
- package/dist/mint-components/p-b567780d.system.js +0 -1
- package/dist/mint-components/p-c34a507e.system.entry.js +0 -1
- package/dist/mint-components/p-f1a1e7f3.system.entry.js +0 -1
|
@@ -81,8 +81,8 @@ const users = [
|
|
|
81
81
|
];
|
|
82
82
|
const pointsUsers = [
|
|
83
83
|
{
|
|
84
|
-
firstName: "",
|
|
85
|
-
lastInitial: "",
|
|
84
|
+
firstName: "Tom",
|
|
85
|
+
lastInitial: "Smith",
|
|
86
86
|
textValue: "82 Points",
|
|
87
87
|
rank: 1,
|
|
88
88
|
rowNumber: 1,
|
|
@@ -156,18 +156,13 @@ const defaultStyles = {
|
|
|
156
156
|
statsheading: "Referrals",
|
|
157
157
|
rankheading: "Rank",
|
|
158
158
|
anonymousUser: "Anonymous User",
|
|
159
|
+
viewingUserText: "You",
|
|
160
|
+
rankSuffix: "{rank, selectordinal, one {#st} two {#nd} few {#rd} other {#th}}",
|
|
159
161
|
};
|
|
160
162
|
const link = h("a", null, "Support");
|
|
161
163
|
const tag = "Contact" + link + "about upgrading your plan";
|
|
162
164
|
const defaultElements = {
|
|
163
165
|
empty: (h("sqm-empty", { "empty-state-image": "https://res.cloudinary.com/saasquatch/image/upload/v1644360953/squatch-assets/empty_leaderboard2.png", "empty-state-header": "View your rank in the leaderboard", "empty-state-text": "Be the first to refer a friend and reach the top of the leaderboard" })),
|
|
164
|
-
essentials: (h("sqm-empty", { "empty-state-image": "https://res.cloudinary.com/saasquatch/image/upload/v1715360191/squatch-assets/Leaderboard_Not_Available.svg", "empty-state-header": "Leaderboards aren\u2019t available on your plan", "empty-state-text": "Contact {supportText} to upgrade your plan and start leveraging gamification in your program.", "support-text": "Support" })),
|
|
165
|
-
loadingstate: (h("slot", { name: "loading" },
|
|
166
|
-
h("table", null, [...Array(10)].map(() => {
|
|
167
|
-
return (h("tr", null,
|
|
168
|
-
h("td", null,
|
|
169
|
-
h("sl-skeleton", null))));
|
|
170
|
-
})))),
|
|
171
166
|
};
|
|
172
167
|
export const Empty = () => {
|
|
173
168
|
const props = {
|
|
@@ -196,11 +191,10 @@ export const Empty = () => {
|
|
|
196
191
|
};
|
|
197
192
|
return h(LeaderboardView, Object.assign({}, props));
|
|
198
193
|
};
|
|
199
|
-
export const
|
|
194
|
+
export const Loading = () => {
|
|
200
195
|
const props = {
|
|
201
196
|
states: {
|
|
202
|
-
loading:
|
|
203
|
-
isEssentials: true,
|
|
197
|
+
loading: true,
|
|
204
198
|
hasLeaders: false,
|
|
205
199
|
styles: {
|
|
206
200
|
...defaultStyles,
|
|
@@ -208,15 +202,8 @@ export const Essentials = () => {
|
|
|
208
202
|
},
|
|
209
203
|
data: {
|
|
210
204
|
rankType: "rowNumber",
|
|
211
|
-
leaderboard: [],
|
|
212
205
|
rowNumber: 10,
|
|
213
|
-
|
|
214
|
-
firstName: "Kutay",
|
|
215
|
-
lastInitial: "C",
|
|
216
|
-
textValue: "8",
|
|
217
|
-
rowNumber: 11,
|
|
218
|
-
rank: 23,
|
|
219
|
-
},
|
|
206
|
+
leaderboard: [],
|
|
220
207
|
},
|
|
221
208
|
elements: {
|
|
222
209
|
...defaultElements,
|
|
@@ -224,10 +211,11 @@ export const Essentials = () => {
|
|
|
224
211
|
};
|
|
225
212
|
return h(LeaderboardView, Object.assign({}, props));
|
|
226
213
|
};
|
|
227
|
-
export const
|
|
214
|
+
export const Essentials = () => {
|
|
228
215
|
const props = {
|
|
229
216
|
states: {
|
|
230
|
-
loading:
|
|
217
|
+
loading: false,
|
|
218
|
+
isEssentials: true,
|
|
231
219
|
hasLeaders: false,
|
|
232
220
|
styles: {
|
|
233
221
|
...defaultStyles,
|
|
@@ -235,8 +223,15 @@ export const Loading = () => {
|
|
|
235
223
|
},
|
|
236
224
|
data: {
|
|
237
225
|
rankType: "rowNumber",
|
|
238
|
-
rowNumber: 10,
|
|
239
226
|
leaderboard: [],
|
|
227
|
+
rowNumber: 10,
|
|
228
|
+
viewerRank: {
|
|
229
|
+
firstName: "Kutay",
|
|
230
|
+
lastInitial: "C",
|
|
231
|
+
textValue: "8",
|
|
232
|
+
rowNumber: 11,
|
|
233
|
+
rank: 23,
|
|
234
|
+
},
|
|
240
235
|
},
|
|
241
236
|
elements: {
|
|
242
237
|
...defaultElements,
|
|
@@ -373,6 +368,38 @@ export const ReferralLeaderboard = () => {
|
|
|
373
368
|
};
|
|
374
369
|
return h(LeaderboardView, Object.assign({}, props));
|
|
375
370
|
};
|
|
371
|
+
export const ReferralLeaderboardWithMaxWidth = () => {
|
|
372
|
+
const props = {
|
|
373
|
+
states: {
|
|
374
|
+
loading: false,
|
|
375
|
+
hasLeaders: true,
|
|
376
|
+
styles: {
|
|
377
|
+
...defaultStyles,
|
|
378
|
+
rankheading: "Rank",
|
|
379
|
+
usersheading: "User",
|
|
380
|
+
statsheading: "Referrals",
|
|
381
|
+
showRank: false,
|
|
382
|
+
maxWidth: "300px",
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
data: {
|
|
386
|
+
rankType: "rowNumber",
|
|
387
|
+
leaderboard: users,
|
|
388
|
+
rowNumber: 10,
|
|
389
|
+
viewerRank: {
|
|
390
|
+
firstName: "Viktor",
|
|
391
|
+
lastInitial: "V",
|
|
392
|
+
textValue: "82",
|
|
393
|
+
rank: 1,
|
|
394
|
+
rowNumber: 1,
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
elements: {
|
|
398
|
+
...defaultElements,
|
|
399
|
+
},
|
|
400
|
+
};
|
|
401
|
+
return h(LeaderboardView, Object.assign({}, props));
|
|
402
|
+
};
|
|
376
403
|
export const PointsLeaderboard = () => {
|
|
377
404
|
const props = {
|
|
378
405
|
states: {
|
|
@@ -451,7 +478,7 @@ export const ViewerOutside = () => {
|
|
|
451
478
|
lastInitial: "C",
|
|
452
479
|
textValue: "8",
|
|
453
480
|
rowNumber: 11,
|
|
454
|
-
rank:
|
|
481
|
+
rank: 24,
|
|
455
482
|
},
|
|
456
483
|
},
|
|
457
484
|
elements: {
|
|
@@ -482,6 +509,33 @@ export const ViewerAnonymous = () => {
|
|
|
482
509
|
};
|
|
483
510
|
return h(LeaderboardView, Object.assign({}, props));
|
|
484
511
|
};
|
|
512
|
+
export const HideNamesWithViewerOutside = () => {
|
|
513
|
+
const props = {
|
|
514
|
+
states: {
|
|
515
|
+
loading: false,
|
|
516
|
+
hasLeaders: true,
|
|
517
|
+
styles: {
|
|
518
|
+
...defaultStyles,
|
|
519
|
+
showRank: true,
|
|
520
|
+
hideNames: true,
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
data: {
|
|
524
|
+
rankType: "rowNumber",
|
|
525
|
+
leaderboard: users,
|
|
526
|
+
rowNumber: 10,
|
|
527
|
+
viewerRank: {
|
|
528
|
+
textValue: "8",
|
|
529
|
+
rowNumber: 11,
|
|
530
|
+
rank: 42,
|
|
531
|
+
},
|
|
532
|
+
},
|
|
533
|
+
elements: {
|
|
534
|
+
...defaultElements,
|
|
535
|
+
},
|
|
536
|
+
};
|
|
537
|
+
return h(LeaderboardView, Object.assign({}, props));
|
|
538
|
+
};
|
|
485
539
|
export const HideViewer = () => {
|
|
486
540
|
const props = {
|
|
487
541
|
states: {
|
|
@@ -512,3 +566,55 @@ export const HideViewer = () => {
|
|
|
512
566
|
};
|
|
513
567
|
return h(LeaderboardView, Object.assign({}, props));
|
|
514
568
|
};
|
|
569
|
+
export const HideNames = () => {
|
|
570
|
+
const props = {
|
|
571
|
+
states: {
|
|
572
|
+
loading: false,
|
|
573
|
+
hasLeaders: true,
|
|
574
|
+
rowNumber: 10,
|
|
575
|
+
styles: {
|
|
576
|
+
...defaultStyles,
|
|
577
|
+
showRank: true,
|
|
578
|
+
hideNames: true,
|
|
579
|
+
},
|
|
580
|
+
},
|
|
581
|
+
data: {
|
|
582
|
+
rankType: "rowNumber",
|
|
583
|
+
leaderboard: users,
|
|
584
|
+
rowNumber: 10,
|
|
585
|
+
viewerRank: {
|
|
586
|
+
firstName: "Viktor",
|
|
587
|
+
lastInitial: "V",
|
|
588
|
+
textValue: "82",
|
|
589
|
+
rowNumber: 1,
|
|
590
|
+
rank: 1,
|
|
591
|
+
},
|
|
592
|
+
},
|
|
593
|
+
elements: {
|
|
594
|
+
...defaultElements,
|
|
595
|
+
},
|
|
596
|
+
};
|
|
597
|
+
return h(LeaderboardView, Object.assign({}, props));
|
|
598
|
+
};
|
|
599
|
+
export const LeaderboardWithNoNamesAndGraphic = () => {
|
|
600
|
+
return (h("div", { style: {
|
|
601
|
+
display: "flex",
|
|
602
|
+
alignItems: "flex-start",
|
|
603
|
+
justifyContent: "center",
|
|
604
|
+
width: "100%",
|
|
605
|
+
gap: "50px",
|
|
606
|
+
} },
|
|
607
|
+
h("div", { style: {
|
|
608
|
+
display: "flex",
|
|
609
|
+
flexDirection: "column",
|
|
610
|
+
alignItems: "center",
|
|
611
|
+
justifyContent: "center",
|
|
612
|
+
gap: "10px",
|
|
613
|
+
maxWidth: "30%",
|
|
614
|
+
} },
|
|
615
|
+
h("sqm-image", { width: "70%", alignment: "center", imageUrl: "https://res.cloudinary.com/saasquatch-staging/image/upload/v1729728469/Leaderboard_image_z87lsm.png" }),
|
|
616
|
+
h("h2", { style: { margin: "auto" } }, " Top Performers"),
|
|
617
|
+
h("p", { style: { margin: "0" } }, "The leaderboard highlights the top performers in real-time. Stay motivated, stay competitive!")),
|
|
618
|
+
h("sqm-leaderboard", { width: "300px", usersheading: "Referrer", statsheading: "Referrals", "rank-type": "rank", "leaderboard-type": "topStartedReferrers", rankheading: "Rank", "show-rank": "true", "hide-names": "true", "hide-viewer": "true" },
|
|
619
|
+
h("sqm-empty", { "empty-state-image": "https://res.cloudinary.com/saasquatch/image/upload/v1644360953/squatch-assets/empty_leaderboard2.png", "empty-state-header": "View your rank in the leaderboard", "empty-state-text": "Be the first to refer a friend and reach the top of the leaderboard" }))));
|
|
620
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
2
|
import { createStyleSheet } from "../../styling/JSS";
|
|
3
|
+
import { intl } from "../../global/global";
|
|
3
4
|
const style = {
|
|
4
5
|
Leaderboard: {
|
|
5
6
|
"& table": {
|
|
@@ -21,9 +22,10 @@ const style = {
|
|
|
21
22
|
fontWeight: "var(--sl-font-weight-normal)",
|
|
22
23
|
},
|
|
23
24
|
"& .ellipses": {
|
|
24
|
-
textAlign: "
|
|
25
|
+
textAlign: "left",
|
|
25
26
|
padding: "0",
|
|
26
27
|
color: "var(--sl-color-neutral-500)",
|
|
28
|
+
paddingLeft: "25%",
|
|
27
29
|
},
|
|
28
30
|
"& .highlight": {
|
|
29
31
|
background: "var(--sl-color-primary-50)",
|
|
@@ -39,6 +41,12 @@ const style = {
|
|
|
39
41
|
width: "auto",
|
|
40
42
|
whiteSpace: "nowrap",
|
|
41
43
|
},
|
|
44
|
+
"& .Rank": {
|
|
45
|
+
whiteSpace: "nowrap",
|
|
46
|
+
},
|
|
47
|
+
"& .fullWidth": {
|
|
48
|
+
width: "100%",
|
|
49
|
+
},
|
|
42
50
|
},
|
|
43
51
|
};
|
|
44
52
|
const sheet = createStyleSheet(style);
|
|
@@ -49,56 +57,74 @@ const vanillaStyle = `
|
|
|
49
57
|
}
|
|
50
58
|
`;
|
|
51
59
|
export function LeaderboardView(props) {
|
|
52
|
-
var _a, _b, _c
|
|
60
|
+
var _a, _b, _c;
|
|
53
61
|
const { states, data, elements } = props;
|
|
54
62
|
const { styles } = states;
|
|
55
|
-
if (states.
|
|
56
|
-
return (h("
|
|
63
|
+
if (states.isEssentials) {
|
|
64
|
+
return (h("sqm-empty", { "empty-state-image": "https://res.cloudinary.com/saasquatch/image/upload/v1715360191/squatch-assets/Leaderboard_Not_Available.svg", "empty-state-header": "Leaderboards aren\u2019t available on your plan", "empty-state-text": "Contact {supportText} to upgrade your plan and start leveraging gamification in your program.", "support-text": "Support" }));
|
|
65
|
+
}
|
|
66
|
+
if (states.loading) {
|
|
67
|
+
return (h("div", { class: sheet.classes.Leaderboard, style: { width: styles.width || "100%" } },
|
|
57
68
|
h("style", { type: "text/css" },
|
|
58
69
|
styleString,
|
|
59
70
|
vanillaStyle),
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
71
|
+
h("table", null, [...Array(10)].map(() => {
|
|
72
|
+
return (h("tr", null,
|
|
73
|
+
h("td", null,
|
|
74
|
+
h("sl-skeleton", null))));
|
|
75
|
+
}))));
|
|
76
|
+
}
|
|
63
77
|
if (!states.hasLeaders)
|
|
64
78
|
return elements.empty;
|
|
65
79
|
let userSeenFlag = false;
|
|
66
|
-
|
|
80
|
+
const getUsersName = (user) => {
|
|
81
|
+
if (!user.firstName && !user.lastInitial)
|
|
82
|
+
return styles.anonymousUser;
|
|
83
|
+
const { firstName, lastInitial } = user;
|
|
84
|
+
if (firstName && lastInitial)
|
|
85
|
+
return `${firstName} ${lastInitial}`;
|
|
86
|
+
if (firstName || lastInitial)
|
|
87
|
+
return firstName || lastInitial;
|
|
88
|
+
return styles.anonymousUser;
|
|
89
|
+
};
|
|
90
|
+
const getRankCellText = (userRank, isViewingUsersRow) => {
|
|
91
|
+
if (!userRank) {
|
|
92
|
+
return styles.hideNames ? `${styles.viewingUserText}` : "-";
|
|
93
|
+
}
|
|
94
|
+
const viewingUserText = ` - ${styles.viewingUserText}`;
|
|
95
|
+
return styles.rankSuffix
|
|
96
|
+
? intl.formatMessage({
|
|
97
|
+
id: "rank",
|
|
98
|
+
defaultMessage: styles.rankSuffix,
|
|
99
|
+
}, {
|
|
100
|
+
rank: userRank,
|
|
101
|
+
}) + `${isViewingUsersRow && styles.hideNames ? viewingUserText : ""}`
|
|
102
|
+
: `${userRank} ${isViewingUsersRow && styles.hideNames ? viewingUserText : ""}`;
|
|
103
|
+
};
|
|
104
|
+
return (h("div", { class: sheet.classes.Leaderboard, part: "sqm-base", style: { width: styles.width || "100%" } },
|
|
67
105
|
h("style", { type: "text/css" },
|
|
68
106
|
styleString,
|
|
69
107
|
vanillaStyle),
|
|
70
|
-
h("div", null, "Leaderboards"),
|
|
71
108
|
h("table", { part: "sqm-table" },
|
|
72
109
|
h("tr", null,
|
|
73
|
-
styles.showRank && h("th", { class:
|
|
74
|
-
h("th", { class: "User" }, styles.usersheading),
|
|
110
|
+
styles.showRank && (h("th", { class: `Rank ${styles.hideNames ? "fullWidth" : ""}` }, styles.rankheading)),
|
|
111
|
+
!styles.hideNames && h("th", { class: "User" }, styles.usersheading),
|
|
75
112
|
h("th", { class: "Score" }, styles.statsheading)), (_a = data.leaderboard) === null || _a === void 0 ? void 0 :
|
|
76
113
|
_a.map((user) => {
|
|
77
114
|
var _a, _b;
|
|
78
115
|
if (user.rowNumber === ((_a = data.viewerRank) === null || _a === void 0 ? void 0 : _a.rowNumber))
|
|
79
116
|
userSeenFlag = true;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
styles.showRank && h("td", { class: "Rank" }, user.rank),
|
|
85
|
-
h("td", { class: "User" }, user.firstName && user.lastInitial
|
|
86
|
-
? user.firstName + " " + user.lastInitial
|
|
87
|
-
: user.firstName || user.lastInitial
|
|
88
|
-
? user.firstName || user.lastInitial
|
|
89
|
-
: styles.anonymousUser),
|
|
117
|
+
const isViewingUsersRow = !styles.hideViewer && user.rowNumber === ((_b = data.viewerRank) === null || _b === void 0 ? void 0 : _b.rowNumber);
|
|
118
|
+
return (h("tr", { class: isViewingUsersRow ? "highlight" : "" },
|
|
119
|
+
styles.showRank && (h("td", { class: "Rank" }, getRankCellText(user.rank, isViewingUsersRow))),
|
|
120
|
+
!styles.hideNames && h("td", { class: "User" }, getUsersName(user)),
|
|
90
121
|
h("td", { class: "Score" }, user.textValue)));
|
|
91
122
|
}),
|
|
92
123
|
!userSeenFlag && !styles.hideViewer && (h("tr", null,
|
|
93
124
|
h("td", { colSpan: 100, class: "ellipses" },
|
|
94
125
|
h("sl-icon", { name: "three-dots", style: { verticalAlign: "middle" } })))),
|
|
95
126
|
!userSeenFlag && !styles.hideViewer && (h("tr", { class: "highlight" },
|
|
96
|
-
styles.showRank && (h("td", { class: "Rank" }, ((_b = data.viewerRank) === null || _b === void 0 ? void 0 : _b.rank
|
|
97
|
-
h("td", { class: "User" }, (
|
|
98
|
-
|
|
99
|
-
" " + ((_f = data.viewerRank) === null || _f === void 0 ? void 0 : _f.lastInitial)
|
|
100
|
-
: ((_g = data.viewerRank) === null || _g === void 0 ? void 0 : _g.firstName) || ((_h = data.viewerRank) === null || _h === void 0 ? void 0 : _h.lastInitial)
|
|
101
|
-
? ((_j = data.viewerRank) === null || _j === void 0 ? void 0 : _j.firstName) || ((_k = data.viewerRank) === null || _k === void 0 ? void 0 : _k.lastInitial)
|
|
102
|
-
: styles.anonymousUser),
|
|
103
|
-
h("td", { class: "Score" }, ((_l = data.viewerRank) === null || _l === void 0 ? void 0 : _l.textValue) || "0"))))));
|
|
127
|
+
styles.showRank && (h("td", { class: "Rank" }, getRankCellText((_b = data.viewerRank) === null || _b === void 0 ? void 0 : _b.rank, true))),
|
|
128
|
+
!styles.hideNames && (h("td", { class: "User" }, getUsersName(data.viewerRank || {}))),
|
|
129
|
+
h("td", { class: "Score" }, ((_c = data.viewerRank) === null || _c === void 0 ? void 0 : _c.textValue) || "0"))))));
|
|
104
130
|
}
|
|
@@ -10,13 +10,20 @@ import { useLeaderboard } from "./useLeaderboard";
|
|
|
10
10
|
* @slots [{"name":"empty", "title":"Empty State"}]
|
|
11
11
|
* @requiredFeatures ["LEADERBOARDS"]
|
|
12
12
|
* @exampleGroup Leaderboard
|
|
13
|
-
* @example Referral Started Leaderboard - <sqm-leaderboard usersheading="Referrer" statsheading="Referrals" rank-type="rank" leaderboard-type="topStartedReferrers" rankheading="Rank" show-rank="true"><sqm-empty empty-state-image="https://res.cloudinary.com/saasquatch/image/upload/v1644360953/squatch-assets/empty_leaderboard2.png" empty-state-header="View your rank in the leaderboard" empty-state-text="Be the first to refer a friend and reach the top of the leaderboard" ></sqm-empty></sqm-leaderboard>
|
|
14
|
-
* @example Referral Converted Leaderboard - <sqm-leaderboard usersheading="Referrer" statsheading="Referrals" rank-type="rank" leaderboard-type="topConvertedReferrers" rankheading="Rank" show-rank="true"><sqm-empty empty-state-image="https://res.cloudinary.com/saasquatch/image/upload/v1644360953/squatch-assets/empty_leaderboard2.png" empty-state-header="View your rank in the leaderboard" empty-state-text="Be the first to refer a friend and reach the top of the leaderboard" ></sqm-empty></sqm-leaderboard>
|
|
15
|
-
* @example Points Earned Leaderboard - <sqm-leaderboard usersheading="Name" statsheading="Points" rank-type="rank" leaderboard-type="topPointEarners" rankheading="Rank" show-rank="true"><sqm-empty empty-state-image="https://res.cloudinary.com/saasquatch/image/upload/v1644360953/squatch-assets/empty_leaderboard2.png" empty-state-header="View your rank in the leaderboard" empty-state-text="Be the first to refer a friend and reach the top of the leaderboard" ></sqm-empty></sqm-leaderboard>
|
|
13
|
+
* @example Referral Started Leaderboard - <sqm-leaderboard usersheading="Referrer" rank-suffix="{rank, selectordinal, one {#st} two {#nd} few {#rd} other {#th}}" statsheading="Referrals" rank-type="rank" leaderboard-type="topStartedReferrers" rankheading="Rank" show-rank="true"><sqm-empty empty-state-image="https://res.cloudinary.com/saasquatch/image/upload/v1644360953/squatch-assets/empty_leaderboard2.png" empty-state-header="View your rank in the leaderboard" empty-state-text="Be the first to refer a friend and reach the top of the leaderboard" ></sqm-empty></sqm-leaderboard>
|
|
14
|
+
* @example Referral Converted Leaderboard - <sqm-leaderboard usersheading="Referrer" rank-suffix="{rank, selectordinal, one {#st} two {#nd} few {#rd} other {#th}}" statsheading="Referrals" rank-type="rank" leaderboard-type="topConvertedReferrers" rankheading="Rank" show-rank="true"><sqm-empty empty-state-image="https://res.cloudinary.com/saasquatch/image/upload/v1644360953/squatch-assets/empty_leaderboard2.png" empty-state-header="View your rank in the leaderboard" empty-state-text="Be the first to refer a friend and reach the top of the leaderboard" ></sqm-empty></sqm-leaderboard>
|
|
15
|
+
* @example Points Earned Leaderboard - <sqm-leaderboard usersheading="Name" rank-suffix="{rank, selectordinal, one {#st} two {#nd} few {#rd} other {#th}}" statsheading="Points" rank-type="rank" leaderboard-type="topPointEarners" rankheading="Rank" show-rank="true"><sqm-empty empty-state-image="https://res.cloudinary.com/saasquatch/image/upload/v1644360953/squatch-assets/empty_leaderboard2.png" empty-state-header="View your rank in the leaderboard" empty-state-text="Be the first to refer a friend and reach the top of the leaderboard" ></sqm-empty></sqm-leaderboard>
|
|
16
|
+
* @example Anonymous Leaderboard - <div style="display: flex; align-items: flex-start; justify-content: center; width: 100%; gap: 50px;"><div style="display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; max-width: 30%;"><sqm-image width="70%" alignment="center" image-url="https://res.cloudinary.com/saasquatch-staging/image/upload/v1729728469/Leaderboard_image_z87lsm.png"></sqm-image><h2 style="margin: auto;">Top Performers</h2><p style="margin: 0; text-align: center;">The leaderboard highlights the top performers in real-time. Stay motivated, stay competitive!</p></div><sqm-leaderboard width="300px" usersheading="Referrer" rank-suffix="{rank, selectordinal, one {#st} two {#nd} few {#rd} other {#th}}" statsheading="Referrals" rank-type="rank" leaderboard-type="topStartedReferrers" rankheading="Rank" show-rank="true" hide-names="true" hide-viewer="true"><sqm-empty empty-state-image="https://res.cloudinary.com/saasquatch/image/upload/v1644360953/squatch-assets/empty_leaderboard2.png" empty-state-header="View your rank in the leaderboard" empty-state-text="Be the first to refer a friend and reach the top of the leaderboard"></sqm-empty></sqm-leaderboard></div>
|
|
16
17
|
* @featureTooltip <div>Motivate your participants by gamifying your program. Contact <a href="mailto:saasquatch-support%40impact.com?subject=Next steps for Leaderboards feature&body=Hi Support Team, %0D%0A%0D%0A I am interested in learning more about how Leaderboards can support the growth of our referral program. Please connect me with a program strategy manager to discuss this feature further, and determine the next steps.%0D%0A%0D%0A%0D%0AThank you,%0D%0A[Add your name here]">Support</a> to upgrade your plan and add a leaderboard.</div>
|
|
17
18
|
*/
|
|
18
19
|
export class Leaderboard {
|
|
19
20
|
constructor() {
|
|
21
|
+
/**
|
|
22
|
+
* Restrict the width of the leaderboard (Can be a pixel value or a percentage i.e. "500px", "33%", etc.)
|
|
23
|
+
*
|
|
24
|
+
* @uiName Width
|
|
25
|
+
*/
|
|
26
|
+
this.width = "100%";
|
|
20
27
|
/**
|
|
21
28
|
* Hide the viewer's leaderboard row if not in the top results.
|
|
22
29
|
*
|
|
@@ -25,12 +32,16 @@ export class Leaderboard {
|
|
|
25
32
|
*/
|
|
26
33
|
this.hideViewer = false;
|
|
27
34
|
/**
|
|
28
|
-
*
|
|
35
|
+
* @uiName Viewing user text
|
|
36
|
+
*/
|
|
37
|
+
this.viewingUserText = "You";
|
|
38
|
+
/**
|
|
39
|
+
* Hide the Names of users to protect personal identifiable information
|
|
29
40
|
*
|
|
30
|
-
* @uiName Hide
|
|
41
|
+
* @uiName Hide users names
|
|
31
42
|
* @default
|
|
32
43
|
*/
|
|
33
|
-
this.
|
|
44
|
+
this.hideNames = false;
|
|
34
45
|
/**
|
|
35
46
|
* Title displayed for users without names
|
|
36
47
|
* @uiName Unknown user text
|
|
@@ -50,8 +61,6 @@ export class Leaderboard {
|
|
|
50
61
|
render() {
|
|
51
62
|
const props = {
|
|
52
63
|
empty: h(EmptySlot, null),
|
|
53
|
-
essentials: h(EssentialsSlot, null),
|
|
54
|
-
loadingstate: h(LoadingSlot, null),
|
|
55
64
|
usersheading: this.usersheading,
|
|
56
65
|
statsheading: this.statsheading,
|
|
57
66
|
rankheading: this.rankheading,
|
|
@@ -62,8 +71,11 @@ export class Leaderboard {
|
|
|
62
71
|
anonymousUser: this.anonymousUser,
|
|
63
72
|
interval: this.interval,
|
|
64
73
|
hideViewer: this.hideViewer,
|
|
74
|
+
viewingUserText: this.viewingUserText,
|
|
75
|
+
hideNames: this.hideNames,
|
|
65
76
|
showRank: this.showRank,
|
|
66
|
-
|
|
77
|
+
rankSuffix: this.rankSuffix,
|
|
78
|
+
width: this.width,
|
|
67
79
|
};
|
|
68
80
|
const demoProps = { ...props, demoData: this.demoData };
|
|
69
81
|
const viewprops = isDemo()
|
|
@@ -177,6 +189,47 @@ export class Leaderboard {
|
|
|
177
189
|
"attribute": "show-rank",
|
|
178
190
|
"reflect": false
|
|
179
191
|
},
|
|
192
|
+
"width": {
|
|
193
|
+
"type": "string",
|
|
194
|
+
"mutable": false,
|
|
195
|
+
"complexType": {
|
|
196
|
+
"original": "string",
|
|
197
|
+
"resolved": "string",
|
|
198
|
+
"references": {}
|
|
199
|
+
},
|
|
200
|
+
"required": false,
|
|
201
|
+
"optional": false,
|
|
202
|
+
"docs": {
|
|
203
|
+
"tags": [{
|
|
204
|
+
"text": "Width",
|
|
205
|
+
"name": "uiName"
|
|
206
|
+
}],
|
|
207
|
+
"text": "Restrict the width of the leaderboard (Can be a pixel value or a percentage i.e. \"500px\", \"33%\", etc.)"
|
|
208
|
+
},
|
|
209
|
+
"attribute": "width",
|
|
210
|
+
"reflect": false,
|
|
211
|
+
"defaultValue": "\"100%\""
|
|
212
|
+
},
|
|
213
|
+
"rankSuffix": {
|
|
214
|
+
"type": "string",
|
|
215
|
+
"mutable": false,
|
|
216
|
+
"complexType": {
|
|
217
|
+
"original": "string",
|
|
218
|
+
"resolved": "string",
|
|
219
|
+
"references": {}
|
|
220
|
+
},
|
|
221
|
+
"required": false,
|
|
222
|
+
"optional": false,
|
|
223
|
+
"docs": {
|
|
224
|
+
"tags": [{
|
|
225
|
+
"text": "Rank Suffix",
|
|
226
|
+
"name": "uiName"
|
|
227
|
+
}],
|
|
228
|
+
"text": "A JSONata string that formats the rank with the appropriate ordinal suffix (e.g., \"st\" for 1st, \"nd\" for 2nd, \"rd\" for 3rd, and \"th\" for all others)."
|
|
229
|
+
},
|
|
230
|
+
"attribute": "rank-suffix",
|
|
231
|
+
"reflect": false
|
|
232
|
+
},
|
|
180
233
|
"hideViewer": {
|
|
181
234
|
"type": "boolean",
|
|
182
235
|
"mutable": false,
|
|
@@ -201,7 +254,28 @@ export class Leaderboard {
|
|
|
201
254
|
"reflect": false,
|
|
202
255
|
"defaultValue": "false"
|
|
203
256
|
},
|
|
204
|
-
"
|
|
257
|
+
"viewingUserText": {
|
|
258
|
+
"type": "string",
|
|
259
|
+
"mutable": false,
|
|
260
|
+
"complexType": {
|
|
261
|
+
"original": "string",
|
|
262
|
+
"resolved": "string",
|
|
263
|
+
"references": {}
|
|
264
|
+
},
|
|
265
|
+
"required": false,
|
|
266
|
+
"optional": false,
|
|
267
|
+
"docs": {
|
|
268
|
+
"tags": [{
|
|
269
|
+
"text": "Viewing user text",
|
|
270
|
+
"name": "uiName"
|
|
271
|
+
}],
|
|
272
|
+
"text": ""
|
|
273
|
+
},
|
|
274
|
+
"attribute": "viewing-user-text",
|
|
275
|
+
"reflect": false,
|
|
276
|
+
"defaultValue": "\"You\""
|
|
277
|
+
},
|
|
278
|
+
"hideNames": {
|
|
205
279
|
"type": "boolean",
|
|
206
280
|
"mutable": false,
|
|
207
281
|
"complexType": {
|
|
@@ -210,18 +284,18 @@ export class Leaderboard {
|
|
|
210
284
|
"references": {}
|
|
211
285
|
},
|
|
212
286
|
"required": false,
|
|
213
|
-
"optional":
|
|
287
|
+
"optional": false,
|
|
214
288
|
"docs": {
|
|
215
289
|
"tags": [{
|
|
216
|
-
"text": "Hide
|
|
290
|
+
"text": "Hide users names",
|
|
217
291
|
"name": "uiName"
|
|
218
292
|
}, {
|
|
219
293
|
"text": undefined,
|
|
220
294
|
"name": "default"
|
|
221
295
|
}],
|
|
222
|
-
"text": "
|
|
296
|
+
"text": "Hide the Names of users to protect personal identifiable information"
|
|
223
297
|
},
|
|
224
|
-
"attribute": "
|
|
298
|
+
"attribute": "hide-names",
|
|
225
299
|
"reflect": false,
|
|
226
300
|
"defaultValue": "false"
|
|
227
301
|
},
|
|
@@ -359,7 +433,7 @@ export class Leaderboard {
|
|
|
359
433
|
"mutable": false,
|
|
360
434
|
"complexType": {
|
|
361
435
|
"original": "DemoData<LeaderboardViewProps>",
|
|
362
|
-
"resolved": "{ states?: { loading: boolean; hasLeaders: boolean; isEssentials?: boolean; styles: { usersheading: string; statsheading: string; rankheading?: string; showRank?: boolean; hideViewer?: boolean; anonymousUser?: string; }; }; data?: { rankType: string; leaderboard: { textValue: string; rank: number; firstName: string; lastInitial: string; rowNumber: number; }[]; viewerRank?: { textValue: string; rank: number; firstName
|
|
436
|
+
"resolved": "{ states?: { loading: boolean; hasLeaders: boolean; isEssentials?: boolean; styles: { usersheading: string; statsheading: string; rankheading?: string; showRank?: boolean; hideViewer?: boolean; viewingUserText?: string; hideNames?: boolean; anonymousUser?: string; rankSuffix?: string; width?: string; }; }; data?: { rankType: string; leaderboard: { textValue: string; rank: number; firstName: string; lastInitial: string; rowNumber: number; }[]; viewerRank?: { textValue: string; rank: number; firstName?: string; lastInitial?: string; rowNumber: number; }; }; elements?: { empty: VNode; }; }",
|
|
363
437
|
"references": {
|
|
364
438
|
"DemoData": {
|
|
365
439
|
"location": "import",
|
|
@@ -393,18 +467,6 @@ function EmptySlot() {
|
|
|
393
467
|
return (h("slot", { name: "empty" },
|
|
394
468
|
h("sqm-empty", { "empty-state-image": "https://res.cloudinary.com/saasquatch/image/upload/v1644360953/squatch-assets/empty_leaderboard2.png", "empty-state-header": "View your rank in the leaderboard", "empty-state-text": "Be the first to refer a friend and reach the top of the leaderboard" })));
|
|
395
469
|
}
|
|
396
|
-
function EssentialsSlot() {
|
|
397
|
-
return (h("slot", { name: "essentials" },
|
|
398
|
-
h("sqm-empty", { "empty-state-image": "https://res.cloudinary.com/saasquatch/image/upload/v1715360191/squatch-assets/Leaderboard_Not_Available.svg", "empty-state-header": "Leaderboards aren\u2019t available on your plan", "empty-state-text": "Contact {supportText} to upgrade your plan and start leveraging gamification in your program.", "support-text": "Support", "missing-feature": "Leaderboards" })));
|
|
399
|
-
}
|
|
400
|
-
function LoadingSlot() {
|
|
401
|
-
return (h("slot", { name: "loading" },
|
|
402
|
-
h("table", null, [...Array(10)].map(() => {
|
|
403
|
-
return (h("tr", null,
|
|
404
|
-
h("td", null,
|
|
405
|
-
h("sl-skeleton", null))));
|
|
406
|
-
}))));
|
|
407
|
-
}
|
|
408
470
|
function useLeaderboardDemo(props) {
|
|
409
471
|
var _a, _b;
|
|
410
472
|
const data = ((_b = (_a = props.demoData) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.leaderboard) || [
|
|
@@ -460,6 +522,10 @@ function useLeaderboardDemo(props) {
|
|
|
460
522
|
: "Anonymous User",
|
|
461
523
|
showRank: props.showRank,
|
|
462
524
|
hideViewer: props.hideViewer,
|
|
525
|
+
viewingUserText: props.viewingUserText,
|
|
526
|
+
hideNames: props.hideNames,
|
|
527
|
+
rankSuffix: props.rankSuffix,
|
|
528
|
+
width: props.width,
|
|
463
529
|
},
|
|
464
530
|
},
|
|
465
531
|
data: {
|
|
@@ -468,8 +534,6 @@ function useLeaderboardDemo(props) {
|
|
|
468
534
|
},
|
|
469
535
|
elements: {
|
|
470
536
|
empty: h(EmptySlot, null),
|
|
471
|
-
essentials: h(EssentialsSlot, null),
|
|
472
|
-
loadingstate: h(LoadingSlot, null),
|
|
473
537
|
},
|
|
474
538
|
}, props.demoData || {}, { arrayMerge: (_, a) => a });
|
|
475
539
|
}
|
|
@@ -23,6 +23,26 @@ const GET_LEADERBOARD = gql `
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
`;
|
|
26
|
+
const GET_LEADERBOARD_WITHOUT_NAMES = gql `
|
|
27
|
+
query (
|
|
28
|
+
$type: String!
|
|
29
|
+
$filter: UserLeaderboardFilterInput
|
|
30
|
+
$locale: RSLocale
|
|
31
|
+
$limit: Int!
|
|
32
|
+
) {
|
|
33
|
+
userLeaderboard(type: $type, filter: $filter) {
|
|
34
|
+
dateModified
|
|
35
|
+
rows(limit: $limit) {
|
|
36
|
+
textValue(locale: $locale)
|
|
37
|
+
rank {
|
|
38
|
+
rank
|
|
39
|
+
denseRank
|
|
40
|
+
rowNumber
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
26
46
|
const GET_RANK = gql `
|
|
27
47
|
query (
|
|
28
48
|
$type: String!
|
|
@@ -43,6 +63,24 @@ const GET_RANK = gql `
|
|
|
43
63
|
}
|
|
44
64
|
}
|
|
45
65
|
`;
|
|
66
|
+
const GET_RANK_WITHOUT_NAMES = gql `
|
|
67
|
+
query (
|
|
68
|
+
$type: String!
|
|
69
|
+
$filter: UserLeaderboardFilterInput
|
|
70
|
+
$locale: RSLocale
|
|
71
|
+
) {
|
|
72
|
+
viewer {
|
|
73
|
+
... on User {
|
|
74
|
+
leaderboardRank(type: $type, filter: $filter) {
|
|
75
|
+
textValue(locale: $locale)
|
|
76
|
+
rank
|
|
77
|
+
denseRank
|
|
78
|
+
rowNumber
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
46
84
|
export function useLeaderboard(props) {
|
|
47
85
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
48
86
|
const programIdContext = useProgramId();
|
|
@@ -68,8 +106,8 @@ export function useLeaderboard(props) {
|
|
|
68
106
|
if (props.maxRows > 0) {
|
|
69
107
|
variables["limit"] = props.maxRows;
|
|
70
108
|
}
|
|
71
|
-
const { data: leaderboardData, loading: loadingLeaderboard, errors: leaderboardErrors, } = useQuery(GET_LEADERBOARD, variables, !(user === null || user === void 0 ? void 0 : user.jwt), { batch: false });
|
|
72
|
-
const { data: rankData } = useQuery(GET_RANK, variables, !(user === null || user === void 0 ? void 0 : user.jwt));
|
|
109
|
+
const { data: leaderboardData, loading: loadingLeaderboard, errors: leaderboardErrors, } = useQuery(props.hideNames ? GET_LEADERBOARD_WITHOUT_NAMES : GET_LEADERBOARD, variables, !(user === null || user === void 0 ? void 0 : user.jwt), { batch: false });
|
|
110
|
+
const { data: rankData } = useQuery(props.hideNames ? GET_RANK_WITHOUT_NAMES : GET_RANK, variables, !(user === null || user === void 0 ? void 0 : user.jwt));
|
|
73
111
|
const leaderboardRows = (_b = leaderboardData === null || leaderboardData === void 0 ? void 0 : leaderboardData.userLeaderboard) === null || _b === void 0 ? void 0 : _b.rows;
|
|
74
112
|
const flattenedLeaderboard = getFlattenedLeaderboard(leaderboardRows);
|
|
75
113
|
const sortedLeaderboard = flattenedLeaderboard === null || flattenedLeaderboard === void 0 ? void 0 : flattenedLeaderboard.sort(function (a, b) {
|
|
@@ -113,8 +151,6 @@ export function useLeaderboard(props) {
|
|
|
113
151
|
},
|
|
114
152
|
elements: {
|
|
115
153
|
empty: props.empty,
|
|
116
|
-
essentials: props.essentials,
|
|
117
|
-
loadingstate: props.loadingstate,
|
|
118
154
|
},
|
|
119
155
|
};
|
|
120
156
|
}
|