@sonic-equipment/ui 0.0.99 → 0.0.100

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.d.ts CHANGED
@@ -4048,7 +4048,7 @@ interface Props$2 {
4048
4048
  onCartLineUpdated?: (cartLine: CartLineModel$1) => void;
4049
4049
  }
4050
4050
  declare function CartProvider(props: Props$2): null;
4051
- declare function useCartEvents(): Props$2;
4051
+ declare function useCartEvents(): Props$2 | undefined;
4052
4052
 
4053
4053
  interface Props$1 {
4054
4054
  onFavoriteAdded: () => void;
package/dist/index.js CHANGED
@@ -1133,9 +1133,6 @@ function CartProvider(props) {
1133
1133
  }
1134
1134
  function useCartEvents() {
1135
1135
  const [state] = useGlobalState('cart');
1136
- if (!state) {
1137
- throw new Error('useCart must be used together with the CartProvider');
1138
- }
1139
1136
  return state;
1140
1137
  }
1141
1138
 
@@ -1639,7 +1636,7 @@ const ConnectedAddToCartButton = ({ onAddToCart, productId }) => {
1639
1636
  const { isPending: isPendingDeleteCartLine, mutate: deleteCartLine } = useDeleteCartLineById();
1640
1637
  const { mutate: updateCartLine } = useUpdateCartLineById();
1641
1638
  const { addToast } = useToast();
1642
- const { onCartLineAdded, onCartLineError, onCartLineRemoved, onCartLineUpdated, } = useCartEvents();
1639
+ const { onCartLineAdded, onCartLineError, onCartLineRemoved, onCartLineUpdated, } = useCartEvents() || {};
1643
1640
  const cartLine = cartLines?.find(line => line.productId === productId);
1644
1641
  const quantity = cartLine?.qtyOrdered || 0;
1645
1642
  const handleChange = (quantity) => {
@@ -8095,19 +8092,17 @@ var styles$H = {"badge":"badge-module-X5Au9","count":"badge-module-ododp","is-an
8095
8092
 
8096
8093
  const ANIMATION_DURATION = 600;
8097
8094
  function Badge({ count, variant = 'red' }) {
8098
- const [prevCount, setPrevCount] = useState(count);
8099
8095
  const [isAnimating, setIsAnimating] = useState(false);
8100
8096
  useEffect(() => {
8101
- if (count && prevCount !== undefined && count > prevCount) {
8102
- setIsAnimating(true);
8103
- const timer = setTimeout(() => setIsAnimating(false), ANIMATION_DURATION);
8104
- return () => clearTimeout(timer);
8105
- }
8106
- setPrevCount(count);
8107
- }, [count, prevCount]);
8097
+ if (count === undefined)
8098
+ return;
8099
+ setIsAnimating(true);
8100
+ const timer = setTimeout(() => setIsAnimating(false), ANIMATION_DURATION);
8101
+ return () => clearTimeout(timer);
8102
+ }, [count]);
8108
8103
  return (jsx("span", { className: clsx(styles$H.badge, styles$H[variant], {
8109
8104
  [styles$H['is-animating']]: isAnimating,
8110
- }), style: { '--animation-duration': `${ANIMATION_DURATION}ms` }, children: count && count > 0 && jsx("span", { className: styles$H.count, children: count }) }, count));
8105
+ }), style: { '--animation-duration': `${ANIMATION_DURATION}ms` }, children: count !== undefined && jsx("span", { className: styles$H.count, children: count }) }, count));
8111
8106
  }
8112
8107
 
8113
8108
  var styles$G = {"icon-with-badge":"icon-with-badge-module-eCTIN","badge-wrapper":"icon-with-badge-module-NUjwN"};
@@ -6,5 +6,5 @@ interface Props {
6
6
  onCartLineUpdated?: (cartLine: CartLineModel) => void;
7
7
  }
8
8
  export declare function CartProvider(props: Props): null;
9
- export declare function useCartEvents(): Props;
9
+ export declare function useCartEvents(): Props | undefined;
10
10
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "0.0.99",
3
+ "version": "0.0.100",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {