@jobber/components 4.26.9-JOB-75261.10 → 4.26.9
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/DataList/DataList.const.d.ts +11 -0
- package/dist/DataList/DataList.d.ts +1 -1
- package/dist/DataList/DataList.stories.d.ts +1 -0
- package/dist/DataList/DataList.types.d.ts +10 -0
- package/dist/DataList/DataList.utils.d.ts +6 -0
- package/dist/DataList/components/DataListLayout/DataListLayout.d.ts +7 -2
- package/dist/DataList/components/DataListLayoutInternal/DataListHeader.d.ts +12 -0
- package/dist/DataList/components/DataListLayoutInternal/DataListItems.d.ts +11 -0
- package/dist/DataList/components/DataListLayoutInternal/DataListLayoutInternal.d.ts +11 -0
- package/dist/DataList/components/DataListLayoutInternal/index.d.ts +2 -0
- package/dist/DataList/hooks/useLayoutMediaQueries.d.ts +1 -0
- package/dist/DataTable/Body.d.ts +1 -2
- package/dist/DataTable/DataTable.d.ts +1 -5
- package/dist/DataTable/Pagination.d.ts +1 -2
- package/dist/DataTable/index.js +9 -13
- package/package.json +3 -3
|
@@ -1,2 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grab the type from breakpoints const
|
|
3
|
+
*/
|
|
4
|
+
type ValuesOf<T extends readonly unknown[]> = T[number];
|
|
5
|
+
export type Breakpoints = ValuesOf<typeof BREAKPOINTS>;
|
|
1
6
|
export declare const EMPTY_FILTER_RESULTS_MESSAGE = "No Results for Selected Filters";
|
|
2
7
|
export declare const EMPTY_FILTER_RESULTS_ACTION_LABEL = "Clear Filters";
|
|
8
|
+
/**
|
|
9
|
+
* Breakpoints that we support
|
|
10
|
+
*/
|
|
11
|
+
export declare const BREAKPOINTS: readonly ["xs", "sm", "md", "lg", "xl"];
|
|
12
|
+
export declare const BREAKPOINT_SIZES: Record<Breakpoints, number>;
|
|
13
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DataListLayout } from "./components/DataListLayout";
|
|
3
3
|
import { DataListObject, DataListProps } from "./DataList.types";
|
|
4
|
-
export declare function DataList<T extends DataListObject>({ data, headers, loading, filterApplied, children, title, totalCount, }: DataListProps<T>): JSX.Element;
|
|
4
|
+
export declare function DataList<T extends DataListObject>({ data, headers, loading, filterApplied, children, title, totalCount, headerVisibility, }: DataListProps<T>): JSX.Element;
|
|
5
5
|
export declare namespace DataList {
|
|
6
6
|
var Layout: typeof DataListLayout;
|
|
7
7
|
var EmptyState: typeof import("./components/EmptyState").EmptyState;
|
|
@@ -4,3 +4,4 @@ declare const _default: ComponentMeta<typeof DataList>;
|
|
|
4
4
|
export default _default;
|
|
5
5
|
export declare const Basic: ComponentStory<typeof DataList>;
|
|
6
6
|
export declare const EmptyState: ComponentStory<typeof DataList>;
|
|
7
|
+
export declare const Breakpoints: ComponentStory<typeof DataList>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from "react";
|
|
2
|
+
import { Breakpoints } from "./DataList.const";
|
|
3
|
+
export { Breakpoints } from "./DataList.const";
|
|
2
4
|
export type DataListItemType<T extends DataListObject[]> = Record<keyof T[number], ReactElement>;
|
|
3
5
|
export type DataListItemTypeFromHeader<TData extends DataListObject, THeader extends DataListHeader<TData>> = Record<keyof THeader, ReactElement>;
|
|
4
6
|
export interface DataListObject {
|
|
@@ -54,4 +56,12 @@ export interface DataListProps<T extends DataListObject> {
|
|
|
54
56
|
* in the list
|
|
55
57
|
*/
|
|
56
58
|
readonly totalCount?: number | null;
|
|
59
|
+
/**
|
|
60
|
+
* Determine if the header is visible at a given breakpoint. If one isn't provided,
|
|
61
|
+
* it will use the value from the next smallest breakpoint that has a value.
|
|
62
|
+
* @default { xs: true, sm: true, md: true, lg: true, xl: true }
|
|
63
|
+
*/
|
|
64
|
+
readonly headerVisibility?: {
|
|
65
|
+
[Breakpoint in Breakpoints]?: boolean;
|
|
66
|
+
};
|
|
57
67
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import React, { ReactElement } from "react";
|
|
2
2
|
import { DataListHeader, DataListItemType, DataListItemTypeFromHeader, DataListObject } from "./DataList.types";
|
|
3
3
|
import { EmptyStateProps } from "./components/EmptyState";
|
|
4
|
+
import { Breakpoints } from "./DataList.const";
|
|
4
5
|
/**
|
|
5
6
|
* Return the child component that matches the `type` provided
|
|
6
7
|
*/
|
|
7
8
|
export declare function getCompoundComponent<T>(children: ReactElement | ReactElement[], type: ReactElement<T>["type"]): ReactElement<T> | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Return all instances child component that matches the `type` provided
|
|
11
|
+
*/
|
|
12
|
+
export declare function getCompoundComponents<T>(children: ReactElement | ReactElement[], type: ReactElement<T>["type"]): ReactElement<T>[];
|
|
8
13
|
/**
|
|
9
14
|
* Generate the default elements the DataList would use on the data provided.
|
|
10
15
|
*/
|
|
@@ -22,4 +27,5 @@ interface UseDataListEmptyStateProps {
|
|
|
22
27
|
* Modify EmptyState to include an empty filter results when filtering happens
|
|
23
28
|
*/
|
|
24
29
|
export declare function generateDataListEmptyState({ children, isFilterApplied, setIsFilterApplied, }: UseDataListEmptyStateProps): React.ReactElement<EmptyStateProps> | undefined;
|
|
30
|
+
export declare function sortSizeProp(sizeProp: Breakpoints[]): ("xs" | "sm" | "md" | "lg" | "xl")[];
|
|
25
31
|
export {};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DataListItemType, DataListObject } from "../../DataList.types";
|
|
2
|
+
import { Breakpoints, DataListItemType, DataListObject } from "../../DataList.types";
|
|
3
3
|
export interface DataListLayoutProps<T extends DataListObject> {
|
|
4
|
-
children: (item: DataListItemType<T[]>) => JSX.Element;
|
|
4
|
+
readonly children: (item: DataListItemType<T[]>) => JSX.Element;
|
|
5
|
+
/**
|
|
6
|
+
* The breakpoint at which the layout should be displayed. It will be rendered until a layout with a larger breakpoint is found.
|
|
7
|
+
* @default "xs"
|
|
8
|
+
*/
|
|
9
|
+
readonly size?: Breakpoints;
|
|
5
10
|
}
|
|
6
11
|
export declare function DataListLayout<T extends DataListObject>(_: DataListLayoutProps<T>): JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Breakpoints } from "../../DataList.const";
|
|
3
|
+
import { DataListHeader as DataListHeaderType, DataListItemTypeFromHeader, DataListObject, DataListProps } from "../../DataList.types";
|
|
4
|
+
import { DataListLayoutProps } from "../DataListLayout/DataListLayout";
|
|
5
|
+
interface DataListHeaderProps<T extends DataListObject> {
|
|
6
|
+
readonly layouts: React.ReactElement<DataListLayoutProps<T>>[] | undefined;
|
|
7
|
+
readonly mediaMatches?: Record<Breakpoints, boolean>;
|
|
8
|
+
readonly headerData?: DataListItemTypeFromHeader<T, DataListHeaderType<T>>;
|
|
9
|
+
readonly headerVisibility: NonNullable<DataListProps<T>["headerVisibility"]>;
|
|
10
|
+
}
|
|
11
|
+
export declare function DataListHeader<T extends DataListObject>({ layouts, mediaMatches, headerData, headerVisibility, }: DataListHeaderProps<T>): JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Breakpoints } from "../../DataList.const";
|
|
3
|
+
import { DataListObject } from "../../DataList.types";
|
|
4
|
+
import { DataListLayoutProps } from "../DataListLayout/DataListLayout";
|
|
5
|
+
interface DataListItemsProps<T extends DataListObject> {
|
|
6
|
+
readonly layouts: React.ReactElement<DataListLayoutProps<T>>[] | undefined;
|
|
7
|
+
readonly mediaMatches?: Record<Breakpoints, boolean>;
|
|
8
|
+
readonly data: T[];
|
|
9
|
+
}
|
|
10
|
+
export declare function DataListItems<T extends DataListObject>({ layouts, mediaMatches, data, }: DataListItemsProps<T>): JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Breakpoints } from "../../DataList.const";
|
|
3
|
+
import { DataListObject } from "../../DataList.types";
|
|
4
|
+
import { DataListLayoutProps } from "../DataListLayout/DataListLayout";
|
|
5
|
+
interface DataListLayoutInternalProps<T extends DataListObject> {
|
|
6
|
+
readonly layouts: React.ReactElement<DataListLayoutProps<T>>[] | undefined;
|
|
7
|
+
readonly renderLayout: (layout: React.ReactElement<DataListLayoutProps<T>>) => JSX.Element;
|
|
8
|
+
readonly mediaMatches?: Record<Breakpoints, boolean>;
|
|
9
|
+
}
|
|
10
|
+
export declare function DataListLayoutInternal<T extends DataListObject>({ layouts, renderLayout, mediaMatches, }: DataListLayoutInternalProps<T>): JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useLayoutMediaQueries(): Record<"xs" | "sm" | "md" | "lg" | "xl", boolean>;
|
package/dist/DataTable/Body.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ interface BodyProps<T> {
|
|
|
5
5
|
onRowClick?: (row: Row<T>) => void;
|
|
6
6
|
height?: number;
|
|
7
7
|
emptyState?: ReactNode | ReactNode[];
|
|
8
|
-
loading: boolean;
|
|
9
8
|
}
|
|
10
|
-
export declare function Body<T extends object>({ table, onRowClick, emptyState,
|
|
9
|
+
export declare function Body<T extends object>({ table, onRowClick, emptyState, }: BodyProps<T>): JSX.Element;
|
|
11
10
|
export {};
|
|
@@ -49,9 +49,5 @@ export interface DataTableProps<T> {
|
|
|
49
49
|
* The elements to display when the data table is empty
|
|
50
50
|
*/
|
|
51
51
|
emptyState?: ReactNode | ReactNode[];
|
|
52
|
-
/**
|
|
53
|
-
* When true, shows the loading state of the DataTable
|
|
54
|
-
*/
|
|
55
|
-
loading?: boolean;
|
|
56
52
|
}
|
|
57
|
-
export declare function DataTable<T extends object>({ data, columns, pagination, sorting, height, stickyHeader, pinFirstColumn, onRowClick, emptyState,
|
|
53
|
+
export declare function DataTable<T extends object>({ data, columns, pagination, sorting, height, stickyHeader, pinFirstColumn, onRowClick, emptyState, }: DataTableProps<T>): JSX.Element;
|
|
@@ -4,7 +4,6 @@ interface PaginationProps<T> {
|
|
|
4
4
|
table: Table<T>;
|
|
5
5
|
itemsPerPage?: number[];
|
|
6
6
|
totalItems: number;
|
|
7
|
-
loading: boolean;
|
|
8
7
|
}
|
|
9
|
-
export declare function Pagination<T extends object>({ table, itemsPerPage, totalItems,
|
|
8
|
+
export declare function Pagination<T extends object>({ table, itemsPerPage, totalItems, }: PaginationProps<T>): JSX.Element;
|
|
10
9
|
export {};
|
package/dist/DataTable/index.js
CHANGED
|
@@ -7,12 +7,10 @@ var classnames = require('classnames');
|
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var jobberHooks = require('@jobber/hooks/useResizeObserver');
|
|
9
9
|
var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
|
|
10
|
-
var Glimmer = require('../Glimmer-a14ad7fd.js');
|
|
11
10
|
var tslib_es6 = require('../tslib.es6-5b8768b7.js');
|
|
12
11
|
var Option = require('../Option-63267b27.js');
|
|
13
12
|
var Button = require('../Button-7698424c.js');
|
|
14
13
|
var Text = require('../Text-e7ed0974.js');
|
|
15
|
-
require('../Content-a6590328.js');
|
|
16
14
|
require('../FormField-0f880b07.js');
|
|
17
15
|
require('uuid');
|
|
18
16
|
require('react-hook-form');
|
|
@@ -52,16 +50,14 @@ var css_248z$3 = ".m5A5oeRFaMs- {\n position: relative;\n border: calc(16px /
|
|
|
52
50
|
var styles$3 = {"dataTableContainer":"m5A5oeRFaMs-","tableContainer":"cY-5BrIIUg8-","table":"y8xnHe7fwrI-","pinFirstColumn":"t8QYvdtkQXQ-","stickyHeader":"Y21JuHX6fhk-","pinFirstHeaderSortable":"PJEX8dlqCMA-","sortableColumn":"_9ps4aWGs8W0-","clickableRow":"_59XEEB8l5pI-","emptyState":"a2BGGBkY5J8-"};
|
|
53
51
|
styleInject_es.styleInject(css_248z$3);
|
|
54
52
|
|
|
55
|
-
function Body({ table, onRowClick, emptyState,
|
|
53
|
+
function Body({ table, onRowClick, emptyState, }) {
|
|
56
54
|
const bodyRowClasses = classnames__default["default"]({ [styles$3.clickableRow]: !!onRowClick });
|
|
57
55
|
const handleRowClick = React.useCallback((row) => () => {
|
|
58
56
|
if (onRowClick == undefined)
|
|
59
57
|
return;
|
|
60
58
|
onRowClick(row);
|
|
61
59
|
}, [onRowClick]);
|
|
62
|
-
|
|
63
|
-
const loaderColumns = table.getAllColumns().length;
|
|
64
|
-
return (React__default["default"].createElement(React__default["default"].Fragment, null, !loading ? (table.getRowModel().rows.length ? (React__default["default"].createElement("tbody", null, table.getRowModel().rows.map(row => {
|
|
60
|
+
return table.getRowModel().rows.length ? (React__default["default"].createElement("tbody", null, table.getRowModel().rows.map(row => {
|
|
65
61
|
return (React__default["default"].createElement("tr", { key: row.id, onClick: handleRowClick(row), className: bodyRowClasses }, row.getVisibleCells().map(cell => {
|
|
66
62
|
return (React__default["default"].createElement("td", { key: cell.id, style: {
|
|
67
63
|
width: cell.column.getSize(),
|
|
@@ -69,8 +65,7 @@ function Body({ table, onRowClick, emptyState, loading, }) {
|
|
|
69
65
|
maxWidth: cell.column.columnDef.maxSize,
|
|
70
66
|
} }, reactTable.flexRender(cell.column.columnDef.cell, cell.getContext())));
|
|
71
67
|
})));
|
|
72
|
-
}))) : (React__default["default"].createElement("div", { className: classnames__default["default"](styles$3.emptyState) }, emptyState))
|
|
73
|
-
React__default["default"].createElement(Glimmer.Glimmer, null)))))))))));
|
|
68
|
+
}))) : (React__default["default"].createElement("div", { className: classnames__default["default"](styles$3.emptyState) }, emptyState));
|
|
74
69
|
}
|
|
75
70
|
|
|
76
71
|
function createTableSettings(data, columns, options) {
|
|
@@ -131,14 +126,15 @@ var styles$2 = {"pagination":"zn0VRVhObt0-","paginationInfo":"_1d4uh90gfSI-","pa
|
|
|
131
126
|
styleInject_es.styleInject(css_248z$2);
|
|
132
127
|
|
|
133
128
|
const defaultItemsPerPageOptions = ["10", "20", "30", "40", "50"];
|
|
134
|
-
function Pagination({ table, itemsPerPage, totalItems,
|
|
129
|
+
function Pagination({ table, itemsPerPage, totalItems, }) {
|
|
135
130
|
const { pageIndex, pageSize } = table.getState().pagination;
|
|
136
131
|
const totalRows = totalItems;
|
|
137
132
|
const firstPosition = pageIndex * pageSize + 1;
|
|
138
133
|
const secondPosition = Math.min(totalRows, pageSize * (pageIndex + 1));
|
|
139
134
|
const itemsPerPageOptions = React.useMemo(() => { var _a; return (_a = itemsPerPage === null || itemsPerPage === void 0 ? void 0 : itemsPerPage.map(item => String(item))) !== null && _a !== void 0 ? _a : defaultItemsPerPageOptions; }, [itemsPerPage]);
|
|
140
135
|
return secondPosition <= 0 ? (React__default["default"].createElement("div", { className: styles$2.pagination },
|
|
141
|
-
React__default["default"].createElement("div", { className: styles$2.paginationInfo },
|
|
136
|
+
React__default["default"].createElement("div", { className: styles$2.paginationInfo },
|
|
137
|
+
React__default["default"].createElement(Text.Text, null, "No items")))) : (React__default["default"].createElement("div", { className: styles$2.pagination },
|
|
142
138
|
React__default["default"].createElement("div", { className: styles$2.paginationInfo }, `Showing ${firstPosition}-${secondPosition} of ${totalRows} items`),
|
|
143
139
|
React__default["default"].createElement("div", { className: styles$2.paginationNav },
|
|
144
140
|
React__default["default"].createElement("div", { className: styles$2.paginationSelect },
|
|
@@ -237,7 +233,7 @@ function Header({ table, stickyHeader, sorting, onRowClick, }) {
|
|
|
237
233
|
}))))));
|
|
238
234
|
}
|
|
239
235
|
|
|
240
|
-
function DataTable({ data, columns, pagination, sorting, height, stickyHeader, pinFirstColumn, onRowClick, emptyState,
|
|
236
|
+
function DataTable({ data, columns, pagination, sorting, height, stickyHeader, pinFirstColumn, onRowClick, emptyState, }) {
|
|
241
237
|
const [ref, { exactWidth }] = jobberHooks.useResizeObserver();
|
|
242
238
|
const tableSettings = createTableSettings(data, columns, {
|
|
243
239
|
pagination,
|
|
@@ -251,7 +247,7 @@ function DataTable({ data, columns, pagination, sorting, height, stickyHeader, p
|
|
|
251
247
|
React__default["default"].createElement("div", { className: styles$3.tableContainer, style: { height }, ref: ref },
|
|
252
248
|
React__default["default"].createElement("table", { className: tableClasses },
|
|
253
249
|
React__default["default"].createElement(Header, { table: table, sorting: sorting, onRowClick: onRowClick, stickyHeader: stickyHeader }),
|
|
254
|
-
React__default["default"].createElement(Body, { table: table, onRowClick: onRowClick, height: height ? height * 0.7 : undefined, emptyState: emptyState
|
|
250
|
+
React__default["default"].createElement(Body, { table: table, onRowClick: onRowClick, height: height ? height * 0.7 : undefined, emptyState: emptyState }),
|
|
255
251
|
table.getRowModel().rows.length &&
|
|
256
252
|
exactWidth &&
|
|
257
253
|
exactWidth > jobberHooks.Breakpoints.small ? (React__default["default"].createElement(Footer, { table: table, viewType: "desktop" })) : null)),
|
|
@@ -260,7 +256,7 @@ function DataTable({ data, columns, pagination, sorting, height, stickyHeader, p
|
|
|
260
256
|
exactWidth <= jobberHooks.Breakpoints.small ? (React__default["default"].createElement(Footer, { table: table })) : null,
|
|
261
257
|
pagination && (React__default["default"].createElement(Pagination, { table: table, itemsPerPage: pagination.itemsPerPage, totalItems: pagination.manualPagination
|
|
262
258
|
? pagination.totalItems
|
|
263
|
-
: table.getCoreRowModel().rows.length
|
|
259
|
+
: table.getCoreRowModel().rows.length }))));
|
|
264
260
|
}
|
|
265
261
|
|
|
266
262
|
const mockContainerWidth = (exactWidth) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.26.9
|
|
3
|
+
"version": "4.26.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@jobber/design": "^0.44.4",
|
|
23
|
-
"@jobber/formatters": "
|
|
23
|
+
"@jobber/formatters": "*",
|
|
24
24
|
"@jobber/hooks": "^2.1.5",
|
|
25
25
|
"@popperjs/core": "^2.0.6",
|
|
26
26
|
"@std-proposal/temporal": "0.0.1",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"> 1%",
|
|
85
85
|
"IE 10"
|
|
86
86
|
],
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "18e397823f86b38faa243214efcb621513417f44"
|
|
88
88
|
}
|