@giro-ds/react 3.0.6 → 3.0.7

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/index.esm.js CHANGED
@@ -1875,13 +1875,13 @@ const ListItem = ({ id, className, variant = 'text', text, name, subText, disabl
1875
1875
  return (jsx("li", { className: listItemClass, tabIndex: disabled ? -1 : 0, onKeyDown: handleKeyDown, "aria-selected": variant === 'text' || variant === 'icon' ? internalSelected : undefined, "aria-disabled": disabled, "aria-checked": getAriaChecked(), "aria-labelledby": `${itemId}-text`, "aria-describedby": showSubText && subText ? `${itemId}-subtext` : undefined, "data-testid": "list-item", ...rest, children: renderVariantContent() }));
1876
1876
  };
1877
1877
 
1878
- var styles$6 = {"content":"Menu-module__content___pnDF6","subContent":"Menu-module__subContent___O9T-y","itemsWrapper":"Menu-module__itemsWrapper___Fcg71","item":"Menu-module__item___S3HKY","subTrigger":"Menu-module__subTrigger___CdnJE","itemSubText":"Menu-module__itemSubText___U1HFP","itemIcon":"Menu-module__itemIcon___iyxmZ","itemSelected":"Menu-module__itemSelected___O5Ebi","itemText":"Menu-module__itemText___2fd2B","wrapperText":"Menu-module__wrapperText___PomUe","chevronIcon":"Menu-module__chevronIcon___Gda-U","searchWrapper":"Menu-module__searchWrapper___e0knQ","emptyState":"Menu-module__emptyState___3wh-S","loadingMore":"Menu-module__loadingMore___fUCvH"};
1878
+ var styles$6 = {"content":"Menu-module__content___pnDF6","subContent":"Menu-module__subContent___O9T-y","itemsWrapper":"Menu-module__itemsWrapper___Fcg71","item":"Menu-module__item___S3HKY","subTrigger":"Menu-module__subTrigger___CdnJE","itemSubText":"Menu-module__itemSubText___U1HFP","itemIcon":"Menu-module__itemIcon___iyxmZ","wrapperText":"Menu-module__wrapperText___PomUe","itemText":"Menu-module__itemText___2fd2B","chevronIcon":"Menu-module__chevronIcon___Gda-U","searchWrapper":"Menu-module__searchWrapper___e0knQ","emptyState":"Menu-module__emptyState___3wh-S","loadingMore":"Menu-module__loadingMore___fUCvH"};
1879
1879
 
1880
1880
  const MenuItem = memo(({ item, isSelected, onSelect }) => {
1881
1881
  const handleSelect = () => {
1882
1882
  onSelect(item);
1883
1883
  };
1884
- return (jsxs(DropdownMenu.Item, { className: clsx(styles$6.item, { [styles$6.itemSelected]: isSelected }), onSelect: handleSelect, disabled: item.disabled, children: [item.icon && jsx("span", { className: styles$6.itemIcon, children: item.icon }), jsxs("div", { className: styles$6.wrapperText, children: [jsx("span", { className: styles$6.itemText, children: item.text }), item.subText && (jsx("span", { className: styles$6.itemSubText, children: item.subText }))] })] }));
1884
+ return (jsxs(DropdownMenu.Item, { className: clsx(styles$6.item), "data-selected": isSelected || undefined, onSelect: handleSelect, disabled: item.disabled, children: [item.icon && jsx("span", { className: styles$6.itemIcon, children: item.icon }), jsxs("div", { className: styles$6.wrapperText, children: [jsx("span", { className: styles$6.itemText, children: item.text }), item.subText && (jsx("span", { className: styles$6.itemSubText, children: item.subText }))] })] }));
1885
1885
  });
1886
1886
  MenuItem.displayName = 'MenuItem';
1887
1887
 
@@ -2334,7 +2334,7 @@ const Quantity = ({ defaultValue = 0, value: controlledValue, onChange, disabled
2334
2334
  const memorizedQuantity = React__default.memo(Quantity);
2335
2335
  memorizedQuantity.displayName = 'Quantity';
2336
2336
 
2337
- var styles$4 = {"fieldContainer":"index-module__fieldContainer___gp5Hz","trigger":"index-module__trigger___rHQJz","disabled":"index-module__disabled___MIJba","open":"index-module__open___bVB-1","error":"index-module__error___nPFjW","hasValue":"index-module__hasValue___a4Sy4","triggerText":"index-module__triggerText___tyjAQ","containerLabel":"index-module__containerLabel___CExNh","content":"index-module__content___9nWeY","viewport":"index-module__viewport___nkVG9","group":"index-module__group___-PiX6","container":"index-module__container___Wg-pd","searchWrapper":"index-module__searchWrapper___umf9d","item":"index-module__item___R-Xle","subTitle":"index-module__subTitle___sXaqd","title":"index-module__title___x1Bia","checkboxItem":"index-module__checkboxItem___FTUbN","checkboxContent":"index-module__checkboxContent___skcd5","itemWrapper":"index-module__itemWrapper___PAglx","selected":"index-module__selected___VFFMN","icon":"index-module__icon___l2Zze","itemIndicator":"index-module__itemIndicator___FhOim","textContent":"index-module__textContent___cBJbp","helper":"index-module__helper___w4VC7","errorMessage":"index-module__errorMessage___gquqW","noResults":"index-module__noResults___qgzod","loadingMore":"index-module__loadingMore___GHc31","expandableItemContainer":"index-module__expandableItemContainer___NexPi","chevron":"index-module__chevron___c6mu-","childrenWrapper":"index-module__childrenWrapper___tj2R-"};
2337
+ var styles$4 = {"fieldContainer":"index-module__fieldContainer___gp5Hz","trigger":"index-module__trigger___rHQJz","disabled":"index-module__disabled___MIJba","open":"index-module__open___bVB-1","error":"index-module__error___nPFjW","hasValue":"index-module__hasValue___a4Sy4","triggerText":"index-module__triggerText___tyjAQ","containerLabel":"index-module__containerLabel___CExNh","content":"index-module__content___9nWeY","viewport":"index-module__viewport___nkVG9","group":"index-module__group___-PiX6","container":"index-module__container___Wg-pd","searchWrapper":"index-module__searchWrapper___umf9d","item":"index-module__item___R-Xle","subTitle":"index-module__subTitle___sXaqd","checkboxItem":"index-module__checkboxItem___FTUbN","checkboxContent":"index-module__checkboxContent___skcd5","itemWrapper":"index-module__itemWrapper___PAglx","title":"index-module__title___x1Bia","icon":"index-module__icon___l2Zze","itemIndicator":"index-module__itemIndicator___FhOim","textContent":"index-module__textContent___cBJbp","helper":"index-module__helper___w4VC7","errorMessage":"index-module__errorMessage___gquqW","noResults":"index-module__noResults___qgzod","loadingMore":"index-module__loadingMore___GHc31","expandableItemContainer":"index-module__expandableItemContainer___NexPi","chevron":"index-module__chevron___c6mu-","childrenWrapper":"index-module__childrenWrapper___tj2R-"};
2338
2338
 
2339
2339
  const CheckboxSelectItem = ({ text, subTitle, disabled, checked, onCheckedChange, value, ...restProps }) => {
2340
2340
  const itemRef = useRef(null);
@@ -6137,13 +6137,19 @@ const useSelection = (dataSource, rowSelection) => {
6137
6137
  : [...selectedKeys, key];
6138
6138
  handleChange(newKeys);
6139
6139
  }, [selectedKeys, selectedSet, handleChange]);
6140
+ const selectableKeys = useMemo(() => (dataSource
6141
+ .map((row, index) => ({ index, disabled: rowSelection?.getCheckboxProps?.(row, index)?.disabled }))
6142
+ .filter(({ disabled }) => !disabled)
6143
+ .map(({ index }) => index)), [dataSource, rowSelection]);
6140
6144
  const toggleAll = useCallback(() => {
6141
- const allKeys = dataSource.map((_, index) => index);
6142
- const newKeys = selectedKeys.length === dataSource.length ? [] : allKeys;
6145
+ const isAllSelectableSelected = selectableKeys.every(k => selectedSet.has(k));
6146
+ const newKeys = isAllSelectableSelected
6147
+ ? selectedKeys.filter(k => !selectableKeys.includes(k))
6148
+ : [...new Set([...selectedKeys, ...selectableKeys])];
6143
6149
  handleChange(newKeys);
6144
- }, [dataSource, selectedKeys.length, handleChange]);
6145
- const isAllSelected = selectedKeys.length === dataSource.length && dataSource.length > 0;
6146
- const isIndeterminate = selectedKeys.length > 0 && selectedKeys.length < dataSource.length;
6150
+ }, [selectableKeys, selectedKeys, selectedSet, handleChange]);
6151
+ const isAllSelected = selectableKeys.length > 0 && selectableKeys.every(k => selectedSet.has(k));
6152
+ const isIndeterminate = selectableKeys.some(k => selectedSet.has(k)) && !isAllSelected;
6147
6153
  return {
6148
6154
  selectedSet,
6149
6155
  selectedKeys,