@jobber/components 4.26.9-JOB-75261.9 → 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.
@@ -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,2 @@
1
+ export { DataListItems } from "./DataListItems";
2
+ export { DataListHeader } from "./DataListHeader";
@@ -0,0 +1 @@
1
+ export declare function useLayoutMediaQueries(): Record<"xs" | "sm" | "md" | "lg" | "xl", boolean>;
@@ -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, loading, }: BodyProps<T>): JSX.Element;
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, loading, }: DataTableProps<T>): JSX.Element;
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, loading, }: PaginationProps<T>): JSX.Element;
8
+ export declare function Pagination<T extends object>({ table, itemsPerPage, totalItems, }: PaginationProps<T>): JSX.Element;
10
9
  export {};
@@ -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, loading, }) {
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
- const loaderRows = table.getState().pagination.pageSize;
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,13 +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) },
73
- emptyState,
74
- " ",
75
- React__default["default"].createElement("div", null,
76
- "is it loading? ",
77
- loading)))) : (React__default["default"].createElement("tbody", null, Array.from(Array(loaderRows).keys()).map(row => (React__default["default"].createElement("tr", { key: row }, Array.from(Array(loaderColumns).keys()).map(arr => (React__default["default"].createElement("td", { key: arr },
78
- React__default["default"].createElement(Glimmer.Glimmer, null)))))))))));
68
+ }))) : (React__default["default"].createElement("div", { className: classnames__default["default"](styles$3.emptyState) }, emptyState));
79
69
  }
80
70
 
81
71
  function createTableSettings(data, columns, options) {
@@ -136,14 +126,15 @@ var styles$2 = {"pagination":"zn0VRVhObt0-","paginationInfo":"_1d4uh90gfSI-","pa
136
126
  styleInject_es.styleInject(css_248z$2);
137
127
 
138
128
  const defaultItemsPerPageOptions = ["10", "20", "30", "40", "50"];
139
- function Pagination({ table, itemsPerPage, totalItems, loading, }) {
129
+ function Pagination({ table, itemsPerPage, totalItems, }) {
140
130
  const { pageIndex, pageSize } = table.getState().pagination;
141
131
  const totalRows = totalItems;
142
132
  const firstPosition = pageIndex * pageSize + 1;
143
133
  const secondPosition = Math.min(totalRows, pageSize * (pageIndex + 1));
144
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]);
145
135
  return secondPosition <= 0 ? (React__default["default"].createElement("div", { className: styles$2.pagination },
146
- React__default["default"].createElement("div", { className: styles$2.paginationInfo }, !loading ? React__default["default"].createElement(Text.Text, null, "No items") : React__default["default"].createElement(Glimmer.Glimmer, { width: 200 })))) : (React__default["default"].createElement("div", { className: styles$2.pagination },
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 },
147
138
  React__default["default"].createElement("div", { className: styles$2.paginationInfo }, `Showing ${firstPosition}-${secondPosition} of ${totalRows} items`),
148
139
  React__default["default"].createElement("div", { className: styles$2.paginationNav },
149
140
  React__default["default"].createElement("div", { className: styles$2.paginationSelect },
@@ -242,7 +233,7 @@ function Header({ table, stickyHeader, sorting, onRowClick, }) {
242
233
  }))))));
243
234
  }
244
235
 
245
- function DataTable({ data, columns, pagination, sorting, height, stickyHeader, pinFirstColumn, onRowClick, emptyState, loading = false, }) {
236
+ function DataTable({ data, columns, pagination, sorting, height, stickyHeader, pinFirstColumn, onRowClick, emptyState, }) {
246
237
  const [ref, { exactWidth }] = jobberHooks.useResizeObserver();
247
238
  const tableSettings = createTableSettings(data, columns, {
248
239
  pagination,
@@ -256,7 +247,7 @@ function DataTable({ data, columns, pagination, sorting, height, stickyHeader, p
256
247
  React__default["default"].createElement("div", { className: styles$3.tableContainer, style: { height }, ref: ref },
257
248
  React__default["default"].createElement("table", { className: tableClasses },
258
249
  React__default["default"].createElement(Header, { table: table, sorting: sorting, onRowClick: onRowClick, stickyHeader: stickyHeader }),
259
- React__default["default"].createElement(Body, { table: table, onRowClick: onRowClick, height: height ? height * 0.7 : undefined, emptyState: emptyState, loading: loading }),
250
+ React__default["default"].createElement(Body, { table: table, onRowClick: onRowClick, height: height ? height * 0.7 : undefined, emptyState: emptyState }),
260
251
  table.getRowModel().rows.length &&
261
252
  exactWidth &&
262
253
  exactWidth > jobberHooks.Breakpoints.small ? (React__default["default"].createElement(Footer, { table: table, viewType: "desktop" })) : null)),
@@ -265,7 +256,7 @@ function DataTable({ data, columns, pagination, sorting, height, stickyHeader, p
265
256
  exactWidth <= jobberHooks.Breakpoints.small ? (React__default["default"].createElement(Footer, { table: table })) : null,
266
257
  pagination && (React__default["default"].createElement(Pagination, { table: table, itemsPerPage: pagination.itemsPerPage, totalItems: pagination.manualPagination
267
258
  ? pagination.totalItems
268
- : table.getCoreRowModel().rows.length, loading: loading }))));
259
+ : table.getCoreRowModel().rows.length }))));
269
260
  }
270
261
 
271
262
  const mockContainerWidth = (exactWidth) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "4.26.9-JOB-75261.9+e2544f82",
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": "^0.2.2",
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": "e2544f821998f10cae184786edce75cad1b74c28"
87
+ "gitHead": "18e397823f86b38faa243214efcb621513417f44"
88
88
  }