@molecule/app-related-items-card-svelte 0.0.1-stage → 1.1.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/README.md +5 -4
- package/dist/RelatedItemsCard.svelte +28 -11
- package/dist/RelatedItemsCard.svelte.d.ts.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/package.json +5 -5
- package/dist/dom.d.ts +0 -32
- package/dist/dom.d.ts.map +0 -1
- package/dist/dom.js +0 -31
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-21T12:47:07.636Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-related-items-card-svelte
|
|
@@ -129,9 +129,10 @@ Peer dependencies:
|
|
|
129
129
|
- The "View all" label is hardcoded English in the React reference (not
|
|
130
130
|
routed through i18n) and is the same literal here; pass a translated link
|
|
131
131
|
via `headerActions` in localized apps.
|
|
132
|
-
- `onItemClick` rows
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
- `onItemClick` rows stay `<li>` list items: the card wraps each row's
|
|
133
|
+
content in an inner `role="button"` control (focusable, Enter/Space
|
|
134
|
+
activate it) so the click works from the keyboard too. A real
|
|
135
|
+
`<button>`/`<a>` inside `renderItem` still takes its own clicks and focus.
|
|
135
136
|
- `viewAllHref` renders a plain `<a href>` (full page load in SPA routers);
|
|
136
137
|
use `headerActions` with your router's Link for client-side navigation.
|
|
137
138
|
- Node-valued props (`title`, `icon`, `emptyState`, `headerActions`) arrive
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
`@molecule/app-related-items-card-react`'s `RelatedItemsCard` — a titled Card
|
|
4
4
|
with header + list + empty state + "View all" link. Same props (React
|
|
5
5
|
names), same DOM for the same input: the header always renders both of its
|
|
6
|
-
inner rows, `items.length === 0` swaps the list for `emptyState`, and
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
the React package renders; it does not route that label
|
|
6
|
+
inner rows, `items.length === 0` swaps the list for `emptyState`, and a
|
|
7
|
+
clickable row (`onItemClick`) keeps its `<li>` and wraps the row content in
|
|
8
|
+
an inner `role="button"` div the way React does — focusable, with Enter and
|
|
9
|
+
Space running the same handler the click does. The "View all" label is the
|
|
10
|
+
same literal English the React package renders; it does not route that label
|
|
11
|
+
through i18n.
|
|
11
12
|
-->
|
|
12
13
|
<script lang="ts" generics="T">
|
|
13
14
|
import { getClassMap } from '@molecule/app-ui'
|
|
14
15
|
import { Card } from '@molecule/app-ui-svelte'
|
|
15
16
|
|
|
16
|
-
import { rowClick } from './dom.js'
|
|
17
17
|
import type { ReactNodeProp } from './node-prop.js'
|
|
18
18
|
import type { RelatedItemsCardProps } from './types.js'
|
|
19
19
|
|
|
@@ -56,11 +56,28 @@
|
|
|
56
56
|
{:else}
|
|
57
57
|
<ul class={cm.stack(2)}>
|
|
58
58
|
{#each items as item, i (i)}
|
|
59
|
-
<li
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
<li>
|
|
60
|
+
{#if onItemClick}
|
|
61
|
+
<!-- Keyboard activation for a clickable row — the same call the
|
|
62
|
+
mouse click makes. The row control is a `role="button"` div (an
|
|
63
|
+
`<li>` may not carry button semantics), so it activates Enter
|
|
64
|
+
and Space itself. -->
|
|
65
|
+
<div
|
|
66
|
+
role="button"
|
|
67
|
+
tabindex="0"
|
|
68
|
+
class={cm.cursorPointer}
|
|
69
|
+
onclick={() => onItemClick?.(item, i)}
|
|
70
|
+
onkeydown={(event) => {
|
|
71
|
+
if (event.key !== 'Enter' && event.key !== ' ') return
|
|
72
|
+
event.preventDefault()
|
|
73
|
+
onItemClick?.(item, i)
|
|
74
|
+
}}
|
|
75
|
+
>
|
|
76
|
+
{@render renderItem(item, i)}
|
|
77
|
+
</div>
|
|
78
|
+
{:else}
|
|
79
|
+
{@render renderItem(item, i)}
|
|
80
|
+
{/if}
|
|
64
81
|
</li>
|
|
65
82
|
{/each}
|
|
66
83
|
</ul>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelatedItemsCard.svelte.d.ts","sourceRoot":"","sources":["../src/RelatedItemsCard.svelte"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RelatedItemsCard.svelte.d.ts","sourceRoot":"","sources":["../src/RelatedItemsCard.svelte"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxD,iBAAS,QAAQ,CAAC,CAAC;WAmEU,qBAAqB,CAAC,CAAC,CAAC;;;;;EAA4E;AACjI,cAAM,iBAAiB,CAAC,CAAC;IACrB,KAAK,IAAI,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAChD,MAAM,IAAI,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAClD,KAAK,IAAI,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAChD,QAAQ;IACR,OAAO;CACV;AAED,UAAU,qBAAqB;IAC3B,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAA;KAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC5X,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3H,YAAY,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;CACjE;AACD,QAAA,MAAM,gBAAgB,EAAE,qBAAmC,CAAC;AAC1C,KAAK,gBAAgB,CAAC,CAAC,IAAI,YAAY,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;AACtE,eAAe,gBAAgB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -47,9 +47,10 @@
|
|
|
47
47
|
* - The "View all" label is hardcoded English in the React reference (not
|
|
48
48
|
* routed through i18n) and is the same literal here; pass a translated link
|
|
49
49
|
* via `headerActions` in localized apps.
|
|
50
|
-
* - `onItemClick` rows
|
|
51
|
-
*
|
|
52
|
-
*
|
|
50
|
+
* - `onItemClick` rows stay `<li>` list items: the card wraps each row's
|
|
51
|
+
* content in an inner `role="button"` control (focusable, Enter/Space
|
|
52
|
+
* activate it) so the click works from the keyboard too. A real
|
|
53
|
+
* `<button>`/`<a>` inside `renderItem` still takes its own clicks and focus.
|
|
53
54
|
* - `viewAllHref` renders a plain `<a href>` (full page load in SPA routers);
|
|
54
55
|
* use `headerActions` with your router's Link for client-side navigation.
|
|
55
56
|
* - Node-valued props (`title`, `icon`, `emptyState`, `headerActions`) arrive
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -47,9 +47,10 @@
|
|
|
47
47
|
* - The "View all" label is hardcoded English in the React reference (not
|
|
48
48
|
* routed through i18n) and is the same literal here; pass a translated link
|
|
49
49
|
* via `headerActions` in localized apps.
|
|
50
|
-
* - `onItemClick` rows
|
|
51
|
-
*
|
|
52
|
-
*
|
|
50
|
+
* - `onItemClick` rows stay `<li>` list items: the card wraps each row's
|
|
51
|
+
* content in an inner `role="button"` control (focusable, Enter/Space
|
|
52
|
+
* activate it) so the click works from the keyboard too. A real
|
|
53
|
+
* `<button>`/`<a>` inside `renderItem` still takes its own clicks and focus.
|
|
53
54
|
* - `viewAllHref` renders a plain `<a href>` (full page load in SPA routers);
|
|
54
55
|
* use `headerActions` with your router's Link for client-side navigation.
|
|
55
56
|
* - Node-valued props (`title`, `icon`, `emptyState`, `headerActions`) arrive
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-related-items-card-svelte",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Card container for cross-linked items: company→deals, contact→notes, ticket→articles",
|
|
5
5
|
"homepage": "https://www.molecule.dev/packages/app-related-items-card-svelte",
|
|
6
6
|
"type": "module",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@molecule/app-framework-conformance": "0.0.0",
|
|
58
|
-
"@molecule/app-i18n": "1.2.
|
|
58
|
+
"@molecule/app-i18n": "1.2.2",
|
|
59
59
|
"@molecule/app-icons": "1.0.4",
|
|
60
|
-
"@molecule/app-svelte": "3.
|
|
61
|
-
"@molecule/app-ui": "1.
|
|
62
|
-
"@molecule/app-ui-svelte": "1.1
|
|
60
|
+
"@molecule/app-svelte": "3.9.0",
|
|
61
|
+
"@molecule/app-ui": "1.5.0",
|
|
62
|
+
"@molecule/app-ui-svelte": "1.2.1",
|
|
63
63
|
"@sveltejs/package": "3.0.2",
|
|
64
64
|
"@sveltejs/vite-plugin-svelte": "7.1.2",
|
|
65
65
|
"@types/node": "26.6.5",
|
package/dist/dom.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DOM helpers for {@link RelatedItemsCard}: the row click wiring.
|
|
3
|
-
*
|
|
4
|
-
* React attaches `onClick` to each item `<li>` only when the caller supplied a
|
|
5
|
-
* handler (its JSDoc is explicit that the rows are mouse-only, with no keyboard
|
|
6
|
-
* affordance), so the listener is attached through a Svelte action instead of
|
|
7
|
-
* an `onclick` attribute: the reference markup intentionally carries no
|
|
8
|
-
* handler attribute.
|
|
9
|
-
*
|
|
10
|
-
* @module
|
|
11
|
-
*/
|
|
12
|
-
/** One row's click wiring. */
|
|
13
|
-
export interface RowClick<T> {
|
|
14
|
-
/** The caller's handler, absent for non-clickable rows. */
|
|
15
|
-
onItemClick?: (item: T, index: number) => void;
|
|
16
|
-
/** The row's item. */
|
|
17
|
-
item: T;
|
|
18
|
-
/** The row's index. */
|
|
19
|
-
index: number;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Svelte action keeping a row's click handler in sync with the caller's prop.
|
|
23
|
-
*
|
|
24
|
-
* @param node - The `<li>` the handler belongs to.
|
|
25
|
-
* @param params - The current handler and the row's item and index.
|
|
26
|
-
* @returns The action with an update that re-targets the same listener.
|
|
27
|
-
*/
|
|
28
|
-
export declare function rowClick<T>(node: HTMLElement, params: RowClick<T>): {
|
|
29
|
-
update: (next: RowClick<T>) => void;
|
|
30
|
-
destroy: () => void;
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=dom.d.ts.map
|
package/dist/dom.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,8BAA8B;AAC9B,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9C,sBAAsB;IACtB,IAAI,EAAE,CAAC,CAAA;IACP,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,GAClB;IAAE,MAAM,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAY9D"}
|
package/dist/dom.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DOM helpers for {@link RelatedItemsCard}: the row click wiring.
|
|
3
|
-
*
|
|
4
|
-
* React attaches `onClick` to each item `<li>` only when the caller supplied a
|
|
5
|
-
* handler (its JSDoc is explicit that the rows are mouse-only, with no keyboard
|
|
6
|
-
* affordance), so the listener is attached through a Svelte action instead of
|
|
7
|
-
* an `onclick` attribute: the reference markup intentionally carries no
|
|
8
|
-
* handler attribute.
|
|
9
|
-
*
|
|
10
|
-
* @module
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Svelte action keeping a row's click handler in sync with the caller's prop.
|
|
14
|
-
*
|
|
15
|
-
* @param node - The `<li>` the handler belongs to.
|
|
16
|
-
* @param params - The current handler and the row's item and index.
|
|
17
|
-
* @returns The action with an update that re-targets the same listener.
|
|
18
|
-
*/
|
|
19
|
-
export function rowClick(node, params) {
|
|
20
|
-
let current = params;
|
|
21
|
-
const listener = () => current.onItemClick?.(current.item, current.index);
|
|
22
|
-
node.addEventListener('click', listener);
|
|
23
|
-
return {
|
|
24
|
-
update(next) {
|
|
25
|
-
current = next;
|
|
26
|
-
},
|
|
27
|
-
destroy() {
|
|
28
|
-
node.removeEventListener('click', listener);
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
}
|