@jobber/components 4.77.2-fixdatali.1 → 4.77.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.
|
@@ -31,13 +31,13 @@ export interface DataListObject {
|
|
|
31
31
|
export type DataListHeader<T extends DataListObject> = {
|
|
32
32
|
readonly [K in keyof T]?: string;
|
|
33
33
|
};
|
|
34
|
-
export interface DataListSorting extends SortableOptions {
|
|
34
|
+
export interface DataListSorting extends Partial<SortableOptions> {
|
|
35
35
|
readonly key: string;
|
|
36
36
|
}
|
|
37
37
|
export interface SortableOptions {
|
|
38
|
-
readonly id
|
|
39
|
-
readonly label
|
|
40
|
-
readonly order
|
|
38
|
+
readonly id: string;
|
|
39
|
+
readonly label: string;
|
|
40
|
+
readonly order: "asc" | "desc";
|
|
41
41
|
}
|
|
42
42
|
export interface DataListProps<T extends DataListObject> {
|
|
43
43
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { SortableOptions } from "../../../DataList.types";
|
|
2
|
+
import { DataListSorting, SortableOptions } from "../../../DataList.types";
|
|
3
3
|
interface DataListSortingOptionsProps {
|
|
4
4
|
readonly options: SortableOptions[];
|
|
5
|
-
readonly selectedOption:
|
|
5
|
+
readonly selectedOption: DataListSorting | null;
|
|
6
6
|
readonly onSelectChange: (selectedOption: SortableOptions) => void;
|
|
7
7
|
readonly onClose: () => void;
|
|
8
8
|
readonly optionsListRef: React.RefObject<HTMLUListElement>;
|
package/dist/DataList/index.js
CHANGED
|
@@ -339,28 +339,28 @@ function DataListHeaderTile({ headers, headerKey, visible = false, }) {
|
|
|
339
339
|
const isSortable = Boolean(sortableItem);
|
|
340
340
|
const sortingState = sorting === null || sorting === void 0 ? void 0 : sorting.state;
|
|
341
341
|
const Tag = isSortable ? "button" : "div";
|
|
342
|
-
const selectedOption = (sorting === null || sorting === void 0 ? void 0 : sorting.state) || null;
|
|
343
342
|
return (React__default["default"].createElement(Tag, { className: classnames__default["default"](styles$a.headerLabel, {
|
|
344
343
|
[styles$a.sortable]: isSortable,
|
|
345
344
|
}), onClick: handleOnClick, ref: dataListHeaderTileRef },
|
|
346
345
|
React__default["default"].createElement(Text.Text, { maxLines: "single" }, headers[headerKey]),
|
|
347
|
-
isSortable && (sortableItem === null || sortableItem === void 0 ? void 0 : sortableItem.options) && isDropDownOpen && (React__default["default"].createElement(DataListSortingOptions, { options: sortableItem.options, selectedOption:
|
|
346
|
+
isSortable && (sortableItem === null || sortableItem === void 0 ? void 0 : sortableItem.options) && isDropDownOpen && (React__default["default"].createElement(DataListSortingOptions, { options: sortableItem.options, selectedOption: (sorting === null || sorting === void 0 ? void 0 : sorting.state) || null, onSelectChange: handleSelectChange, onClose: () => setIsDropDownOpen(false), optionsListRef: optionsListRef, dataListHeaderTileRef: dataListHeaderTileRef })),
|
|
348
347
|
(sortingState === null || sortingState === void 0 ? void 0 : sortingState.key) === headerKey ? (React__default["default"].createElement(DataListSortingArrows, { order: sortingState.order })) : (sortingState === null || sortingState === void 0 ? void 0 : sortingState.key) !== headerKey && isSortable ? (React__default["default"].createElement(DataListSortingArrows, { order: "none" })) : null));
|
|
349
|
-
function toggleSorting(
|
|
350
|
-
const isSameKey =
|
|
348
|
+
function toggleSorting(newSortingKey, newId, newLabel, newOrder) {
|
|
349
|
+
const isSameKey = newSortingKey === (sortingState === null || sortingState === void 0 ? void 0 : sortingState.key);
|
|
351
350
|
const isDescending = (sortingState === null || sortingState === void 0 ? void 0 : sortingState.order) === "desc";
|
|
352
|
-
if (isSameKey && isDescending &&
|
|
353
|
-
if (order === "desc")
|
|
354
|
-
return;
|
|
351
|
+
if (isSameKey && isDescending && newOrder === undefined) {
|
|
355
352
|
sorting === null || sorting === void 0 ? void 0 : sorting.onSort(undefined);
|
|
356
353
|
return;
|
|
357
354
|
}
|
|
358
|
-
const sortingOrder =
|
|
355
|
+
const sortingOrder = newOrder || (isSameKey && !isDescending ? "desc" : "asc");
|
|
356
|
+
setSorting(newSortingKey, newId, newLabel, sortingOrder);
|
|
357
|
+
}
|
|
358
|
+
function setSorting(newSortingKey, newId, newLabel, newOrder) {
|
|
359
359
|
sorting === null || sorting === void 0 ? void 0 : sorting.onSort({
|
|
360
|
-
key:
|
|
361
|
-
id,
|
|
362
|
-
label,
|
|
363
|
-
order:
|
|
360
|
+
key: newSortingKey,
|
|
361
|
+
id: newId,
|
|
362
|
+
label: newLabel,
|
|
363
|
+
order: newOrder,
|
|
364
364
|
});
|
|
365
365
|
}
|
|
366
366
|
function handleOnClick() {
|
|
@@ -380,7 +380,7 @@ function DataListHeaderTile({ headers, headerKey, visible = false, }) {
|
|
|
380
380
|
}
|
|
381
381
|
function handleSelectChange(newSortOption) {
|
|
382
382
|
if (sortableItem) {
|
|
383
|
-
|
|
383
|
+
setSorting(sortableItem.key, newSortOption.id, newSortOption.label, newSortOption.order);
|
|
384
384
|
}
|
|
385
385
|
setIsDropDownOpen(true);
|
|
386
386
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.77.
|
|
3
|
+
"version": "4.77.3",
|
|
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.53.0",
|
|
23
|
-
"@jobber/formatters": "
|
|
23
|
+
"@jobber/formatters": "*",
|
|
24
24
|
"@jobber/hooks": "^2.8.1",
|
|
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": "0691129f73092a3143495c15965874d7956c91c1"
|
|
88
88
|
}
|