@xsolla/xui-b2b-accordion 0.148.0 → 0.148.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 +124 -0
  2. package/package.json +4 -4
package/README.md ADDED
@@ -0,0 +1,124 @@
1
+ # B2B Accordion
2
+
3
+ A stacked list of `Collapsible` items with coordinated open/close behaviour. By default only one item can be open at a time (single mode). Use for FAQ sections, setup guides, or any ordered list of expandable content.
4
+
5
+ For a single standalone expandable section, use `@xsolla/xui-b2b-collapsible` instead.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @xsolla/xui-b2b-accordion
11
+ # or
12
+ yarn add @xsolla/xui-b2b-accordion
13
+ ```
14
+
15
+ > `@xsolla/xui-b2b-collapsible` is a peer dependency and is installed automatically.
16
+
17
+ ## Demo
18
+
19
+ ### Setup Guide Pattern
20
+
21
+ ```tsx
22
+ import React from 'react';
23
+ import { Accordion, type AccordionItem } from '@xsolla/xui-b2b-accordion';
24
+ import { Status } from '@xsolla/xui-status';
25
+
26
+ const items: AccordionItem[] = [
27
+ {
28
+ key: 'template',
29
+ title: 'Create and review the template of your game store page',
30
+ trailing: <Status palette="success" size="md" labelType="dot-color">Done</Status>,
31
+ content: <p>Content here.</p>,
32
+ },
33
+ {
34
+ key: 'tips',
35
+ title: 'See tips and tricks for your game store',
36
+ trailing: <Status palette="warning" size="md" labelType="dot-color">In progress</Status>,
37
+ content: <p>Content here.</p>,
38
+ },
39
+ {
40
+ key: 'keys',
41
+ title: 'Set up game keys to sell on your game store page',
42
+ trailing: <Status palette="default" size="md" labelType="dot-color">Pending</Status>,
43
+ content: <p>Content here.</p>,
44
+ },
45
+ ];
46
+
47
+ <Accordion items={items} defaultOpenKeys={['template']} />
48
+ ```
49
+
50
+ ### FAQ Pattern
51
+
52
+ ```tsx
53
+ const items: AccordionItem[] = [
54
+ {
55
+ key: 'what',
56
+ title: 'What is Xsolla?',
57
+ caption: 'About',
58
+ content: <p>Xsolla is a global video game commerce company.</p>,
59
+ },
60
+ {
61
+ key: 'sdk',
62
+ title: 'How do I integrate the SDK?',
63
+ caption: 'Integration',
64
+ content: <p>Follow the integration guide in the developer docs.</p>,
65
+ },
66
+ ];
67
+
68
+ <Accordion items={items} defaultOpenKeys={['what']} />
69
+ ```
70
+
71
+ ### Multiple Open Items
72
+
73
+ ```tsx
74
+ // Allow more than one item open at the same time
75
+ <Accordion items={items} multiple defaultOpenKeys={['what', 'payments']} />
76
+ ```
77
+
78
+ ### Controlled
79
+
80
+ ```tsx
81
+ import React, { useState } from 'react';
82
+
83
+ const [openKeys, setOpenKeys] = useState<string[]>(['what']);
84
+
85
+ <Accordion
86
+ items={items}
87
+ multiple
88
+ openKeys={openKeys}
89
+ onOpenChange={setOpenKeys}
90
+ />
91
+ ```
92
+
93
+ ## API Reference
94
+
95
+ ### Accordion
96
+
97
+ | Prop | Type | Default | Description |
98
+ | :--- | :--- | :------ | :---------- |
99
+ | `items` | `AccordionItem[]` | — | **Required.** Array of item definitions. |
100
+ | `multiple` | `boolean` | `false` | Allow more than one item open simultaneously. |
101
+ | `defaultOpenKeys` | `string[]` | `[]` | Keys open on first render (uncontrolled). |
102
+ | `openKeys` | `string[]` | — | Controlled open keys. |
103
+ | `onOpenChange` | `(keys: string[]) => void` | — | Called when open keys change. |
104
+ | `className` | `string` | — | CSS class applied to the root wrapper. |
105
+ | `themeMode` | `string` | — | Override the global theme mode. |
106
+ | `themeProductContext` | `string` | — | Override the global product context. |
107
+
108
+ ### AccordionItem
109
+
110
+ | Field | Type | Description |
111
+ | :---- | :--- | :---------- |
112
+ | `key` | `string` | **Required.** Unique identifier used for open/close tracking. |
113
+ | `title` | `ReactNode` | **Required.** Title text or node in the trigger row. |
114
+ | `content` | `ReactNode` | **Required.** Body content shown when expanded. |
115
+ | `caption` | `ReactNode` | Secondary text below the title (e.g. category label). |
116
+ | `trailing` | `ReactNode` | Content to the right of the text, before the chevron (e.g. `Status`). |
117
+
118
+ ## Behaviour
119
+
120
+ - Items always use `view="white-surface"` — the Accordion composes `Collapsible` internally.
121
+ - In **single mode** (default), opening an item closes all others.
122
+ - In **multiple mode**, items toggle independently.
123
+ - Controlled mode (`openKeys` + `onOpenChange`) overrides all internal state.
124
+ - Panel content is always in the DOM (hidden via CSS `grid-template-rows: 0fr`) — no mount/unmount on toggle.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsolla/xui-b2b-accordion",
3
- "version": "0.148.0",
3
+ "version": "0.148.1",
4
4
  "main": "./web/index.js",
5
5
  "module": "./web/index.mjs",
6
6
  "types": "./web/index.d.ts",
@@ -13,9 +13,9 @@
13
13
  "test:coverage": "vitest run --coverage"
14
14
  },
15
15
  "dependencies": {
16
- "@xsolla/xui-b2b-collapsible": "0.148.0",
17
- "@xsolla/xui-core": "0.148.0",
18
- "@xsolla/xui-primitives-core": "0.148.0"
16
+ "@xsolla/xui-b2b-collapsible": "0.148.1",
17
+ "@xsolla/xui-core": "0.148.1",
18
+ "@xsolla/xui-primitives-core": "0.148.1"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "react": ">=16.8.0",