@saasquatch/mint-components 1.10.2-7 → 1.10.2-9
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-bfb7992d.js → ShadowViewAddon-721bb748.js} +9 -14
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mint-components.cjs.js +1 -1
- package/dist/cjs/sqm-big-stat_38.cjs.entry.js +4 -62
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +3 -67
- package/dist/collection/components/sqm-leaderboard/Leaderboard.stories.js +0 -62
- package/dist/collection/components/sqm-leaderboard/sqm-leaderboard-view.js +9 -15
- package/dist/collection/components/sqm-leaderboard/sqm-leaderboard.js +3 -90
- package/dist/collection/components/sqm-leaderboard/useLeaderboard.js +2 -40
- package/dist/esm/{ShadowViewAddon-e0a3df6c.js → ShadowViewAddon-31eb5b16.js} +9 -14
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mint-components.js +1 -1
- package/dist/esm/sqm-big-stat_38.entry.js +4 -62
- package/dist/esm/sqm-stencilbook.entry.js +3 -67
- package/dist/esm-es5/ShadowViewAddon-31eb5b16.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-big-stat_38.entry.js +1 -1
- 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-0d39c815.system.entry.js +1 -0
- package/dist/mint-components/p-27bd5535.entry.js +187 -0
- package/dist/mint-components/p-b567780d.system.js +1 -0
- package/dist/mint-components/{p-7a89f528.entry.js → p-bf723ae9.entry.js} +2 -2
- package/dist/mint-components/{p-a15e3807.js → p-d6474614.js} +1 -1
- package/dist/mint-components/p-ed17e637.system.js +1 -1
- package/dist/mint-components/p-f1a1e7f3.system.entry.js +1 -0
- package/dist/types/components/sqm-leaderboard/Leaderboard.stories.d.ts +0 -2
- package/dist/types/components/sqm-leaderboard/sqm-leaderboard-view.d.ts +0 -3
- package/dist/types/components/sqm-leaderboard/sqm-leaderboard.d.ts +1 -17
- package/dist/types/components/sqm-leaderboard/useLeaderboard.d.ts +0 -2
- package/dist/types/components.d.ts +2 -30
- 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-e0a3df6c.js +0 -1
- package/dist/mint-components/p-471f5d95.system.entry.js +0 -1
- package/dist/mint-components/p-aedddb29.system.entry.js +0 -1
- package/dist/mint-components/p-b2507e82.entry.js +0 -223
- package/dist/mint-components/p-ed650f66.system.js +0 -1
|
@@ -373,38 +373,6 @@ export const ReferralLeaderboard = () => {
|
|
|
373
373
|
};
|
|
374
374
|
return h(LeaderboardView, Object.assign({}, props));
|
|
375
375
|
};
|
|
376
|
-
export const ReferralLeaderboardWithMaxWidth = () => {
|
|
377
|
-
const props = {
|
|
378
|
-
states: {
|
|
379
|
-
loading: false,
|
|
380
|
-
hasLeaders: true,
|
|
381
|
-
styles: {
|
|
382
|
-
...defaultStyles,
|
|
383
|
-
rankheading: "Rank",
|
|
384
|
-
usersheading: "User",
|
|
385
|
-
statsheading: "Referrals",
|
|
386
|
-
showRank: false,
|
|
387
|
-
maxWidth: "300px",
|
|
388
|
-
},
|
|
389
|
-
},
|
|
390
|
-
data: {
|
|
391
|
-
rankType: "rowNumber",
|
|
392
|
-
leaderboard: users,
|
|
393
|
-
rowNumber: 10,
|
|
394
|
-
viewerRank: {
|
|
395
|
-
firstName: "Viktor",
|
|
396
|
-
lastInitial: "V",
|
|
397
|
-
textValue: "82",
|
|
398
|
-
rank: 1,
|
|
399
|
-
rowNumber: 1,
|
|
400
|
-
},
|
|
401
|
-
},
|
|
402
|
-
elements: {
|
|
403
|
-
...defaultElements,
|
|
404
|
-
},
|
|
405
|
-
};
|
|
406
|
-
return h(LeaderboardView, Object.assign({}, props));
|
|
407
|
-
};
|
|
408
376
|
export const PointsLeaderboard = () => {
|
|
409
377
|
const props = {
|
|
410
378
|
states: {
|
|
@@ -544,33 +512,3 @@ export const HideViewer = () => {
|
|
|
544
512
|
};
|
|
545
513
|
return h(LeaderboardView, Object.assign({}, props));
|
|
546
514
|
};
|
|
547
|
-
export const HideNames = () => {
|
|
548
|
-
const props = {
|
|
549
|
-
states: {
|
|
550
|
-
loading: false,
|
|
551
|
-
hasLeaders: true,
|
|
552
|
-
rowNumber: 10,
|
|
553
|
-
styles: {
|
|
554
|
-
...defaultStyles,
|
|
555
|
-
showRank: true,
|
|
556
|
-
hideNames: true,
|
|
557
|
-
},
|
|
558
|
-
},
|
|
559
|
-
data: {
|
|
560
|
-
rankType: "rowNumber",
|
|
561
|
-
leaderboard: users,
|
|
562
|
-
rowNumber: 10,
|
|
563
|
-
viewerRank: {
|
|
564
|
-
firstName: "Viktor",
|
|
565
|
-
lastInitial: "V",
|
|
566
|
-
textValue: "82",
|
|
567
|
-
rowNumber: 1,
|
|
568
|
-
rank: 1,
|
|
569
|
-
},
|
|
570
|
-
},
|
|
571
|
-
elements: {
|
|
572
|
-
...defaultElements,
|
|
573
|
-
},
|
|
574
|
-
};
|
|
575
|
-
return h(LeaderboardView, Object.assign({}, props));
|
|
576
|
-
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
2
|
import { createStyleSheet } from "../../styling/JSS";
|
|
3
|
-
import { intl } from "../../global/global";
|
|
4
3
|
const style = {
|
|
5
4
|
Leaderboard: {
|
|
6
5
|
"& table": {
|
|
@@ -40,9 +39,6 @@ const style = {
|
|
|
40
39
|
width: "auto",
|
|
41
40
|
whiteSpace: "nowrap",
|
|
42
41
|
},
|
|
43
|
-
"& .fullWidth": {
|
|
44
|
-
width: "100%",
|
|
45
|
-
},
|
|
46
42
|
},
|
|
47
43
|
};
|
|
48
44
|
const sheet = createStyleSheet(style);
|
|
@@ -67,14 +63,15 @@ export function LeaderboardView(props) {
|
|
|
67
63
|
if (!states.hasLeaders)
|
|
68
64
|
return elements.empty;
|
|
69
65
|
let userSeenFlag = false;
|
|
70
|
-
return (h("div", { class: sheet.classes.Leaderboard, part: "sqm-base"
|
|
66
|
+
return (h("div", { class: sheet.classes.Leaderboard, part: "sqm-base" },
|
|
71
67
|
h("style", { type: "text/css" },
|
|
72
68
|
styleString,
|
|
73
69
|
vanillaStyle),
|
|
70
|
+
h("div", null, "Leaderboards"),
|
|
74
71
|
h("table", { part: "sqm-table" },
|
|
75
72
|
h("tr", null,
|
|
76
|
-
styles.showRank &&
|
|
77
|
-
|
|
73
|
+
styles.showRank && h("th", { class: "Rank" }, styles.rankheading),
|
|
74
|
+
h("th", { class: "User" }, styles.usersheading),
|
|
78
75
|
h("th", { class: "Score" }, styles.statsheading)), (_a = data.leaderboard) === null || _a === void 0 ? void 0 :
|
|
79
76
|
_a.map((user) => {
|
|
80
77
|
var _a, _b;
|
|
@@ -84,15 +81,12 @@ export function LeaderboardView(props) {
|
|
|
84
81
|
user.rowNumber === ((_b = data.viewerRank) === null || _b === void 0 ? void 0 : _b.rowNumber)
|
|
85
82
|
? "highlight"
|
|
86
83
|
: "" },
|
|
87
|
-
styles.showRank &&
|
|
88
|
-
|
|
89
|
-
defaultMessage: styles.rankSuffix,
|
|
90
|
-
}, { rank: user.rank }))),
|
|
91
|
-
!styles.hideNames && (h("td", { class: "User" }, user.firstName && user.lastInitial
|
|
84
|
+
styles.showRank && h("td", { class: "Rank" }, user.rank),
|
|
85
|
+
h("td", { class: "User" }, user.firstName && user.lastInitial
|
|
92
86
|
? user.firstName + " " + user.lastInitial
|
|
93
87
|
: user.firstName || user.lastInitial
|
|
94
88
|
? user.firstName || user.lastInitial
|
|
95
|
-
: styles.anonymousUser)
|
|
89
|
+
: styles.anonymousUser),
|
|
96
90
|
h("td", { class: "Score" }, user.textValue)));
|
|
97
91
|
}),
|
|
98
92
|
!userSeenFlag && !styles.hideViewer && (h("tr", null,
|
|
@@ -100,11 +94,11 @@ export function LeaderboardView(props) {
|
|
|
100
94
|
h("sl-icon", { name: "three-dots", style: { verticalAlign: "middle" } })))),
|
|
101
95
|
!userSeenFlag && !styles.hideViewer && (h("tr", { class: "highlight" },
|
|
102
96
|
styles.showRank && (h("td", { class: "Rank" }, ((_b = data.viewerRank) === null || _b === void 0 ? void 0 : _b.rank) || "-")),
|
|
103
|
-
|
|
97
|
+
h("td", { class: "User" }, ((_c = data.viewerRank) === null || _c === void 0 ? void 0 : _c.firstName) && ((_d = data.viewerRank) === null || _d === void 0 ? void 0 : _d.lastInitial)
|
|
104
98
|
? ((_e = data.viewerRank) === null || _e === void 0 ? void 0 : _e.firstName) +
|
|
105
99
|
" " + ((_f = data.viewerRank) === null || _f === void 0 ? void 0 : _f.lastInitial)
|
|
106
100
|
: ((_g = data.viewerRank) === null || _g === void 0 ? void 0 : _g.firstName) || ((_h = data.viewerRank) === null || _h === void 0 ? void 0 : _h.lastInitial)
|
|
107
101
|
? ((_j = data.viewerRank) === null || _j === void 0 ? void 0 : _j.firstName) || ((_k = data.viewerRank) === null || _k === void 0 ? void 0 : _k.lastInitial)
|
|
108
|
-
: styles.anonymousUser)
|
|
102
|
+
: styles.anonymousUser),
|
|
109
103
|
h("td", { class: "Score" }, ((_l = data.viewerRank) === null || _l === void 0 ? void 0 : _l.textValue) || "0"))))));
|
|
110
104
|
}
|
|
@@ -13,19 +13,10 @@ import { useLeaderboard } from "./useLeaderboard";
|
|
|
13
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
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
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>
|
|
16
|
-
* @example Anonymous Leaderboard - <sqm-portal-container direction="row" display="flex" gap="large"><sqm-empty empty-state-image="https://res.cloudinary.com/saasquatch-staging/image/upload/v1729728469/Leaderboard_image_z87lsm.png" empty-state-header="Top Performers" empty-state-text="The leaderboard highlights the top performers in real-time. Stay motivated, stay competitive!"></sqm-empty><sqm-leaderboard usersheading="Referrer" statsheading="Referrals" rank-type="rank" leaderboard-type="topStartedReferrers" rankheading="Rank" show-rank="true" hide-names="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></sqm-portal-container>
|
|
17
16
|
* @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>
|
|
18
17
|
*/
|
|
19
18
|
export class Leaderboard {
|
|
20
19
|
constructor() {
|
|
21
|
-
/**
|
|
22
|
-
* @uiName Place text
|
|
23
|
-
*/
|
|
24
|
-
this.maxWidth = "100%";
|
|
25
|
-
/**
|
|
26
|
-
* @uiName Rank Suffix
|
|
27
|
-
*/
|
|
28
|
-
this.rankSuffix = "{rank, selectordinal, one {#st} two {#nd} few {#rd} other {#th}}";
|
|
29
20
|
/**
|
|
30
21
|
* Hide the viewer's leaderboard row if not in the top results.
|
|
31
22
|
*
|
|
@@ -33,17 +24,10 @@ export class Leaderboard {
|
|
|
33
24
|
* @default
|
|
34
25
|
*/
|
|
35
26
|
this.hideViewer = false;
|
|
36
|
-
/**
|
|
37
|
-
* Hide the Names of users to protect personal identifiable information
|
|
38
|
-
*
|
|
39
|
-
* @uiName Hide users names
|
|
40
|
-
* @default
|
|
41
|
-
*/
|
|
42
|
-
this.hideNames = false;
|
|
43
27
|
/**
|
|
44
28
|
* Hides the leaderboard if user is on Essentials plan
|
|
45
29
|
*
|
|
46
|
-
* @uiName Hide
|
|
30
|
+
* @uiName Hide viewing user
|
|
47
31
|
* @default
|
|
48
32
|
*/
|
|
49
33
|
this.isEssentials = false;
|
|
@@ -78,11 +62,8 @@ export class Leaderboard {
|
|
|
78
62
|
anonymousUser: this.anonymousUser,
|
|
79
63
|
interval: this.interval,
|
|
80
64
|
hideViewer: this.hideViewer,
|
|
81
|
-
hideNames: this.hideNames,
|
|
82
65
|
showRank: this.showRank,
|
|
83
66
|
isEssentials: this.isEssentials,
|
|
84
|
-
rankSuffix: this.rankSuffix,
|
|
85
|
-
maxWidth: this.maxWidth,
|
|
86
67
|
};
|
|
87
68
|
const demoProps = { ...props, demoData: this.demoData };
|
|
88
69
|
const viewprops = isDemo()
|
|
@@ -196,48 +177,6 @@ export class Leaderboard {
|
|
|
196
177
|
"attribute": "show-rank",
|
|
197
178
|
"reflect": false
|
|
198
179
|
},
|
|
199
|
-
"maxWidth": {
|
|
200
|
-
"type": "string",
|
|
201
|
-
"mutable": false,
|
|
202
|
-
"complexType": {
|
|
203
|
-
"original": "string",
|
|
204
|
-
"resolved": "string",
|
|
205
|
-
"references": {}
|
|
206
|
-
},
|
|
207
|
-
"required": false,
|
|
208
|
-
"optional": false,
|
|
209
|
-
"docs": {
|
|
210
|
-
"tags": [{
|
|
211
|
-
"text": "Place text",
|
|
212
|
-
"name": "uiName"
|
|
213
|
-
}],
|
|
214
|
-
"text": ""
|
|
215
|
-
},
|
|
216
|
-
"attribute": "max-width",
|
|
217
|
-
"reflect": false,
|
|
218
|
-
"defaultValue": "\"100%\""
|
|
219
|
-
},
|
|
220
|
-
"rankSuffix": {
|
|
221
|
-
"type": "string",
|
|
222
|
-
"mutable": false,
|
|
223
|
-
"complexType": {
|
|
224
|
-
"original": "string",
|
|
225
|
-
"resolved": "string",
|
|
226
|
-
"references": {}
|
|
227
|
-
},
|
|
228
|
-
"required": false,
|
|
229
|
-
"optional": false,
|
|
230
|
-
"docs": {
|
|
231
|
-
"tags": [{
|
|
232
|
-
"text": "Rank Suffix",
|
|
233
|
-
"name": "uiName"
|
|
234
|
-
}],
|
|
235
|
-
"text": ""
|
|
236
|
-
},
|
|
237
|
-
"attribute": "rank-suffix",
|
|
238
|
-
"reflect": false,
|
|
239
|
-
"defaultValue": "\"{rank, selectordinal, one {#st} two {#nd} few {#rd} other {#th}}\""
|
|
240
|
-
},
|
|
241
180
|
"hideViewer": {
|
|
242
181
|
"type": "boolean",
|
|
243
182
|
"mutable": false,
|
|
@@ -262,30 +201,6 @@ export class Leaderboard {
|
|
|
262
201
|
"reflect": false,
|
|
263
202
|
"defaultValue": "false"
|
|
264
203
|
},
|
|
265
|
-
"hideNames": {
|
|
266
|
-
"type": "boolean",
|
|
267
|
-
"mutable": false,
|
|
268
|
-
"complexType": {
|
|
269
|
-
"original": "boolean",
|
|
270
|
-
"resolved": "boolean",
|
|
271
|
-
"references": {}
|
|
272
|
-
},
|
|
273
|
-
"required": false,
|
|
274
|
-
"optional": false,
|
|
275
|
-
"docs": {
|
|
276
|
-
"tags": [{
|
|
277
|
-
"text": "Hide users names",
|
|
278
|
-
"name": "uiName"
|
|
279
|
-
}, {
|
|
280
|
-
"text": undefined,
|
|
281
|
-
"name": "default"
|
|
282
|
-
}],
|
|
283
|
-
"text": "Hide the Names of users to protect personal identifiable information"
|
|
284
|
-
},
|
|
285
|
-
"attribute": "hide-names",
|
|
286
|
-
"reflect": false,
|
|
287
|
-
"defaultValue": "false"
|
|
288
|
-
},
|
|
289
204
|
"isEssentials": {
|
|
290
205
|
"type": "boolean",
|
|
291
206
|
"mutable": false,
|
|
@@ -298,7 +213,7 @@ export class Leaderboard {
|
|
|
298
213
|
"optional": true,
|
|
299
214
|
"docs": {
|
|
300
215
|
"tags": [{
|
|
301
|
-
"text": "Hide
|
|
216
|
+
"text": "Hide viewing user",
|
|
302
217
|
"name": "uiName"
|
|
303
218
|
}, {
|
|
304
219
|
"text": undefined,
|
|
@@ -444,7 +359,7 @@ export class Leaderboard {
|
|
|
444
359
|
"mutable": false,
|
|
445
360
|
"complexType": {
|
|
446
361
|
"original": "DemoData<LeaderboardViewProps>",
|
|
447
|
-
"resolved": "{ states?: { loading: boolean; hasLeaders: boolean; isEssentials?: boolean; styles: { usersheading: string; statsheading: string; rankheading?: string; showRank?: boolean; hideViewer?: boolean;
|
|
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: string; lastInitial: string; rowNumber: number; }; }; elements?: { empty: VNode; essentials: VNode; loadingstate: VNode; }; }",
|
|
448
363
|
"references": {
|
|
449
364
|
"DemoData": {
|
|
450
365
|
"location": "import",
|
|
@@ -545,8 +460,6 @@ function useLeaderboardDemo(props) {
|
|
|
545
460
|
: "Anonymous User",
|
|
546
461
|
showRank: props.showRank,
|
|
547
462
|
hideViewer: props.hideViewer,
|
|
548
|
-
hideNames: props.hideNames,
|
|
549
|
-
maxWidth: props.maxWidth,
|
|
550
463
|
},
|
|
551
464
|
},
|
|
552
465
|
data: {
|
|
@@ -23,26 +23,6 @@ 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
|
-
`;
|
|
46
26
|
const GET_RANK = gql `
|
|
47
27
|
query (
|
|
48
28
|
$type: String!
|
|
@@ -63,24 +43,6 @@ const GET_RANK = gql `
|
|
|
63
43
|
}
|
|
64
44
|
}
|
|
65
45
|
`;
|
|
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
|
-
`;
|
|
84
46
|
export function useLeaderboard(props) {
|
|
85
47
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
86
48
|
const programIdContext = useProgramId();
|
|
@@ -106,8 +68,8 @@ export function useLeaderboard(props) {
|
|
|
106
68
|
if (props.maxRows > 0) {
|
|
107
69
|
variables["limit"] = props.maxRows;
|
|
108
70
|
}
|
|
109
|
-
const { data: leaderboardData, loading: loadingLeaderboard, errors: leaderboardErrors, } = useQuery(
|
|
110
|
-
const { data: rankData } = useQuery(
|
|
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));
|
|
111
73
|
const leaderboardRows = (_b = leaderboardData === null || leaderboardData === void 0 ? void 0 : leaderboardData.userLeaderboard) === null || _b === void 0 ? void 0 : _b.rows;
|
|
112
74
|
const flattenedLeaderboard = getFlattenedLeaderboard(leaderboardRows);
|
|
113
75
|
const sortedLeaderboard = flattenedLeaderboard === null || flattenedLeaderboard === void 0 ? void 0 : flattenedLeaderboard.sort(function (a, b) {
|
|
@@ -127,9 +127,6 @@ const style$1 = {
|
|
|
127
127
|
width: "auto",
|
|
128
128
|
whiteSpace: "nowrap",
|
|
129
129
|
},
|
|
130
|
-
"& .fullWidth": {
|
|
131
|
-
width: "100%",
|
|
132
|
-
},
|
|
133
130
|
},
|
|
134
131
|
};
|
|
135
132
|
const sheet$1 = createStyleSheet(style$1);
|
|
@@ -154,14 +151,15 @@ function LeaderboardView(props) {
|
|
|
154
151
|
if (!states.hasLeaders)
|
|
155
152
|
return elements.empty;
|
|
156
153
|
let userSeenFlag = false;
|
|
157
|
-
return (h("div", { class: sheet$1.classes.Leaderboard, part: "sqm-base"
|
|
154
|
+
return (h("div", { class: sheet$1.classes.Leaderboard, part: "sqm-base" },
|
|
158
155
|
h("style", { type: "text/css" },
|
|
159
156
|
styleString$1,
|
|
160
157
|
vanillaStyle),
|
|
158
|
+
h("div", null, "Leaderboards"),
|
|
161
159
|
h("table", { part: "sqm-table" },
|
|
162
160
|
h("tr", null,
|
|
163
|
-
styles.showRank &&
|
|
164
|
-
|
|
161
|
+
styles.showRank && h("th", { class: "Rank" }, styles.rankheading),
|
|
162
|
+
h("th", { class: "User" }, styles.usersheading),
|
|
165
163
|
h("th", { class: "Score" }, styles.statsheading)), (_a = data.leaderboard) === null || _a === void 0 ? void 0 :
|
|
166
164
|
_a.map((user) => {
|
|
167
165
|
var _a, _b;
|
|
@@ -171,15 +169,12 @@ function LeaderboardView(props) {
|
|
|
171
169
|
user.rowNumber === ((_b = data.viewerRank) === null || _b === void 0 ? void 0 : _b.rowNumber)
|
|
172
170
|
? "highlight"
|
|
173
171
|
: "" },
|
|
174
|
-
styles.showRank &&
|
|
175
|
-
|
|
176
|
-
defaultMessage: styles.rankSuffix,
|
|
177
|
-
}, { rank: user.rank }))),
|
|
178
|
-
!styles.hideNames && (h("td", { class: "User" }, user.firstName && user.lastInitial
|
|
172
|
+
styles.showRank && h("td", { class: "Rank" }, user.rank),
|
|
173
|
+
h("td", { class: "User" }, user.firstName && user.lastInitial
|
|
179
174
|
? user.firstName + " " + user.lastInitial
|
|
180
175
|
: user.firstName || user.lastInitial
|
|
181
176
|
? user.firstName || user.lastInitial
|
|
182
|
-
: styles.anonymousUser)
|
|
177
|
+
: styles.anonymousUser),
|
|
183
178
|
h("td", { class: "Score" }, user.textValue)));
|
|
184
179
|
}),
|
|
185
180
|
!userSeenFlag && !styles.hideViewer && (h("tr", null,
|
|
@@ -187,12 +182,12 @@ function LeaderboardView(props) {
|
|
|
187
182
|
h("sl-icon", { name: "three-dots", style: { verticalAlign: "middle" } })))),
|
|
188
183
|
!userSeenFlag && !styles.hideViewer && (h("tr", { class: "highlight" },
|
|
189
184
|
styles.showRank && (h("td", { class: "Rank" }, ((_b = data.viewerRank) === null || _b === void 0 ? void 0 : _b.rank) || "-")),
|
|
190
|
-
|
|
185
|
+
h("td", { class: "User" }, ((_c = data.viewerRank) === null || _c === void 0 ? void 0 : _c.firstName) && ((_d = data.viewerRank) === null || _d === void 0 ? void 0 : _d.lastInitial)
|
|
191
186
|
? ((_e = data.viewerRank) === null || _e === void 0 ? void 0 : _e.firstName) +
|
|
192
187
|
" " + ((_f = data.viewerRank) === null || _f === void 0 ? void 0 : _f.lastInitial)
|
|
193
188
|
: ((_g = data.viewerRank) === null || _g === void 0 ? void 0 : _g.firstName) || ((_h = data.viewerRank) === null || _h === void 0 ? void 0 : _h.lastInitial)
|
|
194
189
|
? ((_j = data.viewerRank) === null || _j === void 0 ? void 0 : _j.firstName) || ((_k = data.viewerRank) === null || _k === void 0 ? void 0 : _k.lastInitial)
|
|
195
|
-
: styles.anonymousUser)
|
|
190
|
+
: styles.anonymousUser),
|
|
196
191
|
h("td", { class: "Score" }, ((_l = data.viewerRank) === null || _l === void 0 ? void 0 : _l.textValue) || "0"))))));
|
|
197
192
|
}
|
|
198
193
|
|