@molecule/app-related-items-card-react 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,115 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean any work of authorship, including the
45
+ original version of the Work and any modifications or additions
46
+ to that Work, that is intentionally submitted to the Licensor for
47
+ inclusion in the Work by the copyright owner or by an individual or
48
+ Legal Entity authorized to submit on behalf of the copyright owner.
49
+
50
+ "Contributor" shall mean Licensor and any individual or Legal Entity
51
+ on behalf of whom a Contribution has been received by the Licensor and
52
+ subsequently incorporated within the Work.
53
+
54
+ 2. Grant of Copyright License. Subject to the terms and conditions of
55
+ this License, each Contributor hereby grants to You a perpetual,
56
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
57
+ copyright license to reproduce, prepare Derivative Works of,
58
+ publicly display, publicly perform, sublicense, and distribute the
59
+ Work and such Derivative Works in Source or Object form.
60
+
61
+ 3. Grant of Patent License. Subject to the terms and conditions of
62
+ this License, each Contributor hereby grants to You a perpetual,
63
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
64
+ patent license to make, have made, use, offer to sell, sell, import,
65
+ and otherwise transfer the Work.
66
+
67
+ 4. Redistribution. You may reproduce and distribute copies of the
68
+ Work or Derivative Works thereof in any medium, with or without
69
+ modifications, and in Source or Object form, provided that You
70
+ meet the following conditions:
71
+
72
+ (a) You must give any other recipients of the Work or
73
+ Derivative Works a copy of this License; and
74
+
75
+ (b) You must cause any modified files to carry prominent notices
76
+ stating that You changed the files; and
77
+
78
+ (c) You must retain, in the Source form of any Derivative Works
79
+ that You distribute, all copyright, patent, trademark, and
80
+ attribution notices from the Source form of the Work,
81
+ excluding those notices that do not pertain to any part of
82
+ the Derivative Works; and
83
+
84
+ (d) If the Work includes a "NOTICE" text file as part of its
85
+ distribution, then any Derivative Works that You distribute must
86
+ include a readable copy of the attribution notices contained
87
+ within such NOTICE file.
88
+
89
+ 5. Submission of Contributions.
90
+
91
+ 6. Trademarks. This License does not grant permission to use the trade
92
+ names, trademarks, service marks, or product names of the Licensor.
93
+
94
+ 7. Disclaimer of Warranty. Unless required by applicable law or
95
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
96
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
97
+
98
+ 8. Limitation of Liability. In no event and under no legal theory shall
99
+ any Contributor be liable to You for damages.
100
+
101
+ 9. Accepting Warranty or Additional Liability.
102
+
103
+ Copyright 2026 Molecule Dev, Inc.
104
+
105
+ Licensed under the Apache License, Version 2.0 (the "License");
106
+ you may not use this file except in compliance with the License.
107
+ You may obtain a copy of the License at
108
+
109
+ http://www.apache.org/licenses/LICENSE-2.0
110
+
111
+ Unless required by applicable law or agreed to in writing, software
112
+ distributed under the License is distributed on an "AS IS" BASIS,
113
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
114
+ See the License for the specific language governing permissions and
115
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,156 @@
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-08-04T00:40:55.749Z
7
+ -->
8
+
9
+ # @molecule/app-related-items-card-react
10
+
11
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
+ > It is written to be read by coding agents as much as by people, and is generated from this
13
+ > package's source — edit `src/index.ts` JSDoc, not this file.
14
+
15
+ React card container for cross-linked / related item lists.
16
+
17
+ Exports `<RelatedItemsCard>` — titled Card with header + list + empty state
18
+
19
+ - "View all" link. Use for "Company → Deals", "Contact → Notes",
20
+ "Ticket → Related Articles" panels.
21
+
22
+ Props: `title` (ReactNode), `items: T[]`, `renderItem(item, index)`,
23
+ `icon?`, `onItemClick?(item, index)` (rows become clickable),
24
+ `emptyState?` (rendered when `items` is empty), `viewAllHref?` (header
25
+ "View all" link), `headerActions?` (right-aligned header slot),
26
+ `className?`, `dataMolId?`.
27
+
28
+ ## Quick Start
29
+
30
+ ```tsx
31
+ import { RelatedItemsCard } from '@molecule/app-related-items-card-react'
32
+
33
+ interface Article {
34
+ id: string
35
+ title: string
36
+ }
37
+
38
+ function RelatedArticles({
39
+ articles,
40
+ onOpen,
41
+ }: {
42
+ articles: Article[]
43
+ onOpen: (id: string) => void
44
+ }) {
45
+ return (
46
+ <RelatedItemsCard
47
+ title="Related Articles"
48
+ items={articles}
49
+ viewAllHref="/articles"
50
+ emptyState={<p>No related articles yet.</p>}
51
+ renderItem={(article) => <span>{article.title}</span>}
52
+ onItemClick={(article) => onOpen(article.id)}
53
+ />
54
+ )
55
+ }
56
+ ```
57
+
58
+ ## Type
59
+
60
+ `feature`
61
+
62
+ ## Installation
63
+
64
+ ```bash
65
+ npm install @molecule/app-related-items-card-react @molecule/app-react @molecule/app-ui @molecule/app-ui-react react
66
+ npm install -D @types/react
67
+ ```
68
+
69
+ ## API
70
+
71
+ ### Interfaces
72
+
73
+ #### `RelatedItemsCardProps`
74
+
75
+ Props accepted by the {@link RelatedItemsCard} component.
76
+
77
+ ```typescript
78
+ interface RelatedItemsCardProps<T> {
79
+ /** Card heading. */
80
+ title: ReactNode
81
+ /** Optional leading icon in the header. */
82
+ icon?: ReactNode
83
+ /** Items to render. */
84
+ items: T[]
85
+ /** Render function for each item. */
86
+ renderItem: (item: T, index: number) => ReactNode
87
+ /** Called when an item row is clicked (if applicable). */
88
+ onItemClick?: (item: T, index: number) => void
89
+ /** Rendered when `items` is empty. */
90
+ emptyState?: ReactNode
91
+ /** Optional "View all" link rendered in the header. */
92
+ viewAllHref?: string
93
+ /** Optional right-aligned header actions (e.g. "Add new" button). */
94
+ headerActions?: ReactNode
95
+ /** Extra classes on the Card. */
96
+ className?: string
97
+ /** `data-mol-id` for AI-agent selectors. */
98
+ dataMolId?: string
99
+ }
100
+ ```
101
+
102
+ ### Functions
103
+
104
+ #### `RelatedItemsCard(props)`
105
+
106
+ Card container for a list of cross-linked / related items.
107
+
108
+ Common usage: "Company → Deals", "Contact → Notes",
109
+ "Ticket → Related Articles", "Post → Related Posts". Apps supply the
110
+ item data and a renderer; the card provides consistent header +
111
+ list + empty-state + view-all chrome.
112
+
113
+ ```typescript
114
+ function RelatedItemsCard({
115
+ title,
116
+ icon,
117
+ items,
118
+ renderItem,
119
+ onItemClick,
120
+ emptyState,
121
+ viewAllHref,
122
+ headerActions,
123
+ className,
124
+ dataMolId,
125
+ }: RelatedItemsCardProps<T>): JSX.Element
126
+ ```
127
+
128
+ - `props` — Component props (see {@link RelatedItemsCardProps}).
129
+
130
+ ## Injection Notes
131
+
132
+ ### Requirements
133
+
134
+ Peer dependencies:
135
+
136
+ - `@molecule/app-react` ^1.0.0
137
+ - `@molecule/app-ui` ^1.0.0
138
+ - `@molecule/app-ui-react` ^1.0.0
139
+ - `react` ^18.0.0 || ^19.0.0
140
+
141
+ ### Runtime Dependencies
142
+
143
+ - `@molecule/app-react`
144
+ - `@molecule/app-ui`
145
+ - `@molecule/app-ui-react`
146
+ - `react`
147
+
148
+ - Requires a bonded ClassMap — call `setClassMap()` (e.g. with
149
+ `@molecule/app-ui-tailwind`) at startup or rendering throws.
150
+ - The "View all" label is hardcoded English (not routed through i18n);
151
+ pass a translated link via `headerActions` in localized apps.
152
+ - `onItemClick` rows are mouse-only `<li>` elements (no keyboard handler);
153
+ render a real `<button>`/`<a>` inside `renderItem` when keyboard access
154
+ matters.
155
+ - `viewAllHref` renders a plain `<a href>` (full page load in SPA routers);
156
+ use `headerActions` with your router's Link for client-side navigation.
@@ -0,0 +1,35 @@
1
+ import type { JSX, ReactNode } from 'react';
2
+ /** Props accepted by the {@link RelatedItemsCard} component. */
3
+ export interface RelatedItemsCardProps<T> {
4
+ /** Card heading. */
5
+ title: ReactNode;
6
+ /** Optional leading icon in the header. */
7
+ icon?: ReactNode;
8
+ /** Items to render. */
9
+ items: T[];
10
+ /** Render function for each item. */
11
+ renderItem: (item: T, index: number) => ReactNode;
12
+ /** Called when an item row is clicked (if applicable). */
13
+ onItemClick?: (item: T, index: number) => void;
14
+ /** Rendered when `items` is empty. */
15
+ emptyState?: ReactNode;
16
+ /** Optional "View all" link rendered in the header. */
17
+ viewAllHref?: string;
18
+ /** Optional right-aligned header actions (e.g. "Add new" button). */
19
+ headerActions?: ReactNode;
20
+ /** Extra classes on the Card. */
21
+ className?: string;
22
+ /** `data-mol-id` for AI-agent selectors. */
23
+ dataMolId?: string;
24
+ }
25
+ /**
26
+ * Card container for a list of cross-linked / related items.
27
+ *
28
+ * Common usage: "Company → Deals", "Contact → Notes",
29
+ * "Ticket → Related Articles", "Post → Related Posts". Apps supply the
30
+ * item data and a renderer; the card provides consistent header +
31
+ * list + empty-state + view-all chrome.
32
+ * @param props - Component props (see {@link RelatedItemsCardProps}).
33
+ */
34
+ export declare function RelatedItemsCard<T>({ title, icon, items, renderItem, onItemClick, emptyState, viewAllHref, headerActions, className, dataMolId, }: RelatedItemsCardProps<T>): JSX.Element;
35
+ //# sourceMappingURL=RelatedItemsCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RelatedItemsCard.d.ts","sourceRoot":"","sources":["../src/RelatedItemsCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAK3C,gEAAgE;AAChE,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,oBAAoB;IACpB,KAAK,EAAE,SAAS,CAAA;IAChB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,uBAAuB;IACvB,KAAK,EAAE,CAAC,EAAE,CAAA;IACV,qCAAqC;IACrC,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,SAAS,CAAA;IACjD,0DAA0D;IAC1D,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9C,sCAAsC;IACtC,UAAU,CAAC,EAAE,SAAS,CAAA;IACtB,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qEAAqE;IACrE,aAAa,CAAC,EAAE,SAAS,CAAA;IACzB,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,EAClC,KAAK,EACL,IAAI,EACJ,KAAK,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,aAAa,EACb,SAAS,EACT,SAAS,GACV,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,CAqCxC"}
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { getClassMap } from '@molecule/app-ui';
3
+ import { Card } from '@molecule/app-ui-react';
4
+ /**
5
+ * Card container for a list of cross-linked / related items.
6
+ *
7
+ * Common usage: "Company → Deals", "Contact → Notes",
8
+ * "Ticket → Related Articles", "Post → Related Posts". Apps supply the
9
+ * item data and a renderer; the card provides consistent header +
10
+ * list + empty-state + view-all chrome.
11
+ * @param props - Component props (see {@link RelatedItemsCardProps}).
12
+ */
13
+ export function RelatedItemsCard({ title, icon, items, renderItem, onItemClick, emptyState, viewAllHref, headerActions, className, dataMolId, }) {
14
+ const cm = getClassMap();
15
+ return (_jsx(Card, { className: className, "data-mol-id": dataMolId, children: _jsxs("div", { className: cm.stack(3), children: [_jsxs("header", { className: cm.flex({ justify: 'between', align: 'center', gap: 'sm' }), children: [_jsxs("div", { className: cm.flex({ align: 'center', gap: 'sm' }), children: [icon, _jsx("h3", { className: cm.cn(cm.textSize('base'), cm.fontWeight('semibold')), children: title })] }), _jsxs("div", { className: cm.flex({ align: 'center', gap: 'sm' }), children: [headerActions, viewAllHref && (_jsx("a", { href: viewAllHref, className: cm.cn(cm.textSize('sm'), cm.link), children: "View all" }))] })] }), items.length === 0 ? (emptyState) : (_jsx("ul", { className: cm.stack(2), children: items.map((item, i) => (_jsx("li", { onClick: onItemClick ? () => onItemClick(item, i) : undefined, className: onItemClick ? cm.cursorPointer : undefined, children: renderItem(item, i) }, i))) }))] }) }));
16
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * React card container for cross-linked / related item lists.
3
+ *
4
+ * Exports `<RelatedItemsCard>` — titled Card with header + list + empty state
5
+ * + "View all" link. Use for "Company → Deals", "Contact → Notes",
6
+ * "Ticket → Related Articles" panels.
7
+ *
8
+ * Props: `title` (ReactNode), `items: T[]`, `renderItem(item, index)`,
9
+ * `icon?`, `onItemClick?(item, index)` (rows become clickable),
10
+ * `emptyState?` (rendered when `items` is empty), `viewAllHref?` (header
11
+ * "View all" link), `headerActions?` (right-aligned header slot),
12
+ * `className?`, `dataMolId?`.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * import { RelatedItemsCard } from '@molecule/app-related-items-card-react'
17
+ *
18
+ * interface Article { id: string; title: string }
19
+ *
20
+ * function RelatedArticles({ articles, onOpen }: {
21
+ * articles: Article[]
22
+ * onOpen: (id: string) => void
23
+ * }) {
24
+ * return (
25
+ * <RelatedItemsCard
26
+ * title="Related Articles"
27
+ * items={articles}
28
+ * viewAllHref="/articles"
29
+ * emptyState={<p>No related articles yet.</p>}
30
+ * renderItem={(article) => <span>{article.title}</span>}
31
+ * onItemClick={(article) => onOpen(article.id)}
32
+ * />
33
+ * )
34
+ * }
35
+ * ```
36
+ *
37
+ * @remarks
38
+ * - Requires a bonded ClassMap — call `setClassMap()` (e.g. with
39
+ * `@molecule/app-ui-tailwind`) at startup or rendering throws.
40
+ * - The "View all" label is hardcoded English (not routed through i18n);
41
+ * pass a translated link via `headerActions` in localized apps.
42
+ * - `onItemClick` rows are mouse-only `<li>` elements (no keyboard handler);
43
+ * render a real `<button>`/`<a>` inside `renderItem` when keyboard access
44
+ * matters.
45
+ * - `viewAllHref` renders a plain `<a href>` (full page load in SPA routers);
46
+ * use `headerActions` with your router's Link for client-side navigation.
47
+ *
48
+ * @module
49
+ */
50
+ export * from './RelatedItemsCard.js';
51
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,cAAc,uBAAuB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ /**
2
+ * React card container for cross-linked / related item lists.
3
+ *
4
+ * Exports `<RelatedItemsCard>` — titled Card with header + list + empty state
5
+ * + "View all" link. Use for "Company → Deals", "Contact → Notes",
6
+ * "Ticket → Related Articles" panels.
7
+ *
8
+ * Props: `title` (ReactNode), `items: T[]`, `renderItem(item, index)`,
9
+ * `icon?`, `onItemClick?(item, index)` (rows become clickable),
10
+ * `emptyState?` (rendered when `items` is empty), `viewAllHref?` (header
11
+ * "View all" link), `headerActions?` (right-aligned header slot),
12
+ * `className?`, `dataMolId?`.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * import { RelatedItemsCard } from '@molecule/app-related-items-card-react'
17
+ *
18
+ * interface Article { id: string; title: string }
19
+ *
20
+ * function RelatedArticles({ articles, onOpen }: {
21
+ * articles: Article[]
22
+ * onOpen: (id: string) => void
23
+ * }) {
24
+ * return (
25
+ * <RelatedItemsCard
26
+ * title="Related Articles"
27
+ * items={articles}
28
+ * viewAllHref="/articles"
29
+ * emptyState={<p>No related articles yet.</p>}
30
+ * renderItem={(article) => <span>{article.title}</span>}
31
+ * onItemClick={(article) => onOpen(article.id)}
32
+ * />
33
+ * )
34
+ * }
35
+ * ```
36
+ *
37
+ * @remarks
38
+ * - Requires a bonded ClassMap — call `setClassMap()` (e.g. with
39
+ * `@molecule/app-ui-tailwind`) at startup or rendering throws.
40
+ * - The "View all" label is hardcoded English (not routed through i18n);
41
+ * pass a translated link via `headerActions` in localized apps.
42
+ * - `onItemClick` rows are mouse-only `<li>` elements (no keyboard handler);
43
+ * render a real `<button>`/`<a>` inside `renderItem` when keyboard access
44
+ * matters.
45
+ * - `viewAllHref` renders a plain `<a href>` (full page load in SPA routers);
46
+ * use `headerActions` with your router's Link for client-side navigation.
47
+ *
48
+ * @module
49
+ */
50
+ export * from './RelatedItemsCard.js';
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@molecule/app-related-items-card-react",
3
+ "version": "1.0.0",
4
+ "description": "Card container for cross-linked items: company→deals, contact→notes, ticket→articles",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "test": "vitest run",
11
+ "test:watch": "vitest"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "README.md"
22
+ ],
23
+ "keywords": [
24
+ "molecule",
25
+ "related-items-card",
26
+ "react"
27
+ ],
28
+ "license": "Apache-2.0",
29
+ "peerDependencies": {
30
+ "@molecule/app-react": "^1.0.0",
31
+ "@molecule/app-ui": "^1.0.0",
32
+ "@molecule/app-ui-react": "^1.0.0",
33
+ "react": "^18.0.0 || ^19.0.0"
34
+ },
35
+ "devDependencies": {
36
+ "@molecule/app-react": "1.0.0",
37
+ "@molecule/app-ui": "1.0.0",
38
+ "@molecule/app-ui-react": "1.0.0",
39
+ "@types/node": "26.1.2",
40
+ "@types/react": "19.2.17",
41
+ "@types/react-dom": "19.2.3",
42
+ "react": "19.2.8",
43
+ "react-dom": "19.2.8",
44
+ "typescript": "6.0.3",
45
+ "vitest": "4.1.10"
46
+ }
47
+ }