@razorpay/blade 10.18.0 → 10.18.2

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.
@@ -1,6 +1,6 @@
1
1
  import _defineProperty$1 from '@babel/runtime/helpers/defineProperty';
2
2
  import * as React from 'react';
3
- import React__default, { useMemo, useCallback, useState, useEffect, useRef, useContext, createContext, Fragment as Fragment$1, useImperativeHandle, Children, cloneElement, forwardRef } from 'react';
3
+ import React__default, { useMemo, useCallback, useState, useRef, useEffect, useContext, createContext, Fragment as Fragment$1, useImperativeHandle, Children, cloneElement, forwardRef } from 'react';
4
4
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
5
  import styled, { ThemeProvider, css, keyframes } from 'styled-components';
6
6
  import _objectWithoutProperties$1 from '@babel/runtime/helpers/objectWithoutProperties';
@@ -59,6 +59,20 @@ var getPlatformType = function getPlatformType() {
59
59
  return 'unknown';
60
60
  };
61
61
 
62
+ var isBrowser$1 = getPlatformType() == 'browser';
63
+
64
+ /**
65
+ * useIsomorphicLayoutEffect enables us to safely call `useLayoutEffect` on the browser
66
+ * (for SSR reasons)
67
+ *
68
+ * React currently throws a warning when using useLayoutEffect on the server.
69
+ * To get around it, we can conditionally useEffect on the server (no-op) and
70
+ * useLayoutEffect in the browser.
71
+ *
72
+ * @see https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
73
+ */
74
+ var useIsomorphicLayoutEffect = isBrowser$1 ? React.useLayoutEffect : React.useEffect;
75
+
62
76
  var deviceType = {
63
77
  desktop: 'desktop',
64
78
  mobile: 'mobile'
@@ -113,7 +127,8 @@ var useBreakpoint = function useBreakpoint(_ref) {
113
127
  if ((event === null || event === void 0 ? void 0 : event.media) === mediaQuery) {
114
128
  return true;
115
129
  }
116
- // this will run when the state is initialised for the first time and hence the event object will be empty so we'll fallback to browser's window object
130
+
131
+ // this will run when the state is initialised for the first time and hence the event object will be empty because the event listener wouldn't have triggered
117
132
  if (window.matchMedia(mediaQuery).matches) {
118
133
  return true;
119
134
  }
@@ -121,18 +136,25 @@ var useBreakpoint = function useBreakpoint(_ref) {
121
136
  })) === null || _breakpointsTokenAndQ2 === void 0 ? void 0 : _breakpointsTokenAndQ2.token) !== null && _breakpointsTokenAndQ !== void 0 ? _breakpointsTokenAndQ : undefined;
122
137
  return matchedBreakpoint;
123
138
  }, [breakpointsTokenAndQueryCollection]);
124
- var _useState = useState(function () {
139
+ var _useState = useState({
140
+ matchedBreakpoint: undefined,
141
+ matchedDeviceType: deviceType.desktop
142
+ }),
143
+ _useState2 = _slicedToArray(_useState, 2),
144
+ breakpointAndDevice = _useState2[0],
145
+ setBreakpointAndDevice = _useState2[1];
146
+ useIsomorphicLayoutEffect(function () {
147
+ // set the breakpoint and devicetype for the first time because eventlisteners will only trigger after the screen is actually changed
148
+ setBreakpointAndDevice(function () {
125
149
  var matchedBreakpoint = getMatchedBreakpoint();
126
150
  var matchedDeviceType = getMatchedDeviceType(matchedBreakpoint);
127
151
  return {
128
152
  matchedBreakpoint: matchedBreakpoint,
129
153
  matchedDeviceType: matchedDeviceType
130
154
  };
131
- }),
132
- _useState2 = _slicedToArray(_useState, 2),
133
- breakpointAndDevice = _useState2[0],
134
- setBreakpointAndDevice = _useState2[1];
135
- useEffect(function () {
155
+ });
156
+
157
+ // for react-native and SSR we don't need to register event listeners
136
158
  if (!supportsMatchMedia) {
137
159
  return undefined;
138
160
  }
@@ -173,8 +195,6 @@ var useBreakpoint = function useBreakpoint(_ref) {
173
195
  });
174
196
  };
175
197
  }, [breakpointsTokenAndQueryCollection, getMatchedBreakpoint, getMatchedDeviceType, supportsMatchMedia]);
176
-
177
- // @TODO: handle SSR scenarios
178
198
  return breakpointAndDevice;
179
199
  };
180
200
 
@@ -244,20 +264,6 @@ var useColorScheme = function useColorScheme() {
244
264
  };
245
265
  };
246
266
 
247
- var isBrowser$1 = getPlatformType() == 'browser';
248
-
249
- /**
250
- * useIsomorphicLayoutEffect enables us to safely call `useLayoutEffect` on the browser
251
- * (for SSR reasons)
252
- *
253
- * React currently throws a warning when using useLayoutEffect on the server.
254
- * To get around it, we can conditionally useEffect on the server (no-op) and
255
- * useLayoutEffect in the browser.
256
- *
257
- * @see https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
258
- */
259
- var useIsomorphicLayoutEffect = isBrowser$1 ? React.useLayoutEffect : React.useEffect;
260
-
261
267
  /* eslint-disable consistent-return */
262
268
  function useInterval(callback, _ref) {
263
269
  var delay = _ref.delay,
@@ -19724,7 +19730,7 @@ var StyledCarouselItem = /*#__PURE__*/styled(BaseBox).withConfig({
19724
19730
  }, isResponsive && {
19725
19731
  width: '100%',
19726
19732
  scrollSnapAlign: isMobile || !shouldAddStartEndSpacing ? 'start' : 'center',
19727
- marginLeft: shouldHaveStartSpacing ? '100%' : 0
19733
+ marginLeft: shouldHaveStartSpacing ? '40%' : 0
19728
19734
  });
19729
19735
  });
19730
19736
  var _CarouselItem = function _CarouselItem(_ref2) {