@bacon-pos/ui 0.9.0 → 0.10.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/lib/commonjs/components/EmptyState/EmptyState.js +88 -0
- package/lib/commonjs/components/EmptyState/EmptyState.js.map +1 -0
- package/lib/commonjs/components/EmptyState/EmptyState.stories.js +46 -0
- package/lib/commonjs/components/EmptyState/EmptyState.stories.js.map +1 -0
- package/lib/commonjs/components/EmptyState/EmptyState.test.js +40 -0
- package/lib/commonjs/components/EmptyState/EmptyState.test.js.map +1 -0
- package/lib/commonjs/components/EmptyState/index.js +13 -0
- package/lib/commonjs/components/EmptyState/index.js.map +1 -0
- package/lib/commonjs/components/Sidebar/Sidebar.js +264 -0
- package/lib/commonjs/components/Sidebar/Sidebar.js.map +1 -0
- package/lib/commonjs/components/Sidebar/Sidebar.stories.js +229 -0
- package/lib/commonjs/components/Sidebar/Sidebar.stories.js.map +1 -0
- package/lib/commonjs/components/Sidebar/Sidebar.test.js +131 -0
- package/lib/commonjs/components/Sidebar/Sidebar.test.js.map +1 -0
- package/lib/commonjs/components/Sidebar/index.js +13 -0
- package/lib/commonjs/components/Sidebar/index.js.map +1 -0
- package/lib/commonjs/components/Table/DataTable.js +149 -0
- package/lib/commonjs/components/Table/DataTable.js.map +1 -0
- package/lib/commonjs/components/Table/DataTable.stories.js +214 -0
- package/lib/commonjs/components/Table/DataTable.stories.js.map +1 -0
- package/lib/commonjs/components/Table/DataTable.test.js +143 -0
- package/lib/commonjs/components/Table/DataTable.test.js.map +1 -0
- package/lib/commonjs/components/Table/Table.js +520 -0
- package/lib/commonjs/components/Table/Table.js.map +1 -0
- package/lib/commonjs/components/Table/Table.stories.js +385 -0
- package/lib/commonjs/components/Table/Table.stories.js.map +1 -0
- package/lib/commonjs/components/Table/Table.test.js +278 -0
- package/lib/commonjs/components/Table/Table.test.js.map +1 -0
- package/lib/commonjs/components/Table/index.js +20 -0
- package/lib/commonjs/components/Table/index.js.map +1 -0
- package/lib/commonjs/components/brand/BaconLogo.js +29 -0
- package/lib/commonjs/components/brand/BaconLogo.js.map +1 -0
- package/lib/commonjs/components/brand/index.js +7 -0
- package/lib/commonjs/components/brand/index.js.map +1 -1
- package/lib/commonjs/components/index.js +50 -17
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/module/components/EmptyState/EmptyState.js +84 -0
- package/lib/module/components/EmptyState/EmptyState.js.map +1 -0
- package/lib/module/components/EmptyState/EmptyState.stories.js +42 -0
- package/lib/module/components/EmptyState/EmptyState.stories.js.map +1 -0
- package/lib/module/components/EmptyState/EmptyState.test.js +40 -0
- package/lib/module/components/EmptyState/EmptyState.test.js.map +1 -0
- package/lib/module/components/EmptyState/index.js +4 -0
- package/lib/module/components/EmptyState/index.js.map +1 -0
- package/lib/module/components/Sidebar/Sidebar.js +260 -0
- package/lib/module/components/Sidebar/Sidebar.js.map +1 -0
- package/lib/module/components/Sidebar/Sidebar.stories.js +225 -0
- package/lib/module/components/Sidebar/Sidebar.stories.js.map +1 -0
- package/lib/module/components/Sidebar/Sidebar.test.js +131 -0
- package/lib/module/components/Sidebar/Sidebar.test.js.map +1 -0
- package/lib/module/components/Sidebar/index.js +4 -0
- package/lib/module/components/Sidebar/index.js.map +1 -0
- package/lib/module/components/Table/DataTable.js +145 -0
- package/lib/module/components/Table/DataTable.js.map +1 -0
- package/lib/module/components/Table/DataTable.stories.js +210 -0
- package/lib/module/components/Table/DataTable.stories.js.map +1 -0
- package/lib/module/components/Table/DataTable.test.js +143 -0
- package/lib/module/components/Table/DataTable.test.js.map +1 -0
- package/lib/module/components/Table/Table.js +516 -0
- package/lib/module/components/Table/Table.js.map +1 -0
- package/lib/module/components/Table/Table.stories.js +381 -0
- package/lib/module/components/Table/Table.stories.js.map +1 -0
- package/lib/module/components/Table/Table.test.js +278 -0
- package/lib/module/components/Table/Table.test.js.map +1 -0
- package/lib/module/components/Table/index.js +5 -0
- package/lib/module/components/Table/index.js.map +1 -0
- package/lib/module/components/brand/BaconLogo.js +25 -0
- package/lib/module/components/brand/BaconLogo.js.map +1 -0
- package/lib/module/components/brand/index.js +1 -0
- package/lib/module/components/brand/index.js.map +1 -1
- package/lib/module/components/index.js +3 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/typescript/commonjs/components/EmptyState/EmptyState.d.ts +30 -0
- package/lib/typescript/commonjs/components/EmptyState/EmptyState.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/EmptyState/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/EmptyState/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Sidebar/Sidebar.d.ts +57 -0
- package/lib/typescript/commonjs/components/Sidebar/Sidebar.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Sidebar/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Sidebar/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Table/DataTable.d.ts +53 -0
- package/lib/typescript/commonjs/components/Table/DataTable.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Table/Table.d.ts +85 -0
- package/lib/typescript/commonjs/components/Table/Table.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Table/index.d.ts +5 -0
- package/lib/typescript/commonjs/components/Table/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/brand/BaconLogo.d.ts +13 -0
- package/lib/typescript/commonjs/components/brand/BaconLogo.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/brand/index.d.ts +1 -0
- package/lib/typescript/commonjs/components/brand/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/index.d.ts.map +1 -1
- package/lib/typescript/module/components/EmptyState/EmptyState.d.ts +30 -0
- package/lib/typescript/module/components/EmptyState/EmptyState.d.ts.map +1 -0
- package/lib/typescript/module/components/EmptyState/index.d.ts +3 -0
- package/lib/typescript/module/components/EmptyState/index.d.ts.map +1 -0
- package/lib/typescript/module/components/Sidebar/Sidebar.d.ts +57 -0
- package/lib/typescript/module/components/Sidebar/Sidebar.d.ts.map +1 -0
- package/lib/typescript/module/components/Sidebar/index.d.ts +3 -0
- package/lib/typescript/module/components/Sidebar/index.d.ts.map +1 -0
- package/lib/typescript/module/components/Table/DataTable.d.ts +53 -0
- package/lib/typescript/module/components/Table/DataTable.d.ts.map +1 -0
- package/lib/typescript/module/components/Table/Table.d.ts +85 -0
- package/lib/typescript/module/components/Table/Table.d.ts.map +1 -0
- package/lib/typescript/module/components/Table/index.d.ts +5 -0
- package/lib/typescript/module/components/Table/index.d.ts.map +1 -0
- package/lib/typescript/module/components/brand/BaconLogo.d.ts +13 -0
- package/lib/typescript/module/components/brand/BaconLogo.d.ts.map +1 -0
- package/lib/typescript/module/components/brand/index.d.ts +1 -0
- package/lib/typescript/module/components/brand/index.d.ts.map +1 -1
- package/lib/typescript/module/components/index.d.ts +3 -0
- package/lib/typescript/module/components/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/EmptyState/EmptyState.tsx +91 -0
- package/src/components/EmptyState/index.ts +2 -0
- package/src/components/Sidebar/Sidebar.tsx +320 -0
- package/src/components/Sidebar/index.ts +2 -0
- package/src/components/Table/DataTable.tsx +173 -0
- package/src/components/Table/Table.tsx +556 -0
- package/src/components/Table/index.ts +10 -0
- package/src/components/brand/BaconLogo.tsx +25 -0
- package/src/components/brand/index.ts +1 -0
- package/src/components/index.ts +3 -0
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithActions = exports.SortableSelectable = exports.Scrollable = exports.Loading = exports.Expandable = exports.Empty = exports.Base = exports.Alignment = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _Table = require("./Table.js");
|
|
10
|
+
var _Badge = require("../Badge/Badge.js");
|
|
11
|
+
var _EmptyState = require("../EmptyState/EmptyState.js");
|
|
12
|
+
var _IconButton = require("../IconButton/IconButton.js");
|
|
13
|
+
var _Text = require("../Text/Text.js");
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
const meta = {
|
|
16
|
+
title: 'Components/Table',
|
|
17
|
+
component: _Table.Table
|
|
18
|
+
};
|
|
19
|
+
var _default = exports.default = meta;
|
|
20
|
+
const SHIFTS = [{
|
|
21
|
+
id: '1',
|
|
22
|
+
date: 'Wed 07/29/26',
|
|
23
|
+
in: '06:30 AM',
|
|
24
|
+
breaks: 'No breaks',
|
|
25
|
+
out: '07:07 h.',
|
|
26
|
+
total: '7:07 h.',
|
|
27
|
+
active: true
|
|
28
|
+
}, {
|
|
29
|
+
id: '2',
|
|
30
|
+
date: 'Thu 07/30/26',
|
|
31
|
+
in: '07:15 AM',
|
|
32
|
+
breaks: '1 break',
|
|
33
|
+
out: '02:01 PM',
|
|
34
|
+
total: '6:45 h.'
|
|
35
|
+
}, {
|
|
36
|
+
id: '3',
|
|
37
|
+
date: 'Fri 07/31/26',
|
|
38
|
+
in: '06:45 AM',
|
|
39
|
+
breaks: '1 break',
|
|
40
|
+
out: '01:18 PM',
|
|
41
|
+
total: '5:30 h.'
|
|
42
|
+
}, {
|
|
43
|
+
id: '4',
|
|
44
|
+
date: 'Sat 08/01/26',
|
|
45
|
+
in: '08:00 AM',
|
|
46
|
+
breaks: '2 breaks',
|
|
47
|
+
out: '11:58 AM',
|
|
48
|
+
total: '4:50 h.'
|
|
49
|
+
}];
|
|
50
|
+
|
|
51
|
+
/** Base table (Figma) with a Badge cell. */
|
|
52
|
+
const Base = exports.Base = {
|
|
53
|
+
render: () => {
|
|
54
|
+
const columns = [{
|
|
55
|
+
key: 'date',
|
|
56
|
+
header: 'Date'
|
|
57
|
+
}, {
|
|
58
|
+
key: 'in',
|
|
59
|
+
header: 'In'
|
|
60
|
+
}, {
|
|
61
|
+
key: 'breaks',
|
|
62
|
+
header: 'Breaks'
|
|
63
|
+
}, {
|
|
64
|
+
key: 'out',
|
|
65
|
+
header: 'Out',
|
|
66
|
+
render: r => r.active ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Badge.Badge, {
|
|
67
|
+
label: "Active"
|
|
68
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
69
|
+
variant: "bodyMedium",
|
|
70
|
+
children: r.out
|
|
71
|
+
})
|
|
72
|
+
}, {
|
|
73
|
+
key: 'total',
|
|
74
|
+
header: 'Total'
|
|
75
|
+
}];
|
|
76
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
77
|
+
style: {
|
|
78
|
+
padding: 24,
|
|
79
|
+
width: 900
|
|
80
|
+
},
|
|
81
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
82
|
+
columns: columns,
|
|
83
|
+
data: SHIFTS,
|
|
84
|
+
keyExtractor: r => r.id
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/** Expandable (accordion) rows — tap a row to reveal detail; single open at a time. */
|
|
91
|
+
const Expandable = exports.Expandable = {
|
|
92
|
+
render: () => {
|
|
93
|
+
const columns = [{
|
|
94
|
+
key: 'date',
|
|
95
|
+
header: 'Date'
|
|
96
|
+
}, {
|
|
97
|
+
key: 'in',
|
|
98
|
+
header: 'In'
|
|
99
|
+
}, {
|
|
100
|
+
key: 'out',
|
|
101
|
+
header: 'Out'
|
|
102
|
+
}, {
|
|
103
|
+
key: 'total',
|
|
104
|
+
header: 'Total'
|
|
105
|
+
}];
|
|
106
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
107
|
+
style: {
|
|
108
|
+
padding: 24,
|
|
109
|
+
width: 900
|
|
110
|
+
},
|
|
111
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
112
|
+
columns: columns,
|
|
113
|
+
data: SHIFTS,
|
|
114
|
+
keyExtractor: r => r.id,
|
|
115
|
+
expandable: true,
|
|
116
|
+
renderExpanded: r => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Text.Text, {
|
|
117
|
+
variant: "bodyMedium",
|
|
118
|
+
color: "secondary",
|
|
119
|
+
children: ["Breaks: ", r.breaks, " \xB7 Clocked in at ", r.in, ", out at ", r.out, "."]
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const ITEMS = [{
|
|
126
|
+
id: '1',
|
|
127
|
+
name: 'Spicy Mango Salsa',
|
|
128
|
+
category: 'Starter',
|
|
129
|
+
price: '$4.25'
|
|
130
|
+
}, {
|
|
131
|
+
id: '2',
|
|
132
|
+
name: 'Creamy Garlic Pasta',
|
|
133
|
+
category: 'Starter',
|
|
134
|
+
price: '$5.75'
|
|
135
|
+
}, {
|
|
136
|
+
id: '3',
|
|
137
|
+
name: 'Zesty Lemon Chicken',
|
|
138
|
+
category: 'Starter',
|
|
139
|
+
price: '$7.10'
|
|
140
|
+
}, {
|
|
141
|
+
id: '4',
|
|
142
|
+
name: 'Grilled Vegetable Skewers',
|
|
143
|
+
category: 'Main plates',
|
|
144
|
+
price: '$6.50'
|
|
145
|
+
}];
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Actions column (edit / delete). A whole-row press can coexist with the action
|
|
149
|
+
* buttons — tapping a button runs its own handler; tapping elsewhere runs the row
|
|
150
|
+
* action (here it opens detail; can be the same as an action button or different).
|
|
151
|
+
*/
|
|
152
|
+
const WithActions = exports.WithActions = {
|
|
153
|
+
render: () => {
|
|
154
|
+
const [log, setLog] = (0, _react.useState)('—');
|
|
155
|
+
const columns = [{
|
|
156
|
+
key: 'name',
|
|
157
|
+
header: 'Item name',
|
|
158
|
+
flex: 2
|
|
159
|
+
}, {
|
|
160
|
+
key: 'category',
|
|
161
|
+
header: 'Category'
|
|
162
|
+
}, {
|
|
163
|
+
key: 'price',
|
|
164
|
+
header: 'Price',
|
|
165
|
+
align: 'right'
|
|
166
|
+
}];
|
|
167
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
168
|
+
style: {
|
|
169
|
+
padding: 24,
|
|
170
|
+
width: 900,
|
|
171
|
+
gap: 8
|
|
172
|
+
},
|
|
173
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
174
|
+
columns: columns,
|
|
175
|
+
data: ITEMS,
|
|
176
|
+
keyExtractor: r => r.id,
|
|
177
|
+
onRowPress: r => setLog(`row: ${r.name}`),
|
|
178
|
+
renderActions: r => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
179
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.IconButton, {
|
|
180
|
+
icon: "edit",
|
|
181
|
+
accessibilityLabel: "Edit",
|
|
182
|
+
variant: "ghost",
|
|
183
|
+
size: "sm",
|
|
184
|
+
onPress: () => setLog(`edit: ${r.name}`)
|
|
185
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.IconButton, {
|
|
186
|
+
icon: "trash",
|
|
187
|
+
accessibilityLabel: "Delete",
|
|
188
|
+
variant: "ghost",
|
|
189
|
+
size: "sm",
|
|
190
|
+
onPress: () => setLog(`delete: ${r.name}`)
|
|
191
|
+
})]
|
|
192
|
+
})
|
|
193
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Text.Text, {
|
|
194
|
+
variant: "caption",
|
|
195
|
+
color: "secondary",
|
|
196
|
+
children: ["last: ", log]
|
|
197
|
+
})]
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/** Column alignment: left / center / right. */
|
|
203
|
+
const Alignment = exports.Alignment = {
|
|
204
|
+
render: () => {
|
|
205
|
+
const columns = [{
|
|
206
|
+
key: 'name',
|
|
207
|
+
header: 'Left',
|
|
208
|
+
flex: 2,
|
|
209
|
+
align: 'left'
|
|
210
|
+
}, {
|
|
211
|
+
key: 'category',
|
|
212
|
+
header: 'Center',
|
|
213
|
+
align: 'center'
|
|
214
|
+
}, {
|
|
215
|
+
key: 'price',
|
|
216
|
+
header: 'Right',
|
|
217
|
+
align: 'right'
|
|
218
|
+
}];
|
|
219
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
220
|
+
style: {
|
|
221
|
+
padding: 24,
|
|
222
|
+
width: 900
|
|
223
|
+
},
|
|
224
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
225
|
+
columns: columns,
|
|
226
|
+
data: ITEMS,
|
|
227
|
+
keyExtractor: r => r.id
|
|
228
|
+
})
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
/** Sortable headers + row selection. */
|
|
234
|
+
const SortableSelectable = exports.SortableSelectable = {
|
|
235
|
+
render: () => {
|
|
236
|
+
const [selected, setSelected] = (0, _react.useState)(['2']);
|
|
237
|
+
const columns = [{
|
|
238
|
+
key: 'name',
|
|
239
|
+
header: 'Item name',
|
|
240
|
+
flex: 2,
|
|
241
|
+
sortable: true,
|
|
242
|
+
sortAccessor: r => r.name
|
|
243
|
+
}, {
|
|
244
|
+
key: 'category',
|
|
245
|
+
header: 'Category',
|
|
246
|
+
sortable: true,
|
|
247
|
+
sortAccessor: r => r.category
|
|
248
|
+
}, {
|
|
249
|
+
key: 'price',
|
|
250
|
+
header: 'Price',
|
|
251
|
+
align: 'right',
|
|
252
|
+
sortable: true,
|
|
253
|
+
sortAccessor: r => Number(r.price.replace('$', ''))
|
|
254
|
+
}];
|
|
255
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
256
|
+
style: {
|
|
257
|
+
padding: 24,
|
|
258
|
+
width: 900
|
|
259
|
+
},
|
|
260
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
261
|
+
columns: columns,
|
|
262
|
+
data: ITEMS,
|
|
263
|
+
keyExtractor: r => r.id,
|
|
264
|
+
selectable: true,
|
|
265
|
+
selectedKeys: selected,
|
|
266
|
+
onSelectionChange: setSelected,
|
|
267
|
+
defaultSort: {
|
|
268
|
+
key: 'price',
|
|
269
|
+
direction: 'asc'
|
|
270
|
+
}
|
|
271
|
+
})
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
/** Long list — sticky header, body scrolls (elegant indicator). */
|
|
277
|
+
const Scrollable = exports.Scrollable = {
|
|
278
|
+
render: () => {
|
|
279
|
+
const many = Array.from({
|
|
280
|
+
length: 25
|
|
281
|
+
}).map((_, i) => ({
|
|
282
|
+
id: String(i),
|
|
283
|
+
name: `Menu item ${i + 1}`,
|
|
284
|
+
category: i % 2 ? 'Main plates' : 'Starter',
|
|
285
|
+
price: `$${(i + 1) * 1.5}`
|
|
286
|
+
}));
|
|
287
|
+
const columns = [{
|
|
288
|
+
key: 'name',
|
|
289
|
+
header: 'Item name',
|
|
290
|
+
flex: 2
|
|
291
|
+
}, {
|
|
292
|
+
key: 'category',
|
|
293
|
+
header: 'Category'
|
|
294
|
+
}, {
|
|
295
|
+
key: 'price',
|
|
296
|
+
header: 'Price',
|
|
297
|
+
align: 'right'
|
|
298
|
+
}];
|
|
299
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
300
|
+
style: {
|
|
301
|
+
padding: 24,
|
|
302
|
+
width: 900
|
|
303
|
+
},
|
|
304
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
305
|
+
columns: columns,
|
|
306
|
+
data: many,
|
|
307
|
+
keyExtractor: r => r.id,
|
|
308
|
+
maxHeight: 360
|
|
309
|
+
})
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
const LOADING_COLS = [{
|
|
314
|
+
key: 'name',
|
|
315
|
+
header: 'Item name',
|
|
316
|
+
flex: 2
|
|
317
|
+
}, {
|
|
318
|
+
key: 'category',
|
|
319
|
+
header: 'Category'
|
|
320
|
+
}, {
|
|
321
|
+
key: 'price',
|
|
322
|
+
header: 'Price',
|
|
323
|
+
align: 'right'
|
|
324
|
+
}];
|
|
325
|
+
|
|
326
|
+
/** Empty state. */
|
|
327
|
+
const Empty = exports.Empty = {
|
|
328
|
+
render: () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
329
|
+
style: {
|
|
330
|
+
padding: 24,
|
|
331
|
+
width: 900
|
|
332
|
+
},
|
|
333
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
334
|
+
columns: LOADING_COLS,
|
|
335
|
+
data: [],
|
|
336
|
+
keyExtractor: r => r.id,
|
|
337
|
+
empty: /*#__PURE__*/(0, _jsxRuntime.jsx)(_EmptyState.EmptyState, {
|
|
338
|
+
icon: "dish",
|
|
339
|
+
title: "No items yet",
|
|
340
|
+
description: "Create your first one to get started.",
|
|
341
|
+
action: {
|
|
342
|
+
label: 'Create item',
|
|
343
|
+
icon: 'plus',
|
|
344
|
+
onPress: () => {}
|
|
345
|
+
}
|
|
346
|
+
})
|
|
347
|
+
})
|
|
348
|
+
})
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
/** Loading: spinner (with/without text) and skeleton. */
|
|
352
|
+
const Loading = exports.Loading = {
|
|
353
|
+
render: () => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
354
|
+
style: {
|
|
355
|
+
padding: 24,
|
|
356
|
+
width: 900,
|
|
357
|
+
gap: 24
|
|
358
|
+
},
|
|
359
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
360
|
+
columns: LOADING_COLS,
|
|
361
|
+
data: [],
|
|
362
|
+
keyExtractor: r => r.id,
|
|
363
|
+
loading: true
|
|
364
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
365
|
+
columns: LOADING_COLS,
|
|
366
|
+
data: [],
|
|
367
|
+
keyExtractor: r => r.id,
|
|
368
|
+
loading: true,
|
|
369
|
+
loadingText: "Fetching menu\u2026"
|
|
370
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
371
|
+
columns: LOADING_COLS,
|
|
372
|
+
data: [],
|
|
373
|
+
keyExtractor: r => r.id,
|
|
374
|
+
loading: true,
|
|
375
|
+
loadingText: null
|
|
376
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
377
|
+
columns: LOADING_COLS,
|
|
378
|
+
data: [],
|
|
379
|
+
keyExtractor: r => r.id,
|
|
380
|
+
loading: true,
|
|
381
|
+
loadingVariant: "skeleton"
|
|
382
|
+
})]
|
|
383
|
+
})
|
|
384
|
+
};
|
|
385
|
+
//# sourceMappingURL=Table.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_Table","_Badge","_EmptyState","_IconButton","_Text","_jsxRuntime","meta","title","component","Table","_default","exports","default","SHIFTS","id","date","in","breaks","out","total","active","Base","render","columns","key","header","r","jsx","Badge","label","Text","variant","children","View","style","padding","width","data","keyExtractor","Expandable","expandable","renderExpanded","jsxs","color","ITEMS","name","category","price","WithActions","log","setLog","useState","flex","align","gap","onRowPress","renderActions","Fragment","IconButton","icon","accessibilityLabel","size","onPress","Alignment","SortableSelectable","selected","setSelected","sortable","sortAccessor","Number","replace","selectable","selectedKeys","onSelectionChange","defaultSort","direction","Scrollable","many","Array","from","length","map","_","i","String","maxHeight","LOADING_COLS","Empty","empty","EmptyState","description","action","Loading","loading","loadingText","loadingVariant"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Table/Table.stories.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA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CAAAqC,IAAA,EAAC3C,YAAA,CAAAkC,IAAI;IAACC,KAAK,EAAE;MAAEC,OAAO,EAAE,EAAE;MAAEC,KAAK,EAAE,GAAG;MAAEkB,GAAG,EAAE;IAAG,CAAE;IAAAtB,QAAA,gBAChD,IAAA3B,WAAA,CAAAsB,GAAA,EAAC3B,MAAA,CAAAS,KAAK;MAACc,OAAO,EAAE+D,YAAa;MAACjD,IAAI,EAAE,EAAG;MAACC,YAAY,EAAGZ,CAAC,IAAKA,CAAC,CAACZ,EAAG;MAAC+E,OAAO;IAAA,CAAE,CAAC,eAC7E,IAAAxF,WAAA,CAAAsB,GAAA,EAAC3B,MAAA,CAAAS,KAAK;MAACc,OAAO,EAAE+D,YAAa;MAACjD,IAAI,EAAE,EAAG;MAACC,YAAY,EAAGZ,CAAC,IAAKA,CAAC,CAACZ,EAAG;MAAC+E,OAAO;MAACC,WAAW,EAAC;IAAgB,CAAE,CAAC,eAC1G,IAAAzF,WAAA,CAAAsB,GAAA,EAAC3B,MAAA,CAAAS,KAAK;MAACc,OAAO,EAAE+D,YAAa;MAACjD,IAAI,EAAE,EAAG;MAACC,YAAY,EAAGZ,CAAC,IAAKA,CAAC,CAACZ,EAAG;MAAC+E,OAAO;MAACC,WAAW,EAAE;IAAK,CAAE,CAAC,eAChG,IAAAzF,WAAA,CAAAsB,GAAA,EAAC3B,MAAA,CAAAS,KAAK;MAACc,OAAO,EAAE+D,YAAa;MAACjD,IAAI,EAAE,EAAG;MAACC,YAAY,EAAGZ,CAAC,IAAKA,CAAC,CAACZ,EAAG;MAAC+E,OAAO;MAACE,cAAc,EAAC;IAAU,CAAE,CAAC;EAAA,CACnG;AAEV,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _reactNative = require("@testing-library/react-native");
|
|
4
|
+
var _reactNative2 = require("react-native");
|
|
5
|
+
var _index = require("../../theme/index.js");
|
|
6
|
+
var _IconButton = require("../IconButton/IconButton.js");
|
|
7
|
+
var _Table = require("./Table.js");
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
function wrap(ui) {
|
|
10
|
+
return (0, _reactNative.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ThemeProvider, {
|
|
11
|
+
children: ui
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
const DATA = [{
|
|
15
|
+
id: 'a',
|
|
16
|
+
name: 'Alpha',
|
|
17
|
+
price: '$3'
|
|
18
|
+
}, {
|
|
19
|
+
id: 'b',
|
|
20
|
+
name: 'Beta',
|
|
21
|
+
price: '$1'
|
|
22
|
+
}, {
|
|
23
|
+
id: 'c',
|
|
24
|
+
name: 'Gamma',
|
|
25
|
+
price: '$2'
|
|
26
|
+
}];
|
|
27
|
+
const COLS = [{
|
|
28
|
+
key: 'name',
|
|
29
|
+
header: 'Name'
|
|
30
|
+
}, {
|
|
31
|
+
key: 'price',
|
|
32
|
+
header: 'Price'
|
|
33
|
+
}];
|
|
34
|
+
// mobileBreakpoint={0} forces the desktop layout regardless of the test window.
|
|
35
|
+
const desktop = {
|
|
36
|
+
mobileBreakpoint: 0
|
|
37
|
+
};
|
|
38
|
+
describe('Table', () => {
|
|
39
|
+
it('renders headers and cell values', () => {
|
|
40
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
41
|
+
...desktop,
|
|
42
|
+
columns: COLS,
|
|
43
|
+
data: DATA,
|
|
44
|
+
keyExtractor: r => r.id
|
|
45
|
+
}));
|
|
46
|
+
expect(_reactNative.screen.getByText('Name')).toBeTruthy();
|
|
47
|
+
expect(_reactNative.screen.getByText('Alpha')).toBeTruthy();
|
|
48
|
+
expect(_reactNative.screen.getByText('$3')).toBeTruthy();
|
|
49
|
+
});
|
|
50
|
+
it('renders a custom cell node', () => {
|
|
51
|
+
const cols = [{
|
|
52
|
+
key: 'name',
|
|
53
|
+
header: 'Name'
|
|
54
|
+
}, {
|
|
55
|
+
key: 'price',
|
|
56
|
+
header: 'Price',
|
|
57
|
+
render: r => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative2.Text, {
|
|
58
|
+
children: `price:${r.price}`
|
|
59
|
+
})
|
|
60
|
+
}];
|
|
61
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
62
|
+
...desktop,
|
|
63
|
+
columns: cols,
|
|
64
|
+
data: DATA,
|
|
65
|
+
keyExtractor: r => r.id
|
|
66
|
+
}));
|
|
67
|
+
expect(_reactNative.screen.getByText('price:$3')).toBeTruthy();
|
|
68
|
+
});
|
|
69
|
+
it('fires onRowPress', () => {
|
|
70
|
+
const onRowPress = jest.fn();
|
|
71
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
72
|
+
...desktop,
|
|
73
|
+
columns: COLS,
|
|
74
|
+
data: DATA,
|
|
75
|
+
keyExtractor: r => r.id,
|
|
76
|
+
onRowPress: onRowPress
|
|
77
|
+
}));
|
|
78
|
+
_reactNative.fireEvent.press(_reactNative.screen.getByText('Alpha'));
|
|
79
|
+
expect(onRowPress).toHaveBeenCalledWith(DATA[0], 0);
|
|
80
|
+
});
|
|
81
|
+
it('expands a row on press and collapses the previous one (single mode)', () => {
|
|
82
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
83
|
+
...desktop,
|
|
84
|
+
columns: COLS,
|
|
85
|
+
data: DATA,
|
|
86
|
+
keyExtractor: r => r.id,
|
|
87
|
+
expandable: true,
|
|
88
|
+
renderExpanded: r => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative2.Text, {
|
|
89
|
+
children: `detail-${r.id}`
|
|
90
|
+
})
|
|
91
|
+
}));
|
|
92
|
+
expect(_reactNative.screen.queryByText('detail-a')).toBeNull();
|
|
93
|
+
_reactNative.fireEvent.press(_reactNative.screen.getByText('Alpha'));
|
|
94
|
+
expect(_reactNative.screen.getByText('detail-a')).toBeTruthy();
|
|
95
|
+
_reactNative.fireEvent.press(_reactNative.screen.getByText('Beta'));
|
|
96
|
+
expect(_reactNative.screen.queryByText('detail-a')).toBeNull();
|
|
97
|
+
expect(_reactNative.screen.getByText('detail-b')).toBeTruthy();
|
|
98
|
+
});
|
|
99
|
+
it('renders an actions column', () => {
|
|
100
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
101
|
+
...desktop,
|
|
102
|
+
columns: COLS,
|
|
103
|
+
data: DATA,
|
|
104
|
+
keyExtractor: r => r.id,
|
|
105
|
+
renderActions: () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative2.Text, {
|
|
106
|
+
children: "row-action"
|
|
107
|
+
})
|
|
108
|
+
}));
|
|
109
|
+
expect(_reactNative.screen.getAllByText('row-action').length).toBe(DATA.length);
|
|
110
|
+
});
|
|
111
|
+
it('row press coexists with the actions column (buttons keep their own handlers)', () => {
|
|
112
|
+
const onRowPress = jest.fn();
|
|
113
|
+
const onEdit = jest.fn();
|
|
114
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
115
|
+
...desktop,
|
|
116
|
+
columns: COLS,
|
|
117
|
+
data: DATA,
|
|
118
|
+
keyExtractor: r => r.id,
|
|
119
|
+
onRowPress: onRowPress,
|
|
120
|
+
renderActions: r => /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.IconButton, {
|
|
121
|
+
icon: "edit",
|
|
122
|
+
accessibilityLabel: `edit-${r.id}`,
|
|
123
|
+
variant: "ghost",
|
|
124
|
+
size: "sm",
|
|
125
|
+
onPress: () => onEdit(r.id)
|
|
126
|
+
})
|
|
127
|
+
}));
|
|
128
|
+
// Pressing the action button runs its handler, not the row's.
|
|
129
|
+
_reactNative.fireEvent.press(_reactNative.screen.getByLabelText('edit-a'));
|
|
130
|
+
expect(onEdit).toHaveBeenCalledWith('a');
|
|
131
|
+
expect(onRowPress).not.toHaveBeenCalled();
|
|
132
|
+
// Pressing a cell runs the row handler.
|
|
133
|
+
_reactNative.fireEvent.press(_reactNative.screen.getByText('Alpha'));
|
|
134
|
+
expect(onRowPress).toHaveBeenCalledWith(DATA[0], 0);
|
|
135
|
+
});
|
|
136
|
+
it('shows a spinner with default loading text, a custom text, or none', () => {
|
|
137
|
+
const {
|
|
138
|
+
rerender
|
|
139
|
+
} = wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
140
|
+
...desktop,
|
|
141
|
+
columns: COLS,
|
|
142
|
+
data: [],
|
|
143
|
+
keyExtractor: r => r.id,
|
|
144
|
+
loading: true
|
|
145
|
+
}));
|
|
146
|
+
expect(_reactNative.screen.getByText('Loading data')).toBeTruthy();
|
|
147
|
+
rerender(/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ThemeProvider, {
|
|
148
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
149
|
+
...desktop,
|
|
150
|
+
columns: COLS,
|
|
151
|
+
data: [],
|
|
152
|
+
keyExtractor: r => r.id,
|
|
153
|
+
loading: true,
|
|
154
|
+
loadingText: "Fetching\u2026"
|
|
155
|
+
})
|
|
156
|
+
}));
|
|
157
|
+
expect(_reactNative.screen.getByText('Fetching…')).toBeTruthy();
|
|
158
|
+
rerender(/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ThemeProvider, {
|
|
159
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
160
|
+
...desktop,
|
|
161
|
+
columns: COLS,
|
|
162
|
+
data: [],
|
|
163
|
+
keyExtractor: r => r.id,
|
|
164
|
+
loading: true,
|
|
165
|
+
loadingText: null
|
|
166
|
+
})
|
|
167
|
+
}));
|
|
168
|
+
expect(_reactNative.screen.queryByText('Loading data')).toBeNull();
|
|
169
|
+
});
|
|
170
|
+
it('renders a skeleton without the loading text', () => {
|
|
171
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
172
|
+
...desktop,
|
|
173
|
+
columns: COLS,
|
|
174
|
+
data: [],
|
|
175
|
+
keyExtractor: r => r.id,
|
|
176
|
+
loading: true,
|
|
177
|
+
loadingVariant: "skeleton"
|
|
178
|
+
}));
|
|
179
|
+
expect(_reactNative.screen.queryByText('Loading data')).toBeNull();
|
|
180
|
+
// Header is still shown while skeleton loads.
|
|
181
|
+
expect(_reactNative.screen.getByText('Name')).toBeTruthy();
|
|
182
|
+
});
|
|
183
|
+
it('selects rows and select-all', () => {
|
|
184
|
+
const onSelectionChange = jest.fn();
|
|
185
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
186
|
+
...desktop,
|
|
187
|
+
columns: COLS,
|
|
188
|
+
data: DATA,
|
|
189
|
+
keyExtractor: r => r.id,
|
|
190
|
+
selectable: true,
|
|
191
|
+
selectedKeys: [],
|
|
192
|
+
onSelectionChange: onSelectionChange
|
|
193
|
+
}));
|
|
194
|
+
const checkboxes = _reactNative.screen.getAllByRole('checkbox');
|
|
195
|
+
// [0] = header select-all, [1..] = rows
|
|
196
|
+
_reactNative.fireEvent.press(checkboxes[1]);
|
|
197
|
+
expect(onSelectionChange).toHaveBeenCalledWith(['a']);
|
|
198
|
+
_reactNative.fireEvent.press(checkboxes[0]);
|
|
199
|
+
expect(onSelectionChange).toHaveBeenCalledWith(['a', 'b', 'c']);
|
|
200
|
+
});
|
|
201
|
+
it('emits sort changes from a sortable header (controlled)', () => {
|
|
202
|
+
const onSortChange = jest.fn();
|
|
203
|
+
const cols = [{
|
|
204
|
+
key: 'name',
|
|
205
|
+
header: 'Name',
|
|
206
|
+
sortable: true,
|
|
207
|
+
sortAccessor: r => r.name
|
|
208
|
+
}, {
|
|
209
|
+
key: 'price',
|
|
210
|
+
header: 'Price'
|
|
211
|
+
}];
|
|
212
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
213
|
+
...desktop,
|
|
214
|
+
columns: cols,
|
|
215
|
+
data: DATA,
|
|
216
|
+
keyExtractor: r => r.id,
|
|
217
|
+
sort: {
|
|
218
|
+
key: 'price',
|
|
219
|
+
direction: 'asc'
|
|
220
|
+
},
|
|
221
|
+
onSortChange: onSortChange
|
|
222
|
+
}));
|
|
223
|
+
_reactNative.fireEvent.press(_reactNative.screen.getByText('Name'));
|
|
224
|
+
expect(onSortChange).toHaveBeenCalledWith({
|
|
225
|
+
key: 'name',
|
|
226
|
+
direction: 'asc'
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
it('sorts internally by the column accessor', () => {
|
|
230
|
+
const cols = [{
|
|
231
|
+
key: 'name',
|
|
232
|
+
header: 'Name'
|
|
233
|
+
}, {
|
|
234
|
+
key: 'price',
|
|
235
|
+
header: 'Price',
|
|
236
|
+
sortable: true,
|
|
237
|
+
sortAccessor: r => Number(r.price.replace('$', ''))
|
|
238
|
+
}];
|
|
239
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
240
|
+
...desktop,
|
|
241
|
+
columns: cols,
|
|
242
|
+
data: DATA,
|
|
243
|
+
keyExtractor: r => r.id,
|
|
244
|
+
defaultSort: {
|
|
245
|
+
key: 'price',
|
|
246
|
+
direction: 'asc'
|
|
247
|
+
}
|
|
248
|
+
}));
|
|
249
|
+
// Ascending by price: Beta ($1), Gamma ($2), Alpha ($3)
|
|
250
|
+
const names = _reactNative.screen.getAllByText(/Alpha|Beta|Gamma/).map(n => n.props.children);
|
|
251
|
+
expect(names).toEqual(['Beta', 'Gamma', 'Alpha']);
|
|
252
|
+
});
|
|
253
|
+
it('shows the empty slot when there is no data', () => {
|
|
254
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
255
|
+
...desktop,
|
|
256
|
+
columns: COLS,
|
|
257
|
+
data: [],
|
|
258
|
+
keyExtractor: r => r.id,
|
|
259
|
+
empty: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative2.Text, {
|
|
260
|
+
children: "Nothing here"
|
|
261
|
+
})
|
|
262
|
+
}));
|
|
263
|
+
expect(_reactNative.screen.getByText('Nothing here')).toBeTruthy();
|
|
264
|
+
});
|
|
265
|
+
it('renders a card layout below the mobile breakpoint (no header row)', () => {
|
|
266
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
267
|
+
mobileBreakpoint: 99999,
|
|
268
|
+
columns: COLS,
|
|
269
|
+
data: DATA,
|
|
270
|
+
keyExtractor: r => r.id
|
|
271
|
+
}));
|
|
272
|
+
// Values still render; header labels appear inside each card.
|
|
273
|
+
expect(_reactNative.screen.getByText('Alpha')).toBeTruthy();
|
|
274
|
+
// "Name" header label appears once per card (3), not once as a table header.
|
|
275
|
+
expect(_reactNative.screen.getAllByText('Name').length).toBe(DATA.length);
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
//# sourceMappingURL=Table.test.js.map
|