@jobber/components 4.78.3 → 4.78.4

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.
@@ -304,13 +304,13 @@ styleInject_es.styleInject(css_248z$8);
304
304
  function DataListSortingOptions({ options, selectedOption, onSelectChange, onClose, optionsListRef, dataListHeaderTileRef, }) {
305
305
  useRefocusOnActivator.useRefocusOnActivator(!optionsListRef.current);
306
306
  useOnKeyDown.useOnKeyDown(() => onClose(), "Escape");
307
- React__default["default"].useEffect(() => {
307
+ React.useEffect(() => {
308
308
  document.addEventListener("mousedown", handleClickOutside);
309
309
  return () => {
310
310
  document.removeEventListener("mousedown", handleClickOutside);
311
311
  };
312
312
  }, [optionsListRef, dataListHeaderTileRef, onClose]);
313
- return (React__default["default"].createElement("ul", { className: styles$8.optionsList, ref: optionsListRef }, options.map((option, index) => (React__default["default"].createElement("li", { className: styles$8.option, key: index, onClick: () => onSelectChange(option), onKeyDown: event => handleKeyDown(event, option), tabIndex: 0, "data-value": option.id },
313
+ return (React__default["default"].createElement("ul", { className: styles$8.optionsList, ref: optionsListRef }, options.map(option => (React__default["default"].createElement("li", { className: styles$8.option, key: option.id, onClick: () => onSelectChange(option), onKeyDown: event => handleKeyDown(event, option), tabIndex: 0, "data-value": option.id },
314
314
  option.label,
315
315
  option.label === (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) && (React__default["default"].createElement(Icon.Icon, { name: "checkmark", color: "blue" })))))));
316
316
  function handleKeyDown(event, option) {
@@ -320,9 +320,9 @@ function DataListSortingOptions({ options, selectedOption, onSelectChange, onClo
320
320
  }
321
321
  function handleClickOutside(event) {
322
322
  var _a, _b;
323
- const isClickInsideOptions = (_a = optionsListRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target);
324
- const isClickInsideHeader = (_b = dataListHeaderTileRef.current) === null || _b === void 0 ? void 0 : _b.contains(event.target);
325
- if (!isClickInsideOptions && !isClickInsideHeader) {
323
+ const isClickInside = ((_a = optionsListRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target)) ||
324
+ ((_b = dataListHeaderTileRef.current) === null || _b === void 0 ? void 0 : _b.contains(event.target));
325
+ if (!isClickInside) {
326
326
  onClose();
327
327
  }
328
328
  }
@@ -332,9 +332,9 @@ function DataListSortingOptions({ options, selectedOption, onSelectChange, onClo
332
332
  function DataListHeaderTile({ headers, headerKey, visible = false, }) {
333
333
  useRefocusOnActivator.useRefocusOnActivator(visible);
334
334
  const { sorting } = useDataListContext();
335
- const [isDropDownOpen, setIsDropDownOpen] = React__default["default"].useState(false);
335
+ const [isDropDownOpen, setIsDropDownOpen] = React.useState(false);
336
336
  const optionsListRef = useFocusTrap.useFocusTrap(isDropDownOpen);
337
- const dataListHeaderTileRef = React__default["default"].useRef(null);
337
+ const dataListHeaderTileRef = React.useRef(null);
338
338
  const sortableItem = sorting === null || sorting === void 0 ? void 0 : sorting.sortable.find(item => item.key === headerKey);
339
339
  const isSortable = Boolean(sortableItem);
340
340
  const sortingState = sorting === null || sorting === void 0 ? void 0 : sorting.state;
@@ -344,15 +344,15 @@ function DataListHeaderTile({ headers, headerKey, visible = false, }) {
344
344
  }), onClick: handleOnClick, ref: dataListHeaderTileRef },
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
- (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(newSortingKey, newId, newLabel, newOrder) {
347
+ isSortable && (React__default["default"].createElement(DataListSortingArrows, { order: (sortingState === null || sortingState === void 0 ? void 0 : sortingState.key) === headerKey ? sortingState.order : "none" }))));
348
+ function toggleSorting(newSortingKey, newId, newLabel) {
349
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 && newOrder === undefined) {
351
+ if (isSameKey && isDescending) {
352
352
  sorting === null || sorting === void 0 ? void 0 : sorting.onSort(undefined);
353
353
  return;
354
354
  }
355
- const sortingOrder = newOrder || (isSameKey && !isDescending ? "desc" : "asc");
355
+ const sortingOrder = isSameKey ? "desc" : "asc";
356
356
  setSorting(newSortingKey, newId, newLabel, sortingOrder);
357
357
  }
358
358
  function setSorting(newSortingKey, newId, newLabel, newOrder) {
@@ -371,11 +371,8 @@ function DataListHeaderTile({ headers, headerKey, visible = false, }) {
371
371
  setIsDropDownOpen(!isDropDownOpen);
372
372
  }
373
373
  else {
374
- const headerValue = headers[headerKey];
375
374
  const id = ((_b = (_a = sortableItem === null || sortableItem === void 0 ? void 0 : sortableItem.options) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.id) || headerKey;
376
- if (headerValue !== undefined) {
377
- toggleSorting(id, headerKey, headerValue);
378
- }
375
+ toggleSorting(id, headerKey, headers[headerKey]);
379
376
  }
380
377
  }
381
378
  function handleSelectChange(newSortOption) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "4.78.3",
3
+ "version": "4.78.4",
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": "3caaa43e03388b7d034d0606dc803218394929c2"
87
+ "gitHead": "f1a0ac8ba5499c0d892c534a5916c2c799e85ad7"
88
88
  }