@xsolla/xui-b2b-collapsible 0.148.0 → 0.148.2

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 +192 -0
  2. package/package.json +4 -4
package/README.md ADDED
@@ -0,0 +1,192 @@
1
+ # B2B Collapsible
2
+
3
+ A single expandable section with animated open/close. Use for "Show more" patterns, technical details, or any card-level secondary content. For FAQ sections or stacked expandable lists, use `@xsolla/xui-b2b-accordion` instead.
4
+
5
+ > **Migrating from `@xsolla/publisher-account-core`?** See the [prop migration table](#migrating-from-publisher-account-core) below.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @xsolla/xui-b2b-collapsible
11
+ # or
12
+ yarn add @xsolla/xui-b2b-collapsible
13
+ ```
14
+
15
+ ## Demo
16
+
17
+ ### Basic Usage
18
+
19
+ ```tsx
20
+ import React from 'react';
21
+ import { Collapsible } from '@xsolla/xui-b2b-collapsible';
22
+
23
+ <Collapsible
24
+ title="Create and review the template of your game store page"
25
+ caption="Setup"
26
+ view="white-surface"
27
+ >
28
+ <p>Content goes here.</p>
29
+ </Collapsible>
30
+ ```
31
+
32
+ ### Three View Variants
33
+
34
+ ```tsx
35
+ // No background — shows a bottom border divider
36
+ <Collapsible title="Without surface" view="without-surface">
37
+ <p>Content</p>
38
+ </Collapsible>
39
+
40
+ // White card background with border radius
41
+ <Collapsible title="White surface" view="white-surface">
42
+ <p>Content</p>
43
+ </Collapsible>
44
+
45
+ // Grey tinted card background
46
+ <Collapsible title="Grey surface" view="grey-surface">
47
+ <p>Content</p>
48
+ </Collapsible>
49
+ ```
50
+
51
+ ### Open by Default
52
+
53
+ ```tsx
54
+ <Collapsible title="Pre-expanded" view="white-surface" defaultOpen>
55
+ <p>Visible on first render.</p>
56
+ </Collapsible>
57
+ ```
58
+
59
+ ### With Icon Slot (Left)
60
+
61
+ The `icon` slot is a pass-through — wrap with `IconWrapper` or use a `Checkbox` directly.
62
+
63
+ ```tsx
64
+ import { IconWrapper } from '@xsolla/xui-icon-wrapper';
65
+ import { ReverseLeft } from '@xsolla/xui-icons-base';
66
+ import { Checkbox } from '@xsolla/xui-checkbox';
67
+
68
+ // Icon with grey rounded background
69
+ <Collapsible
70
+ title="Setup"
71
+ view="white-surface"
72
+ icon={
73
+ <IconWrapper size="md" shape="smooth">
74
+ <ReverseLeft />
75
+ </IconWrapper>
76
+ }
77
+ >
78
+ <p>Content</p>
79
+ </Collapsible>
80
+
81
+ // Checkbox as the left slot
82
+ <Collapsible
83
+ title="Mark as complete"
84
+ view="white-surface"
85
+ icon={<Checkbox size="md" checked={checked} onChange={(e) => setChecked(e.target.checked)} />}
86
+ >
87
+ <p>Content</p>
88
+ </Collapsible>
89
+ ```
90
+
91
+ ### With Trailing Slot (Right)
92
+
93
+ ```tsx
94
+ import { Status } from '@xsolla/xui-status';
95
+
96
+ <Collapsible
97
+ title="Publish your game store page"
98
+ caption="Publishing"
99
+ view="white-surface"
100
+ trailing={<Status palette="warning" size="md" labelType="dot-color">In progress</Status>}
101
+ >
102
+ <p>Content</p>
103
+ </Collapsible>
104
+ ```
105
+
106
+ ### Controlled
107
+
108
+ ```tsx
109
+ import React, { useState } from 'react';
110
+
111
+ const [open, setOpen] = useState(false);
112
+
113
+ <Collapsible
114
+ title="Controlled"
115
+ view="white-surface"
116
+ open={open}
117
+ onOpenChange={setOpen}
118
+ >
119
+ <p>Content</p>
120
+ </Collapsible>
121
+ ```
122
+
123
+ ## API Reference
124
+
125
+ ### Collapsible
126
+
127
+ | Prop | Type | Default | Description |
128
+ | :--- | :--- | :------ | :---------- |
129
+ | `title` | `ReactNode` | — | **Required.** Title text or node in the trigger row. |
130
+ | `children` | `ReactNode` | — | **Required.** Body content shown when expanded. |
131
+ | `view` | `"without-surface" \| "white-surface" \| "grey-surface"` | `"without-surface"` | Visual surface style. |
132
+ | `caption` | `ReactNode` | — | Secondary text rendered below the title. |
133
+ | `icon` | `ReactNode` | — | Optional slot at the left of the trigger. Consumer controls styling (use `IconWrapper` or `Checkbox`). |
134
+ | `trailing` | `ReactNode` | — | Optional slot to the right of the text, before the chevron (e.g. `Status`). |
135
+ | `defaultOpen` | `boolean` | `false` | Initial open state for uncontrolled usage. |
136
+ | `open` | `boolean` | — | Controlled open state. |
137
+ | `onOpenChange` | `(open: boolean) => void` | — | Called when open state changes. |
138
+ | `className` | `string` | — | CSS class applied to the root element. |
139
+ | `aria-label` | `string` | auto | Accessible label for the trigger button. Defaults to `title` when it is a string. |
140
+ | `themeMode` | `string` | — | Override the global theme mode for this component. |
141
+ | `themeProductContext` | `string` | — | Override the global product context for this component. |
142
+
143
+ ### Deprecated Props (migrating from `@xsolla/publisher-account-core`)
144
+
145
+ These props are still accepted but will log a TypeScript `@deprecated` warning in your IDE.
146
+
147
+ | Deprecated prop | Use instead | Notes |
148
+ | :-------------- | :---------- | :---- |
149
+ | `onChange` | `onOpenChange` | Same signature `(isOpen: boolean) => void` |
150
+ | `statusIcon` | `trailing` | Same shape |
151
+ | `description` | `caption` | Covers the `lg` size `description` prop from the legacy API |
152
+
153
+ Props with no equivalent in the new API (intentional redesign): `backgroundColor`, `size`, `childContentPadding`, `label` (sm size), `openingState` (use `open` / `defaultOpen`).
154
+
155
+ ## Accessibility
156
+
157
+ - Trigger has `role="button"`, `tabIndex={0}`, and `aria-expanded`.
158
+ - Responds to Enter and Space key events.
159
+ - Panel content is always in the DOM (hidden via `grid-template-rows: 0fr`) for screen-reader access.
160
+
161
+ ## Migrating from `@xsolla/publisher-account-core`
162
+
163
+ ```tsx
164
+ // BEFORE
165
+ import { Collapsible } from '@xsolla/publisher-account-core';
166
+
167
+ <Collapsible
168
+ title="Setup"
169
+ description="Step 1 of 3"
170
+ backgroundColor="primary"
171
+ size="lg"
172
+ statusIcon={<CheckIcon />}
173
+ openingState={false}
174
+ onChange={(isOpen) => console.log(isOpen)}
175
+ >
176
+ content
177
+ </Collapsible>
178
+
179
+ // AFTER
180
+ import { Collapsible } from '@xsolla/xui-b2b-collapsible';
181
+
182
+ <Collapsible
183
+ title="Setup"
184
+ caption="Step 1 of 3"
185
+ view="white-surface"
186
+ trailing={<CheckIcon />}
187
+ defaultOpen={false}
188
+ onOpenChange={(isOpen) => console.log(isOpen)}
189
+ >
190
+ content
191
+ </Collapsible>
192
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsolla/xui-b2b-collapsible",
3
- "version": "0.148.0",
3
+ "version": "0.148.2",
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-core": "0.148.0",
17
- "@xsolla/xui-icons-base": "0.148.0",
18
- "@xsolla/xui-primitives-core": "0.148.0"
16
+ "@xsolla/xui-core": "0.148.2",
17
+ "@xsolla/xui-icons-base": "0.148.2",
18
+ "@xsolla/xui-primitives-core": "0.148.2"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "react": ">=16.8.0",