@molecule/app-collapsible-section-react 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/README.md +165 -0
  2. package/package.json +14 -8
package/README.md ADDED
@@ -0,0 +1,165 @@
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-04T01:50:19.355Z
7
+ -->
8
+
9
+ # @molecule/app-collapsible-section-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 collapsible-section and show-more.
16
+
17
+ Exports:
18
+
19
+ - `<CollapsibleSection>` — expandable section with clickable heading.
20
+ - `<ShowMore>` — "Show N more" / "Show less" toggle for long lists.
21
+
22
+ ## Quick Start
23
+
24
+ ```tsx
25
+ import { CollapsibleSection, ShowMore } from '@molecule/app-collapsible-section-react'
26
+
27
+ <CollapsibleSection title="Key concepts" defaultExpanded={true}>
28
+ <p>Content revealed when expanded.</p>
29
+ </CollapsibleSection>
30
+
31
+ <ShowMore initialCount={3}>
32
+ {items.map((item) => <div key={item.id}>{item.label}</div>)}
33
+ </ShowMore>
34
+ ```
35
+
36
+ ## Type
37
+
38
+ `feature`
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ npm install @molecule/app-collapsible-section-react @molecule/app-react @molecule/app-ui @molecule/app-ui-react react
44
+ npm install -D @types/react
45
+ ```
46
+
47
+ ## API
48
+
49
+ ### Interfaces
50
+
51
+ #### `CollapsibleSectionProps`
52
+
53
+ Props for {@link CollapsibleSection}.
54
+
55
+ ```typescript
56
+ interface CollapsibleSectionProps {
57
+ /** Section heading — rendered as an expand-toggle button. */
58
+ title: ReactNode
59
+ /** Body to show when expanded. */
60
+ children: ReactNode
61
+ /** Controlled expansion — if omitted, the component owns state. */
62
+ expanded?: boolean
63
+ /** Initial expanded state when uncontrolled. Defaults to false. */
64
+ defaultExpanded?: boolean
65
+ /** Called when expansion state changes. */
66
+ onExpandedChange?: (expanded: boolean) => void
67
+ /** Optional badge / count shown in the header. */
68
+ badge?: ReactNode
69
+ /** Optional right-side actions. */
70
+ actions?: ReactNode
71
+ /** Heading level — affects rendered tag, defaults to 3. */
72
+ level?: 2 | 3 | 4 | 5 | 6
73
+ /** Extra classes. */
74
+ className?: string
75
+ }
76
+ ```
77
+
78
+ #### `ShowMoreProps`
79
+
80
+ Props for {@link ShowMore}.
81
+
82
+ ```typescript
83
+ interface ShowMoreProps {
84
+ /** Items before truncation. */
85
+ children: ReactNode[]
86
+ /** Number to show initially. Defaults to 3. */
87
+ initialCount?: number
88
+ /** i18n key for the "Show more" label — receives `{ remaining }`. */
89
+ moreKey?: string
90
+ /** i18n key for the "Show less" label. */
91
+ lessKey?: string
92
+ /** Extra classes. */
93
+ className?: string
94
+ }
95
+ ```
96
+
97
+ ### Functions
98
+
99
+ #### `CollapsibleSection(props)`
100
+
101
+ Expandable section with a clickable heading. Lighter-weight than
102
+ `<Accordion>` — renders a single toggle, not a group of panels.
103
+
104
+ Typical uses: "Key concepts" in lesson pages, filter groups in a
105
+ sidebar, FAQ rows, disclosure in settings.
106
+
107
+ ```typescript
108
+ function CollapsibleSection({
109
+ title,
110
+ children,
111
+ expanded,
112
+ defaultExpanded = false,
113
+ onExpandedChange,
114
+ badge,
115
+ actions,
116
+ level = 3,
117
+ className,
118
+ }: CollapsibleSectionProps): JSX.Element
119
+ ```
120
+
121
+ - `props` — Component props (see {@link CollapsibleSectionProps}).
122
+
123
+ #### `ShowMore(props)`
124
+
125
+ "Show N more" / "Show less" toggle. Simpler than `<CollapsibleSection>`
126
+ when you just want to truncate a long list.
127
+
128
+ ```typescript
129
+ function ShowMore({
130
+ children,
131
+ initialCount = 3,
132
+ moreKey = 'showMore.more',
133
+ lessKey = 'showMore.less',
134
+ className,
135
+ }: ShowMoreProps): JSX.Element
136
+ ```
137
+
138
+ - `props` — Component props (see {@link CollapsibleSectionProps}).
139
+
140
+ ## Injection Notes
141
+
142
+ ### Requirements
143
+
144
+ Peer dependencies:
145
+
146
+ - `@molecule/app-react` ^1.0.1
147
+ - `@molecule/app-ui` ^1.0.1
148
+ - `@molecule/app-ui-react` ^1.0.1
149
+ - `react` ^18.0.0 || ^19.0.0
150
+
151
+ ### Runtime Dependencies
152
+
153
+ - `@molecule/app-react`
154
+ - `@molecule/app-ui`
155
+ - `@molecule/app-ui-react`
156
+ - `react`
157
+
158
+ `<CollapsibleSection>` is uncontrolled by default (`defaultExpanded`);
159
+ passing `expanded` makes it fully controlled — then you must update it from
160
+ `onExpandedChange`. The header renders as a single `<button>`, so anything
161
+ passed to `actions` must NOT contain buttons/links (nested interactive
162
+ elements are invalid HTML) — put row actions outside the section instead.
163
+ `<ShowMore>`'s labels use the i18n keys `showMore.more` / `showMore.less`
164
+ with English `defaultValue`s; no companion locale bond ships these keys —
165
+ add them to your app's locale resources (or pass custom `moreKey`/`lessKey`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-collapsible-section-react",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Expandable section with optional \"show more / show less\" and count",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -17,7 +17,8 @@
17
17
  }
18
18
  },
19
19
  "files": [
20
- "dist"
20
+ "dist",
21
+ "README.md"
21
22
  ],
22
23
  "keywords": [
23
24
  "molecule",
@@ -25,16 +26,21 @@
25
26
  "react"
26
27
  ],
27
28
  "license": "Apache-2.0",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/molecule-dev/molecule.git",
32
+ "directory": "packages/app/features/collapsible-section-react"
33
+ },
28
34
  "peerDependencies": {
29
- "@molecule/app-react": "^1.0.0",
30
- "@molecule/app-ui": "^1.0.0",
31
- "@molecule/app-ui-react": "^1.0.0",
35
+ "@molecule/app-react": "^1.0.1",
36
+ "@molecule/app-ui": "^1.0.1",
37
+ "@molecule/app-ui-react": "^1.0.1",
32
38
  "react": "^18.0.0 || ^19.0.0"
33
39
  },
34
40
  "devDependencies": {
35
- "@molecule/app-react": "1.0.0",
36
- "@molecule/app-ui": "1.0.0",
37
- "@molecule/app-ui-react": "1.0.0",
41
+ "@molecule/app-react": "1.0.1",
42
+ "@molecule/app-ui": "1.0.1",
43
+ "@molecule/app-ui-react": "1.0.1",
38
44
  "@types/node": "26.1.2",
39
45
  "@types/react": "19.2.17",
40
46
  "@types/react-dom": "19.2.3",