@fvc/accordion 1.1.1 → 1.1.2-rc.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.
Files changed (2) hide show
  1. package/README.md +294 -0
  2. package/package.json +11 -1
package/README.md ADDED
@@ -0,0 +1,294 @@
1
+ # @fvc/accordion
2
+
3
+ `@fvc/accordion` provides FE-VIS styled accordion primitives on top of Ant Design Collapse. It keeps the Ant Design Collapse API familiar while adding the design-system behaviour used across FE-VIS applications: bordered and transparent variants, item-level border and background controls, header alignment options, collapse layout mode, and a disabled state.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @fvc/accordion
9
+ ```
10
+
11
+ ## Peer Dependencies
12
+
13
+ The package expects these dependencies to be available in the consuming application:
14
+
15
+ ```bash
16
+ bun add react antd
17
+ ```
18
+
19
+ ## Import
20
+
21
+ ```tsx
22
+ import { Accordion } from '@fvc/accordion';
23
+ ```
24
+
25
+ ## Quick Start
26
+
27
+ ```tsx
28
+ import { Accordion } from '@fvc/accordion';
29
+
30
+ export function FaqSection() {
31
+ return (
32
+ <Accordion
33
+ defaultActiveKey="1"
34
+ items={[
35
+ { key: '1', label: 'What is FE-VIS?', children: 'FE-VIS is a design system for enterprise applications.' },
36
+ { key: '2', label: 'How do I install it?', children: 'Run bun add @fvc/accordion.' },
37
+ ]}
38
+ />
39
+ );
40
+ }
41
+ ```
42
+
43
+ ## Common Usage
44
+
45
+ ### Bordered and Borderless
46
+
47
+ Bordered is the default. Pass `bordered: false` inside `collapseProps` to remove the outer border.
48
+
49
+ ```tsx
50
+ <Accordion
51
+ collapseProps={{ bordered: false }}
52
+ items={[
53
+ { key: '1', label: 'Section', children: 'Content' },
54
+ ]}
55
+ />
56
+ ```
57
+
58
+ ### Transparent Background
59
+
60
+ ```tsx
61
+ <Accordion
62
+ collapseProps={{ transparent: true }}
63
+ items={[
64
+ { key: '1', label: 'Section', children: 'Content' },
65
+ ]}
66
+ />
67
+ ```
68
+
69
+ ### Collapse Layout Mode
70
+
71
+ Use `collapse` for a flat, continuous layout without rounded corners — suitable for panels embedded inside cards or drawers.
72
+
73
+ ```tsx
74
+ <Accordion
75
+ collapse
76
+ items={[
77
+ { key: '1', label: 'Details', children: 'Content' },
78
+ { key: '2', label: 'More', children: 'Content' },
79
+ ]}
80
+ />
81
+ ```
82
+
83
+ ### Header Vertical Alignment
84
+
85
+ By default the header text and expand icon are top-aligned. Use `center` to flex-center them — useful when the label contains multi-line or rich content.
86
+
87
+ ```tsx
88
+ <Accordion
89
+ collapseHeaderProps={{ verticalAlign: 'center' }}
90
+ items={[
91
+ { key: '1', label: 'Section', children: 'Content' },
92
+ ]}
93
+ />
94
+ ```
95
+
96
+ ### Multiple Open Panels
97
+
98
+ ```tsx
99
+ <Accordion
100
+ defaultActiveKey={['1', '2']}
101
+ items={[
102
+ { key: '1', label: 'First', children: 'Content' },
103
+ { key: '2', label: 'Second', children: 'Content' },
104
+ { key: '3', label: 'Third', children: 'Content' },
105
+ ]}
106
+ />
107
+ ```
108
+
109
+ ### Disabled State
110
+
111
+ Disable the entire accordion with the `disabled` prop, or disable individual items via the `items` array.
112
+
113
+ ```tsx
114
+ {/* Entire accordion disabled */}
115
+ <Accordion
116
+ disabled
117
+ items={[
118
+ { key: '1', label: 'Section', children: 'Content' },
119
+ ]}
120
+ />
121
+
122
+ {/* Single item disabled */}
123
+ <Accordion
124
+ items={[
125
+ { key: '1', label: 'Available', children: 'Content' },
126
+ { key: '2', label: 'Unavailable', children: 'Content', disabled: true },
127
+ ]}
128
+ />
129
+ ```
130
+
131
+ ### Custom Header Content
132
+
133
+ The `label` field accepts any React node.
134
+
135
+ ```tsx
136
+ <Accordion
137
+ items={[
138
+ {
139
+ key: '1',
140
+ label: <span style={{ fontWeight: 700 }}>Custom Header</span>,
141
+ children: 'Content',
142
+ },
143
+ ]}
144
+ />
145
+ ```
146
+
147
+ ### Expand Icon Position
148
+
149
+ ```tsx
150
+ <Accordion
151
+ expandIconPosition="end"
152
+ items={[
153
+ { key: '1', label: 'Section', children: 'Content' },
154
+ ]}
155
+ />
156
+ ```
157
+
158
+ ### Item-level Border and Background
159
+
160
+ Override border and background for individual items using `collapseItemProps`.
161
+
162
+ ```tsx
163
+ <Accordion
164
+ collapseItemProps={{ bordered: false, transparent: true }}
165
+ items={[
166
+ { key: '1', label: 'Section', children: 'Content' },
167
+ ]}
168
+ />
169
+ ```
170
+
171
+ ### Nested Components
172
+
173
+ Use `forceRender` to prevent lazy unmounting when the panel closes — required when the child component holds internal state.
174
+
175
+ ```tsx
176
+ <Accordion
177
+ items={[
178
+ {
179
+ key: '1',
180
+ label: 'Data table',
181
+ children: <Table columns={columns} dataSource={data} />,
182
+ forceRender: true,
183
+ },
184
+ ]}
185
+ />
186
+ ```
187
+
188
+ ### Controlled
189
+
190
+ ```tsx
191
+ <Accordion
192
+ activeKey={activeKey}
193
+ onChange={(key) => setActiveKey(key)}
194
+ items={[
195
+ { key: '1', label: 'Section', children: 'Content' },
196
+ ]}
197
+ />
198
+ ```
199
+
200
+ ## Props
201
+
202
+ | Prop | Type | Description |
203
+ | --- | --- | --- |
204
+ | `collapseProps` | `{ bordered?: boolean; transparent?: boolean }` | Styling for the outer collapse container. |
205
+ | `collapseItemProps` | `{ bordered?: boolean; transparent?: boolean }` | Styling applied to every accordion item. |
206
+ | `collapseHeaderProps` | `{ verticalAlign?: 'default' \| 'center' }` | Header alignment. Defaults to `'default'` (top-aligned). |
207
+ | `disabled` | `boolean` | Disables the entire accordion. |
208
+ | `collapse` | `boolean` | Flat, borderless collapse layout mode. |
209
+ | `testId` | `string` | Maps to `data-testid`. Defaults to `'accordion'`. |
210
+ | *All `CollapseProps`* | — | All Ant Design Collapse props are supported (`items`, `activeKey`, `defaultActiveKey`, `expandIcon`, `expandIconPosition`, `onChange`, etc.). |
211
+
212
+ > **Deprecated props:** `children` (use `items` instead) and the `onChange` wrapper (use the native `CollapseProps.onChange` directly).
213
+
214
+ ## Consumer Example
215
+
216
+ ```tsx
217
+ import { Accordion } from '@fvc/accordion';
218
+
219
+ export function ContractDetails({ contract }) {
220
+ return (
221
+ <Accordion
222
+ collapse
223
+ collapseHeaderProps={{ verticalAlign: 'center' }}
224
+ defaultActiveKey="general"
225
+ items={[
226
+ {
227
+ key: 'general',
228
+ label: 'General information',
229
+ children: <GeneralInfoPanel data={contract.general} />,
230
+ },
231
+ {
232
+ key: 'parties',
233
+ label: 'Parties',
234
+ children: <PartiesPanel data={contract.parties} />,
235
+ },
236
+ {
237
+ key: 'attachments',
238
+ label: 'Attachments',
239
+ children: <AttachmentsTable data={contract.attachments} />,
240
+ forceRender: true,
241
+ },
242
+ ]}
243
+ />
244
+ );
245
+ }
246
+ ```
247
+
248
+ ## Testing
249
+
250
+ Use `testId` when a stable test selector is needed.
251
+
252
+ ```tsx
253
+ <Accordion
254
+ testId="faq-accordion"
255
+ items={[
256
+ { key: '1', label: 'Question', children: 'Answer' },
257
+ ]}
258
+ />
259
+ ```
260
+
261
+ ```tsx
262
+ screen.getByTestId('faq-accordion');
263
+ ```
264
+
265
+ ## CSS Customisation
266
+
267
+ The component consumes global design tokens. Override them in your application's global styles to retheme the accordion:
268
+
269
+ ```css
270
+ :root {
271
+ /* Border */
272
+ --blue-gray-200: #c9d3e0;
273
+
274
+ /* Backgrounds */
275
+ --neutral-0: #ffffff;
276
+
277
+ /* Active header text */
278
+ --link-on-light-bg-color-500: #0057b7;
279
+
280
+ /* Content text */
281
+ --body-text-color-1000: #1a1a1a;
282
+ }
283
+ ```
284
+
285
+ For the full style reference see [`src/Accordion.scss`](./src/Accordion.scss).
286
+
287
+ ## Development
288
+
289
+ ```bash
290
+ bun run lint
291
+ bun run type-check
292
+ bun run test
293
+ bun run build
294
+ ```
package/package.json CHANGED
@@ -1,6 +1,16 @@
1
1
  {
2
2
  "name": "@fvc/accordion",
3
- "version": "1.1.1",
3
+ "version": "1.1.2-rc.0",
4
+ "keywords": [
5
+ "react",
6
+ "react-component",
7
+ "fvc",
8
+ "fe-vis-core",
9
+ "ui",
10
+ "accordion",
11
+ "design-system",
12
+ "antd"
13
+ ],
4
14
  "main": "./dist/lib/index.js",
5
15
  "types": "./dist/lib/accordion/src/index.d.ts",
6
16
  "files": [