@papernote/ui 1.3.1 → 1.6.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.
- package/dist/components/ActionBar.d.ts +112 -0
- package/dist/components/ActionBar.d.ts.map +1 -0
- package/dist/components/BottomNavigation.d.ts +98 -0
- package/dist/components/BottomNavigation.d.ts.map +1 -0
- package/dist/components/Checkbox.d.ts +2 -0
- package/dist/components/Checkbox.d.ts.map +1 -1
- package/dist/components/CheckboxList.d.ts +81 -0
- package/dist/components/CheckboxList.d.ts.map +1 -0
- package/dist/components/Chip.d.ts +92 -1
- package/dist/components/Chip.d.ts.map +1 -1
- package/dist/components/ConfirmDialog.d.ts +43 -1
- package/dist/components/ConfirmDialog.d.ts.map +1 -1
- package/dist/components/DataTable.d.ts +10 -1
- package/dist/components/DataTable.d.ts.map +1 -1
- package/dist/components/DataTableCardView.d.ts +99 -0
- package/dist/components/DataTableCardView.d.ts.map +1 -0
- package/dist/components/ExpandablePanel.d.ts +142 -0
- package/dist/components/ExpandablePanel.d.ts.map +1 -0
- package/dist/components/FloatingActionButton.d.ts +98 -0
- package/dist/components/FloatingActionButton.d.ts.map +1 -0
- package/dist/components/Input.d.ts +45 -1
- package/dist/components/Input.d.ts.map +1 -1
- package/dist/components/MobileHeader.d.ts +98 -0
- package/dist/components/MobileHeader.d.ts.map +1 -0
- package/dist/components/MobileLayout.d.ts +121 -0
- package/dist/components/MobileLayout.d.ts.map +1 -0
- package/dist/components/Modal.d.ts +78 -1
- package/dist/components/Modal.d.ts.map +1 -1
- package/dist/components/PageHeader.d.ts +86 -0
- package/dist/components/PageHeader.d.ts.map +1 -0
- package/dist/components/PullToRefresh.d.ts +87 -0
- package/dist/components/PullToRefresh.d.ts.map +1 -0
- package/dist/components/QueryTransparency.d.ts +1 -1
- package/dist/components/QueryTransparency.d.ts.map +1 -1
- package/dist/components/SearchableList.d.ts +83 -0
- package/dist/components/SearchableList.d.ts.map +1 -0
- package/dist/components/Select.d.ts +16 -2
- package/dist/components/Select.d.ts.map +1 -1
- package/dist/components/Sidebar.d.ts +40 -1
- package/dist/components/Sidebar.d.ts.map +1 -1
- package/dist/components/SwipeActions.d.ts +93 -0
- package/dist/components/SwipeActions.d.ts.map +1 -0
- package/dist/components/Switch.d.ts +1 -0
- package/dist/components/Switch.d.ts.map +1 -1
- package/dist/components/Textarea.d.ts +13 -0
- package/dist/components/Textarea.d.ts.map +1 -1
- package/dist/components/index.d.ts +31 -3
- package/dist/components/index.d.ts.map +1 -1
- package/dist/context/MobileContext.d.ts +168 -0
- package/dist/context/MobileContext.d.ts.map +1 -0
- package/dist/hooks/useResponsive.d.ts +158 -0
- package/dist/hooks/useResponsive.d.ts.map +1 -0
- package/dist/index.d.ts +1871 -51
- package/dist/index.esm.js +3025 -196
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3063 -194
- package/dist/index.js.map +1 -1
- package/dist/styles.css +434 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/ActionBar.stories.tsx +246 -0
- package/src/components/ActionBar.tsx +242 -0
- package/src/components/BottomNavigation.stories.tsx +142 -0
- package/src/components/BottomNavigation.tsx +225 -0
- package/src/components/Checkbox.stories.tsx +162 -0
- package/src/components/Checkbox.tsx +22 -6
- package/src/components/CheckboxList.stories.tsx +311 -0
- package/src/components/CheckboxList.tsx +433 -0
- package/src/components/Chip.stories.tsx +389 -0
- package/src/components/Chip.tsx +182 -3
- package/src/components/ConfirmDialog.tsx +56 -4
- package/src/components/DataTable.tsx +60 -1
- package/src/components/DataTableCardView.stories.tsx +307 -0
- package/src/components/DataTableCardView.tsx +419 -0
- package/src/components/ExpandablePanel.stories.tsx +620 -0
- package/src/components/ExpandablePanel.tsx +383 -0
- package/src/components/FloatingActionButton.stories.tsx +197 -0
- package/src/components/FloatingActionButton.tsx +301 -0
- package/src/components/Grid.stories.tsx +16 -16
- package/src/components/Input.stories.tsx +214 -0
- package/src/components/Input.tsx +81 -4
- package/src/components/MobileHeader.stories.tsx +205 -0
- package/src/components/MobileHeader.tsx +233 -0
- package/src/components/MobileLayout.stories.tsx +338 -0
- package/src/components/MobileLayout.tsx +313 -0
- package/src/components/Modal.stories.tsx +388 -0
- package/src/components/Modal.tsx +122 -4
- package/src/components/PageHeader.stories.tsx +198 -0
- package/src/components/PageHeader.tsx +217 -0
- package/src/components/PullToRefresh.stories.tsx +321 -0
- package/src/components/PullToRefresh.tsx +294 -0
- package/src/components/QueryTransparency.tsx +1 -1
- package/src/components/SearchableList.stories.tsx +437 -0
- package/src/components/SearchableList.tsx +326 -0
- package/src/components/Select.stories.tsx +190 -0
- package/src/components/Select.tsx +353 -137
- package/src/components/Sidebar.tsx +193 -10
- package/src/components/SwipeActions.stories.tsx +327 -0
- package/src/components/SwipeActions.tsx +387 -0
- package/src/components/Switch.stories.tsx +158 -0
- package/src/components/Switch.tsx +12 -3
- package/src/components/Textarea.tsx +31 -1
- package/src/components/index.ts +69 -3
- package/src/context/MobileContext.tsx +296 -0
- package/src/hooks/useResponsive.ts +360 -0
- package/src/types/index.ts +4 -0
- package/tailwind.config.js +56 -1
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import CheckboxList from './CheckboxList';
|
|
4
|
+
import { CheckboxListItem } from './CheckboxList';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Forms/CheckboxList',
|
|
8
|
+
component: CheckboxList,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
docs: {
|
|
12
|
+
description: {
|
|
13
|
+
component: `
|
|
14
|
+
A multi-select list component with checkboxes, grouping support, and search functionality.
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
- **Multi-select**: Click checkboxes to select/deselect items
|
|
18
|
+
- **Grouping**: Organize items into collapsible groups
|
|
19
|
+
- **Search/Filter**: Built-in search with debounce
|
|
20
|
+
- **Select All**: Optional select all checkbox
|
|
21
|
+
- **Selected Count**: Show number of selected items
|
|
22
|
+
- **Sizes**: sm, md, lg variants
|
|
23
|
+
- **Variants**: default, bordered, card styles
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
\`\`\`tsx
|
|
28
|
+
import { CheckboxList } from 'notebook-ui';
|
|
29
|
+
|
|
30
|
+
<CheckboxList
|
|
31
|
+
items={[
|
|
32
|
+
{ key: '1', label: 'Option 1' },
|
|
33
|
+
{ key: '2', label: 'Option 2', description: 'With description' },
|
|
34
|
+
]}
|
|
35
|
+
selectedKeys={selected}
|
|
36
|
+
onSelectionChange={setSelected}
|
|
37
|
+
searchable
|
|
38
|
+
showSelectAll
|
|
39
|
+
/>
|
|
40
|
+
\`\`\`
|
|
41
|
+
`,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
tags: ['autodocs'],
|
|
46
|
+
argTypes: {
|
|
47
|
+
size: {
|
|
48
|
+
control: 'select',
|
|
49
|
+
options: ['sm', 'md', 'lg'],
|
|
50
|
+
description: 'Size variant',
|
|
51
|
+
},
|
|
52
|
+
variant: {
|
|
53
|
+
control: 'select',
|
|
54
|
+
options: ['default', 'bordered', 'card'],
|
|
55
|
+
description: 'Visual variant',
|
|
56
|
+
},
|
|
57
|
+
searchable: {
|
|
58
|
+
control: 'boolean',
|
|
59
|
+
description: 'Enable search functionality',
|
|
60
|
+
},
|
|
61
|
+
showSelectAll: {
|
|
62
|
+
control: 'boolean',
|
|
63
|
+
description: 'Show select all checkbox',
|
|
64
|
+
},
|
|
65
|
+
showSelectedCount: {
|
|
66
|
+
control: 'boolean',
|
|
67
|
+
description: 'Show selected count',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
decorators: [
|
|
71
|
+
(Story) => (
|
|
72
|
+
<div style={{ minWidth: '400px' }}>
|
|
73
|
+
<Story />
|
|
74
|
+
</div>
|
|
75
|
+
),
|
|
76
|
+
],
|
|
77
|
+
} satisfies Meta<typeof CheckboxList>;
|
|
78
|
+
|
|
79
|
+
export default meta;
|
|
80
|
+
type Story = StoryObj<typeof meta>;
|
|
81
|
+
|
|
82
|
+
const simpleItems: CheckboxListItem[] = [
|
|
83
|
+
{ key: '1', label: 'Email notifications' },
|
|
84
|
+
{ key: '2', label: 'Push notifications' },
|
|
85
|
+
{ key: '3', label: 'SMS notifications' },
|
|
86
|
+
{ key: '4', label: 'Marketing emails' },
|
|
87
|
+
{ key: '5', label: 'Weekly digest' },
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
const itemsWithDescriptions: CheckboxListItem[] = [
|
|
91
|
+
{ key: 'email', label: 'Email', description: 'Receive notifications via email' },
|
|
92
|
+
{ key: 'push', label: 'Push', description: 'Browser push notifications' },
|
|
93
|
+
{ key: 'sms', label: 'SMS', description: 'Text message alerts' },
|
|
94
|
+
{ key: 'slack', label: 'Slack', description: 'Slack channel notifications' },
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
const groupedItems: CheckboxListItem[] = [
|
|
98
|
+
{ key: 'users.id', label: 'ID', description: 'uuid', group: 'users' },
|
|
99
|
+
{ key: 'users.name', label: 'Name', description: 'string', group: 'users' },
|
|
100
|
+
{ key: 'users.email', label: 'Email', description: 'string', group: 'users' },
|
|
101
|
+
{ key: 'users.created_at', label: 'Created At', description: 'timestamp', group: 'users' },
|
|
102
|
+
{ key: 'orders.id', label: 'ID', description: 'uuid', group: 'orders' },
|
|
103
|
+
{ key: 'orders.total', label: 'Total', description: 'number', group: 'orders' },
|
|
104
|
+
{ key: 'orders.status', label: 'Status', description: 'string', group: 'orders' },
|
|
105
|
+
{ key: 'products.id', label: 'ID', description: 'uuid', group: 'products' },
|
|
106
|
+
{ key: 'products.name', label: 'Name', description: 'string', group: 'products' },
|
|
107
|
+
{ key: 'products.price', label: 'Price', description: 'number', group: 'products' },
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
export const Default: Story = {
|
|
111
|
+
render: () => {
|
|
112
|
+
const [selected, setSelected] = useState<string[]>(['1', '3']);
|
|
113
|
+
return (
|
|
114
|
+
<CheckboxList
|
|
115
|
+
items={simpleItems}
|
|
116
|
+
selectedKeys={selected}
|
|
117
|
+
onSelectionChange={setSelected}
|
|
118
|
+
/>
|
|
119
|
+
);
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const WithDescriptions: Story = {
|
|
124
|
+
render: () => {
|
|
125
|
+
const [selected, setSelected] = useState<string[]>(['email']);
|
|
126
|
+
return (
|
|
127
|
+
<CheckboxList
|
|
128
|
+
items={itemsWithDescriptions}
|
|
129
|
+
selectedKeys={selected}
|
|
130
|
+
onSelectionChange={setSelected}
|
|
131
|
+
variant="bordered"
|
|
132
|
+
/>
|
|
133
|
+
);
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export const Searchable: Story = {
|
|
138
|
+
render: () => {
|
|
139
|
+
const [selected, setSelected] = useState<string[]>([]);
|
|
140
|
+
return (
|
|
141
|
+
<CheckboxList
|
|
142
|
+
items={itemsWithDescriptions}
|
|
143
|
+
selectedKeys={selected}
|
|
144
|
+
onSelectionChange={setSelected}
|
|
145
|
+
searchable
|
|
146
|
+
searchPlaceholder="Search notifications..."
|
|
147
|
+
variant="card"
|
|
148
|
+
/>
|
|
149
|
+
);
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export const WithSelectAll: Story = {
|
|
154
|
+
render: () => {
|
|
155
|
+
const [selected, setSelected] = useState<string[]>(['1', '2']);
|
|
156
|
+
return (
|
|
157
|
+
<CheckboxList
|
|
158
|
+
items={simpleItems}
|
|
159
|
+
selectedKeys={selected}
|
|
160
|
+
onSelectionChange={setSelected}
|
|
161
|
+
showSelectAll
|
|
162
|
+
showSelectedCount
|
|
163
|
+
variant="bordered"
|
|
164
|
+
/>
|
|
165
|
+
);
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export const Grouped: Story = {
|
|
170
|
+
render: () => {
|
|
171
|
+
const [selected, setSelected] = useState<string[]>(['users.id', 'users.name', 'orders.total']);
|
|
172
|
+
const [expandedGroups, setExpandedGroups] = useState<string[]>(['users', 'orders']);
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<CheckboxList
|
|
176
|
+
items={groupedItems}
|
|
177
|
+
selectedKeys={selected}
|
|
178
|
+
onSelectionChange={setSelected}
|
|
179
|
+
groupLabels={{
|
|
180
|
+
users: 'Users Table',
|
|
181
|
+
orders: 'Orders Table',
|
|
182
|
+
products: 'Products Table',
|
|
183
|
+
}}
|
|
184
|
+
expandedGroups={expandedGroups}
|
|
185
|
+
onGroupToggle={(group, expanded) => {
|
|
186
|
+
if (expanded) {
|
|
187
|
+
setExpandedGroups([...expandedGroups, group]);
|
|
188
|
+
} else {
|
|
189
|
+
setExpandedGroups(expandedGroups.filter(g => g !== group));
|
|
190
|
+
}
|
|
191
|
+
}}
|
|
192
|
+
searchable
|
|
193
|
+
searchPlaceholder="Search fields..."
|
|
194
|
+
showSelectAll
|
|
195
|
+
showSelectedCount
|
|
196
|
+
maxHeight="350px"
|
|
197
|
+
variant="card"
|
|
198
|
+
/>
|
|
199
|
+
);
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export const Small: Story = {
|
|
204
|
+
render: () => {
|
|
205
|
+
const [selected, setSelected] = useState<string[]>(['1']);
|
|
206
|
+
return (
|
|
207
|
+
<CheckboxList
|
|
208
|
+
items={simpleItems}
|
|
209
|
+
selectedKeys={selected}
|
|
210
|
+
onSelectionChange={setSelected}
|
|
211
|
+
size="sm"
|
|
212
|
+
variant="bordered"
|
|
213
|
+
/>
|
|
214
|
+
);
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export const Large: Story = {
|
|
219
|
+
render: () => {
|
|
220
|
+
const [selected, setSelected] = useState<string[]>(['email', 'push']);
|
|
221
|
+
return (
|
|
222
|
+
<CheckboxList
|
|
223
|
+
items={itemsWithDescriptions}
|
|
224
|
+
selectedKeys={selected}
|
|
225
|
+
onSelectionChange={setSelected}
|
|
226
|
+
size="lg"
|
|
227
|
+
variant="card"
|
|
228
|
+
/>
|
|
229
|
+
);
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export const WithDisabledItems: Story = {
|
|
234
|
+
render: () => {
|
|
235
|
+
const items: CheckboxListItem[] = [
|
|
236
|
+
{ key: '1', label: 'Available option' },
|
|
237
|
+
{ key: '2', label: 'Another available option' },
|
|
238
|
+
{ key: '3', label: 'Disabled option', disabled: true },
|
|
239
|
+
{ key: '4', label: 'Also disabled', disabled: true },
|
|
240
|
+
{ key: '5', label: 'Last available option' },
|
|
241
|
+
];
|
|
242
|
+
const [selected, setSelected] = useState<string[]>(['1']);
|
|
243
|
+
|
|
244
|
+
return (
|
|
245
|
+
<CheckboxList
|
|
246
|
+
items={items}
|
|
247
|
+
selectedKeys={selected}
|
|
248
|
+
onSelectionChange={setSelected}
|
|
249
|
+
showSelectAll
|
|
250
|
+
variant="bordered"
|
|
251
|
+
/>
|
|
252
|
+
);
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
export const EmptyState: Story = {
|
|
257
|
+
render: () => {
|
|
258
|
+
const [selected, setSelected] = useState<string[]>([]);
|
|
259
|
+
return (
|
|
260
|
+
<CheckboxList
|
|
261
|
+
items={[]}
|
|
262
|
+
selectedKeys={selected}
|
|
263
|
+
onSelectionChange={setSelected}
|
|
264
|
+
emptyMessage="No items available"
|
|
265
|
+
variant="card"
|
|
266
|
+
/>
|
|
267
|
+
);
|
|
268
|
+
},
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
export const FieldSelector: Story = {
|
|
272
|
+
parameters: {
|
|
273
|
+
docs: {
|
|
274
|
+
description: {
|
|
275
|
+
story: 'Example of a field selector for a report builder, with grouped database columns.',
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
render: () => {
|
|
280
|
+
const [selected, setSelected] = useState<string[]>([
|
|
281
|
+
'users.name',
|
|
282
|
+
'users.email',
|
|
283
|
+
'orders.total',
|
|
284
|
+
]);
|
|
285
|
+
|
|
286
|
+
return (
|
|
287
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
|
|
288
|
+
<h3 style={{ fontSize: '1rem', fontWeight: 600 }}>Select Report Fields</h3>
|
|
289
|
+
<CheckboxList
|
|
290
|
+
items={groupedItems}
|
|
291
|
+
selectedKeys={selected}
|
|
292
|
+
onSelectionChange={setSelected}
|
|
293
|
+
groupLabels={{
|
|
294
|
+
users: 'Users (u)',
|
|
295
|
+
orders: 'Orders (o)',
|
|
296
|
+
products: 'Products (p)',
|
|
297
|
+
}}
|
|
298
|
+
defaultExpandedGroups={['users', 'orders', 'products']}
|
|
299
|
+
searchable
|
|
300
|
+
searchPlaceholder="Search columns..."
|
|
301
|
+
showSelectedCount
|
|
302
|
+
maxHeight="400px"
|
|
303
|
+
variant="card"
|
|
304
|
+
/>
|
|
305
|
+
<div style={{ fontSize: '0.875rem', color: '#666' }}>
|
|
306
|
+
Selected: {selected.join(', ') || 'None'}
|
|
307
|
+
</div>
|
|
308
|
+
</div>
|
|
309
|
+
);
|
|
310
|
+
},
|
|
311
|
+
};
|