@jobber/components 4.77.2 → 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.
@@ -345,21 +345,22 @@ function DataListHeaderTile({ headers, headerKey, visible = false, }) {
345
345
  React__default["default"].createElement(Text.Text, { maxLines: "single" }, headers[headerKey]),
346
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 })),
347
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));
348
- function toggleSorting(sortingKey, id, label, order) {
349
- const isSameKey = (sortingState === null || sortingState === void 0 ? void 0 : sortingState.label) === label && sortingKey === (sortingState === null || sortingState === void 0 ? void 0 : sortingState.key);
348
+ function toggleSorting(newSortingKey, newId, newLabel, newOrder) {
349
+ const isSameKey = newSortingKey === (sortingState === null || sortingState === void 0 ? void 0 : sortingState.key);
350
350
  const isDescending = (sortingState === null || sortingState === void 0 ? void 0 : sortingState.order) === "desc";
351
- if (isSameKey && isDescending && order !== "asc") {
352
- if (order === "desc")
353
- return;
351
+ if (isSameKey && isDescending && newOrder === undefined) {
354
352
  sorting === null || sorting === void 0 ? void 0 : sorting.onSort(undefined);
355
353
  return;
356
354
  }
357
- const sortingOrder = order || (isSameKey && !isDescending ? "desc" : "asc");
355
+ const sortingOrder = newOrder || (isSameKey && !isDescending ? "desc" : "asc");
356
+ setSorting(newSortingKey, newId, newLabel, sortingOrder);
357
+ }
358
+ function setSorting(newSortingKey, newId, newLabel, newOrder) {
358
359
  sorting === null || sorting === void 0 ? void 0 : sorting.onSort({
359
- key: sortingKey,
360
- id,
361
- label,
362
- order: sortingOrder,
360
+ key: newSortingKey,
361
+ id: newId,
362
+ label: newLabel,
363
+ order: newOrder,
363
364
  });
364
365
  }
365
366
  function handleOnClick() {
@@ -379,7 +380,7 @@ function DataListHeaderTile({ headers, headerKey, visible = false, }) {
379
380
  }
380
381
  function handleSelectChange(newSortOption) {
381
382
  if (sortableItem) {
382
- toggleSorting(sortableItem.key, newSortOption.id, newSortOption.label, newSortOption.order);
383
+ setSorting(sortableItem.key, newSortOption.id, newSortOption.label, newSortOption.order);
383
384
  }
384
385
  setIsDropDownOpen(true);
385
386
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "4.77.2",
3
+ "version": "4.77.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": "b1e06d1334c34d9a11b4106fceafb869a7e34079"
87
+ "gitHead": "0691129f73092a3143495c15965874d7956c91c1"
88
88
  }