@jobber/components 4.45.1 → 4.45.3
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.d.ts +1 -1
- package/dist/DataList/DataList.types.d.ts +20 -1
- package/dist/DataList/DataList.utils.d.ts +1 -1
- package/dist/DataList/components/DataListActions/DataListActions.d.ts +3 -0
- package/dist/DataList/components/DataListActions/index.d.ts +1 -0
- package/dist/DataList/components/DataListHeader/DataListHeader.d.ts +2 -0
- package/dist/DataList/components/DataListHeader/index.d.ts +1 -0
- package/dist/DataList/components/DataListItem/DataListItem.d.ts +2 -2
- package/dist/DataList/components/DataListItemActions/DataListItemActions.d.ts +1 -5
- package/dist/DataList/components/DataListItemActions/index.d.ts +0 -1
- package/dist/DataList/components/{DataListItemActions → DataListItemActionsOverflow}/DataListItemActionsOverflow.d.ts +1 -1
- package/dist/DataList/components/DataListItemActionsOverflow/index.d.ts +1 -0
- package/dist/DataList/components/DataListItems/DataListItems.d.ts +7 -0
- package/dist/DataList/components/DataListItems/index.d.ts +1 -0
- package/dist/DataList/components/DataListLayout/DataListLayout.d.ts +2 -2
- package/dist/DataList/components/DataListLoadingState/DataListLoadingState.d.ts +2 -9
- package/dist/DataList/context/DataListContext/DataListContext.d.ts +3 -3
- package/dist/DataList/hooks/useActiveLayout.d.ts +4 -0
- package/dist/DataList/index.js +287 -287
- package/package.json +2 -2
- package/dist/DataList/components/DataListLayoutInternal/DataListHeader.d.ts +0 -11
- package/dist/DataList/components/DataListLayoutInternal/DataListItems.d.ts +0 -10
- package/dist/DataList/components/DataListLayoutInternal/DataListLayoutInternal.d.ts +0 -10
- package/dist/DataList/components/DataListLayoutInternal/index.d.ts +0 -3
- package/dist/DataList/hooks/useLayoutMediaQueries.d.ts +0 -1
- /package/dist/DataList/components/{DataListLayoutInternal → DataListHeader}/DataListHeaderCheckbox.d.ts +0 -0
|
@@ -8,7 +8,7 @@ import { DataListAction } from "./components/DataListAction";
|
|
|
8
8
|
import { DataListLayoutActions } from "./components/DataListLayoutActions";
|
|
9
9
|
import { DataListBulkActionProps, DataListObject, DataListProps } from "./DataList.types";
|
|
10
10
|
import { DataListBulkActions } from "./components/DataListBulkActions";
|
|
11
|
-
export declare function DataList<T extends DataListObject>({ sorting, ...props }: DataListProps<T>): JSX.Element;
|
|
11
|
+
export declare function DataList<T extends DataListObject>({ selected, sorting, ...props }: DataListProps<T>): JSX.Element;
|
|
12
12
|
export declare namespace DataList {
|
|
13
13
|
var Layout: typeof DataListLayout;
|
|
14
14
|
var LayoutActions: typeof DataListLayoutActions;
|
|
@@ -102,8 +102,9 @@ export interface DataListProps<T extends DataListObject> {
|
|
|
102
102
|
readonly selected?: T["id"][];
|
|
103
103
|
readonly onSelectAll?: () => void;
|
|
104
104
|
}
|
|
105
|
+
export type LayoutRenderer<T extends DataListObject> = (item: DataListItemType<T[]>) => JSX.Element;
|
|
105
106
|
export interface DataListLayoutProps<T extends DataListObject> {
|
|
106
|
-
readonly children:
|
|
107
|
+
readonly children: LayoutRenderer<T>;
|
|
107
108
|
/**
|
|
108
109
|
* The breakpoint at which the layout should be displayed. It will be rendered until a layout with a larger breakpoint is found.
|
|
109
110
|
* @default "xs"
|
|
@@ -149,6 +150,12 @@ export interface DataListContextProps<T extends DataListObject> extends DataList
|
|
|
149
150
|
readonly layoutComponents?: ReactElement<DataListLayoutProps<T>>[];
|
|
150
151
|
readonly itemActionComponent?: ReactElement<DataListItemActionsProps<T>>;
|
|
151
152
|
readonly bulkActionsComponent?: ReactElement<DataListItemActionsProps<T>>;
|
|
153
|
+
readonly layoutBreakpoints: Breakpoints[];
|
|
154
|
+
readonly registerLayoutBreakpoints: (breakpoint: Breakpoints) => void;
|
|
155
|
+
readonly layouts: {
|
|
156
|
+
readonly [Breakpoint in Breakpoints]?: LayoutRenderer<T>;
|
|
157
|
+
};
|
|
158
|
+
readonly registerLayout: (size: Breakpoints, layout: LayoutRenderer<T>) => void;
|
|
152
159
|
}
|
|
153
160
|
export interface DataListLayoutContextProps {
|
|
154
161
|
readonly isInLayoutProvider: boolean;
|
|
@@ -215,6 +222,18 @@ export interface DataListActionProps<T extends DataListObject> {
|
|
|
215
222
|
*/
|
|
216
223
|
readonly onClick?: (data: T) => void;
|
|
217
224
|
}
|
|
225
|
+
export interface DataListActionsProps<T extends DataListObject> {
|
|
226
|
+
/**
|
|
227
|
+
* The actions to render for each item in the DataList. This only accepts the
|
|
228
|
+
* DataList.Action component.
|
|
229
|
+
*/
|
|
230
|
+
readonly children?: Fragment<ReactElement<DataListActionProps<T>>>;
|
|
231
|
+
/**
|
|
232
|
+
* The number of items to expose before the "More" button is shown.
|
|
233
|
+
* @default 2
|
|
234
|
+
*/
|
|
235
|
+
readonly itemsToExpose?: number;
|
|
236
|
+
}
|
|
218
237
|
export interface DataListBulkActionProps extends DataListActionProps<DataListObject> {
|
|
219
238
|
/**
|
|
220
239
|
* The callback function when the action is clicked.
|
|
@@ -17,5 +17,5 @@ export declare function generateListItemElement<T extends DataListObject>(item:
|
|
|
17
17
|
* Generate the header elements with the default styling
|
|
18
18
|
*/
|
|
19
19
|
export declare function generateHeaderElements<T extends DataListObject>(headers: DataListHeader<T>): DataListItemTypeFromHeader<T, DataListHeader<T>> | undefined;
|
|
20
|
-
export declare function
|
|
20
|
+
export declare function sortBreakpoints(sizeProp: Breakpoints[]): ("xs" | "sm" | "md" | "lg" | "xl")[];
|
|
21
21
|
export declare function getExposedActions(childrenArray: ReactElement[], childCount?: number): React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./DataListActions";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./DataListHeader";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { DataListLayoutProps, DataListObject } from "@jobber/components/DataList/DataList.types";
|
|
3
3
|
interface DataListItem<T extends DataListObject> {
|
|
4
4
|
readonly item: T;
|
|
5
5
|
readonly index: number;
|
|
6
|
-
readonly layout:
|
|
6
|
+
readonly layout: DataListLayoutProps<T>["children"];
|
|
7
7
|
}
|
|
8
8
|
export declare function DataListItem<T extends DataListObject>({ item, layout, }: DataListItem<T>): JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DataListItemActionsProps, DataListObject } from "../../DataList.types";
|
|
3
3
|
export declare function DataListItemActions<T extends DataListObject>(_: DataListItemActionsProps<T>): null;
|
|
4
|
-
|
|
5
|
-
readonly item: T;
|
|
6
|
-
}
|
|
7
|
-
export declare function InternalDataListItemActions<T extends DataListObject>({ item, }: InternalDataListItemActionsProps<T>): JSX.Element | null;
|
|
8
|
-
export {};
|
|
4
|
+
export declare function InternalDataListItemActions(): JSX.Element | null;
|
|
@@ -3,5 +3,5 @@ import { DataListActionProps, DataListObject } from "../../DataList.types";
|
|
|
3
3
|
interface DataListItemActionsOverflowProps<T extends DataListObject> {
|
|
4
4
|
readonly actions: ReactElement<DataListActionProps<T>>[];
|
|
5
5
|
}
|
|
6
|
-
export declare function DataListItemActionsOverflow<T extends DataListObject>({ actions, }: DataListItemActionsOverflowProps<T>): JSX.Element;
|
|
6
|
+
export declare function DataListItemActionsOverflow<T extends DataListObject>({ actions, }: DataListItemActionsOverflowProps<T>): JSX.Element | null;
|
|
7
7
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./DataListItemActionsOverflow";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Breakpoints, DataListObject } from "@jobber/components/DataList/DataList.types";
|
|
3
|
+
interface DataListItemsProps {
|
|
4
|
+
readonly size?: Breakpoints;
|
|
5
|
+
}
|
|
6
|
+
export declare function DataListItems<T extends DataListObject>({ size, }: DataListItemsProps): JSX.Element | null;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./DataListItems";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DataListLayoutProps, DataListObject } from "
|
|
3
|
-
export declare function DataListLayout<T extends DataListObject>(
|
|
2
|
+
import { DataListLayoutProps, DataListObject } from "@jobber/components/DataList/DataList.types";
|
|
3
|
+
export declare function DataListLayout<T extends DataListObject>({ children, size, }: DataListLayoutProps<T>): JSX.Element | null;
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { Breakpoints, DataListHeader, DataListLayoutProps, DataListObject } from "../../DataList.types";
|
|
3
|
-
interface DataListLoadingStateProps<T extends DataListObject> {
|
|
4
|
-
readonly headers: DataListHeader<T>;
|
|
5
|
-
readonly layouts: React.ReactElement<DataListLayoutProps<T>>[] | undefined;
|
|
6
|
-
readonly mediaMatches?: Record<Breakpoints, boolean>;
|
|
7
|
-
}
|
|
1
|
+
/// <reference types="react" />
|
|
8
2
|
export declare const LOADING_STATE_LIMIT_ITEMS = 10;
|
|
9
3
|
export declare const DATALIST_LOADINGSTATE_ROW_TEST_ID = "ATL-DataList-LoadingState-Row";
|
|
10
|
-
export declare function DataListLoadingState
|
|
11
|
-
export {};
|
|
4
|
+
export declare function DataListLoadingState(): JSX.Element | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { DataListContextProps, DataListObject } from "../../DataList.types";
|
|
3
3
|
export declare const defaultValues: DataListContextProps<DataListObject>;
|
|
4
|
-
export declare const DataListContext:
|
|
5
|
-
export declare function useDataListContext(): DataListContextProps<
|
|
4
|
+
export declare const DataListContext: React.Context<DataListContextProps<DataListObject>>;
|
|
5
|
+
export declare function useDataListContext<T extends DataListObject>(): DataListContextProps<T>;
|
package/dist/DataList/index.js
CHANGED
|
@@ -7,40 +7,39 @@ var React = require('react');
|
|
|
7
7
|
var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
|
|
8
8
|
var Text = require('../Text-59bde58c.js');
|
|
9
9
|
var Glimmer = require('../Glimmer-cfa92a88.js');
|
|
10
|
-
var framerMotion = require('framer-motion');
|
|
11
|
-
var classnames = require('classnames');
|
|
12
10
|
var noop = require('lodash/noop');
|
|
13
|
-
var reactRouterDom = require('react-router-dom');
|
|
14
|
-
var Button = require('../Button-d89f2271.js');
|
|
15
11
|
var design = require('@jobber/design');
|
|
16
|
-
var
|
|
17
|
-
var
|
|
12
|
+
var framerMotion = require('framer-motion');
|
|
13
|
+
var classnames = require('classnames');
|
|
18
14
|
var Tooltip = require('../Tooltip-59dbab5b.js');
|
|
19
|
-
require('
|
|
15
|
+
var Button = require('../Button-d89f2271.js');
|
|
16
|
+
var useInView = require('@jobber/hooks/useInView');
|
|
17
|
+
var isEmpty = require('lodash/isEmpty');
|
|
18
|
+
var InlineLabel = require('../InlineLabel-3d461632.js');
|
|
19
|
+
var FormatDate = require('../FormatDate-70ea5b43.js');
|
|
20
|
+
var Heading = require('../Heading-4562900a.js');
|
|
20
21
|
var useFocusTrap = require('@jobber/hooks/useFocusTrap');
|
|
21
22
|
var useRefocusOnActivator = require('@jobber/hooks/useRefocusOnActivator');
|
|
22
23
|
var useOnKeyDown = require('@jobber/hooks/useOnKeyDown');
|
|
24
|
+
var ReactDOM = require('react-dom');
|
|
23
25
|
var foundation = require('@jobber/design/foundation');
|
|
24
|
-
var isEmpty = require('lodash/isEmpty');
|
|
25
|
-
var InlineLabel = require('../InlineLabel-3d461632.js');
|
|
26
|
-
var styles$f = require('@jobber/components/DataList/DataList.css');
|
|
27
|
-
require('uuid');
|
|
28
|
-
require('react-hook-form');
|
|
29
26
|
var Checkbox = require('../Checkbox-eac63b7f.js');
|
|
30
|
-
var
|
|
31
|
-
var Heading = require('../Heading-4562900a.js');
|
|
27
|
+
var reactRouterDom = require('react-router-dom');
|
|
32
28
|
var AnimatedSwitcher = require('../AnimatedSwitcher-d1e1ddcf.js');
|
|
33
|
-
var useInView = require('@jobber/hooks/useInView');
|
|
34
29
|
var Popover = require('../Popover-d401fb54.js');
|
|
35
30
|
var Content = require('../Content-2ca1ffe1.js');
|
|
36
31
|
var Chip = require('../Chip-4d8e6370.js');
|
|
37
32
|
require('@jobber/hooks/useAssert');
|
|
38
33
|
require('../Avatar-1aa30ee1.js');
|
|
39
34
|
require('color');
|
|
35
|
+
var Typography = require('../Typography-9bff9c91.js');
|
|
36
|
+
require('react-popper');
|
|
40
37
|
var debounce = require('lodash/debounce');
|
|
41
38
|
var InputText = require('../InputText-5ac5cfe0.js');
|
|
42
39
|
var Spinner = require('../Spinner-9d8fc7ff.js');
|
|
43
40
|
var Icon = require('../Icon-405a216c.js');
|
|
41
|
+
require('uuid');
|
|
42
|
+
require('react-hook-form');
|
|
44
43
|
require('../ButtonDismiss-250840a4.js');
|
|
45
44
|
require('lodash/sortBy');
|
|
46
45
|
require('@jobber/hooks/useLiveAnnounce');
|
|
@@ -50,14 +49,13 @@ require('../InputValidation-4e809bdd.js');
|
|
|
50
49
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
51
50
|
|
|
52
51
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
53
|
-
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
54
52
|
var noop__default = /*#__PURE__*/_interopDefaultLegacy(noop);
|
|
53
|
+
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
55
54
|
var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
|
|
56
|
-
var styles__default = /*#__PURE__*/_interopDefaultLegacy(styles$f);
|
|
57
55
|
var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
|
|
58
56
|
|
|
59
|
-
var css_248z$e = ".TkdrExYnvcY-,\n.TkdrExYnvcY- * {\n box-sizing: border-box;\n}\n\n.TkdrExYnvcY- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-direction: column;\n flex-direction: column;\n position: relative;\n z-index: 0;\n z-index: var(--elevation-default);\n -ms-flex: 1;\n flex: 1;\n}\n\n/*\n * Header\n */\n\n.IcAlZHoB4LI- {\n display: -ms-flexbox;\n display: flex;\n position: relative;\n z-index: 1;\n z-index: var(--elevation-base);\n margin-bottom: calc(16px / 2);\n margin-bottom: var(--space-small);\n -ms-flex-align: center;\n align-items: center;\n}\n\n.TFO76ysivmg- {\n display: grid;\n padding: calc(16px / 2) 0;\n padding: var(--space-small) 0;\n gap: calc(16px / 2);\n grid-gap: calc(16px / 2);\n grid-gap: var(--space-small);\n gap: var(--space-small);\n grid-template-columns: auto -webkit-max-content;\n grid-template-columns: auto max-content;\n}\n\n.jGHZZYZm1ZY- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-direction: column;\n flex-direction: column;\n -ms-flex-pack: center;\n justify-content: center;\n min-height: calc(16px * 3);\n min-height: var(--space-largest);\n padding: calc(16px / 2);\n padding: var(--space-small);\n border-bottom: calc(16px / 8) solid rgb(225, 225, 225);\n border-bottom: var(--border-thick) solid var(--color-border);\n}\n\n.jMSVGIAr5tk- > p {\n font-weight: 500;\n white-space: nowrap;\n}\n\n.jMSVGIAr5tk- {\n display: -ms-flexbox;\n display: flex;\n
|
|
60
|
-
var styles$e = {"wrapper":"TkdrExYnvcY-","titleContainer":"IcAlZHoB4LI-","headerFilters":"TFO76ysivmg-","headerTitles":"jGHZZYZm1ZY-","headerBatchSelect":"jMSVGIAr5tk-","listItem":"ise8kHCfhCY-","active":"Pc0JGX6jCD4-","listItemClickable":"Tq6e0BGwcSM-","selectable":"d-79rkMqufg-","selectAllCheckbox":"qm-SSuWTXkI-","visible":"VA9RnQp6nbI-","selected":"_4L7iXXzLr5k-","filtering":"Kkp-IYmwq-s-","filteringSpinner":"m-eCShL7TU4-","srOnly":"esUiRgWabYw-"};
|
|
57
|
+
var css_248z$e = ".TkdrExYnvcY-,\n.TkdrExYnvcY- * {\n box-sizing: border-box;\n}\n\n.TkdrExYnvcY- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-direction: column;\n flex-direction: column;\n position: relative;\n z-index: 0;\n z-index: var(--elevation-default);\n -ms-flex: 1;\n flex: 1;\n}\n\n/*\n * Header\n */\n\n.IcAlZHoB4LI- {\n display: -ms-flexbox;\n display: flex;\n position: relative;\n z-index: 1;\n z-index: var(--elevation-base);\n margin-bottom: calc(16px / 2);\n margin-bottom: var(--space-small);\n -ms-flex-align: center;\n align-items: center;\n}\n\n.TFO76ysivmg- {\n display: grid;\n padding: calc(16px / 2) 0;\n padding: var(--space-small) 0;\n gap: calc(16px / 2);\n grid-gap: calc(16px / 2);\n grid-gap: var(--space-small);\n gap: var(--space-small);\n grid-template-columns: auto -webkit-max-content;\n grid-template-columns: auto max-content;\n}\n\n.jGHZZYZm1ZY- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-direction: column;\n flex-direction: column;\n -ms-flex-pack: center;\n justify-content: center;\n min-height: calc(16px * 3);\n min-height: var(--space-largest);\n padding: calc(16px / 2);\n padding: var(--space-small);\n border-bottom: calc(16px / 8) solid rgb(225, 225, 225);\n border-bottom: var(--border-thick) solid var(--color-border);\n}\n\n.GiD7MjZJbcw- {\n display: -ms-flexbox;\n display: flex;\n}\n\n@media (max-width: 489.98px) {\n\n.GiD7MjZJbcw- {\n -ms-flex-pack: justify;\n justify-content: space-between;\n width: 100%;\n}\n }\n\n@media (--small-screens-and-below) {\n\n.GiD7MjZJbcw- {\n -ms-flex-pack: justify;\n justify-content: space-between;\n width: 100%;\n}\n }\n\n.jMSVGIAr5tk- > p {\n font-weight: 500;\n white-space: nowrap;\n}\n\n.jMSVGIAr5tk- {\n display: -ms-flexbox;\n display: flex;\n margin: calc((16px / 2) * -1) 0;\n margin: calc(calc(16px / 2) * -1) 0;\n margin: calc(var(--space-small) * -1) 0;\n -ms-flex-align: center;\n align-items: center;\n gap: calc(16px / 4);\n gap: var(--space-smaller);\n}\n\n/*\n * List Item\n */\n\n.ise8kHCfhCY- {\n position: relative;\n padding: calc(16px / 2);\n padding: var(--space-small);\n border-bottom: calc(16px / 16) solid rgb(225, 225, 225);\n border-bottom: var(--border-base) solid var(--color-border);\n transition: all 200ms;\n transition: all var(--timing-base);\n}\n\n.ise8kHCfhCY-.Pc0JGX6jCD4-,\n.ise8kHCfhCY-:hover,\n.ise8kHCfhCY-:focus-within {\n --data-list-item-active-color: var(--color-surface--background);\n background-color: rgb(244, 244, 244);\n background-color: var(--data-list-item-active-color);\n}\n\n.Tq6e0BGwcSM- {\n display: block;\n margin: calc((16px / 2) * -1) 0;\n margin: calc(calc(16px / 2) * -1) 0;\n margin: calc(var(--space-small) * -1) 0;\n padding: calc(16px / 2) 0;\n padding: var(--space-small) 0;\n border: none;\n text-align: left;\n -webkit-text-decoration: none;\n text-decoration: none;\n background-color: transparent;\n cursor: pointer;\n}\n\n/**\n * Enable a better hover and focus experience when :has() is supported.\n * This is a workaround for Firefox where the :has() selector is not supported.\n */\n\n@supports selector(*:has(*)) {\n .ise8kHCfhCY-:hover,\n .ise8kHCfhCY-:focus-within {\n background-color: transparent;\n }\n\n .ise8kHCfhCY-:has(.Tq6e0BGwcSM-:hover, .Tq6e0BGwcSM-:focus) {\n background-color: var(--data-list-item-active-color);\n }\n}\n\n/*\n * List Item Selection\n */\n\n.d-79rkMqufg- {\n display: grid;\n -ms-flex-align: start;\n align-items: flex-start;\n}\n\n@media (min-width: 768px) {\n\n.d-79rkMqufg- {\n -ms-flex-align: center;\n align-items: center;\n}\n }\n\n@media (--medium-screens-and-up) {\n\n.d-79rkMqufg- {\n -ms-flex-align: center;\n align-items: center;\n}\n }\n\n.d-79rkMqufg-,\n.jGHZZYZm1ZY- .d-79rkMqufg- {\n grid-template-columns: -webkit-max-content minmax(0px, auto);\n grid-template-columns: max-content minmax(0px, auto);\n -webkit-column-gap: calc(16px / 2);\n -webkit-column-gap: var(--space-small);\n -moz-column-gap: calc(16px / 2);\n -moz-column-gap: var(--space-small);\n column-gap: calc(16px / 2);\n column-gap: var(--space-small);\n}\n\n.jGHZZYZm1ZY- .d-79rkMqufg- {\n display: grid;\n -ms-flex-align: center;\n align-items: center;\n}\n\n.qm-SSuWTXkI- {\n display: -ms-flexbox;\n display: flex;\n visibility: hidden;\n\n /* To compensate the Checkbox's label margin that we are using for screen-readers */\n margin-right: calc((16px * 1) * -1);\n margin-right: calc(calc(16px * 1) * -1);\n margin-right: calc(var(--space-base) * -1);\n}\n\n.qm-SSuWTXkI-.VA9RnQp6nbI- {\n visibility: visible;\n}\n\n.ise8kHCfhCY- .d-79rkMqufg- > :first-child {\n -ms-flex-order: 2;\n order: 2;\n}\n\n.ise8kHCfhCY- .d-79rkMqufg- > :last-child {\n -ms-flex-order: 1;\n order: 1;\n padding-top: calc(16px / 4);\n padding-top: var(--space-smaller);\n opacity: 1;\n transition: opacity 100ms ease-in-out;\n transition: opacity var(--transition-properties);\n --transition-properties: var(--timing-quick) ease-in-out;\n}\n\n@media (min-width: 768px) {\n\n.ise8kHCfhCY- .d-79rkMqufg- > :last-child {\n padding-top: 0;\n opacity: 0;\n}\n }\n\n@media (--medium-screens-and-up) {\n\n.ise8kHCfhCY- .d-79rkMqufg- > :last-child {\n padding-top: 0;\n opacity: 0;\n}\n }\n\n.ise8kHCfhCY-:hover .d-79rkMqufg- > :last-child,\n.ise8kHCfhCY-:focus-within .d-79rkMqufg- > :last-child,\n.ise8kHCfhCY- .d-79rkMqufg-._4L7iXXzLr5k- > :last-child {\n opacity: 1;\n}\n\n/*\n * Filters\n */\n\n.Kkp-IYmwq-s- {\n display: -ms-flexbox;\n display: flex;\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: rgba(255, 255, 255, 0.6);\n background-color: var(--color-overlay--dimmed);\n -ms-flex-align: start;\n align-items: flex-start;\n -ms-flex-pack: center;\n justify-content: center;\n}\n\n.m-eCShL7TU4- {\n position: sticky;\n top: 50vh;\n}\n\n/* This hides the text from the UI but not from the screen readers */\n\n.esUiRgWabYw- {\n position: absolute;\n top: auto;\n left: -10000px;\n width: 1px;\n height: 1px;\n overflow: hidden;\n text-indent: -10000px;\n}\n";
|
|
58
|
+
var styles$e = {"wrapper":"TkdrExYnvcY-","titleContainer":"IcAlZHoB4LI-","headerFilters":"TFO76ysivmg-","headerTitles":"jGHZZYZm1ZY-","batchSelectContainer":"GiD7MjZJbcw-","headerBatchSelect":"jMSVGIAr5tk-","listItem":"ise8kHCfhCY-","active":"Pc0JGX6jCD4-","listItemClickable":"Tq6e0BGwcSM-","selectable":"d-79rkMqufg-","selectAllCheckbox":"qm-SSuWTXkI-","visible":"VA9RnQp6nbI-","selected":"_4L7iXXzLr5k-","filtering":"Kkp-IYmwq-s-","filteringSpinner":"m-eCShL7TU4-","srOnly":"esUiRgWabYw-"};
|
|
61
59
|
styleInject_es.styleInject(css_248z$e);
|
|
62
60
|
|
|
63
61
|
var css_248z$d = ".F56prQsXm3A- {\n min-width: 80px;\n margin-left: calc(16px / 2);\n margin-left: var(--space-small);\n}\n";
|
|
@@ -81,40 +79,42 @@ function DataListTotalCount({ totalCount, loading, }) {
|
|
|
81
79
|
return (React__default["default"].createElement("div", { className: styles$d.results, "data-testid": DATALIST_TOTALCOUNT_TEST_ID }, output));
|
|
82
80
|
}
|
|
83
81
|
|
|
84
|
-
var css_248z$c = ".Rh--6fVpkm4- {\n padding: calc(16px / 2);\n padding: var(--space-small);\n}\n\n.zbS7UvpVoWI- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-direction: column;\n flex-direction: column;\n -ms-flex-pack: justify;\n justify-content: space-between;\n height: calc(16px * 3);\n height: var(--space-largest);\n padding: calc(16px * 1) 0;\n padding: var(--space-base) 0;\n}\n";
|
|
85
|
-
var styles$c = {"loadingItem":"Rh--6fVpkm4-","mobileLoadingState":"zbS7UvpVoWI-"};
|
|
86
|
-
styleInject_es.styleInject(css_248z$c);
|
|
87
|
-
|
|
88
82
|
const defaultValues$1 = {
|
|
89
83
|
title: "",
|
|
90
84
|
data: [],
|
|
91
85
|
headers: {},
|
|
92
86
|
children: [],
|
|
93
87
|
selected: [],
|
|
88
|
+
layoutBreakpoints: [],
|
|
89
|
+
registerLayoutBreakpoints: noop__default["default"],
|
|
90
|
+
layouts: {
|
|
91
|
+
xs: children => React__default["default"].createElement(React__default["default"].Fragment, null, children),
|
|
92
|
+
sm: children => React__default["default"].createElement(React__default["default"].Fragment, null, children),
|
|
93
|
+
md: children => React__default["default"].createElement(React__default["default"].Fragment, null, children),
|
|
94
|
+
lg: children => React__default["default"].createElement(React__default["default"].Fragment, null, children),
|
|
95
|
+
xl: children => React__default["default"].createElement(React__default["default"].Fragment, null, children),
|
|
96
|
+
},
|
|
97
|
+
registerLayout: noop__default["default"],
|
|
94
98
|
};
|
|
95
99
|
const DataListContext = React.createContext(defaultValues$1);
|
|
96
100
|
function useDataListContext() {
|
|
97
101
|
return React.useContext(DataListContext);
|
|
98
102
|
}
|
|
99
103
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
function useMediaQuery(CSSMediaQuery) {
|
|
105
|
+
const [matches, setMatches] = React.useState(window.matchMedia(CSSMediaQuery).matches);
|
|
106
|
+
React.useEffect(() => {
|
|
107
|
+
const media = window.matchMedia(CSSMediaQuery);
|
|
108
|
+
if (media.matches !== matches) {
|
|
109
|
+
setMatches(media.matches);
|
|
110
|
+
}
|
|
111
|
+
const listener = () => setMatches(media.matches);
|
|
112
|
+
media.addEventListener("change", listener);
|
|
113
|
+
return () => media.removeEventListener("change", listener);
|
|
114
|
+
}, [CSSMediaQuery]);
|
|
115
|
+
return matches;
|
|
108
116
|
}
|
|
109
117
|
|
|
110
|
-
var css_248z$b = ".jHcHGQ-HDbk- {\n display: -ms-flexbox;\n display: flex;\n position: absolute;\n top: calc((16px / 2) * -1);\n top: calc(calc(16px / 2) * -1);\n top: calc(var(--space-small) * -1);\n right: 0;\n z-index: 6;\n z-index: var(--elevation-menu);\n box-shadow: 0px calc(16px / 16) calc(16px / 4) 0px\n rgba(0, 0, 0, 0.1),\n 0px calc(16px / 4) 12px 0px rgba(0, 0, 0, 0.05);\n box-shadow: var(--shadow-base);\n padding: calc(16px / 4);\n padding: var(--space-smaller);\n border: calc(16px / 16) solid rgb(225, 225, 225);\n border: var(--border-base) solid var(--color-border);\n border-radius: calc(16px / 2);\n border-radius: var(--radius-larger);\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n gap: calc(16px / 4);\n gap: var(--space-smaller);\n}\n";
|
|
111
|
-
var styles$b = {"menu":"jHcHGQ-HDbk-"};
|
|
112
|
-
styleInject_es.styleInject(css_248z$b);
|
|
113
|
-
|
|
114
|
-
var css_248z$a = ".aokwZU8jbWU- {\n position: fixed;\n top: 0;\n top: var(--actions-menu-y, 0);\n left: 0;\n left: var(--actions-menu-x, 0);\n z-index: 6;\n z-index: var(--elevation-menu);\n min-width: 150px;\n box-shadow: 0px calc(16px / 16) calc(16px / 4) 0px\n rgba(0, 0, 0, 0.1),\n 0px calc(16px / 4) 12px 0px rgba(0, 0, 0, 0.05);\n box-shadow: var(--shadow-base);\n padding: calc(16px / 4);\n padding: var(--space-smaller);\n border: calc(16px / 16) solid rgb(225, 225, 225);\n border: var(--border-base) solid var(--color-border);\n border-radius: calc(16px / 2);\n border-radius: var(--radius-larger);\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n}\n\n.XtVRP97TVSE- {\n position: fixed;\n top: 0;\n left: 0;\n z-index: calc(6 - 1);\n z-index: calc(var(--elevation-menu) - 1);\n width: 100%;\n height: 100%;\n padding: 0;\n border: none;\n background-color: transparent;\n}\n";
|
|
115
|
-
var styles$a = {"menu":"aokwZU8jbWU-","overlay":"XtVRP97TVSE-"};
|
|
116
|
-
styleInject_es.styleInject(css_248z$a);
|
|
117
|
-
|
|
118
118
|
const EMPTY_RESULTS_MESSAGE = "List is looking empty";
|
|
119
119
|
const EMPTY_FILTER_RESULTS_MESSAGE = "No results for selected filters";
|
|
120
120
|
const EMPTY_STATE_ACTION_BUTTON_ONLY_ERROR = "DataListEmptyState action prop must be a Button component";
|
|
@@ -136,56 +136,74 @@ const DATA_LOAD_MORE_TEST_ID = "ATL-DataList-LoadMore-trigger";
|
|
|
136
136
|
const TRANSITION_DURATION_IN_SECONDS = design.tokens["timing-base"] / 1000;
|
|
137
137
|
const TRANSITION_DELAY_IN_SECONDS = design.tokens["timing-quick"] / 1000;
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
function useResponsiveSizing() {
|
|
140
|
+
const xs = useMediaQuery(`(width > ${BREAKPOINT_SIZES.xs}px)`);
|
|
141
|
+
const sm = useMediaQuery(`(width >= ${BREAKPOINT_SIZES.sm}px)`);
|
|
142
|
+
const md = useMediaQuery(`(width >= ${BREAKPOINT_SIZES.md}px)`);
|
|
143
|
+
const lg = useMediaQuery(`(width >= ${BREAKPOINT_SIZES.lg}px)`);
|
|
144
|
+
const xl = useMediaQuery(`(width >= ${BREAKPOINT_SIZES.xl}px)`);
|
|
145
|
+
return { xs, sm, md, lg, xl };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function useActiveLayout() {
|
|
149
|
+
const { layoutBreakpoints, layouts } = useDataListContext();
|
|
150
|
+
const breakpoints = useResponsiveSizing();
|
|
151
|
+
const reversedLayoutBreakpoints = [...layoutBreakpoints].reverse();
|
|
152
|
+
const activeBreakpoint = reversedLayoutBreakpoints.find(key => breakpoints[key]) ||
|
|
153
|
+
layoutBreakpoints[0];
|
|
154
|
+
const layout = layouts[activeBreakpoint];
|
|
155
|
+
return { layout, activeBreakpoint };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
var css_248z$c = "._8cMzUF8XEwY- {\n position: relative;\n}\n\n._8cMzUF8XEwY-::after {\n content: \"\";\n display: block;\n position: absolute;\n right: 0;\n bottom: 0;\n left: 0;\n height: 100px;\n background-image: linear-gradient(\n to top,\n rgba(255, 255, 255, 1) 0%,\n rgba(255, 255, 255, 0) 100%\n );\n background-image: linear-gradient(\n to top,\n var(--color-surface) 0%,\n rgba(var(--color-white--rgb), 0) 100%\n );\n}\n\n.Rh--6fVpkm4- {\n padding: calc(16px / 2);\n padding: var(--space-small);\n}\n\n.NFaWWvmxtkw- {\n width: 100%;\n min-width: calc(16px * 3);\n min-width: var(--space-largest);\n}\n";
|
|
159
|
+
var styles$c = {"wrapper":"_8cMzUF8XEwY-","loadingItem":"Rh--6fVpkm4-","glimmer":"NFaWWvmxtkw-"};
|
|
160
|
+
styleInject_es.styleInject(css_248z$c);
|
|
161
|
+
|
|
162
|
+
const LOADING_STATE_LIMIT_ITEMS = 10;
|
|
163
|
+
const DATALIST_LOADINGSTATE_ROW_TEST_ID = "ATL-DataList-LoadingState-Row";
|
|
164
|
+
function DataListLoadingState() {
|
|
165
|
+
const { headers } = useDataListContext();
|
|
166
|
+
const { layout, activeBreakpoint } = useActiveLayout();
|
|
167
|
+
if (!layout)
|
|
168
|
+
return null;
|
|
169
|
+
const glimmerSize = activeBreakpoint === "xs" ? "small" : "base";
|
|
170
|
+
const glimmersFromHeader = Object.keys(headers).reduce((data, key) => (Object.assign(Object.assign({}, data), { [key]: (React__default["default"].createElement("div", { className: styles$c.glimmer },
|
|
171
|
+
React__default["default"].createElement(Glimmer.Glimmer, { size: glimmerSize }))) })), {});
|
|
172
|
+
const loadingData = new Array(LOADING_STATE_LIMIT_ITEMS).fill(glimmersFromHeader);
|
|
173
|
+
return (React__default["default"].createElement("div", { className: styles$c.wrapper }, loadingData.map((child, i) => (React__default["default"].createElement("div", { key: i, className: styles$c.loadingItem, "data-testid": DATALIST_LOADINGSTATE_ROW_TEST_ID }, layout(child))))));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const defaultValues = {
|
|
177
|
+
isInLayoutProvider: false,
|
|
178
|
+
hasInLayoutActions: false,
|
|
179
|
+
setHasInLayoutActions: noop__default["default"],
|
|
142
180
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const focusTrapRef = useFocusTrap.useFocusTrap(visible);
|
|
147
|
-
useOnKeyDown.useOnKeyDown(onRequestClose, "Escape");
|
|
148
|
-
return ReactDOM.createPortal(React__default["default"].createElement(framerMotion.AnimatePresence, null, visible && (React__default["default"].createElement("div", { ref: focusTrapRef },
|
|
149
|
-
React__default["default"].createElement(framerMotion.motion.div, { role: "menu", ref: setRef, variants: variants$1, initial: "hidden", animate: "visible", exit: "hidden", transition: { duration: TRANSITION_DELAY_IN_SECONDS }, className: styles$a.menu, style: getPositionCssVars(), onClick: onRequestClose }, children),
|
|
150
|
-
React__default["default"].createElement("button", { className: styles$a.overlay, onClick: onRequestClose, "aria-label": "Close menu" })))), document.body);
|
|
151
|
-
function getPositionCssVars() {
|
|
152
|
-
const { posX, posY } = getPosition();
|
|
153
|
-
return {
|
|
154
|
-
"--actions-menu-x": `${posX}px`,
|
|
155
|
-
"--actions-menu-y": `${posY}px`,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
function getPosition() {
|
|
159
|
-
const rect = ref === null || ref === void 0 ? void 0 : ref.getBoundingClientRect();
|
|
160
|
-
const { width = 0, height = 0 } = rect || {};
|
|
161
|
-
const { x, y } = position;
|
|
162
|
-
const xIsOffScreen = x + width > window.innerWidth;
|
|
163
|
-
const yIsOffScreen = y + height > window.innerHeight;
|
|
164
|
-
const xOffSet = x + width - window.innerWidth + foundation.tokens["space-base"];
|
|
165
|
-
const yOffSet = y + height - window.innerHeight;
|
|
166
|
-
const newPosX = Math.floor(xIsOffScreen ? x - xOffSet : x);
|
|
167
|
-
const newPosY = Math.floor(yIsOffScreen ? y - yOffSet : y);
|
|
168
|
-
return { posX: newPosX, posY: newPosY };
|
|
169
|
-
}
|
|
181
|
+
const DataListLayoutContext = React.createContext(defaultValues);
|
|
182
|
+
function useDataListLayoutContext() {
|
|
183
|
+
return React.useContext(DataListLayoutContext);
|
|
170
184
|
}
|
|
171
185
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
var css_248z$b = ".jHcHGQ-HDbk- {\n display: -ms-flexbox;\n display: flex;\n position: absolute;\n top: calc((16px / 2) * -1);\n top: calc(calc(16px / 2) * -1);\n top: calc(var(--space-small) * -1);\n right: 0;\n z-index: 6;\n z-index: var(--elevation-menu);\n box-shadow: 0px calc(16px / 16) calc(16px / 4) 0px\n rgba(0, 0, 0, 0.1),\n 0px calc(16px / 4) 12px 0px rgba(0, 0, 0, 0.05);\n box-shadow: var(--shadow-base);\n padding: calc(16px / 4);\n padding: var(--space-smaller);\n border: calc(16px / 16) solid rgb(225, 225, 225);\n border: var(--border-base) solid var(--color-border);\n border-radius: calc(16px / 2);\n border-radius: var(--radius-larger);\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n gap: calc(16px / 4);\n gap: var(--space-smaller);\n}\n";
|
|
187
|
+
var styles$b = {"menu":"jHcHGQ-HDbk-"};
|
|
188
|
+
styleInject_es.styleInject(css_248z$b);
|
|
189
|
+
|
|
190
|
+
const CONTAINER_TEST_ID = "ATL-DataListFilters-Container";
|
|
191
|
+
|
|
192
|
+
var css_248z$a = ".jbBRoxlZlNI- {\n -ms-flex-item-align: center;\n align-self: center;\n position: relative;\n min-width: 0;\n}\n\n.MnN8qbS4hw4- {\n display: grid;\n overflow-x: auto;\n grid-auto-flow: column;\n grid-auto-columns: -webkit-max-content;\n grid-auto-columns: max-content;\n -ms-flex-align: center;\n align-items: center;\n}\n\n.MnN8qbS4hw4- > :nth-child(n + 3):not(:last-child) {\n margin-left: calc(16px / 2);\n margin-left: var(--space-small);\n}\n\n.b-5P7Z8eGO8- {\n visibility: hidden;\n}\n\n.xzaCS4slLpI-::before,\n.Jf227kC8Nu0-::after {\n content: \"\";\n position: absolute;\n top: 0;\n width: calc(16px * 1.5);\n width: var(--space-large);\n height: 100%;\n background-image: linear-gradient(\n to right,\n rgba(255, 255, 255, 1) 0%,\n rgba(255, 255, 255, 0) 100%\n );\n background-image: linear-gradient(\n var(--data-list-overflow-shadow-angle, to right),\n var(--color-surface) 0%,\n rgba(var(--color-white--rgb), 0) 100%\n );\n pointer-events: none;\n}\n\n.xzaCS4slLpI-::before {\n left: 0;\n}\n\n.Jf227kC8Nu0-::after {\n --data-list-overflow-shadow-angle: to left;\n right: 0;\n}\n";
|
|
193
|
+
var styles$a = {"fadeContainer":"jbBRoxlZlNI-","overflowGrid":"MnN8qbS4hw4-","overflowTrigger":"b-5P7Z8eGO8-","overflowLeft":"xzaCS4slLpI-","overflowRight":"Jf227kC8Nu0-"};
|
|
194
|
+
styleInject_es.styleInject(css_248z$a);
|
|
195
|
+
|
|
196
|
+
function DataListOverflowFade({ children }) {
|
|
197
|
+
const [leftRef, isLeftVisible] = useInView.useInView();
|
|
198
|
+
const [rightRef, isRightVisible] = useInView.useInView();
|
|
199
|
+
return (React__default["default"].createElement("div", { "data-testid": CONTAINER_TEST_ID, className: classnames__default["default"](styles$a.fadeContainer, {
|
|
200
|
+
[styles$a.overflowLeft]: !isLeftVisible,
|
|
201
|
+
[styles$a.overflowRight]: !isRightVisible,
|
|
202
|
+
}) },
|
|
203
|
+
React__default["default"].createElement("div", { className: styles$a.overflowGrid },
|
|
204
|
+
React__default["default"].createElement("span", { ref: leftRef, className: styles$a.overflowTrigger }),
|
|
205
|
+
children,
|
|
206
|
+
React__default["default"].createElement("span", { ref: rightRef, className: styles$a.overflowTrigger }))));
|
|
189
207
|
}
|
|
190
208
|
|
|
191
209
|
var css_248z$9 = ".WRV-UmQmPzo- {\n display: -ms-flexbox;\n display: flex;\n position: relative;\n z-index: 0;\n z-index: var(--elevation-default);\n overflow: hidden;\n gap: calc(16px / 2);\n gap: var(--space-small);\n}\n\n.liQeWCMenD0- {\n --overflow-bg: var(--data-list-item-active-color, var(--color-surface));\n\n display: -ms-flexbox;\n\n display: flex;\n position: absolute;\n top: 0;\n right: 0;\n height: 100%;\n padding-left: calc(16px * 1);\n padding-left: var(--space-base);\n background-image: linear-gradient(\n 90deg,\n transparent 0,\n rgba(255, 255, 255, 1) calc(16px * 1),\n rgba(255, 255, 255, 1) 100%\n );\n background-image: linear-gradient(\n 90deg,\n transparent 0,\n var(--overflow-bg) var(--space-base),\n var(--overflow-bg) 100%\n );\n -ms-flex-align: center;\n align-items: center;\n transition: all 200ms;\n transition: all var(--timing-base);\n}\n";
|
|
@@ -340,7 +358,7 @@ function generateHeaderElements(headers) {
|
|
|
340
358
|
const headerElements = Object.keys(headers).reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: React__default["default"].createElement(DataListHeaderTile, { headers: headers, headerKey: key }) })), {});
|
|
341
359
|
return isEmpty__default["default"](headerElements) ? undefined : headerElements;
|
|
342
360
|
}
|
|
343
|
-
function
|
|
361
|
+
function sortBreakpoints(sizeProp) {
|
|
344
362
|
return sizeProp.sort((a, b) => BREAKPOINTS.indexOf(a) - BREAKPOINTS.indexOf(b));
|
|
345
363
|
}
|
|
346
364
|
function getExposedActions(childrenArray, childCount = 2) {
|
|
@@ -358,6 +376,92 @@ function getExposedActions(childrenArray, childCount = 2) {
|
|
|
358
376
|
}, []);
|
|
359
377
|
}
|
|
360
378
|
|
|
379
|
+
const DataListLayoutActionsContext = React.createContext({ activeItem: undefined });
|
|
380
|
+
function useDataListLayoutActionsContext() {
|
|
381
|
+
return React.useContext(DataListLayoutActionsContext);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
var css_248z$6 = ".aokwZU8jbWU- {\n position: fixed;\n top: 0;\n top: var(--actions-menu-y, 0);\n left: 0;\n left: var(--actions-menu-x, 0);\n z-index: 6;\n z-index: var(--elevation-menu);\n min-width: 150px;\n box-shadow: 0px calc(16px / 16) calc(16px / 4) 0px\n rgba(0, 0, 0, 0.1),\n 0px calc(16px / 4) 12px 0px rgba(0, 0, 0, 0.05);\n box-shadow: var(--shadow-base);\n padding: calc(16px / 4);\n padding: var(--space-smaller);\n border: calc(16px / 16) solid rgb(225, 225, 225);\n border: var(--border-base) solid var(--color-border);\n border-radius: calc(16px / 2);\n border-radius: var(--radius-larger);\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n}\n\n.XtVRP97TVSE- {\n position: fixed;\n top: 0;\n left: 0;\n z-index: calc(6 - 1);\n z-index: calc(var(--elevation-menu) - 1);\n width: 100%;\n height: 100%;\n padding: 0;\n border: none;\n background-color: transparent;\n}\n";
|
|
385
|
+
var styles$6 = {"menu":"aokwZU8jbWU-","overlay":"XtVRP97TVSE-"};
|
|
386
|
+
styleInject_es.styleInject(css_248z$6);
|
|
387
|
+
|
|
388
|
+
const variants$1 = {
|
|
389
|
+
hidden: { opacity: 0, y: -10 },
|
|
390
|
+
visible: { opacity: 1, y: 0 },
|
|
391
|
+
};
|
|
392
|
+
function DataListActionsMenu({ visible = false, position, onRequestClose, children, }) {
|
|
393
|
+
const [ref, setRef] = React.useState();
|
|
394
|
+
useRefocusOnActivator.useRefocusOnActivator(visible);
|
|
395
|
+
const focusTrapRef = useFocusTrap.useFocusTrap(visible);
|
|
396
|
+
useOnKeyDown.useOnKeyDown(onRequestClose, "Escape");
|
|
397
|
+
return ReactDOM.createPortal(React__default["default"].createElement(framerMotion.AnimatePresence, null, visible && (React__default["default"].createElement("div", { ref: focusTrapRef },
|
|
398
|
+
React__default["default"].createElement(framerMotion.motion.div, { role: "menu", ref: setRef, variants: variants$1, initial: "hidden", animate: "visible", exit: "hidden", transition: { duration: TRANSITION_DELAY_IN_SECONDS }, className: styles$6.menu, style: getPositionCssVars(), onClick: onRequestClose }, children),
|
|
399
|
+
React__default["default"].createElement("button", { className: styles$6.overlay, onClick: onRequestClose, "aria-label": "Close menu" })))), document.body);
|
|
400
|
+
function getPositionCssVars() {
|
|
401
|
+
const { posX, posY } = getPosition();
|
|
402
|
+
return {
|
|
403
|
+
"--actions-menu-x": `${posX}px`,
|
|
404
|
+
"--actions-menu-y": `${posY}px`,
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
function getPosition() {
|
|
408
|
+
const rect = ref === null || ref === void 0 ? void 0 : ref.getBoundingClientRect();
|
|
409
|
+
const { width = 0, height = 0 } = rect || {};
|
|
410
|
+
const { x, y } = position;
|
|
411
|
+
const xIsOffScreen = x + width > window.innerWidth;
|
|
412
|
+
const yIsOffScreen = y + height > window.innerHeight;
|
|
413
|
+
const xOffSet = x + width - window.innerWidth + foundation.tokens["space-base"];
|
|
414
|
+
const yOffSet = y + height - window.innerHeight;
|
|
415
|
+
const newPosX = Math.floor(xIsOffScreen ? x - xOffSet : x);
|
|
416
|
+
const newPosY = Math.floor(yIsOffScreen ? y - yOffSet : y);
|
|
417
|
+
return { posX: newPosX, posY: newPosY };
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function DataListItemActionsOverflow({ actions, }) {
|
|
422
|
+
const [menuPosition, setMenuPosition] = React.useState({ x: 0, y: 0 });
|
|
423
|
+
const [showMenu, setShowMenu] = React.useState(false);
|
|
424
|
+
if (actions.length === 0)
|
|
425
|
+
return null;
|
|
426
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
427
|
+
React__default["default"].createElement(Tooltip.Tooltip, { message: "More actions" },
|
|
428
|
+
React__default["default"].createElement(Button.Button, { icon: "more", ariaLabel: "More actions", type: "secondary", variation: "subtle", onClick: handleMoreClick })),
|
|
429
|
+
React__default["default"].createElement(DataListActionsMenu, { visible: showMenu, position: menuPosition, onRequestClose: handleClose }, actions)));
|
|
430
|
+
function handleMoreClick(event) {
|
|
431
|
+
setShowMenu(true);
|
|
432
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
433
|
+
const posX = rect.x;
|
|
434
|
+
const posY = rect.y + rect.height;
|
|
435
|
+
setMenuPosition({ x: posX, y: posY });
|
|
436
|
+
}
|
|
437
|
+
function handleClose() {
|
|
438
|
+
setShowMenu(false);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function DataListActions({ children, itemsToExpose = 2, }) {
|
|
443
|
+
const { activeItem } = useDataListLayoutActionsContext();
|
|
444
|
+
const childrenArray = React.Children.toArray(children).filter(React.isValidElement);
|
|
445
|
+
const exposedActions = getExposedActions(childrenArray, itemsToExpose);
|
|
446
|
+
childrenArray.splice(0, exposedActions.length);
|
|
447
|
+
return (React__default["default"].createElement(DataListOverflowFade, null,
|
|
448
|
+
exposedActions.map(({ props }) => {
|
|
449
|
+
if (!props.icon)
|
|
450
|
+
return null;
|
|
451
|
+
return (React__default["default"].createElement(Tooltip.Tooltip, { key: props.label, message: props.label },
|
|
452
|
+
React__default["default"].createElement(Button.Button, { icon: props.icon, ariaLabel: props.label, onClick: () => {
|
|
453
|
+
var _a, _b;
|
|
454
|
+
if (activeItem) {
|
|
455
|
+
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, activeItem);
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
(_b = props.onClick) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
459
|
+
}
|
|
460
|
+
}, type: "secondary", variation: "subtle" })));
|
|
461
|
+
}),
|
|
462
|
+
React__default["default"].createElement(DataListItemActionsOverflow, { actions: childrenArray })));
|
|
463
|
+
}
|
|
464
|
+
|
|
361
465
|
// This component is meant to capture the props of the DataList.ItemActions
|
|
362
466
|
function DataListItemActions(
|
|
363
467
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -368,40 +472,26 @@ const variants = {
|
|
|
368
472
|
hidden: { opacity: 0, y: 10 },
|
|
369
473
|
visible: { opacity: 1, y: 0 },
|
|
370
474
|
};
|
|
371
|
-
function InternalDataListItemActions(
|
|
475
|
+
function InternalDataListItemActions() {
|
|
372
476
|
const { itemActionComponent } = useDataListContext();
|
|
373
477
|
if (!itemActionComponent)
|
|
374
478
|
return null;
|
|
375
479
|
const { children } = itemActionComponent.props;
|
|
376
|
-
const childrenArray = React.Children.toArray(children).filter(React.isValidElement);
|
|
377
|
-
const exposedActions = getExposedActions(childrenArray);
|
|
378
|
-
childrenArray.splice(0, exposedActions.length);
|
|
379
480
|
return (React__default["default"].createElement(framerMotion.motion.div, { variants: variants, initial: "hidden", animate: "visible", exit: "hidden", transition: {
|
|
380
481
|
duration: TRANSITION_DURATION_IN_SECONDS,
|
|
381
482
|
delay: TRANSITION_DELAY_IN_SECONDS,
|
|
382
483
|
}, className: styles$b.menu, onContextMenu: handleContextMenu },
|
|
383
|
-
|
|
384
|
-
if (!props.icon)
|
|
385
|
-
return null;
|
|
386
|
-
return (React__default["default"].createElement(Tooltip.Tooltip, { key: props.label, message: props.label },
|
|
387
|
-
React__default["default"].createElement(Button.Button, { icon: props.icon, ariaLabel: props.label, onClick: () => { var _a; return (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, item); }, type: "secondary", variation: "subtle" })));
|
|
388
|
-
}),
|
|
389
|
-
Boolean(childrenArray.length) && (React__default["default"].createElement(DataListItemActionsOverflow, { actions: childrenArray }))));
|
|
484
|
+
React__default["default"].createElement(DataListActions, null, children)));
|
|
390
485
|
}
|
|
391
486
|
function handleContextMenu(event) {
|
|
392
487
|
event.stopPropagation();
|
|
393
488
|
}
|
|
394
489
|
|
|
395
|
-
const DataListLayoutActionsContext = React.createContext({ activeItem: undefined });
|
|
396
|
-
function useDataListLayoutActionsContext() {
|
|
397
|
-
return React.useContext(DataListLayoutActionsContext);
|
|
398
|
-
}
|
|
399
|
-
|
|
400
490
|
function DataListItemInternal({ children, item, }) {
|
|
401
491
|
const { selected, onSelect } = useDataListContext();
|
|
402
492
|
if (selected !== undefined && onSelect) {
|
|
403
|
-
return (React__default["default"].createElement("div", { className: classnames__default["default"](
|
|
404
|
-
[
|
|
493
|
+
return (React__default["default"].createElement("div", { className: classnames__default["default"](styles$e.selectable, {
|
|
494
|
+
[styles$e.selected]: selected === null || selected === void 0 ? void 0 : selected.length,
|
|
405
495
|
}) },
|
|
406
496
|
children,
|
|
407
497
|
React__default["default"].createElement(Checkbox.Checkbox, { checked: selected === null || selected === void 0 ? void 0 : selected.includes(item.id), onChange: handleChange })));
|
|
@@ -423,14 +513,14 @@ function DataListItemClickableInternal({ onClick, url, to, children, }) {
|
|
|
423
513
|
return React__default["default"].createElement(React__default["default"].Fragment, null, children);
|
|
424
514
|
if (to) {
|
|
425
515
|
const computedTo = typeof to === "string" ? to : to(activeItem);
|
|
426
|
-
return (React__default["default"].createElement(reactRouterDom.Link, { className:
|
|
516
|
+
return (React__default["default"].createElement(reactRouterDom.Link, { className: styles$e.listItemClickable, to: computedTo, onClick: handleClick }, children));
|
|
427
517
|
}
|
|
428
518
|
if (url) {
|
|
429
519
|
const href = typeof url === "string" ? url : url(activeItem);
|
|
430
|
-
return (React__default["default"].createElement("a", { className:
|
|
520
|
+
return (React__default["default"].createElement("a", { className: styles$e.listItemClickable, href: href, onClick: handleClick }, children));
|
|
431
521
|
}
|
|
432
522
|
if (onClick) {
|
|
433
|
-
return (React__default["default"].createElement("button", { className:
|
|
523
|
+
return (React__default["default"].createElement("button", { className: styles$e.listItemClickable, onClick: handleClick }, children));
|
|
434
524
|
}
|
|
435
525
|
return React__default["default"].createElement(React__default["default"].Fragment, null, children);
|
|
436
526
|
function handleClick() {
|
|
@@ -457,13 +547,13 @@ function DataListItem({ item, layout, }) {
|
|
|
457
547
|
const isContextMenuVisible = Boolean(contextPosition);
|
|
458
548
|
const shouldShowContextMenu = showMenu && isContextMenuVisible && Boolean(contextMenuActions);
|
|
459
549
|
return (React__default["default"].createElement(DataListLayoutActionsContext.Provider, { value: { activeItem: item } },
|
|
460
|
-
React__default["default"].createElement("div", { onMouseEnter: handleShowMenu, onMouseLeave: handleHideMenu, onFocus: handleShowMenu, onBlur: handleHideMenu, onContextMenu: handleContextMenu, className: classnames__default["default"](
|
|
461
|
-
[
|
|
550
|
+
React__default["default"].createElement("div", { onMouseEnter: handleShowMenu, onMouseLeave: handleHideMenu, onFocus: handleShowMenu, onBlur: handleHideMenu, onContextMenu: handleContextMenu, className: classnames__default["default"](styles$e.listItem, {
|
|
551
|
+
[styles$e.active]: showMenu && isContextMenuVisible,
|
|
462
552
|
}), key: item.id },
|
|
463
553
|
React__default["default"].createElement(DataListItemInternal, { item: item },
|
|
464
|
-
React__default["default"].createElement(DataListItemClickable, null, layout
|
|
554
|
+
React__default["default"].createElement(DataListItemClickable, null, layout(generatedItem))),
|
|
465
555
|
React__default["default"].createElement(framerMotion.AnimatePresence, null,
|
|
466
|
-
showMenu && !hasInLayoutActions &&
|
|
556
|
+
showMenu && !hasInLayoutActions && React__default["default"].createElement(InternalDataListItemActions, null),
|
|
467
557
|
React__default["default"].createElement(DataListActionsMenu, { key: item.id, visible: shouldShowContextMenu, position: contextPosition || { x: 0, y: 0 }, onRequestClose: () => setContextPosition(undefined) }, contextMenuActions)))));
|
|
468
558
|
function handleShowMenu() {
|
|
469
559
|
setShowMenu(true);
|
|
@@ -482,65 +572,35 @@ function DataListItem({ item, layout, }) {
|
|
|
482
572
|
}
|
|
483
573
|
}
|
|
484
574
|
|
|
485
|
-
function
|
|
486
|
-
const
|
|
487
|
-
const layoutToRender = layouts === null || layouts === void 0 ? void 0 : layouts.find(layout => {
|
|
488
|
-
const layoutSize = layout.props.size || "xs";
|
|
489
|
-
const isVisible = isLayoutVisible({
|
|
490
|
-
layoutSize,
|
|
491
|
-
mediaMatches,
|
|
492
|
-
sizePropsOfLayouts,
|
|
493
|
-
});
|
|
494
|
-
return isVisible;
|
|
495
|
-
});
|
|
496
|
-
return (layoutToRender && renderLayout(layoutToRender)) || React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Determine is layout is visible by checking a media query matches for the
|
|
500
|
-
* visible sizes of the layout and there isn't a larger layout that should be rendered
|
|
501
|
-
*/
|
|
502
|
-
function isLayoutVisible({ layoutSize, mediaMatches, sizePropsOfLayouts, }) {
|
|
503
|
-
const largerBreakpointsToHide = sizePropsOfLayouts === null || sizePropsOfLayouts === void 0 ? void 0 : sizePropsOfLayouts.filter(size => BREAKPOINTS.indexOf(size) > BREAKPOINTS.indexOf(layoutSize));
|
|
504
|
-
const sortedLargerBreakpoints = sortSizeProp(largerBreakpointsToHide || []);
|
|
505
|
-
const visibleBreakpoints = BREAKPOINTS.slice(BREAKPOINTS.indexOf(layoutSize), sortedLargerBreakpoints[0]
|
|
506
|
-
? BREAKPOINTS.indexOf(sortedLargerBreakpoints[0])
|
|
507
|
-
: undefined);
|
|
508
|
-
const isVisibleBreakpoint = visibleBreakpoints.some(breakpoint => {
|
|
509
|
-
return Boolean(mediaMatches === null || mediaMatches === void 0 ? void 0 : mediaMatches[breakpoint]);
|
|
510
|
-
});
|
|
511
|
-
const largerLayoutIsNotVisible = largerBreakpointsToHide === null || largerBreakpointsToHide === void 0 ? void 0 : largerBreakpointsToHide.reduce((acc, breakpoint) => {
|
|
512
|
-
return acc && !(mediaMatches === null || mediaMatches === void 0 ? void 0 : mediaMatches[breakpoint]);
|
|
513
|
-
}, true);
|
|
514
|
-
return isVisibleBreakpoint && largerLayoutIsNotVisible;
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
function DataListItems({ layouts, mediaMatches, data, }) {
|
|
575
|
+
function DataListItems({ size = "xs", }) {
|
|
576
|
+
const { data, layouts } = useDataListContext();
|
|
518
577
|
const [hasInLayoutActions, setHasInLayoutActions] = React.useState(false);
|
|
578
|
+
const layout = layouts[size];
|
|
579
|
+
if (!layout)
|
|
580
|
+
return null;
|
|
519
581
|
return (React__default["default"].createElement(DataListLayoutContext.Provider, { value: {
|
|
520
582
|
isInLayoutProvider: true,
|
|
521
583
|
hasInLayoutActions,
|
|
522
584
|
setHasInLayoutActions,
|
|
523
|
-
} },
|
|
524
|
-
React__default["default"].createElement(DataListLayoutInternal, { layouts: layouts, mediaMatches: mediaMatches, renderLayout: layout => (React__default["default"].createElement(React__default["default"].Fragment, null, data.map((child, i) => (React__default["default"].createElement(DataListItem, { key: data[i].id, index: i, item: child, layout: layout }))))) })));
|
|
585
|
+
} }, data.map((child, i) => (React__default["default"].createElement(DataListItem, { key: data[i].id, index: i, item: child, layout: layout })))));
|
|
525
586
|
}
|
|
526
587
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
React__default["default"].createElement(
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
React__default["default"].createElement("span", { ref: rightRef, className: styles$6.overflowTrigger }))));
|
|
588
|
+
function DataListLayout({ children, size = "xs", }) {
|
|
589
|
+
const { layoutBreakpoints, registerLayout, registerLayoutBreakpoints, loadingState, } = useDataListContext();
|
|
590
|
+
const breakpoints = useResponsiveSizing();
|
|
591
|
+
React.useEffect(() => {
|
|
592
|
+
registerLayoutBreakpoints(size);
|
|
593
|
+
}, [size]);
|
|
594
|
+
React.useEffect(() => {
|
|
595
|
+
registerLayout(size, children);
|
|
596
|
+
}, [size, children]);
|
|
597
|
+
const sizeIndex = layoutBreakpoints.indexOf(size);
|
|
598
|
+
const nextAvailableSize = layoutBreakpoints[sizeIndex + 1];
|
|
599
|
+
const shouldRenderList = breakpoints[size] && !breakpoints[nextAvailableSize];
|
|
600
|
+
if (loadingState !== "initial" && shouldRenderList) {
|
|
601
|
+
return React__default["default"].createElement(DataListItems, { size: size });
|
|
602
|
+
}
|
|
603
|
+
return null;
|
|
544
604
|
}
|
|
545
605
|
|
|
546
606
|
// This component is meant to capture the props of the DataList.BulkActions
|
|
@@ -554,40 +614,10 @@ function InternalDataListBulkActions() {
|
|
|
554
614
|
if (!bulkActionsComponent)
|
|
555
615
|
return null;
|
|
556
616
|
const { children } = bulkActionsComponent.props;
|
|
557
|
-
const
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
return (React__default["default"].createElement(
|
|
561
|
-
exposedActions.map(({ props }) => {
|
|
562
|
-
if (!props.icon)
|
|
563
|
-
return null;
|
|
564
|
-
return (React__default["default"].createElement(Tooltip.Tooltip, { key: props.label, message: props.label },
|
|
565
|
-
React__default["default"].createElement(Button.Button, { icon: props.icon, ariaLabel: props.label, onClick: () => { var _a; return (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props); }, type: "secondary", variation: "subtle" })));
|
|
566
|
-
}),
|
|
567
|
-
React__default["default"].createElement(DataListItemActionsOverflow, { actions: childrenArray })));
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
function useMediaQuery(CSSMediaQuery) {
|
|
571
|
-
const [matches, setMatches] = React.useState(window.matchMedia(CSSMediaQuery).matches);
|
|
572
|
-
React.useEffect(() => {
|
|
573
|
-
const media = window.matchMedia(CSSMediaQuery);
|
|
574
|
-
if (media.matches !== matches) {
|
|
575
|
-
setMatches(media.matches);
|
|
576
|
-
}
|
|
577
|
-
const listener = () => setMatches(media.matches);
|
|
578
|
-
media.addEventListener("change", listener);
|
|
579
|
-
return () => media.removeEventListener("change", listener);
|
|
580
|
-
}, [CSSMediaQuery]);
|
|
581
|
-
return matches;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
function useResponsiveSizing() {
|
|
585
|
-
const xs = useMediaQuery(`(width > ${BREAKPOINT_SIZES.xs}px)`);
|
|
586
|
-
const sm = useMediaQuery(`(width >= ${BREAKPOINT_SIZES.sm}px)`);
|
|
587
|
-
const md = useMediaQuery(`(width >= ${BREAKPOINT_SIZES.md}px)`);
|
|
588
|
-
const lg = useMediaQuery(`(width >= ${BREAKPOINT_SIZES.lg}px)`);
|
|
589
|
-
const xl = useMediaQuery(`(width >= ${BREAKPOINT_SIZES.xl}px)`);
|
|
590
|
-
return { xs, sm, md, lg, xl };
|
|
617
|
+
const { sm } = useResponsiveSizing();
|
|
618
|
+
// Collapse all actions under "More actions" when breakpoint is smaller than sm
|
|
619
|
+
const itemsToExpose = sm ? 3 : 0;
|
|
620
|
+
return (React__default["default"].createElement(DataListActions, { itemsToExpose: itemsToExpose }, children));
|
|
591
621
|
}
|
|
592
622
|
|
|
593
623
|
function DataListHeaderCheckbox({ children }) {
|
|
@@ -604,12 +634,12 @@ function DataListHeaderCheckbox({ children }) {
|
|
|
604
634
|
}) },
|
|
605
635
|
React__default["default"].createElement(Checkbox.Checkbox, { checked: isAllSelected(), indeterminate: selected.length > 0 && !isAllSelected(), onChange: onSelectAll },
|
|
606
636
|
React__default["default"].createElement("div", { className: styles$e.srOnly }, selectedLabel))),
|
|
607
|
-
React__default["default"].createElement(AnimatedSwitcher.AnimatedSwitcher, { switched: Boolean(selected.length), initialChild: children, switchTo: React__default["default"].createElement("div", { className: styles$e.
|
|
608
|
-
React__default["default"].createElement(
|
|
609
|
-
React__default["default"].createElement(
|
|
637
|
+
React__default["default"].createElement(AnimatedSwitcher.AnimatedSwitcher, { switched: Boolean(selected.length), initialChild: children, switchTo: React__default["default"].createElement("div", { className: styles$e.batchSelectContainer },
|
|
638
|
+
React__default["default"].createElement("div", { className: styles$e.headerBatchSelect },
|
|
639
|
+
React__default["default"].createElement(Text.Text, null,
|
|
610
640
|
selected.length,
|
|
611
|
-
" selected")
|
|
612
|
-
|
|
641
|
+
" selected"),
|
|
642
|
+
React__default["default"].createElement(Button.Button, { label: deselectText, onClick: () => onSelect === null || onSelect === void 0 ? void 0 : onSelect([]), type: "tertiary" })),
|
|
613
643
|
React__default["default"].createElement(InternalDataListBulkActions, null)) })));
|
|
614
644
|
function isAllSelected() {
|
|
615
645
|
// If there's a totalCount, we can use that to accurately determine if the
|
|
@@ -625,57 +655,26 @@ function DataListHeaderCheckbox({ children }) {
|
|
|
625
655
|
}
|
|
626
656
|
}
|
|
627
657
|
|
|
628
|
-
function
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
const
|
|
633
|
-
const
|
|
634
|
-
const showHeader = sizeKeys.reduce((previous, breakpoint) => {
|
|
635
|
-
const isHeaderVisible = headerVisibility[breakpoint] || false;
|
|
636
|
-
const isBreakpointTriggered = sizes[breakpoint];
|
|
637
|
-
return previous || (isBreakpointTriggered && isHeaderVisible);
|
|
638
|
-
}, false);
|
|
639
|
-
return showHeader;
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
function DataListHeader({ layouts, mediaMatches, headerData, }) {
|
|
643
|
-
const showHeader = useShowHeader();
|
|
644
|
-
const { selected } = useDataListContext();
|
|
658
|
+
function DataListHeader() {
|
|
659
|
+
const breakpoints = useResponsiveSizing();
|
|
660
|
+
const { headerVisibility = { xs: true, sm: true, md: true, lg: true, xl: true }, headers, selected, layoutBreakpoints, } = useDataListContext();
|
|
661
|
+
const size = getVisibleSize();
|
|
662
|
+
const { layout } = useActiveLayout();
|
|
663
|
+
const visible = headerVisibility[size];
|
|
645
664
|
const noItemsSelected = (selected === null || selected === void 0 ? void 0 : selected.length) === 0;
|
|
646
|
-
if ((!
|
|
665
|
+
if ((!visible && noItemsSelected) || !layout)
|
|
647
666
|
return null;
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
}, {}));
|
|
660
|
-
return (React__default["default"].createElement(DataListLayoutInternal, { layouts: layouts, mediaMatches: mediaMatches, renderLayout: layout => {
|
|
661
|
-
if (layout.props.size === "xs") {
|
|
662
|
-
return React__default["default"].createElement(LoadingStateXSBreakpoint, null);
|
|
663
|
-
}
|
|
664
|
-
return (React__default["default"].createElement(React__default["default"].Fragment, null, loadingElements.map((child, i) => (React__default["default"].createElement("div", { className: styles$c.loadingItem, key: i, "data-testid": DATALIST_LOADINGSTATE_ROW_TEST_ID }, layout.props.children(child))))));
|
|
665
|
-
} }));
|
|
666
|
-
}
|
|
667
|
-
function LoadingStateXSBreakpoint() {
|
|
668
|
-
const loadingData = new Array(LOADING_STATE_LIMIT_ITEMS).fill(0);
|
|
669
|
-
return (React__default["default"].createElement(React__default["default"].Fragment, null, loadingData.map((_, i) => {
|
|
670
|
-
return (React__default["default"].createElement("div", { className: styles$c.mobileLoadingState, key: i },
|
|
671
|
-
React__default["default"].createElement(Glimmer.Glimmer.Text, null)));
|
|
672
|
-
})));
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
function DataListLayout(
|
|
676
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
677
|
-
_) {
|
|
678
|
-
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
667
|
+
const headerData = generateHeaderElements(headers);
|
|
668
|
+
if (!headerData)
|
|
669
|
+
return null;
|
|
670
|
+
return (React__default["default"].createElement("div", { className: styles$e.headerTitles },
|
|
671
|
+
React__default["default"].createElement(DataListHeaderCheckbox, null, layout(headerData))));
|
|
672
|
+
function getVisibleSize() {
|
|
673
|
+
const visibilityKeys = Object.keys(headerVisibility);
|
|
674
|
+
const headerBreakpoints = sortBreakpoints(visibilityKeys).reverse();
|
|
675
|
+
const visibleHeaderSize = headerBreakpoints.find(key => breakpoints[key]);
|
|
676
|
+
return visibleHeaderSize || layoutBreakpoints[0];
|
|
677
|
+
}
|
|
679
678
|
}
|
|
680
679
|
|
|
681
680
|
function DataListSort() {
|
|
@@ -731,6 +730,20 @@ function DataListSort() {
|
|
|
731
730
|
}
|
|
732
731
|
}
|
|
733
732
|
|
|
733
|
+
function useShowHeader() {
|
|
734
|
+
const { headerVisibility } = useDataListContext();
|
|
735
|
+
if (headerVisibility === undefined)
|
|
736
|
+
return true;
|
|
737
|
+
const sizes = useResponsiveSizing();
|
|
738
|
+
const sizeKeys = Object.keys(sizes);
|
|
739
|
+
const showHeader = sizeKeys.reduce((previous, breakpoint) => {
|
|
740
|
+
const isHeaderVisible = headerVisibility[breakpoint] || false;
|
|
741
|
+
const isBreakpointTriggered = sizes[breakpoint];
|
|
742
|
+
return previous || (isBreakpointTriggered && isHeaderVisible);
|
|
743
|
+
}, false);
|
|
744
|
+
return showHeader;
|
|
745
|
+
}
|
|
746
|
+
|
|
734
747
|
// This component is meant to capture the props of the DataList.Filters
|
|
735
748
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
736
749
|
function DataListFilters(_) {
|
|
@@ -914,7 +927,7 @@ var styles = {"hidden":"_0m75bgCVBhk-"};
|
|
|
914
927
|
styleInject_es.styleInject(css_248z);
|
|
915
928
|
|
|
916
929
|
function DataListLayoutActions() {
|
|
917
|
-
const { itemActionComponent } = useDataListContext();
|
|
930
|
+
const { itemActionComponent, loadingState } = useDataListContext();
|
|
918
931
|
const { setHasInLayoutActions } = useDataListLayoutContext();
|
|
919
932
|
const { children: actionsChildren } = (itemActionComponent === null || itemActionComponent === void 0 ? void 0 : itemActionComponent.props) || {};
|
|
920
933
|
const actions = React.Children.toArray(actionsChildren);
|
|
@@ -925,6 +938,9 @@ function DataListLayoutActions() {
|
|
|
925
938
|
setHasInLayoutActions(false);
|
|
926
939
|
};
|
|
927
940
|
}, []);
|
|
941
|
+
if (loadingState === "initial") {
|
|
942
|
+
return React__default["default"].createElement(Glimmer.Glimmer, { shape: "square", size: "large" });
|
|
943
|
+
}
|
|
928
944
|
if (!hasActions)
|
|
929
945
|
return null;
|
|
930
946
|
return (React__default["default"].createElement(DataListLayoutActionsWrapper, null,
|
|
@@ -937,34 +953,10 @@ function DataListLayoutActionsWrapper({ children }) {
|
|
|
937
953
|
return React__default["default"].createElement("div", { className: styles.hidden }, children);
|
|
938
954
|
}
|
|
939
955
|
|
|
940
|
-
function useLayoutMediaQueries() {
|
|
941
|
-
const mediaQueries = BREAKPOINTS.reduce((previous, breakpoint) => (Object.assign(Object.assign({}, previous), { [breakpoint]: window.matchMedia(breakpointToMediaQuery(breakpoint)) })), {});
|
|
942
|
-
const initialMatches = BREAKPOINTS.reduce((previous, breakpoint) => (Object.assign(Object.assign({}, previous), { [breakpoint]: mediaQueries[breakpoint].matches })), {});
|
|
943
|
-
const [matches, setMatches] = React.useState(initialMatches);
|
|
944
|
-
const handlers = BREAKPOINTS.reduce((previous, breakpoint) => {
|
|
945
|
-
const handler = (e) => setMatches(previousMatches => (Object.assign(Object.assign({}, previousMatches), { [breakpoint]: e.matches })));
|
|
946
|
-
return Object.assign(Object.assign({}, previous), { [breakpoint]: handler });
|
|
947
|
-
}, {});
|
|
948
|
-
// Set up mediaQuery event handlers
|
|
949
|
-
React.useEffect(() => {
|
|
950
|
-
BREAKPOINTS.forEach(breakpoint => {
|
|
951
|
-
mediaQueries[breakpoint].addEventListener("change", handlers[breakpoint]);
|
|
952
|
-
});
|
|
953
|
-
return () => {
|
|
954
|
-
BREAKPOINTS.forEach(breakpoint => {
|
|
955
|
-
mediaQueries[breakpoint].removeEventListener("change", handlers[breakpoint]);
|
|
956
|
-
});
|
|
957
|
-
};
|
|
958
|
-
}, [mediaQueries]);
|
|
959
|
-
return matches;
|
|
960
|
-
}
|
|
961
|
-
function breakpointToMediaQuery(breakpoint) {
|
|
962
|
-
return `(min-width: ${BREAKPOINT_SIZES[breakpoint]}px)`;
|
|
963
|
-
}
|
|
964
|
-
|
|
965
956
|
function DataList(_a) {
|
|
966
|
-
var
|
|
967
|
-
|
|
957
|
+
var { selected = [], sorting } = _a, props = tslib_es6.__rest(_a, ["selected", "sorting"]);
|
|
958
|
+
const [layoutBreakpoints, setLayoutBreakpoints] = React.useState([]);
|
|
959
|
+
const [layouts, setLayouts] = React.useState({});
|
|
968
960
|
const searchComponent = getCompoundComponent(props.children, DataListSearch);
|
|
969
961
|
const filterComponent = getCompoundComponent(props.children, DataListFilters);
|
|
970
962
|
const layoutComponents = getCompoundComponents(props.children, DataListLayout);
|
|
@@ -976,16 +968,24 @@ function DataList(_a) {
|
|
|
976
968
|
layoutComponents,
|
|
977
969
|
emptyStateComponents,
|
|
978
970
|
itemActionComponent,
|
|
979
|
-
bulkActionsComponent
|
|
971
|
+
bulkActionsComponent,
|
|
972
|
+
layoutBreakpoints,
|
|
973
|
+
registerLayoutBreakpoints,
|
|
974
|
+
layouts,
|
|
975
|
+
registerLayout }, props), { selected,
|
|
980
976
|
// T !== DataListObject
|
|
981
977
|
sorting: sorting }) },
|
|
982
978
|
React__default["default"].createElement(InternalDataList, null)));
|
|
979
|
+
function registerLayoutBreakpoints(size) {
|
|
980
|
+
setLayoutBreakpoints(prev => sortBreakpoints([...prev, size]));
|
|
981
|
+
}
|
|
982
|
+
function registerLayout(size, children) {
|
|
983
|
+
setLayouts(prev => (Object.assign(Object.assign({}, prev), { [size]: children })));
|
|
984
|
+
}
|
|
983
985
|
}
|
|
984
986
|
function InternalDataList() {
|
|
985
|
-
const { data,
|
|
987
|
+
const { data, title, totalCount, loadingState = "none", layoutComponents, } = useDataListContext();
|
|
986
988
|
const backToTopRef = React.useRef(null);
|
|
987
|
-
const headerData = generateHeaderElements(headers);
|
|
988
|
-
const mediaMatches = useLayoutMediaQueries();
|
|
989
989
|
const initialLoading = loadingState === "initial";
|
|
990
990
|
const showEmptyState = !initialLoading && data.length === 0;
|
|
991
991
|
const shouldRenderLoadMoreTrigger = !initialLoading && !showEmptyState;
|
|
@@ -998,10 +998,10 @@ function InternalDataList() {
|
|
|
998
998
|
React__default["default"].createElement("div", { className: styles$e.headerFilters },
|
|
999
999
|
React__default["default"].createElement(InternalDataListFilters, null),
|
|
1000
1000
|
React__default["default"].createElement(InternalDataListSearch, null)),
|
|
1001
|
-
|
|
1002
|
-
initialLoading &&
|
|
1001
|
+
React__default["default"].createElement(DataListHeader, null)),
|
|
1002
|
+
initialLoading && React__default["default"].createElement(DataListLoadingState, null),
|
|
1003
1003
|
showEmptyState && React__default["default"].createElement(InternalDataListEmptyState, null),
|
|
1004
|
-
|
|
1004
|
+
layoutComponents,
|
|
1005
1005
|
loadingState === "filtering" && (React__default["default"].createElement("div", { "data-testid": DATA_LIST_FILTERING_SPINNER_TEST_ID, className: styles$e.filtering },
|
|
1006
1006
|
React__default["default"].createElement("div", { className: styles$e.filteringSpinner },
|
|
1007
1007
|
React__default["default"].createElement(Spinner.Spinner, { size: "small" })))),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.45.
|
|
3
|
+
"version": "4.45.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"> 1%",
|
|
85
85
|
"IE 10"
|
|
86
86
|
],
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "4673b6c87c0e95f84b2bb9b837272c546cc2f5d7"
|
|
88
88
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Breakpoints } from "../../DataList.const";
|
|
3
|
-
import { DataListHeader as DataListHeaderType, DataListItemTypeFromHeader, DataListLayoutProps, DataListObject, DataListProps } from "../../DataList.types";
|
|
4
|
-
interface DataListHeaderProps<T extends DataListObject> {
|
|
5
|
-
readonly layouts: React.ReactElement<DataListLayoutProps<T>>[] | undefined;
|
|
6
|
-
readonly mediaMatches?: Record<Breakpoints, boolean>;
|
|
7
|
-
readonly headerData?: DataListItemTypeFromHeader<T, DataListHeaderType<T>>;
|
|
8
|
-
readonly headerVisibility: NonNullable<DataListProps<T>["headerVisibility"]>;
|
|
9
|
-
}
|
|
10
|
-
export declare function DataListHeader<T extends DataListObject>({ layouts, mediaMatches, headerData, }: DataListHeaderProps<T>): JSX.Element | null;
|
|
11
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Breakpoints } from "@jobber/components/DataList/DataList.const";
|
|
3
|
-
import { DataListLayoutProps, DataListObject } from "@jobber/components/DataList/DataList.types";
|
|
4
|
-
interface DataListItemsProps<T extends DataListObject> {
|
|
5
|
-
readonly layouts: React.ReactElement<DataListLayoutProps<T>>[] | undefined;
|
|
6
|
-
readonly mediaMatches?: Record<Breakpoints, boolean>;
|
|
7
|
-
readonly data: T[];
|
|
8
|
-
}
|
|
9
|
-
export declare function DataListItems<T extends DataListObject>({ layouts, mediaMatches, data, }: DataListItemsProps<T>): JSX.Element;
|
|
10
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Breakpoints } from "../../DataList.const";
|
|
3
|
-
import { DataListLayoutProps, DataListObject } from "../../DataList.types";
|
|
4
|
-
interface DataListLayoutInternalProps<T extends DataListObject> {
|
|
5
|
-
readonly layouts: React.ReactElement<DataListLayoutProps<T>>[] | undefined;
|
|
6
|
-
readonly renderLayout: (layout: React.ReactElement<DataListLayoutProps<T>>) => JSX.Element;
|
|
7
|
-
readonly mediaMatches?: Record<Breakpoints, boolean>;
|
|
8
|
-
}
|
|
9
|
-
export declare function DataListLayoutInternal<T extends DataListObject>({ layouts, renderLayout, mediaMatches, }: DataListLayoutInternalProps<T>): JSX.Element;
|
|
10
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useLayoutMediaQueries(): Record<"xs" | "sm" | "md" | "lg" | "xl", boolean>;
|
|
File without changes
|