@fvc/drawer 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 +188 -0
  2. package/package.json +11 -1
package/README.md ADDED
@@ -0,0 +1,188 @@
1
+ # @fvc/drawer
2
+
3
+ `@fvc/drawer` provides a FE-VIS styled drawer primitive on top of Ant Design Drawer. It keeps the Ant Design Drawer API familiar while adding structured layout slots — `Drawer.Header`, `Drawer.Content`, and `Drawer.Footer` — a push animation default, and sensible dimension defaults for enterprise form panels.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @fvc/drawer
9
+ ```
10
+
11
+ ## Peer Dependencies
12
+
13
+ ```bash
14
+ bun add react antd
15
+ ```
16
+
17
+ ## Import
18
+
19
+ ```tsx
20
+ import { Drawer } from '@fvc/drawer';
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ```tsx
26
+ import { Drawer } from '@fvc/drawer';
27
+
28
+ export function RecordDrawer({ open, onClose }) {
29
+ return (
30
+ <Drawer open={open} onClose={onClose} title="Record details">
31
+ <Drawer.Content>
32
+ <p>Form fields go here.</p>
33
+ </Drawer.Content>
34
+ </Drawer>
35
+ );
36
+ }
37
+ ```
38
+
39
+ ## Components
40
+
41
+ | Component | Use case |
42
+ | --- | --- |
43
+ | `Drawer` | Root drawer container. |
44
+ | `Drawer.Header` | Header slot — sits at the top of the drawer body. |
45
+ | `Drawer.Content` | Main content slot — scrollable area between header and footer. |
46
+ | `Drawer.Footer` | Footer slot — sits at the bottom of the drawer body, typically holds action buttons. |
47
+
48
+ ## Common Usage
49
+
50
+ ### With Header, Content and Footer
51
+
52
+ ```tsx
53
+ <Drawer open={open} onClose={onClose} title="Edit record">
54
+ <Drawer.Header>
55
+ <Tabs items={tabs} />
56
+ </Drawer.Header>
57
+
58
+ <Drawer.Content>
59
+ <Form layout="vertical">
60
+ <Input name="name" label="Name" />
61
+ <Input name="email" label="Email" />
62
+ </Form>
63
+ </Drawer.Content>
64
+
65
+ <Drawer.Footer>
66
+ <Button type="secondary" onClick={onClose}>Cancel</Button>
67
+ <Button type="primary" onClick={handleSave}>Save</Button>
68
+ </Drawer.Footer>
69
+ </Drawer>
70
+ ```
71
+
72
+ ### Placement
73
+
74
+ ```tsx
75
+ <Drawer open={open} placement="left" onClose={onClose}>
76
+ <Drawer.Content>Navigation</Drawer.Content>
77
+ </Drawer>
78
+ ```
79
+
80
+ ### Custom Width
81
+
82
+ ```tsx
83
+ <Drawer open={open} width={480} onClose={onClose}>
84
+ <Drawer.Content>Wide panel</Drawer.Content>
85
+ </Drawer>
86
+ ```
87
+
88
+ ### Without Mask
89
+
90
+ ```tsx
91
+ <Drawer open={open} mask={false} onClose={onClose}>
92
+ <Drawer.Content>Inline panel</Drawer.Content>
93
+ </Drawer>
94
+ ```
95
+
96
+ ### Non-maskClosable
97
+
98
+ ```tsx
99
+ <Drawer open={open} maskClosable={false} onClose={onClose}>
100
+ <Drawer.Content>Must use close button</Drawer.Content>
101
+ </Drawer>
102
+ ```
103
+
104
+ ## Props
105
+
106
+ ### Drawer
107
+
108
+ | Prop | Type | Description |
109
+ | --- | --- | --- |
110
+ | `placement` | `'left' \| 'right' \| 'top' \| 'bottom'` | Side to open from. Defaults to `'right'`. |
111
+ | `width` | `number` | Drawer width in pixels. Defaults to `256`. |
112
+ | `height` | `number` | Drawer height in pixels (for top/bottom placement). Defaults to `256`. |
113
+ | `maskClosable` | `boolean` | Close on mask click. Defaults to `true`. |
114
+ | `mask` | `boolean` | Show overlay mask. Defaults to `true`. |
115
+ | `push` | `{ distance: number }` | Push content when drawer opens. Defaults to `{ distance: 180 }`. |
116
+ | `testId` | `string` | Maps to `data-testid`. Defaults to `'drawer'`. |
117
+ | *All `DrawerProps`* | — | All Ant Design Drawer props (`open`, `onClose`, `title`, `extra`, `footer`, `closable`, etc.). |
118
+
119
+ ### Drawer.Header / Drawer.Content / Drawer.Footer
120
+
121
+ | Prop | Type | Description |
122
+ | --- | --- | --- |
123
+ | `children` | `ReactNode` | Slot content. |
124
+ | `style` | `CSSProperties` | Inline styles. |
125
+ | `testId` | `string` | Maps to `data-testid` (auto-prefixed: `header`, `content`, `footer`). |
126
+ | `testIdPostfix` | `string` | Override the testId postfix. |
127
+
128
+ ## Consumer Example
129
+
130
+ ```tsx
131
+ import { Drawer } from '@fvc/drawer';
132
+ import { Button } from '@fvc/button';
133
+
134
+ export function ContractDrawer({ contractId, open, onClose, onSave }) {
135
+ return (
136
+ <Drawer
137
+ open={open}
138
+ onClose={onClose}
139
+ title="Contract details"
140
+ width={640}
141
+ testId="contract-drawer"
142
+ >
143
+ <Drawer.Content testId="contract-drawer-content">
144
+ <ContractForm contractId={contractId} />
145
+ </Drawer.Content>
146
+
147
+ <Drawer.Footer>
148
+ <Button type="secondary" onClick={onClose}>Cancel</Button>
149
+ <Button type="primary" onClick={onSave}>Save changes</Button>
150
+ </Drawer.Footer>
151
+ </Drawer>
152
+ );
153
+ }
154
+ ```
155
+
156
+ ## Testing
157
+
158
+ ```tsx
159
+ <Drawer open testId="edit-drawer" onClose={() => {}}>
160
+ <Drawer.Content>Content</Drawer.Content>
161
+ </Drawer>
162
+ ```
163
+
164
+ ```tsx
165
+ screen.getByTestId('edit-drawer');
166
+ screen.getByTestId('edit-drawer-content');
167
+ ```
168
+
169
+ ## CSS Customisation
170
+
171
+ ```css
172
+ :root {
173
+ /* Drawer background */
174
+ --card-bg-color-20: #f5f7fa;
175
+
176
+ /* Close button icon */
177
+ --white-icon-color-0: #ffffff;
178
+ }
179
+ ```
180
+
181
+ ## Development
182
+
183
+ ```bash
184
+ bun run lint
185
+ bun run type-check
186
+ bun run test
187
+ bun run build
188
+ ```
package/package.json CHANGED
@@ -1,6 +1,16 @@
1
1
  {
2
2
  "name": "@fvc/drawer",
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
+ "drawer",
11
+ "design-system",
12
+ "antd"
13
+ ],
4
14
  "main": "./dist/lib/index.js",
5
15
  "types": "./dist/lib/drawer/src/index.d.ts",
6
16
  "files": [