@tap-payments/os-micro-frontend-shared 0.1.257-test.1 → 0.1.257-test.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.
@@ -26,16 +26,17 @@ export default function MerchantItem({ brands, isLoading, onFilterChange, mercha
26
26
  return brands.filter((brand) => brand.merchants.some((merchant) => merchantsIds === null || merchantsIds === void 0 ? void 0 : merchantsIds.includes(merchant.legacy_id))).length;
27
27
  }, [brands, merchantsIds]);
28
28
  const onClick = () => {
29
- if (atLeastOneMerchantSelected)
30
- return;
31
29
  if (isAllSelected) {
30
+ if (atLeastOneMerchantSelected && merchantsIds.length === 1)
31
+ return;
32
32
  onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange([]);
33
33
  return;
34
34
  }
35
35
  const allMerchants = brands.flatMap((brand) => brand.merchants.map(({ legacy_id }) => legacy_id));
36
36
  onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange(allMerchants);
37
37
  };
38
- return (_jsxs(MenuItem, Object.assign({ isDisabled: atLeastOneMerchantSelected, isSelected: isAllSelected, hideCheckbox: hideCheckbox, isIndeterminate: isSomeSelected, sx: Object.assign(Object.assign({ maxHeight: 36, minHeight: 36, padding: '12px 8px 12px 16px' }, (open && { boxShadow: '0px 0px 16px 0px #00000021' })), ((isLoading || brands.length <= 0) && {
38
+ const isDisabled = isLoading || !(brands === null || brands === void 0 ? void 0 : brands.length);
39
+ return (_jsxs(MenuItem, Object.assign({ isDisabled: isDisabled, isSelected: isAllSelected, hideCheckbox: hideCheckbox, isIndeterminate: isSomeSelected, sx: Object.assign(Object.assign({ maxHeight: 36, minHeight: 36, padding: '12px 8px 12px 16px' }, (open && { boxShadow: '0px 0px 16px 0px #00000021' })), (isDisabled && {
39
40
  pointerEvents: 'none',
40
41
  opacity: 0.5,
41
42
  cursor: 'default',
@@ -23,9 +23,9 @@ function RetailersItem({ retailersIds = [], isLoading, retailers = [], onFilterC
23
23
  }, [retailers, isRetailerSelected, hideCheckbox]);
24
24
  const isSomeSelected = useMemo(() => !isAllSelected && retailersIds.length > 0, [retailersIds, isAllSelected]);
25
25
  const onClick = () => {
26
- if (atLeastOneRetailerSelected)
27
- return;
28
26
  if (isAllSelected) {
27
+ if (atLeastOneRetailerSelected && retailersIds.length === 1)
28
+ return;
29
29
  onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange([]);
30
30
  return;
31
31
  }
@@ -45,7 +45,7 @@ function RetailersItem({ retailersIds = [], isLoading, retailers = [], onFilterC
45
45
  const uniqueMids = [...new Set([...retailersIds, retailerId])];
46
46
  onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange(uniqueMids);
47
47
  };
48
- const isDisabled = isLoading || (retailers === null || retailers === void 0 ? void 0 : retailers.length) <= 0 || atLeastOneRetailerSelected;
48
+ const isDisabled = isLoading || !(retailers === null || retailers === void 0 ? void 0 : retailers.length);
49
49
  const handleSearchInputChange = (value) => {
50
50
  setSearchInputValue(value);
51
51
  };
@@ -60,7 +60,7 @@ function RetailersItem({ retailersIds = [], isLoading, retailers = [], onFilterC
60
60
  const displayedRetailers = useMemo(() => (showSearchInput ? filteredRetailers : retailers), [filteredRetailers, retailers, showSearchInput]);
61
61
  return (_jsxs(MenuItem, Object.assign({ isDisabled: isDisabled,
62
62
  // TODO: the checkbox ui should be controlled using a state not through the isAllSelected variable
63
- isSelected: isAllSelected, hideCheckbox: hideCheckbox, isIndeterminate: isSomeSelected, sx: Object.assign(Object.assign({ maxHeight: 35, minHeight: 35, padding: '12px 8px 12px 16px' }, (open && { boxShadow: '0px 0px 16px 0px #00000021' })), (!(retailers === null || retailers === void 0 ? void 0 : retailers.length) && { opacity: 0.5, pointerEvents: 'none' })), onMouseEnter: onOpen, onMouseLeave: onClose, onClick: onClick }, { children: [_jsx(Text, Object.assign({ sx: { fontSize: '11px', flex: 1 } }, { children: t('retailers') })), (retailers === null || retailers === void 0 ? void 0 : retailers.length) > 0 && _jsx("img", { src: rightArrow, alt: "arrow", style: { height: 12 } }), _jsxs(Menu, Object.assign({ open: open, anchorEl: anchorEl, placement: "right-start", sx: { height: 300, width: 200, overflow: 'auto' } }, { children: [showSearchInput && (_jsx(SearchListInput, { placeholder: "Retailers", name: "retailers", value: searchInputValue, onSearchChange: handleSearchInputChange, onSearchReset: handleSearchInputReset, sx: { px: '8px' } })), displayedRetailers === null || displayedRetailers === void 0 ? void 0 : displayedRetailers.map((retailer, index) => {
63
+ isSelected: isAllSelected, hideCheckbox: hideCheckbox, isIndeterminate: isSomeSelected, sx: Object.assign(Object.assign({ maxHeight: 35, minHeight: 35, padding: '12px 8px 12px 16px' }, (open && { boxShadow: '0px 0px 16px 0px #00000021' })), (isDisabled && { opacity: 0.5, pointerEvents: 'none', cursor: 'default' })), onMouseEnter: onOpen, onMouseLeave: onClose, onClick: onClick }, { children: [_jsx(Text, Object.assign({ sx: { fontSize: '11px', flex: 1 } }, { children: t('retailers') })), (retailers === null || retailers === void 0 ? void 0 : retailers.length) > 0 && _jsx("img", { src: rightArrow, alt: "arrow", style: { height: 12 } }), _jsxs(Menu, Object.assign({ open: open, anchorEl: anchorEl, placement: "right-start", sx: { height: 300, width: 200, overflow: 'auto' } }, { children: [showSearchInput && (_jsx(SearchListInput, { placeholder: "Retailers", name: "retailers", value: searchInputValue, onSearchChange: handleSearchInputChange, onSearchReset: handleSearchInputReset, sx: { px: '8px' } })), displayedRetailers === null || displayedRetailers === void 0 ? void 0 : displayedRetailers.map((retailer, index) => {
64
64
  var _a, _b, _c, _d, _e;
65
65
  return (_jsx(MenuItem, Object.assign({ isSelected: isRetailerSelected(retailer.id), isDisabled: isLoading || isLastRetailerToBeDisabled(retailer.id), onClick: (e) => {
66
66
  onClickRetailer(e, retailer.id);
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@tap-payments/os-micro-frontend-shared",
3
3
  "description": "Shared components and utilities for Tap Payments micro frontends",
4
- "version": "0.1.257-test.1",
5
- "testVersion": 1,
4
+ "version": "0.1.257-test.3",
5
+ "testVersion": 3,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",