@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,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Toggleable = exports.Scrolling = exports.NoIcon = exports.Minimal = exports.LongLabels = exports.Expanded = exports.CustomLogo = exports.Collapsed = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _Sidebar = require("./Sidebar.js");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
const meta = {
|
|
12
|
+
title: 'Components/Sidebar',
|
|
13
|
+
component: _Sidebar.Sidebar
|
|
14
|
+
};
|
|
15
|
+
var _default = exports.default = meta;
|
|
16
|
+
const ITEMS = [{
|
|
17
|
+
key: 'home',
|
|
18
|
+
label: 'Home',
|
|
19
|
+
icon: 'home'
|
|
20
|
+
}, {
|
|
21
|
+
key: 'tables',
|
|
22
|
+
label: 'Table Map',
|
|
23
|
+
icon: 'table'
|
|
24
|
+
}, {
|
|
25
|
+
key: 'menu',
|
|
26
|
+
label: 'Menu List',
|
|
27
|
+
icon: 'dish'
|
|
28
|
+
}, {
|
|
29
|
+
key: 'orders',
|
|
30
|
+
label: 'Orders',
|
|
31
|
+
icon: 'receipt'
|
|
32
|
+
}, {
|
|
33
|
+
key: 'users',
|
|
34
|
+
label: 'User Mgmt.',
|
|
35
|
+
icon: 'usergroup'
|
|
36
|
+
}, {
|
|
37
|
+
key: 'customers',
|
|
38
|
+
label: 'Customers',
|
|
39
|
+
icon: 'user-star'
|
|
40
|
+
}, {
|
|
41
|
+
key: 'reports',
|
|
42
|
+
label: 'Reports',
|
|
43
|
+
icon: 'analytics'
|
|
44
|
+
}, {
|
|
45
|
+
key: 'settings',
|
|
46
|
+
label: 'Settings',
|
|
47
|
+
icon: 'settings'
|
|
48
|
+
}];
|
|
49
|
+
|
|
50
|
+
// A tall frame so the drawer fills a page-like height.
|
|
51
|
+
function Frame({
|
|
52
|
+
children
|
|
53
|
+
}) {
|
|
54
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
55
|
+
style: {
|
|
56
|
+
height: 720,
|
|
57
|
+
flexDirection: 'row'
|
|
58
|
+
},
|
|
59
|
+
children: children
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Expanded (Figma default), with footer text. */
|
|
64
|
+
const Expanded = exports.Expanded = {
|
|
65
|
+
render: () => {
|
|
66
|
+
const [active, setActive] = (0, _react.useState)('home');
|
|
67
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Frame, {
|
|
68
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
69
|
+
items: ITEMS,
|
|
70
|
+
activeKey: active,
|
|
71
|
+
onChange: setActive,
|
|
72
|
+
footer: "Bacon POS v2.0.12"
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/** Collapsed (icon-only rail). */
|
|
79
|
+
const Collapsed = exports.Collapsed = {
|
|
80
|
+
render: () => {
|
|
81
|
+
const [active, setActive] = (0, _react.useState)('home');
|
|
82
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Frame, {
|
|
83
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
84
|
+
items: ITEMS,
|
|
85
|
+
activeKey: active,
|
|
86
|
+
onChange: setActive,
|
|
87
|
+
defaultCollapsed: true,
|
|
88
|
+
footer: "Bacon POS v2.0.12"
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/** Toggle it — press the arrow to expand/collapse. */
|
|
95
|
+
const Toggleable = exports.Toggleable = {
|
|
96
|
+
render: () => {
|
|
97
|
+
const [active, setActive] = (0, _react.useState)('orders');
|
|
98
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Frame, {
|
|
99
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
100
|
+
items: ITEMS,
|
|
101
|
+
activeKey: active,
|
|
102
|
+
onChange: setActive,
|
|
103
|
+
footer: "Bacon POS v2.0.12"
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/** No footer (default) and few items. */
|
|
110
|
+
const Minimal = exports.Minimal = {
|
|
111
|
+
render: () => {
|
|
112
|
+
const [active, setActive] = (0, _react.useState)('home');
|
|
113
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Frame, {
|
|
114
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
115
|
+
items: ITEMS.slice(0, 3),
|
|
116
|
+
activeKey: active,
|
|
117
|
+
onChange: setActive,
|
|
118
|
+
showToggle: false
|
|
119
|
+
})
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/** Many items — the list scrolls, the footer stays pinned. */
|
|
125
|
+
const Scrolling = exports.Scrolling = {
|
|
126
|
+
render: () => {
|
|
127
|
+
const many = Array.from({
|
|
128
|
+
length: 14
|
|
129
|
+
}).map((_, i) => ({
|
|
130
|
+
key: String(i),
|
|
131
|
+
label: `Section ${i + 1}`,
|
|
132
|
+
icon: 'analytics'
|
|
133
|
+
}));
|
|
134
|
+
const [active, setActive] = (0, _react.useState)('0');
|
|
135
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
136
|
+
style: {
|
|
137
|
+
height: 480,
|
|
138
|
+
flexDirection: 'row'
|
|
139
|
+
},
|
|
140
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
141
|
+
items: many,
|
|
142
|
+
activeKey: active,
|
|
143
|
+
onChange: setActive,
|
|
144
|
+
footer: "Bacon POS v2.0.12"
|
|
145
|
+
})
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/** Long labels truncate with an ellipsis (single line). */
|
|
151
|
+
const LongLabels = exports.LongLabels = {
|
|
152
|
+
render: () => {
|
|
153
|
+
const [active, setActive] = (0, _react.useState)('a');
|
|
154
|
+
const items = [{
|
|
155
|
+
key: 'a',
|
|
156
|
+
label: 'Reservations & waitlist management',
|
|
157
|
+
icon: 'table'
|
|
158
|
+
}, {
|
|
159
|
+
key: 'b',
|
|
160
|
+
label: 'Kitchen display system settings',
|
|
161
|
+
icon: 'settings'
|
|
162
|
+
}, {
|
|
163
|
+
key: 'c',
|
|
164
|
+
label: 'Customer loyalty & rewards program',
|
|
165
|
+
icon: 'user-star'
|
|
166
|
+
}];
|
|
167
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Frame, {
|
|
168
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
169
|
+
items: items,
|
|
170
|
+
activeKey: active,
|
|
171
|
+
onChange: setActive,
|
|
172
|
+
footer: "Bacon POS v2.0.12"
|
|
173
|
+
})
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Items without an icon: expanded keeps the icon's blank space (labels stay
|
|
180
|
+
* aligned); collapsed shows the label's initial.
|
|
181
|
+
*/
|
|
182
|
+
const NoIcon = exports.NoIcon = {
|
|
183
|
+
render: () => {
|
|
184
|
+
const [active, setActive] = (0, _react.useState)('home');
|
|
185
|
+
const items = [{
|
|
186
|
+
key: 'home',
|
|
187
|
+
label: 'Home',
|
|
188
|
+
icon: 'home'
|
|
189
|
+
}, {
|
|
190
|
+
key: 'reports',
|
|
191
|
+
label: 'Reports'
|
|
192
|
+
},
|
|
193
|
+
// no icon → blank space / initial "R"
|
|
194
|
+
{
|
|
195
|
+
key: 'billing',
|
|
196
|
+
label: 'Billing'
|
|
197
|
+
},
|
|
198
|
+
// no icon → "B"
|
|
199
|
+
{
|
|
200
|
+
key: 'settings',
|
|
201
|
+
label: 'Settings',
|
|
202
|
+
icon: 'settings'
|
|
203
|
+
}];
|
|
204
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Frame, {
|
|
205
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
206
|
+
items: items,
|
|
207
|
+
activeKey: active,
|
|
208
|
+
onChange: setActive,
|
|
209
|
+
footer: "Bacon POS v2.0.12"
|
|
210
|
+
})
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
/** Custom logo color. */
|
|
216
|
+
const CustomLogo = exports.CustomLogo = {
|
|
217
|
+
render: () => {
|
|
218
|
+
const [active, setActive] = (0, _react.useState)('home');
|
|
219
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Frame, {
|
|
220
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
221
|
+
items: ITEMS,
|
|
222
|
+
activeKey: active,
|
|
223
|
+
onChange: setActive,
|
|
224
|
+
footer: "Acme v1"
|
|
225
|
+
})
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
//# sourceMappingURL=Sidebar.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_Sidebar","_jsxRuntime","meta","title","component","Sidebar","_default","exports","default","ITEMS","key","label","icon","Frame","children","jsx","View","style","height","flexDirection","Expanded","render","active","setActive","useState","items","activeKey","onChange","footer","Collapsed","defaultCollapsed","Toggleable","Minimal","slice","showToggle","Scrolling","many","Array","from","length","map","_","i","String","LongLabels","NoIcon","CustomLogo"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Sidebar/Sidebar.stories.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAAsD,IAAAG,WAAA,GAAAH,OAAA;AAEtD,MAAMI,IAAI,GAAG;EACXC,KAAK,EAAE,oBAAoB;EAC3BC,SAAS,EAAEC;AACb,CAAgC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAElBN,IAAI;AAGnB,MAAMO,KAAoB,GAAG,CAC3B;EAAEC,GAAG,EAAE,MAAM;EAAEC,KAAK,EAAE,MAAM;EAAEC,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IAAAb,WAAA,CAAAc,GAAA,EAACf,QAAA,CAAAK,OAAO;QAACoB,KAAK,EAAEA,KAAM;QAACC,SAAS,EAAEJ,MAAO;QAACK,QAAQ,EAAEJ,SAAU;QAACK,MAAM,EAAC;MAAmB,CAAE;IAAC,CACvF,CAAC;EAEZ;AACF,CAAC;;AAED;AACO,MAAMkB,UAAiB,GAAAvC,OAAA,CAAAuC,UAAA,GAAG;EAC/BzB,MAAM,EAAEA,CAAA,KAAM;IACZ,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAG,IAAAC,eAAQ,EAAC,MAAM,CAAC;IAC5C,oBACE,IAAAvB,WAAA,CAAAc,GAAA,EAACF,KAAK;MAAAC,QAAA,eACJ,IAAAb,WAAA,CAAAc,GAAA,EAACf,QAAA,CAAAK,OAAO;QAACoB,KAAK,EAAEhB,KAAM;QAACiB,SAAS,EAAEJ,MAAO;QAACK,QAAQ,EAAEJ,SAAU;QAACK,MAAM,EAAC;MAAS,CAAE;IAAC,CAC7E,CAAC;EAEZ;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = require("react");
|
|
4
|
+
var _reactNative = require("@testing-library/react-native");
|
|
5
|
+
var _index = require("../../theme/index.js");
|
|
6
|
+
var _Sidebar = require("./Sidebar.js");
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
function wrap(ui) {
|
|
9
|
+
return (0, _reactNative.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ThemeProvider, {
|
|
10
|
+
children: ui
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
const ITEMS = [{
|
|
14
|
+
key: 'home',
|
|
15
|
+
label: 'Home',
|
|
16
|
+
icon: 'home'
|
|
17
|
+
}, {
|
|
18
|
+
key: 'orders',
|
|
19
|
+
label: 'Orders',
|
|
20
|
+
icon: 'receipt'
|
|
21
|
+
}, {
|
|
22
|
+
key: 'settings',
|
|
23
|
+
label: 'Settings',
|
|
24
|
+
icon: 'settings'
|
|
25
|
+
}];
|
|
26
|
+
describe('Sidebar', () => {
|
|
27
|
+
it('renders all item labels when expanded', () => {
|
|
28
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
29
|
+
items: ITEMS
|
|
30
|
+
}));
|
|
31
|
+
expect(_reactNative.screen.getByText('Home')).toBeTruthy();
|
|
32
|
+
expect(_reactNative.screen.getByText('Orders')).toBeTruthy();
|
|
33
|
+
expect(_reactNative.screen.getByText('Settings')).toBeTruthy();
|
|
34
|
+
});
|
|
35
|
+
it('shows the footer only when provided', () => {
|
|
36
|
+
const {
|
|
37
|
+
rerender
|
|
38
|
+
} = wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
39
|
+
items: ITEMS
|
|
40
|
+
}));
|
|
41
|
+
expect(_reactNative.screen.queryByText('v1.0')).toBeNull();
|
|
42
|
+
rerender(/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ThemeProvider, {
|
|
43
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
44
|
+
items: ITEMS,
|
|
45
|
+
footer: "v1.0"
|
|
46
|
+
})
|
|
47
|
+
}));
|
|
48
|
+
expect(_reactNative.screen.getByText('v1.0')).toBeTruthy();
|
|
49
|
+
});
|
|
50
|
+
it('fires onChange with the pressed item key', () => {
|
|
51
|
+
const onChange = jest.fn();
|
|
52
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
53
|
+
items: ITEMS,
|
|
54
|
+
onChange: onChange
|
|
55
|
+
}));
|
|
56
|
+
_reactNative.fireEvent.press(_reactNative.screen.getByText('Orders'));
|
|
57
|
+
expect(onChange).toHaveBeenCalledWith('orders');
|
|
58
|
+
});
|
|
59
|
+
it('marks the active item as selected', () => {
|
|
60
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
61
|
+
items: ITEMS,
|
|
62
|
+
activeKey: "orders"
|
|
63
|
+
}));
|
|
64
|
+
expect(_reactNative.screen.getByLabelText('Orders').props.accessibilityState).toMatchObject({
|
|
65
|
+
selected: true
|
|
66
|
+
});
|
|
67
|
+
expect(_reactNative.screen.getByLabelText('Home').props.accessibilityState).toMatchObject({
|
|
68
|
+
selected: false
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
it('hides labels and footer when collapsed', () => {
|
|
72
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
73
|
+
items: ITEMS,
|
|
74
|
+
defaultCollapsed: true,
|
|
75
|
+
footer: "v1.0"
|
|
76
|
+
}));
|
|
77
|
+
expect(_reactNative.screen.queryByText('Home')).toBeNull();
|
|
78
|
+
expect(_reactNative.screen.queryByText('v1.0')).toBeNull();
|
|
79
|
+
});
|
|
80
|
+
it('truncates a long label to a single line', () => {
|
|
81
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
82
|
+
items: [{
|
|
83
|
+
key: 'a',
|
|
84
|
+
label: 'A very long navigation label',
|
|
85
|
+
icon: 'home'
|
|
86
|
+
}]
|
|
87
|
+
}));
|
|
88
|
+
expect(_reactNative.screen.getByText('A very long navigation label').props.numberOfLines).toBe(1);
|
|
89
|
+
});
|
|
90
|
+
it('shows the label initial for an icon-less item when collapsed', () => {
|
|
91
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
92
|
+
items: [{
|
|
93
|
+
key: 'r',
|
|
94
|
+
label: 'Reports'
|
|
95
|
+
}],
|
|
96
|
+
defaultCollapsed: true
|
|
97
|
+
}));
|
|
98
|
+
expect(_reactNative.screen.getByText('R')).toBeTruthy();
|
|
99
|
+
});
|
|
100
|
+
it('renders an icon-less item normally when expanded (label shown, no initial)', () => {
|
|
101
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
102
|
+
items: [{
|
|
103
|
+
key: 'r',
|
|
104
|
+
label: 'Reports'
|
|
105
|
+
}]
|
|
106
|
+
}));
|
|
107
|
+
expect(_reactNative.screen.getByText('Reports')).toBeTruthy();
|
|
108
|
+
expect(_reactNative.screen.queryByText('R')).toBeNull();
|
|
109
|
+
});
|
|
110
|
+
it('toggles collapse via the built-in control', () => {
|
|
111
|
+
function Ctrl() {
|
|
112
|
+
const [c, setC] = (0, _react.useState)(false);
|
|
113
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.Sidebar, {
|
|
114
|
+
items: ITEMS,
|
|
115
|
+
collapsed: c,
|
|
116
|
+
onCollapsedChange: setC
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(Ctrl, {}));
|
|
120
|
+
// The control flips its intent immediately (the visual collapse trails the
|
|
121
|
+
// width animation, so we assert on the toggle rather than label unmount).
|
|
122
|
+
expect(_reactNative.screen.getByLabelText('Collapse sidebar')).toBeTruthy();
|
|
123
|
+
_reactNative.fireEvent.press(_reactNative.screen.getByLabelText('Collapse sidebar'));
|
|
124
|
+
expect(_reactNative.screen.getByLabelText('Expand sidebar')).toBeTruthy();
|
|
125
|
+
_reactNative.fireEvent.press(_reactNative.screen.getByLabelText('Expand sidebar'));
|
|
126
|
+
expect(_reactNative.screen.getByLabelText('Collapse sidebar')).toBeTruthy();
|
|
127
|
+
// Labels are still present while expanded.
|
|
128
|
+
expect(_reactNative.screen.getByText('Home')).toBeTruthy();
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
//# sourceMappingURL=Sidebar.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_index","_Sidebar","_jsxRuntime","wrap","ui","render","jsx","ThemeProvider","children","ITEMS","key","label","icon","describe","it","Sidebar","items","expect","screen","getByText","toBeTruthy","rerender","queryByText","toBeNull","footer","onChange","jest","fn","fireEvent","press","toHaveBeenCalledWith","activeKey","getByLabelText","props","accessibilityState","toMatchObject","selected","defaultCollapsed","numberOfLines","toBe","Ctrl","c","setC","useState","collapsed","onCollapsedChange"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Sidebar/Sidebar.test.tsx"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAAsD,IAAAI,WAAA,GAAAJ,OAAA;AAEtD,SAASK,IAAIA,CAACC,EAAsB,EAAE;EACpC,OAAO,IAAAC,mBAAM,eAAC,IAAAH,WAAA,CAAAI,GAAA,EAACN,MAAA,CAAAO,aAAa;IAAAC,QAAA,EAAEJ;EAAE,CAAgB,CAAC,CAAC;AACpD;AAEA,MAAMK,KAAoB,GAAG,CAC3B;EAAEC,GAAG,EAAE,MAAM;EAAEC,KAAK,EAAE,MAAM;EAAEC,IAAI,EAAE;AAAO,CAAC,EAC5C;EAAEF,GAAG,EAAE,QAAQ;EAAEC,KAAK,EAAE,QAAQ;EAAEC,IAAI,EAAE;AAAU,CAAC,EACnD;EAAEF,GAAG,EAAE,UAAU;EAAEC,KAAK,EAAE,UAAU;EAAEC,IAAI,EAAE;AAAW,CAAC,CACzD;AAEDC,QAAQ,CAAC,SAAS,EAAE,MAAM;EACxBC,EAAE,CAAC,uCAAuC,EAAE,MAAM;IAChDX,IAAI,cAAC,IAAAD,WAAA,CAAAI,GAAA,EAACL,QAAA,CAAAc,OAAO;MAACC,KAAK,EAAEP;IAAM,CAAE,CAAC,CAAC;IAC/BQ,MAAM,CAACC,mBAAM,CAACC,SAAS,CAAC,MAAM,CAAC,CAAC,CAACC,UAAU,CAAC,CAAC;IAC7CH,MAAM,CAACC,mBAAM,CAACC,SAAS,CAAC,Q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S,CAACC,KAAK,CAACX,mBAAM,CAACc,cAAc,CAAC,kBAAkB,CAAC,CAAC;IAC1Df,MAAM,CAACC,mBAAM,CAACc,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAACZ,UAAU,CAAC,CAAC;IAC5DQ,sBAAS,CAACC,KAAK,CAACX,mBAAM,CAACc,cAAc,CAAC,gBAAgB,CAAC,CAAC;IACxDf,MAAM,CAACC,mBAAM,CAACc,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAACZ,UAAU,CAAC,CAAC;IAC9D;IACAH,MAAM,CAACC,mBAAM,CAACC,SAAS,CAAC,MAAM,CAAC,CAAC,CAACC,UAAU,CAAC,CAAC;EAC/C,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Sidebar", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Sidebar.Sidebar;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _Sidebar = require("./Sidebar.js");
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_Sidebar","require"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Sidebar/index.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DataTable = DataTable;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _index = require("../../theme/index.js");
|
|
10
|
+
var _Button = require("../Button/Button.js");
|
|
11
|
+
var _ChipGroup = require("../Chip/ChipGroup.js");
|
|
12
|
+
var _EmptyState = require("../EmptyState/EmptyState.js");
|
|
13
|
+
var _Icon = require("../Icon/Icon.js");
|
|
14
|
+
var _IconButton = require("../IconButton/IconButton.js");
|
|
15
|
+
var _Input = require("../Input/Input.js");
|
|
16
|
+
var _Text = require("../Text/Text.js");
|
|
17
|
+
var _Table = require("./Table.js");
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
/**
|
|
20
|
+
* DataTable — the turnkey management table (Figma): optional tabs (`ChipGroup`),
|
|
21
|
+
* a search + create toolbar, the `Table` body, a structured `EmptyState`, and
|
|
22
|
+
* optional pagination — assembled with consistent spacing. For bespoke layouts,
|
|
23
|
+
* compose `Table` + `EmptyState` yourself.
|
|
24
|
+
*/
|
|
25
|
+
function DataTable({
|
|
26
|
+
tabs,
|
|
27
|
+
activeTab,
|
|
28
|
+
defaultTab,
|
|
29
|
+
onTabChange,
|
|
30
|
+
searchable = false,
|
|
31
|
+
searchValue,
|
|
32
|
+
onSearchChange,
|
|
33
|
+
searchPlaceholder = 'Search…',
|
|
34
|
+
createLabel,
|
|
35
|
+
onCreate,
|
|
36
|
+
createIcon = 'plus',
|
|
37
|
+
emptyState,
|
|
38
|
+
empty,
|
|
39
|
+
pagination,
|
|
40
|
+
gap = 16,
|
|
41
|
+
containerStyle,
|
|
42
|
+
...tableProps
|
|
43
|
+
}) {
|
|
44
|
+
const theme = (0, _index.useTheme)();
|
|
45
|
+
const tabControlled = activeTab !== undefined;
|
|
46
|
+
const [tabInternal, setTabInternal] = (0, _react.useState)(defaultTab ?? tabs?.[0]?.value ?? null);
|
|
47
|
+
const currentTab = tabControlled ? activeTab : tabInternal;
|
|
48
|
+
const setTab = value => {
|
|
49
|
+
if (value == null) return; // tabs are not deselectable
|
|
50
|
+
if (!tabControlled) setTabInternal(value);
|
|
51
|
+
onTabChange?.(value);
|
|
52
|
+
};
|
|
53
|
+
const emptyNode = empty ?? (emptyState ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_EmptyState.EmptyState, {
|
|
54
|
+
...emptyState
|
|
55
|
+
}) : undefined);
|
|
56
|
+
const showToolbar = searchable || !!createLabel;
|
|
57
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
58
|
+
style: [{
|
|
59
|
+
gap
|
|
60
|
+
}, containerStyle],
|
|
61
|
+
children: [tabs && tabs.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChipGroup.ChipGroup, {
|
|
62
|
+
tone: "dark",
|
|
63
|
+
options: tabs.map(t => ({
|
|
64
|
+
value: t.value,
|
|
65
|
+
label: t.label,
|
|
66
|
+
icon: t.icon
|
|
67
|
+
})),
|
|
68
|
+
value: currentTab,
|
|
69
|
+
onChange: setTab
|
|
70
|
+
}) : null, showToolbar ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
71
|
+
style: {
|
|
72
|
+
flexDirection: 'row',
|
|
73
|
+
alignItems: 'center',
|
|
74
|
+
gap: 12,
|
|
75
|
+
flexWrap: 'wrap'
|
|
76
|
+
},
|
|
77
|
+
children: [searchable ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
78
|
+
style: {
|
|
79
|
+
flex: 1,
|
|
80
|
+
minWidth: 220
|
|
81
|
+
},
|
|
82
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Input.Input, {
|
|
83
|
+
value: searchValue,
|
|
84
|
+
onChangeText: onSearchChange,
|
|
85
|
+
placeholder: searchPlaceholder,
|
|
86
|
+
leftIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.Icon, {
|
|
87
|
+
name: "search",
|
|
88
|
+
size: 24,
|
|
89
|
+
color: "tertiary"
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
}) : null, createLabel ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.Button, {
|
|
93
|
+
label: createLabel,
|
|
94
|
+
variant: "inverse",
|
|
95
|
+
size: "md",
|
|
96
|
+
onPress: onCreate,
|
|
97
|
+
leftIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.Icon, {
|
|
98
|
+
name: createIcon,
|
|
99
|
+
size: 24,
|
|
100
|
+
color: theme.colors.action.inverseForeground
|
|
101
|
+
})
|
|
102
|
+
}) : null]
|
|
103
|
+
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.Table, {
|
|
104
|
+
...tableProps,
|
|
105
|
+
empty: emptyNode
|
|
106
|
+
}), pagination ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Paginator, {
|
|
107
|
+
...pagination
|
|
108
|
+
}) : null]
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function Paginator({
|
|
112
|
+
page,
|
|
113
|
+
pageSize,
|
|
114
|
+
total,
|
|
115
|
+
onPageChange,
|
|
116
|
+
formatRange
|
|
117
|
+
}) {
|
|
118
|
+
const totalPages = Math.max(1, Math.ceil(total / pageSize));
|
|
119
|
+
const from = total === 0 ? 0 : (page - 1) * pageSize + 1;
|
|
120
|
+
const to = Math.min(page * pageSize, total);
|
|
121
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
122
|
+
style: {
|
|
123
|
+
flexDirection: 'row',
|
|
124
|
+
alignItems: 'center',
|
|
125
|
+
justifyContent: 'flex-end',
|
|
126
|
+
gap: 12
|
|
127
|
+
},
|
|
128
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
129
|
+
variant: "bodySmall",
|
|
130
|
+
color: "secondary",
|
|
131
|
+
children: formatRange ? formatRange(from, to, total) : `${from}–${to} of ${total}`
|
|
132
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.IconButton, {
|
|
133
|
+
icon: "arrow-left",
|
|
134
|
+
accessibilityLabel: "Previous page",
|
|
135
|
+
variant: "secondary",
|
|
136
|
+
size: "sm",
|
|
137
|
+
disabled: page <= 1,
|
|
138
|
+
onPress: () => onPageChange(page - 1)
|
|
139
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.IconButton, {
|
|
140
|
+
icon: "arrow-right",
|
|
141
|
+
accessibilityLabel: "Next page",
|
|
142
|
+
variant: "secondary",
|
|
143
|
+
size: "sm",
|
|
144
|
+
disabled: page >= totalPages,
|
|
145
|
+
onPress: () => onPageChange(page + 1)
|
|
146
|
+
})]
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=DataTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_index","_Button","_ChipGroup","_EmptyState","_Icon","_IconButton","_Input","_Text","_Table","_jsxRuntime","DataTable","tabs","activeTab","defaultTab","onTabChange","searchable","searchValue","onSearchChange","searchPlaceholder","createLabel","onCreate","createIcon","emptyState","empty","pagination","gap","containerStyle","tableProps","theme","useTheme","tabControlled","undefined","tabInternal","setTabInternal","useState","value","currentTab","setTab","emptyNode","jsx","EmptyState","showToolbar","jsxs","View","style","children","length","ChipGroup","tone","options","map","t","label","icon","onChange","flexDirection","alignItems","flexWrap","flex","minWidth","Input","onChangeText","placeholder","leftIcon","Icon","name","size","color","Button","variant","onPress","colors","action","inverseForeground","Table","Paginator","page","pageSize","total","onPageChange","formatRange","totalPages","Math","max","ceil","from","to","min","justifyContent","Text","IconButton","accessibilityLabel","disabled"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Table/DataTable.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAEA,IAAAO,WAAA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