@oclif/table 0.1.0 → 0.1.1
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/index.d.ts +2 -2
- package/lib/index.js +1 -1
- package/lib/table.d.ts +2 -2
- package/lib/table.js +2 -2
- package/lib/types.d.ts +4 -4
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type { TableProps } from './types.js';
|
|
1
|
+
export { printTable, printTables } from './table.js';
|
|
2
|
+
export type { ScalarDict, TableProps } from './types.js';
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { printTable, printTables } from './table.js';
|
package/lib/table.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare function Skeleton(props: React.PropsWithChildren & {
|
|
|
19
19
|
* Renders a table with the given data.
|
|
20
20
|
* @param options see {@link TableProps}
|
|
21
21
|
*/
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
22
|
+
export declare function printTable<T extends ScalarDict>(options: TableProps<T>): void;
|
|
23
|
+
export declare function printTables<T extends ScalarDict[]>(tables: {
|
|
24
24
|
[P in keyof T]: TableProps<T[P]>;
|
|
25
25
|
}, options?: Omit<ContainerProps, 'children'>): void;
|
package/lib/table.js
CHANGED
|
@@ -217,14 +217,14 @@ export function Skeleton(props) {
|
|
|
217
217
|
* Renders a table with the given data.
|
|
218
218
|
* @param options see {@link TableProps}
|
|
219
219
|
*/
|
|
220
|
-
export function
|
|
220
|
+
export function printTable(options) {
|
|
221
221
|
const instance = render(React.createElement(Table, { ...options }));
|
|
222
222
|
instance.unmount();
|
|
223
223
|
}
|
|
224
224
|
function Container(props) {
|
|
225
225
|
return (React.createElement(Box, { flexWrap: "wrap", flexDirection: props.direction ?? 'row', ...props }, props.children));
|
|
226
226
|
}
|
|
227
|
-
export function
|
|
227
|
+
export function printTables(tables, options) {
|
|
228
228
|
const leftMargin = options?.marginLeft ?? options?.margin ?? 0;
|
|
229
229
|
const rightMargin = options?.marginRight ?? options?.margin ?? 0;
|
|
230
230
|
const columns = process.stdout.columns - (leftMargin + rightMargin);
|
package/lib/types.d.ts
CHANGED
|
@@ -123,16 +123,16 @@ export type TableProps<T extends ScalarDict> = {
|
|
|
123
123
|
* ]
|
|
124
124
|
*
|
|
125
125
|
* // sort the name column in ascending order
|
|
126
|
-
*
|
|
126
|
+
* printTable({data, sort: {name: 'asc'}})
|
|
127
127
|
*
|
|
128
128
|
* // sort the name column in descending order
|
|
129
|
-
*
|
|
129
|
+
* printTable({data, sort: {name: 'desc'}})
|
|
130
130
|
*
|
|
131
131
|
* // sort by name in ascending order and age in descending order
|
|
132
|
-
*
|
|
132
|
+
* printTable({data, sort: {name: 'asc', age: 'desc'}})
|
|
133
133
|
*
|
|
134
134
|
* // sort by name in ascending order and age in descending order using a custom sort function
|
|
135
|
-
*
|
|
135
|
+
* printTable({data, sort: {name: 'asc', age: (a, b) => b - a}})
|
|
136
136
|
* ```
|
|
137
137
|
*/
|
|
138
138
|
sort?: Sort<T>;
|