@molecule/app-leaderboard-row-vue 1.1.1 → 1.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/README.md +6 -5
- package/dist/LeaderboardRow.d.ts +4 -3
- package/dist/LeaderboardRow.d.ts.map +1 -1
- package/dist/LeaderboardRow.js +27 -25
- package/dist/LeaderboardRow.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-11-
|
|
6
|
+
Generated: 2026-11-24T08:58:53.196Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-leaderboard-row-vue
|
|
@@ -96,9 +96,10 @@ Leaderboard row — rank + avatar + name + score + optional rank-delta
|
|
|
96
96
|
arrow. Top 3 ranks render a medal in place of the numeric rank. Ranks 1–3
|
|
97
97
|
render medal emoji instead of the rank number; there is no prop to disable
|
|
98
98
|
them. When `name` is not a plain string the Avatar's accessible name falls
|
|
99
|
-
back to 'Player'. `onClick`
|
|
100
|
-
|
|
101
|
-
as a prop AND a same-named slot; the component accepts
|
|
99
|
+
back to 'Player'. With `onClick` the row is a button in the a11y tree
|
|
100
|
+
(Enter / Space activate it). Node-valued props (`name`, `score`,
|
|
101
|
+
`subtitle`) arrive as a prop AND a same-named slot; the component accepts
|
|
102
|
+
either.
|
|
102
103
|
|
|
103
104
|
```typescript
|
|
104
105
|
const LeaderboardRow: DefineComponent<
|
|
@@ -160,7 +161,7 @@ Peer dependencies:
|
|
|
160
161
|
|
|
161
162
|
- `@molecule/app-ui` ^1.4.0
|
|
162
163
|
- `@molecule/app-ui-vue` ^1.1.0
|
|
163
|
-
- `@molecule/app-vue` ^3.
|
|
164
|
+
- `@molecule/app-vue` ^3.13.0
|
|
164
165
|
- `vue` ^3.4.0
|
|
165
166
|
|
|
166
167
|
### Runtime Dependencies
|
package/dist/LeaderboardRow.d.ts
CHANGED
|
@@ -14,9 +14,10 @@ import { type PropType, type VNode } from 'vue';
|
|
|
14
14
|
* arrow. Top 3 ranks render a medal in place of the numeric rank. Ranks 1–3
|
|
15
15
|
* render medal emoji instead of the rank number; there is no prop to disable
|
|
16
16
|
* them. When `name` is not a plain string the Avatar's accessible name falls
|
|
17
|
-
* back to 'Player'. `onClick`
|
|
18
|
-
*
|
|
19
|
-
* as a prop AND a same-named slot; the component accepts
|
|
17
|
+
* back to 'Player'. With `onClick` the row is a button in the a11y tree
|
|
18
|
+
* (Enter / Space activate it). Node-valued props (`name`, `score`,
|
|
19
|
+
* `subtitle`) arrive as a prop AND a same-named slot; the component accepts
|
|
20
|
+
* either.
|
|
20
21
|
*
|
|
21
22
|
* @param props - Component props (see {@link LeaderboardRowProps}).
|
|
22
23
|
* @returns The leaderboard row component.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LeaderboardRow.d.ts","sourceRoot":"","sources":["../src/LeaderboardRow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAsB,KAAK,QAAQ,EAAE,KAAK,KAAK,EAAmB,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"LeaderboardRow.d.ts","sourceRoot":"","sources":["../src/LeaderboardRow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAsB,KAAK,QAAQ,EAAE,KAAK,KAAK,EAAmB,MAAM,KAAK,CAAA;AAyBpF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;cAUM,QAAQ,CAAC,MAAM,IAAI,CAAC;;;;;;;UAgBtC,KAAK;;;;;;;;;;;;;;;;;;;;;cAhBa,QAAQ,CAAC,MAAM,IAAI,CAAC;;;;;;;;;;;mBAAL,IAAI;;4EAoFlD,CAAA"}
|
package/dist/LeaderboardRow.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { defineComponent, h } from 'vue';
|
|
12
12
|
import { getClassMap } from '@molecule/app-ui';
|
|
13
13
|
import { Avatar } from '@molecule/app-ui-vue';
|
|
14
|
+
import { toChildArray } from '@molecule/app-vue';
|
|
14
15
|
/** The medal emoji rendered in place of the rank for the top three. */
|
|
15
16
|
const MEDAL = { 1: '🥇', 2: '🥈', 3: '🥉' };
|
|
16
17
|
/**
|
|
@@ -23,27 +24,18 @@ const MEDAL = { 1: '🥇', 2: '🥈', 3: '🥉' };
|
|
|
23
24
|
*/
|
|
24
25
|
const slotOrProp = (slot, prop) => {
|
|
25
26
|
if (slot)
|
|
26
|
-
return slot();
|
|
27
|
-
return prop != null ?
|
|
27
|
+
return toChildArray(slot());
|
|
28
|
+
return prop != null ? toChildArray(prop) : [];
|
|
28
29
|
};
|
|
29
|
-
/**
|
|
30
|
-
* Whether an optional node-valued prop renders at all: React's
|
|
31
|
-
* `{subtitle && <span>}` truthiness on the prop, plus a same-named slot being
|
|
32
|
-
* present.
|
|
33
|
-
*
|
|
34
|
-
* @param slot - The slot render function, when the caller passed the slot.
|
|
35
|
-
* @param prop - The prop value, when the caller passed the prop.
|
|
36
|
-
* @returns True when the subtitle span renders.
|
|
37
|
-
*/
|
|
38
|
-
const hasNode = (slot, prop) => slot != null || (prop != null && prop !== '' && prop !== false);
|
|
39
30
|
/**
|
|
40
31
|
* Leaderboard row — rank + avatar + name + score + optional rank-delta
|
|
41
32
|
* arrow. Top 3 ranks render a medal in place of the numeric rank. Ranks 1–3
|
|
42
33
|
* render medal emoji instead of the rank number; there is no prop to disable
|
|
43
34
|
* them. When `name` is not a plain string the Avatar's accessible name falls
|
|
44
|
-
* back to 'Player'. `onClick`
|
|
45
|
-
*
|
|
46
|
-
* as a prop AND a same-named slot; the component accepts
|
|
35
|
+
* back to 'Player'. With `onClick` the row is a button in the a11y tree
|
|
36
|
+
* (Enter / Space activate it). Node-valued props (`name`, `score`,
|
|
37
|
+
* `subtitle`) arrive as a prop AND a same-named slot; the component accepts
|
|
38
|
+
* either.
|
|
47
39
|
*
|
|
48
40
|
* @param props - Component props (see {@link LeaderboardRowProps}).
|
|
49
41
|
* @returns The leaderboard row component.
|
|
@@ -63,14 +55,27 @@ export const LeaderboardRow = defineComponent({
|
|
|
63
55
|
},
|
|
64
56
|
setup(props, { slots }) {
|
|
65
57
|
const cm = getClassMap();
|
|
58
|
+
// When the row is interactive, Enter / Space activate it (React's
|
|
59
|
+
// `handleKeyDown`): preventDefault, then the click handler with no event.
|
|
60
|
+
const handleKeyDown = (event) => {
|
|
61
|
+
if (!props.onClick)
|
|
62
|
+
return;
|
|
63
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
props.onClick();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
66
68
|
return () => {
|
|
67
69
|
const displayName = typeof props.name === 'string' ? props.name : 'Player';
|
|
70
|
+
// React's `subtitle && …`: an empty list is absent.
|
|
71
|
+
const subtitleNodes = slotOrProp(slots.subtitle, props.subtitle);
|
|
68
72
|
return h('div', {
|
|
69
|
-
class: cm.cn(cm.flex({ align: 'center', gap: 'sm' }), cm.sp('px', 3), cm.sp('py', 2), props.onClick ? cm.cursorPointer : undefined, props.className),
|
|
70
|
-
style: props.isMe
|
|
71
|
-
? { background: 'rgba(96,165,250,0.1)', borderRadius: '8px' }
|
|
72
|
-
: undefined,
|
|
73
|
+
class: cm.cn(cm.flex({ align: 'center', gap: 'sm' }), cm.sp('px', 3), cm.sp('py', 2), props.onClick ? cm.cursorPointer : undefined, props.isMe ? cm.bgTone('info', { subtle: true }) : undefined, props.className),
|
|
74
|
+
style: props.isMe ? { borderRadius: '8px' } : undefined,
|
|
73
75
|
onClick: props.onClick,
|
|
76
|
+
onKeydown: handleKeyDown,
|
|
77
|
+
role: props.onClick ? 'button' : undefined,
|
|
78
|
+
tabindex: props.onClick ? 0 : undefined,
|
|
74
79
|
}, [
|
|
75
80
|
h('span', {
|
|
76
81
|
class: cm.cn(cm.shrink0, cm.fontWeight('bold'), cm.textCenter),
|
|
@@ -81,18 +86,15 @@ export const LeaderboardRow = defineComponent({
|
|
|
81
86
|
h('div', { class: cm.cn(cm.flex1, cm.stack(0)) }, [
|
|
82
87
|
h('span', { class: cm.cn(cm.textSize('sm'), cm.fontWeight('semibold')) }, slotOrProp(slots.name, props.name)),
|
|
83
88
|
// React's `{subtitle && …}`: a falsy subtitle renders nothing.
|
|
84
|
-
...(
|
|
85
|
-
? [
|
|
86
|
-
h('span', { class: cm.textSize('xs') }, slotOrProp(slots.subtitle, props.subtitle)),
|
|
87
|
-
]
|
|
89
|
+
...(subtitleNodes.length > 0
|
|
90
|
+
? [h('span', { class: cm.textSize('xs') }, subtitleNodes)]
|
|
88
91
|
: []),
|
|
89
92
|
]),
|
|
90
93
|
// React's `rankDelta !== undefined && rankDelta !== 0`: a zero delta renders nothing.
|
|
91
94
|
...(props.rankDelta !== undefined && props.rankDelta !== 0
|
|
92
95
|
? [
|
|
93
96
|
h('span', {
|
|
94
|
-
class: cm.cn(cm.textSize('xs'), cm.fontWeight('semibold')),
|
|
95
|
-
style: { color: props.rankDelta > 0 ? '#22c55e' : '#ef4444' },
|
|
97
|
+
class: cm.cn(cm.textSize('xs'), cm.fontWeight('semibold'), cm.textTone(props.rankDelta > 0 ? 'success' : 'error')),
|
|
96
98
|
}, [props.rankDelta > 0 ? '▲' : '▼', ' ', String(Math.abs(props.rankDelta))]),
|
|
97
99
|
]
|
|
98
100
|
: []),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LeaderboardRow.js","sourceRoot":"","sources":["../src/LeaderboardRow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC,EAA8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K,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CACrC;aACF,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-leaderboard-row-vue",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Leaderboard row — rank, avatar, name, score, optional change indicator",
|
|
5
5
|
"homepage": "https://www.molecule.dev/packages/app-leaderboard-row-vue",
|
|
6
6
|
"type": "module",
|
|
@@ -44,18 +44,18 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@molecule/app-ui": "^1.4.0",
|
|
46
46
|
"@molecule/app-ui-vue": "^1.1.0",
|
|
47
|
-
"@molecule/app-vue": "^3.
|
|
47
|
+
"@molecule/app-vue": "^3.13.0",
|
|
48
48
|
"vue": "^3.4.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@molecule/app-framework-conformance": "0.0.0",
|
|
52
52
|
"@molecule/app-i18n": "1.2.2",
|
|
53
53
|
"@molecule/app-icons": "1.0.4",
|
|
54
|
-
"@molecule/app-ui": "1.
|
|
55
|
-
"@molecule/app-ui-vue": "1.
|
|
56
|
-
"@molecule/app-vue": "3.
|
|
54
|
+
"@molecule/app-ui": "1.5.0",
|
|
55
|
+
"@molecule/app-ui-vue": "1.3.2",
|
|
56
|
+
"@molecule/app-vue": "3.13.1",
|
|
57
57
|
"@types/node": "26.6.5",
|
|
58
|
-
"jsdom": "
|
|
58
|
+
"jsdom": "31.0.1",
|
|
59
59
|
"typescript": "6.0.3",
|
|
60
60
|
"vite": "8.3.5",
|
|
61
61
|
"vitest": "4.1.12",
|