@razorpay/blade 9.6.1 → 10.0.0
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/build/components/index.d.ts +25 -24
- package/build/components/index.development.web.js +4916 -7486
- package/build/components/index.development.web.js.map +1 -1
- package/build/components/index.native.d.ts +17 -16
- package/build/components/index.native.js +430 -425
- package/build/components/index.native.js.map +1 -1
- package/build/components/index.production.web.js +4898 -7421
- package/build/components/index.production.web.js.map +1 -1
- package/build/css/bankingThemeDarkDesktop.css +1 -1
- package/build/css/bankingThemeDarkMobile.css +1 -1
- package/build/css/bankingThemeLightDesktop.css +1 -1
- package/build/css/bankingThemeLightMobile.css +1 -1
- package/build/css/paymentThemeDarkDesktop.css +1 -1
- package/build/css/paymentThemeDarkMobile.css +1 -1
- package/build/css/paymentThemeLightDesktop.css +1 -1
- package/build/css/paymentThemeLightMobile.css +1 -1
- package/build/tokens/index.d.ts +27 -27
- package/build/tokens/index.development.web.js +30 -71
- package/build/tokens/index.development.web.js.map +1 -1
- package/build/tokens/index.native.d.ts +27 -27
- package/build/tokens/index.native.js +4 -5
- package/build/tokens/index.native.js.map +1 -1
- package/build/tokens/index.production.web.js +20 -44
- package/build/tokens/index.production.web.js.map +1 -1
- package/build/utils/index.d.ts +12 -12
- package/build/utils/index.development.web.js +26 -60
- package/build/utils/index.development.web.js.map +1 -1
- package/build/utils/index.native.d.ts +12 -12
- package/build/utils/index.native.js +7 -7
- package/build/utils/index.native.js.map +1 -1
- package/build/utils/index.production.web.js +24 -55
- package/build/utils/index.production.web.js.map +1 -1
- package/package.json +23 -22
package/build/utils/index.d.ts
CHANGED
|
@@ -418,10 +418,10 @@ type Delay = {
|
|
|
418
418
|
xlong: 5000;
|
|
419
419
|
};
|
|
420
420
|
|
|
421
|
-
type
|
|
421
|
+
type EasingFactoryFn = { factory: () => (value: number) => number }; // similar to EasingFactoryFn of `react-native-reanimated`
|
|
422
422
|
type EasingType<Value extends string> = Platform$1.Select<{
|
|
423
423
|
web: Value;
|
|
424
|
-
native:
|
|
424
|
+
native: EasingFactoryFn;
|
|
425
425
|
}>;
|
|
426
426
|
|
|
427
427
|
type Easing = {
|
|
@@ -429,49 +429,49 @@ type Easing = {
|
|
|
429
429
|
standard: {
|
|
430
430
|
/** `cubic-bezier(0.5, 0, 0.3, 1.5)`
|
|
431
431
|
*
|
|
432
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
432
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
433
433
|
attentive: EasingType<'cubic-bezier(0.5, 0, 0.3, 1.5)'>;
|
|
434
434
|
/** `cubic-bezier(0.3, 0, 0.2, 1)`
|
|
435
435
|
*
|
|
436
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
436
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
437
437
|
effective: EasingType<'cubic-bezier(0.3, 0, 0.2, 1)'>;
|
|
438
438
|
/** `cubic-bezier(0.5, 0, 0, 1)`
|
|
439
439
|
*
|
|
440
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
440
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
441
441
|
revealing: EasingType<'cubic-bezier(0.5, 0, 0, 1)'>;
|
|
442
442
|
/** `cubic-bezier(1, 0.5, 0, 0.5)`
|
|
443
443
|
*
|
|
444
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
444
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
445
445
|
wary: EasingType<'cubic-bezier(1, 0.5, 0, 0.5)'>;
|
|
446
446
|
};
|
|
447
447
|
/** Easings for all entrance animations*/
|
|
448
448
|
entrance: {
|
|
449
449
|
/** `cubic-bezier(0.5, 0, 0.3, 1.5)`
|
|
450
450
|
*
|
|
451
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
451
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
452
452
|
attentive: EasingType<'cubic-bezier(0.5, 0, 0.3, 1.5)'>;
|
|
453
453
|
/** `cubic-bezier(0, 0, 0.2, 1)`
|
|
454
454
|
*
|
|
455
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
455
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
456
456
|
effective: EasingType<'cubic-bezier(0, 0, 0.2, 1)'>;
|
|
457
457
|
/** `cubic-bezier(0, 0, 0, 1)`
|
|
458
458
|
*
|
|
459
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
459
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
460
460
|
revealing: EasingType<'cubic-bezier(0, 0, 0, 1)'>;
|
|
461
461
|
};
|
|
462
462
|
/** Easings for all exit animations*/
|
|
463
463
|
exit: {
|
|
464
464
|
/** `cubic-bezier(0.7, 0, 0.5, 1)`
|
|
465
465
|
*
|
|
466
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
466
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
467
467
|
attentive: EasingType<'cubic-bezier(0.7, 0, 0.5, 1)'>;
|
|
468
468
|
/** `cubic-bezier(0.17, 0, 1, 1)`
|
|
469
469
|
*
|
|
470
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
470
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
471
471
|
effective: EasingType<'cubic-bezier(0.17, 0, 1, 1)'>;
|
|
472
472
|
/** `cubic-bezier(0.5, 0, 1, 1)`
|
|
473
473
|
*
|
|
474
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
474
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
475
475
|
revealing: EasingType<'cubic-bezier(0.5, 0, 1, 1)'>;
|
|
476
476
|
};
|
|
477
477
|
};
|
|
@@ -10,21 +10,18 @@ var getColorScheme = function getColorScheme() {
|
|
|
10
10
|
system: 'default'
|
|
11
11
|
};
|
|
12
12
|
var supportsMatchMedia = typeof window !== 'undefined' && typeof window.matchMedia === 'function';
|
|
13
|
-
|
|
14
13
|
if (colorScheme === 'light' || colorScheme === 'dark') {
|
|
15
14
|
return colorScheme;
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
if (colorScheme === 'system' && supportsMatchMedia && window.matchMedia(colorSchemeMediaQueryMap.dark).matches) {
|
|
19
17
|
return 'dark';
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
return 'light';
|
|
23
20
|
};
|
|
24
21
|
|
|
25
22
|
var getMediaQuery = function getMediaQuery(_ref) {
|
|
26
23
|
var min = _ref.min,
|
|
27
|
-
|
|
24
|
+
max = _ref.max;
|
|
28
25
|
return "screen and (min-width: ".concat(min, "px)").concat(max ? " and (max-width: ".concat(max, "px)") : '');
|
|
29
26
|
};
|
|
30
27
|
|
|
@@ -32,15 +29,12 @@ var getPlatformType = function getPlatformType() {
|
|
|
32
29
|
if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|
|
33
30
|
return 'react-native';
|
|
34
31
|
}
|
|
35
|
-
|
|
36
32
|
if (typeof document !== 'undefined') {
|
|
37
33
|
return 'browser';
|
|
38
34
|
}
|
|
39
|
-
|
|
40
35
|
if (typeof process !== 'undefined') {
|
|
41
36
|
return 'node';
|
|
42
37
|
}
|
|
43
|
-
|
|
44
38
|
return 'unknown';
|
|
45
39
|
};
|
|
46
40
|
|
|
@@ -50,17 +44,14 @@ var deviceType = {
|
|
|
50
44
|
};
|
|
51
45
|
var useBreakpoint = function useBreakpoint(_ref) {
|
|
52
46
|
var _window;
|
|
53
|
-
|
|
54
47
|
var breakpoints = _ref.breakpoints;
|
|
55
48
|
var supportsMatchMedia = typeof document !== 'undefined' && typeof window !== 'undefined' && typeof ((_window = window) === null || _window === void 0 ? void 0 : _window.matchMedia) === 'function';
|
|
56
49
|
var breakpointsTokenAndQueryCollection = useMemo(function () {
|
|
57
50
|
return supportsMatchMedia ? Object.entries(breakpoints).map(function (_ref2, index, breakpointsArray) {
|
|
58
51
|
var _breakpointsArray;
|
|
59
|
-
|
|
60
52
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
token = _ref3[0],
|
|
54
|
+
screenSize = _ref3[1];
|
|
64
55
|
var min = screenSize;
|
|
65
56
|
var maxValue = (_breakpointsArray = breakpointsArray[index + 1]) === null || _breakpointsArray === void 0 ? void 0 : _breakpointsArray[1];
|
|
66
57
|
var mediaQuery = getMediaQuery({
|
|
@@ -77,7 +68,6 @@ var useBreakpoint = function useBreakpoint(_ref) {
|
|
|
77
68
|
var getMatchedDeviceType = useCallback(function (matchedBreakpoint) {
|
|
78
69
|
var matchedDeviceType = deviceType.mobile;
|
|
79
70
|
var platform = getPlatformType();
|
|
80
|
-
|
|
81
71
|
if (platform === 'react-native') {
|
|
82
72
|
matchedDeviceType = deviceType.mobile;
|
|
83
73
|
} else if (platform === 'browser') {
|
|
@@ -91,49 +81,40 @@ var useBreakpoint = function useBreakpoint(_ref) {
|
|
|
91
81
|
//@TODO: Check for useragent for node
|
|
92
82
|
matchedDeviceType = deviceType.desktop;
|
|
93
83
|
}
|
|
94
|
-
|
|
95
84
|
return matchedDeviceType;
|
|
96
85
|
}, []);
|
|
97
86
|
var getMatchedBreakpoint = useCallback(function (event) {
|
|
98
87
|
var _breakpointsTokenAndQ, _breakpointsTokenAndQ2;
|
|
99
|
-
|
|
100
88
|
var matchedBreakpoint = (_breakpointsTokenAndQ = (_breakpointsTokenAndQ2 = breakpointsTokenAndQueryCollection.find(function (_ref4) {
|
|
101
89
|
var _ref4$mediaQuery = _ref4.mediaQuery,
|
|
102
|
-
|
|
103
|
-
|
|
90
|
+
mediaQuery = _ref4$mediaQuery === void 0 ? '' : _ref4$mediaQuery;
|
|
104
91
|
// this will run whenever mediaQuery change event is triggered
|
|
105
92
|
if ((event === null || event === void 0 ? void 0 : event.media) === mediaQuery) {
|
|
106
93
|
return true;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
94
|
+
}
|
|
110
95
|
// 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
|
|
111
96
|
if (window.matchMedia(mediaQuery).matches) {
|
|
112
97
|
return true;
|
|
113
98
|
}
|
|
114
|
-
|
|
115
99
|
return false;
|
|
116
100
|
})) === null || _breakpointsTokenAndQ2 === void 0 ? void 0 : _breakpointsTokenAndQ2.token) !== null && _breakpointsTokenAndQ !== void 0 ? _breakpointsTokenAndQ : undefined;
|
|
117
101
|
return matchedBreakpoint;
|
|
118
102
|
}, [breakpointsTokenAndQueryCollection]);
|
|
119
|
-
|
|
120
103
|
var _useState = useState(function () {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
104
|
+
var matchedBreakpoint = getMatchedBreakpoint();
|
|
105
|
+
var matchedDeviceType = getMatchedDeviceType(matchedBreakpoint);
|
|
106
|
+
return {
|
|
107
|
+
matchedBreakpoint: matchedBreakpoint,
|
|
108
|
+
matchedDeviceType: matchedDeviceType
|
|
109
|
+
};
|
|
110
|
+
}),
|
|
111
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
112
|
+
breakpointAndDevice = _useState2[0],
|
|
113
|
+
setBreakpointAndDevice = _useState2[1];
|
|
132
114
|
useEffect(function () {
|
|
133
115
|
if (!supportsMatchMedia) {
|
|
134
116
|
return undefined;
|
|
135
117
|
}
|
|
136
|
-
|
|
137
118
|
var handleMediaQueryChange = function handleMediaQueryChange(event) {
|
|
138
119
|
setBreakpointAndDevice(function () {
|
|
139
120
|
var matchedBreakpoint = getMatchedBreakpoint(event);
|
|
@@ -144,23 +125,20 @@ var useBreakpoint = function useBreakpoint(_ref) {
|
|
|
144
125
|
};
|
|
145
126
|
});
|
|
146
127
|
};
|
|
147
|
-
|
|
148
128
|
var mediaQueryInstances = breakpointsTokenAndQueryCollection.map(function (_ref5) {
|
|
149
129
|
var _ref5$mediaQuery = _ref5.mediaQuery,
|
|
150
|
-
|
|
130
|
+
mediaQuery = _ref5$mediaQuery === void 0 ? '' : _ref5$mediaQuery;
|
|
151
131
|
var mediaQueryInstance = window.matchMedia(mediaQuery);
|
|
152
132
|
/**
|
|
153
133
|
* the mediaquery event listener is available on mediaQuery instances and not `window`
|
|
154
134
|
* we iterate over all the breakpoints we have, register each instance and store them as `mediaQueryInstances` so we can later unregister all of them.
|
|
155
135
|
*/
|
|
156
|
-
|
|
157
136
|
if (mediaQueryInstance.addEventListener) {
|
|
158
137
|
mediaQueryInstance.addEventListener('change', handleMediaQueryChange);
|
|
159
138
|
} else {
|
|
160
139
|
// In older browsers MediaQueryList do not yet inherit from EventTarget, So using addListener as fallback - https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/addListener
|
|
161
140
|
mediaQueryInstance.addListener(handleMediaQueryChange);
|
|
162
141
|
}
|
|
163
|
-
|
|
164
142
|
return mediaQueryInstance;
|
|
165
143
|
});
|
|
166
144
|
return function () {
|
|
@@ -173,12 +151,14 @@ var useBreakpoint = function useBreakpoint(_ref) {
|
|
|
173
151
|
}
|
|
174
152
|
});
|
|
175
153
|
};
|
|
176
|
-
}, [breakpointsTokenAndQueryCollection, getMatchedBreakpoint, getMatchedDeviceType, supportsMatchMedia]);
|
|
154
|
+
}, [breakpointsTokenAndQueryCollection, getMatchedBreakpoint, getMatchedDeviceType, supportsMatchMedia]);
|
|
177
155
|
|
|
156
|
+
// @TODO: handle SSR scenarios
|
|
178
157
|
return breakpointAndDevice;
|
|
179
158
|
};
|
|
180
159
|
|
|
181
160
|
// @TODO: this shall rather be Surface = 'level1' | 'level2' | 'level3' to keep in sync with color tokens
|
|
161
|
+
|
|
182
162
|
// export type ActionProperties = {
|
|
183
163
|
// background: ActionVariants;
|
|
184
164
|
// border: ActionVariants;
|
|
@@ -188,11 +168,9 @@ var useBreakpoint = function useBreakpoint(_ref) {
|
|
|
188
168
|
var colorSchemeNamesInput = ['light', 'dark', 'system'];
|
|
189
169
|
|
|
190
170
|
var PREFIX = '[Blade]:';
|
|
191
|
-
|
|
192
171
|
var throwBladeError = function throwBladeError(_ref) {
|
|
193
172
|
var message = _ref.message,
|
|
194
|
-
|
|
195
|
-
|
|
173
|
+
moduleName = _ref.moduleName;
|
|
196
174
|
{
|
|
197
175
|
var prefix = moduleName ? "[Blade: ".concat(moduleName, "]:") : PREFIX;
|
|
198
176
|
throw new Error("".concat(prefix, " ").concat(message));
|
|
@@ -201,15 +179,13 @@ var throwBladeError = function throwBladeError(_ref) {
|
|
|
201
179
|
|
|
202
180
|
var useColorScheme = function useColorScheme() {
|
|
203
181
|
var initialColorScheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'light';
|
|
204
|
-
|
|
205
182
|
// if colorScheme defined use that else fallback to 'light'
|
|
206
183
|
var _useState = useState(function () {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
184
|
+
return getColorScheme(initialColorScheme);
|
|
185
|
+
}),
|
|
186
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
187
|
+
colorSchemeState = _useState2[0],
|
|
188
|
+
setColorSchemeState = _useState2[1];
|
|
213
189
|
var setColorScheme = useCallback(function setThemeMode(colorScheme) {
|
|
214
190
|
{
|
|
215
191
|
if (!colorSchemeNamesInput.includes(colorScheme)) {
|
|
@@ -219,7 +195,6 @@ var useColorScheme = function useColorScheme() {
|
|
|
219
195
|
});
|
|
220
196
|
}
|
|
221
197
|
}
|
|
222
|
-
|
|
223
198
|
setColorSchemeState(getColorScheme(colorScheme));
|
|
224
199
|
}, []);
|
|
225
200
|
return {
|
|
@@ -229,7 +204,6 @@ var useColorScheme = function useColorScheme() {
|
|
|
229
204
|
};
|
|
230
205
|
|
|
231
206
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
232
|
-
|
|
233
207
|
var isReactNative = function isReactNative() {
|
|
234
208
|
return getPlatformType() === 'react-native';
|
|
235
209
|
};
|
|
@@ -243,7 +217,6 @@ var isAndroid = function isAndroid() {
|
|
|
243
217
|
|
|
244
218
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
245
219
|
var Platform;
|
|
246
|
-
|
|
247
220
|
(function (_Platform) {})(Platform || (Platform = {}));
|
|
248
221
|
|
|
249
222
|
/**
|
|
@@ -263,6 +236,7 @@ var Platform;
|
|
|
263
236
|
var castWebType = function castWebType(value) {
|
|
264
237
|
return value;
|
|
265
238
|
};
|
|
239
|
+
|
|
266
240
|
/**
|
|
267
241
|
* @description
|
|
268
242
|
*
|
|
@@ -277,8 +251,6 @@ var castWebType = function castWebType(value) {
|
|
|
277
251
|
* // ^ number
|
|
278
252
|
* ```
|
|
279
253
|
*/
|
|
280
|
-
|
|
281
|
-
|
|
282
254
|
var castNativeType = function castNativeType(value) {
|
|
283
255
|
return value;
|
|
284
256
|
};
|
|
@@ -287,7 +259,6 @@ function makeBorderSize(size) {
|
|
|
287
259
|
if (typeof size === 'number') {
|
|
288
260
|
return "".concat(size, "px");
|
|
289
261
|
}
|
|
290
|
-
|
|
291
262
|
return size;
|
|
292
263
|
}
|
|
293
264
|
|
|
@@ -322,7 +293,6 @@ var toTitleCase = function toTitleCase(inputString) {
|
|
|
322
293
|
* @see {@link https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state}
|
|
323
294
|
* @deprecated This utility will be deprecated in subsequent version.
|
|
324
295
|
*/
|
|
325
|
-
|
|
326
296
|
function usePrevious(value) {
|
|
327
297
|
var ref = useRef();
|
|
328
298
|
useEffect(function () {
|
|
@@ -340,10 +310,8 @@ var ThemeContext = /*#__PURE__*/createContext({
|
|
|
340
310
|
return null;
|
|
341
311
|
}
|
|
342
312
|
});
|
|
343
|
-
|
|
344
313
|
var useTheme = function useTheme() {
|
|
345
314
|
var themeContext = useContext(ThemeContext);
|
|
346
|
-
|
|
347
315
|
{
|
|
348
316
|
if (!themeContext.theme) {
|
|
349
317
|
throwBladeError({
|
|
@@ -351,7 +319,6 @@ var useTheme = function useTheme() {
|
|
|
351
319
|
moduleName: 'BladeProvider'
|
|
352
320
|
});
|
|
353
321
|
}
|
|
354
|
-
|
|
355
322
|
if (themeContext === undefined) {
|
|
356
323
|
throwBladeError({
|
|
357
324
|
message: 'useTheme must be used within BladeProvider',
|
|
@@ -359,7 +326,6 @@ var useTheme = function useTheme() {
|
|
|
359
326
|
});
|
|
360
327
|
}
|
|
361
328
|
}
|
|
362
|
-
|
|
363
329
|
return themeContext;
|
|
364
330
|
};
|
|
365
331
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.development.web.js","sources":["../../src/utils/getColorScheme/getColorScheme.web.ts","../../src/utils/getMediaQuery/getMediaQuery.ts","../../src/utils/getPlatformType/getPlatformType.ts","../../src/utils/useBreakpoint/useBreakpoint.ts","../../src/tokens/theme/theme.ts","../../src/utils/logger/logger.ts","../../src/utils/useColorScheme/useColorScheme.ts","../../src/utils/platform/isReactNative.ts","../../src/utils/platform/getOS.web.ts","../../src/utils/platform/platform.ts","../../src/utils/platform/castUtils.ts","../../src/utils/makeBorderSize/makeBorderSize.ts","../../src/utils/makeMotionTime/makeMotionTime.web.ts","../../src/utils/makeSpace/makeSpace.ts","../../src/utils/makeTypographySize/makeTypographySize.web.ts","../../src/utils/makeSize/makeSize.ts","../../src/utils/toTitleCase/toTitleCase.ts","../../src/utils/usePrevious/usePrevious.ts","../../src/components/BladeProvider/useTheme.ts"],"sourcesContent":["import type { ColorSchemeNames, ColorSchemeNamesInput } from '~tokens/theme';\n\nexport const getColorScheme = (colorScheme: ColorSchemeNamesInput = 'light'): ColorSchemeNames => {\n // @TODO: create a useMediaQuery hook with an event listener which will subscribe to changes and move all this logic there\n const colorSchemeMediaQueryMap = {\n light: '(prefers-color-scheme: light)',\n dark: '(prefers-color-scheme: dark)',\n system: 'default',\n };\n const supportsMatchMedia =\n typeof window !== 'undefined' && typeof window.matchMedia === 'function';\n\n if (colorScheme === 'light' || colorScheme === 'dark') {\n return colorScheme;\n }\n\n if (\n colorScheme === 'system' &&\n supportsMatchMedia &&\n window.matchMedia(colorSchemeMediaQueryMap.dark).matches\n ) {\n return 'dark';\n }\n\n return 'light';\n};\n","export const getMediaQuery = ({ min, max }: { min: number; max?: number }): string => {\n return `screen and (min-width: ${min}px)${max ? ` and (max-width: ${max}px)` : ''}`;\n};\n","export type PlatformTypes = 'browser' | 'node' | 'react-native' | 'unknown';\n\nexport const getPlatformType = (): PlatformTypes => {\n if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {\n return 'react-native';\n }\n\n if (typeof document !== 'undefined') {\n return 'browser';\n }\n\n if (typeof process !== 'undefined') {\n return 'node';\n }\n\n return 'unknown';\n};\n","/* eslint-disable @typescript-eslint/restrict-plus-operands */\nimport { useEffect, useState, useCallback, useMemo } from 'react';\nimport { getPlatformType } from '../getPlatformType';\nimport { getMediaQuery } from '../getMediaQuery';\nimport type { Breakpoints } from '~tokens/global';\n\nconst deviceType = {\n desktop: 'desktop',\n mobile: 'mobile',\n} as const;\n\ntype DeviceType = keyof typeof deviceType;\ntype Breakpoint = keyof Breakpoints | undefined;\n\ntype BreakpointAndDevice = {\n matchedBreakpoint: Breakpoint;\n matchedDeviceType: DeviceType;\n};\n\nexport const useBreakpoint = ({\n breakpoints,\n}: {\n breakpoints: Breakpoints;\n}): BreakpointAndDevice => {\n const supportsMatchMedia =\n typeof document !== 'undefined' &&\n typeof window !== 'undefined' &&\n typeof window?.matchMedia === 'function';\n\n const breakpointsTokenAndQueryCollection = useMemo(\n () =>\n (supportsMatchMedia\n ? Object.entries(breakpoints).map(([token, screenSize], index, breakpointsArray) => {\n const min = screenSize;\n const maxValue = breakpointsArray[index + 1]?.[1];\n const mediaQuery = getMediaQuery({ min, max: maxValue ? maxValue - 1 : undefined });\n return { token, screenSize, mediaQuery };\n })\n : []) as {\n token: keyof Breakpoints;\n screenSize: number;\n mediaQuery: string;\n }[],\n [breakpoints, supportsMatchMedia],\n );\n\n const getMatchedDeviceType = useCallback((matchedBreakpoint: Breakpoint): DeviceType => {\n let matchedDeviceType: DeviceType = deviceType.mobile;\n const platform = getPlatformType();\n if (platform === 'react-native') {\n matchedDeviceType = deviceType.mobile;\n } else if (platform === 'browser') {\n if (matchedBreakpoint && ['base', 'xs', 's'].includes(matchedBreakpoint)) {\n // tablet is also categorised as mobile\n matchedDeviceType = deviceType.mobile;\n } else {\n matchedDeviceType = deviceType.desktop;\n }\n } else if (platform === 'node') {\n //@TODO: Check for useragent for node\n matchedDeviceType = deviceType.desktop;\n }\n return matchedDeviceType;\n }, []);\n\n const getMatchedBreakpoint = useCallback(\n (event?: MediaQueryListEvent): Breakpoint => {\n const matchedBreakpoint =\n breakpointsTokenAndQueryCollection.find(({ mediaQuery = '' }) => {\n // this will run whenever mediaQuery change event is triggered\n if (event?.media === mediaQuery) {\n return true;\n }\n // 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\n if (window.matchMedia(mediaQuery).matches) {\n return true;\n }\n return false;\n })?.token ?? undefined;\n\n return matchedBreakpoint;\n },\n [breakpointsTokenAndQueryCollection],\n );\n\n const [breakpointAndDevice, setBreakpointAndDevice] = useState(() => {\n const matchedBreakpoint = getMatchedBreakpoint();\n const matchedDeviceType = getMatchedDeviceType(matchedBreakpoint);\n return {\n matchedBreakpoint,\n matchedDeviceType,\n };\n });\n\n useEffect(() => {\n if (!supportsMatchMedia) {\n return undefined;\n }\n\n const handleMediaQueryChange = (event: MediaQueryListEvent): void => {\n setBreakpointAndDevice(() => {\n const matchedBreakpoint = getMatchedBreakpoint(event);\n const matchedDeviceType = getMatchedDeviceType(matchedBreakpoint);\n\n return { matchedBreakpoint, matchedDeviceType };\n });\n };\n\n const mediaQueryInstances = breakpointsTokenAndQueryCollection.map(({ mediaQuery = '' }) => {\n const mediaQueryInstance = window.matchMedia(mediaQuery);\n /**\n * the mediaquery event listener is available on mediaQuery instances and not `window`\n * we iterate over all the breakpoints we have, register each instance and store them as `mediaQueryInstances` so we can later unregister all of them.\n */\n if (mediaQueryInstance.addEventListener) {\n mediaQueryInstance.addEventListener('change', handleMediaQueryChange);\n } else {\n // In older browsers MediaQueryList do not yet inherit from EventTarget, So using addListener as fallback - https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/addListener\n mediaQueryInstance.addListener(handleMediaQueryChange);\n }\n return mediaQueryInstance;\n });\n\n return (): void => {\n mediaQueryInstances.forEach((mediaQueryInstance) => {\n if (mediaQueryInstance.removeEventListener) {\n mediaQueryInstance.removeEventListener('change', handleMediaQueryChange);\n } else {\n // In older browsers MediaQueryList do not yet inherit from EventTarget, So using removeListener as fallback - https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/removeListener\n mediaQueryInstance.removeListener(handleMediaQueryChange);\n }\n });\n };\n }, [\n breakpointsTokenAndQueryCollection,\n getMatchedBreakpoint,\n getMatchedDeviceType,\n supportsMatchMedia,\n ]);\n\n // @TODO: handle SSR scenarios\n return breakpointAndDevice;\n};\n","import type { StringWithAutocomplete } from '~utils/types';\nimport type {\n Border,\n Breakpoints,\n Motion,\n Spacing,\n TypographyWithPlatforms,\n ElevationWithColorModes,\n} from '~tokens/global';\n\nexport type ColorSchemeNames = 'dark' | 'light';\nexport type ColorSchemeNamesInput = ColorSchemeNames | 'system';\n\nexport type ColorSchemeModes = 'onDark' | 'onLight';\n\nexport type TextTypes = 'muted' | 'normal' | 'placeholder' | 'subdued' | 'subtle';\n\nexport type ColorContrastTypes = 'low' | 'high';\n\nexport type Feedback = 'information' | 'negative' | 'neutral' | 'notice' | 'positive';\n\nexport type ColorContrast = {\n [K in ColorContrastTypes as `${Extract<K, string>}Contrast`]: string;\n};\n\n// @TODO: this shall rather be Surface = 'level1' | 'level2' | 'level3' to keep in sync with color tokens\nexport type SurfaceLevels = 1 | 2 | 3;\n\nexport type ActionStates = {\n default: string;\n hover: string;\n focus: string;\n active: string;\n disabled: string;\n};\n\nexport type LinkActionStates = ActionStates & {\n visited: string;\n};\n\nexport type ActionStatesWithContrast = {\n default: ColorContrast;\n hover: ColorContrast;\n focus: ColorContrast;\n active: ColorContrast;\n disabled: ColorContrast;\n};\n\nexport type LinkActionStatesWithContrast = ActionStatesWithContrast & {\n visited: ColorContrast;\n};\n\nexport type ActionVariants = {\n primary: ActionStates;\n secondary: ActionStates;\n tertiary: ActionStates;\n link: LinkActionStates;\n};\n\nexport type ActionVariantsWithContrast = {\n primary: ActionStatesWithContrast;\n secondary: ActionStatesWithContrast;\n tertiary: ActionStatesWithContrast;\n link: ActionStatesWithContrast;\n};\n\n// export type ActionProperties = {\n// background: ActionVariants;\n// border: ActionVariants;\n// text: ActionVariants;\n// icon: ActionVariants;\n// };\n\nexport type FeedbackActions = {\n background: Pick<ActionVariantsWithContrast, 'primary'>;\n border: Pick<ActionVariantsWithContrast, 'primary'>;\n text: Pick<ActionVariantsWithContrast, 'link' | 'primary'>;\n icon: Pick<ActionVariantsWithContrast, 'link' | 'primary'>;\n};\n\nexport type Colors = {\n brand: {\n primary: Record<300 | 400 | 500 | 600 | 700 | 800, string>;\n secondary: Record<500, string>;\n gray: Record<200 | 300 | 400 | 500 | 600 | 700 | 'a50' | 'a100', ColorContrast>;\n };\n feedback: {\n background: Record<Feedback, ColorContrast>;\n border: Record<Feedback, ColorContrast>;\n text: Record<Feedback, ColorContrast>;\n icon: Record<Feedback, ColorContrast>;\n positive: {\n action: FeedbackActions;\n };\n negative: {\n action: FeedbackActions;\n };\n information: {\n action: FeedbackActions;\n };\n notice: {\n action: FeedbackActions;\n };\n neutral: {\n action: FeedbackActions;\n };\n };\n surface: {\n background: Record<'level1' | 'level2' | 'level3', ColorContrast>;\n border: Record<'normal' | 'subtle', ColorContrast>;\n text: Record<TextTypes, ColorContrast>;\n action: {\n icon: ActionStatesWithContrast;\n };\n };\n overlay: Record<'background', string>;\n action: {\n background: Omit<ActionVariants, 'link'>;\n border: Omit<ActionVariants, 'link'>;\n text: ActionVariants;\n icon: ActionVariants;\n };\n badge: {\n background: {\n blue: ColorContrast;\n };\n border: {\n blue: ColorContrast;\n };\n text: {\n blue: ColorContrast;\n };\n icon: {\n blue: ColorContrast;\n };\n };\n};\n\nexport type ColorsWithModes = Record<ColorSchemeModes, Colors>;\n\nexport type ThemeTokens = {\n name: 'paymentTheme' | 'bankingTheme' | StringWithAutocomplete; // Can be used to watch over state changes between theme without watching over entire theme object\n border: Border;\n breakpoints: Breakpoints;\n colors: ColorsWithModes;\n motion: Motion;\n elevation: ElevationWithColorModes;\n spacing: Spacing;\n typography: TypographyWithPlatforms;\n};\n\nexport type SpacingValues = `${Spacing[keyof Spacing]}px`;\nexport type BorderWidthValues = `${Border['width'][keyof Border['width']]}px`;\nexport type BorderRadiusValues =\n | `${Border['radius'][Exclude<keyof Border['radius'], 'round'>]}px`\n | `${Border['radius'][Extract<keyof Border['radius'], 'round'>]}`;\n\nexport const colorSchemeNamesInput: ColorSchemeNamesInput[] = ['light', 'dark', 'system'];\n","type LogType = 'error' | 'warn' | 'log';\n\ntype LoggerOptions = {\n message: string;\n moduleName?: string;\n type: LogType;\n};\n\ntype ThrowBladeErrorOptions = {\n message: string;\n moduleName?: string;\n};\n\nconst PREFIX = '[Blade]:';\n\nconst throwBladeError = ({ message, moduleName }: ThrowBladeErrorOptions): void | never => {\n if (__DEV__) {\n const prefix = moduleName ? `[Blade: ${moduleName}]:` : PREFIX;\n throw new Error(`${prefix} ${message}`);\n }\n};\n\nconst getCommonLogger = (\n type: LogType,\n): typeof console.log | typeof console.error | typeof console.warn => {\n switch (type) {\n case 'error':\n return console.error;\n case 'warn':\n return console.warn;\n case 'log':\n default:\n return console.log;\n }\n};\n\nconst logger = ({ message, moduleName, type }: LoggerOptions): void => {\n if (__DEV__) {\n const prefix = moduleName ? `[Blade: ${moduleName}]:` : PREFIX;\n getCommonLogger(type)(`${prefix} ${message}`);\n }\n};\n\nexport { throwBladeError, logger };\n","import { useState, useCallback } from 'react';\nimport { getColorScheme } from '../getColorScheme';\nimport { colorSchemeNamesInput } from '~tokens/theme/theme';\nimport type { ColorSchemeNames, ColorSchemeNamesInput } from '~tokens/theme';\nimport { throwBladeError } from '~utils/logger';\n\nexport type UseColorScheme = {\n colorScheme: ColorSchemeNames;\n setColorScheme: (colorScheme: ColorSchemeNamesInput) => void;\n};\n\nexport const useColorScheme = (\n initialColorScheme: ColorSchemeNamesInput = 'light',\n): UseColorScheme => {\n // if colorScheme defined use that else fallback to 'light'\n const [colorSchemeState, setColorSchemeState] = useState<ColorSchemeNames>(() =>\n getColorScheme(initialColorScheme),\n );\n\n const setColorScheme = useCallback(function setThemeMode(colorScheme: ColorSchemeNamesInput) {\n if (__DEV__) {\n if (!colorSchemeNamesInput.includes(colorScheme)) {\n throwBladeError({\n message: `Expected color scheme to be one of [${colorSchemeNamesInput.toString()}] but received ${colorScheme}`,\n moduleName: 'useColorScheme',\n });\n }\n }\n setColorSchemeState(getColorScheme(colorScheme));\n }, []);\n\n return {\n colorScheme: colorSchemeState,\n setColorScheme,\n };\n};\n","/* eslint-disable @typescript-eslint/no-namespace */\nimport { getPlatformType } from '../getPlatformType';\n\nconst isReactNative = (): boolean => {\n return getPlatformType() === 'react-native';\n};\n\nexport { isReactNative };\n","import type { Platform } from 'react-native';\n\nexport const getOS = (): typeof Platform.OS => {\n return 'web';\n};\n\nexport const isAndroid = (): boolean => false;\n","/* eslint-disable @typescript-eslint/no-namespace */\nimport type { Brand, NativeOrWebBrand } from './types';\n\nnamespace Platform {\n export type Name = 'web';\n /**\n * Right now, the module resolution is set to resolve `.web` files,\n *\n * Thus Platform.Select<> type will return the `web` type\n */\n export type Select<Options extends { web: unknown; native: unknown }> = Brand<\n Options[Name],\n 'platform-web'\n >;\n\n export type CastNative<T extends NativeOrWebBrand | undefined> = Extract<\n T,\n { __brand__?: 'platform-native' | 'platform-all' }\n >;\n\n export type CastWeb<T extends NativeOrWebBrand | undefined> = Extract<\n T,\n { __brand__?: 'platform-web' | 'platform-all' }\n >;\n}\n\nexport { Platform };\n","import type { Platform } from '.';\n\n/**\n * @description\n *\n * Casts a Platform.Select<> type to web type\n *\n * @example\n *\n * ```ts\n * type Example = Platform.Select<{ web: string; native: number }>;\n *\n * const extractedWebType = castWebType('' as Example);\n * // ^ string\n * ```\n */\nconst castWebType = <T>(value: T): Platform.CastWeb<T> => {\n return value as Platform.CastWeb<typeof value>;\n};\n\n/**\n * @description\n *\n * Casts a Platform.Select<> type to native type\n *\n * @example\n *\n * ```ts\n * type Example = Platform.Select<{ web: string; native: number }>;\n *\n * const extractedNativeType = castNativeType('' as Example);\n * // ^ number\n * ```\n */\nconst castNativeType = <T>(value: T): Platform.CastNative<T> => {\n return value as Platform.CastNative<typeof value>;\n};\n\nexport { castWebType, castNativeType };\n","export function makeBorderSize<T extends number>(size: T): `${T}px`;\nexport function makeBorderSize<T extends string>(size: T): T;\nexport function makeBorderSize<T extends number | string>(size: T): `${T}px` | T {\n if (typeof size === 'number') {\n return `${size}px`;\n }\n return size;\n}\n","import type { MakeMotionTime } from './types';\nimport type { Platform } from '~utils';\n\nexport const makeMotionTime = <T extends number>(time: T): Platform.CastWeb<MakeMotionTime<T>> => {\n return `${time}ms`;\n};\n","export const makeSpace = <T extends number>(size: T): `${T}px` => {\n return `${size}px`;\n};\n","export const makeTypographySize = (size: number): `${number}rem` => {\n const remValue = size / 16;\n return `${remValue}rem`;\n};\n","export type MakeSize<T extends number> = `${T}px`;\n\nexport const makeSize = <T extends number>(size: T): `${T}px` => {\n return `${size}px`;\n};\n","/**\n * @deprecated This utility will be deprecated in subsequent version.\n */\nexport const toTitleCase = (inputString: string): string =>\n inputString\n .toLowerCase()\n .split(' ')\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' ');\n","import type { MutableRefObject } from 'react';\nimport { useEffect, useRef } from 'react';\n\n/**\n * a type-safe version of the `usePrevious` hook described here:\n * @see {@link https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state}\n * @deprecated This utility will be deprecated in subsequent version.\n */\nexport function usePrevious<T>(value: T): MutableRefObject<T | undefined>['current'] {\n const ref = useRef<T>();\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n","import { useContext, createContext } from 'react';\nimport type { UseColorScheme } from '../../utils/useColorScheme';\nimport type { Theme } from './';\nimport type { TypographyPlatforms } from '~tokens/global';\nimport { throwBladeError } from '~utils/logger';\n\nexport type ThemeContext = UseColorScheme & {\n theme: Theme;\n platform: TypographyPlatforms;\n};\n\nexport const ThemeContext = createContext<ThemeContext>({\n // @ts-expect-error set null\n theme: null,\n colorScheme: 'light',\n platform: 'onDesktop',\n setColorScheme: () => null,\n});\n\nconst useTheme = (): ThemeContext => {\n const themeContext = useContext<ThemeContext>(ThemeContext);\n if (__DEV__) {\n if (!themeContext.theme) {\n throwBladeError({\n message: 'BladeProvider is missing theme',\n moduleName: 'BladeProvider',\n });\n }\n if (themeContext === undefined) {\n throwBladeError({\n message: 'useTheme must be used within BladeProvider',\n moduleName: 'BladeProvider',\n });\n }\n }\n return themeContext;\n};\n\nexport default useTheme;\n"],"names":["getColorScheme","colorScheme","colorSchemeMediaQueryMap","light","dark","system","supportsMatchMedia","window","matchMedia","matches","getMediaQuery","min","max","getPlatformType","navigator","product","document","process","deviceType","desktop","mobile","useBreakpoint","breakpoints","breakpointsTokenAndQueryCollection","useMemo","Object","entries","map","index","breakpointsArray","token","screenSize","maxValue","mediaQuery","undefined","getMatchedDeviceType","useCallback","matchedBreakpoint","matchedDeviceType","platform","includes","getMatchedBreakpoint","event","find","media","useState","breakpointAndDevice","setBreakpointAndDevice","useEffect","handleMediaQueryChange","mediaQueryInstances","mediaQueryInstance","addEventListener","addListener","forEach","removeEventListener","removeListener","colorSchemeNamesInput","PREFIX","throwBladeError","message","moduleName","prefix","Error","useColorScheme","initialColorScheme","colorSchemeState","setColorSchemeState","setColorScheme","setThemeMode","toString","isReactNative","getOS","isAndroid","Platform","castWebType","value","castNativeType","makeBorderSize","size","makeMotionTime","time","makeSpace","makeTypographySize","remValue","makeSize","toTitleCase","inputString","toLowerCase","split","word","charAt","toUpperCase","slice","join","usePrevious","ref","useRef","current","ThemeContext","createContext","theme","useTheme","themeContext","useContext"],"mappings":";;;IAEaA,cAAc,GAAG,SAAjBA,cAAiB,GAAoE;AAAA,MAAnEC,WAAmE,uEAA9B,OAA8B;AAChG;AACA,MAAMC,wBAAwB,GAAG;AAC/BC,IAAAA,KAAK,EAAE,+BADwB;AAE/BC,IAAAA,IAAI,EAAE,8BAFyB;AAG/BC,IAAAA,MAAM,EAAE;AAHuB,GAAjC;AAKA,MAAMC,kBAAkB,GACtB,OAAOC,MAAP,KAAkB,WAAlB,IAAiC,OAAOA,MAAM,CAACC,UAAd,KAA6B,UADhE;;AAGA,MAAIP,WAAW,KAAK,OAAhB,IAA2BA,WAAW,KAAK,MAA/C,EAAuD;AACrD,WAAOA,WAAP;AACD;;AAED,MACEA,WAAW,KAAK,QAAhB,IACAK,kBADA,IAEAC,MAAM,CAACC,UAAP,CAAkBN,wBAAwB,CAACE,IAA3C,EAAiDK,OAHnD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HyC;AAItDsC,EAAAA,QAAQ,EAAE,WAJ4C;AAKtD6B,EAAAA,cAAc,EAAE;AAAA,WAAM,IAAN;AAAA;AALsC,CAAf;;IAQnCkC,QAAQ,GAAG,SAAXA,QAAW,GAAoB;AACnC,MAAMC,YAAY,GAAGC,UAAU,CAAeL,YAAf,CAA/B;;AACA,EAAa;AACX,QAAI,CAACI,YAAY,CAACF,KAAlB,EAAyB;AACvB1C,MAAAA,eAAe,CAAC;AACdC,QAAAA,OAAO,EAAE,gCADK;AAEdC,QAAAA,UAAU,EAAE;AAFE,OAAD,CAAf;AAID;;AACD,QAAI0C,YAAY,KAAKrE,SAArB,EAAgC;AAC9ByB,MAAAA,eAAe,CAAC;AACdC,QAAAA,OAAO,EAAE,4CADK;AAEdC,QAAAA,UAAU,EAAE;AAFE,OAAD,CAAf;AAID;AACF;;AACD,SAAO0C,YAAP;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"index.development.web.js","sources":["../../src/utils/getColorScheme/getColorScheme.web.ts","../../src/utils/getMediaQuery/getMediaQuery.ts","../../src/utils/getPlatformType/getPlatformType.ts","../../src/utils/useBreakpoint/useBreakpoint.ts","../../src/tokens/theme/theme.ts","../../src/utils/logger/logger.ts","../../src/utils/useColorScheme/useColorScheme.ts","../../src/utils/platform/isReactNative.ts","../../src/utils/platform/getOS.web.ts","../../src/utils/platform/platform.ts","../../src/utils/platform/castUtils.ts","../../src/utils/makeBorderSize/makeBorderSize.ts","../../src/utils/makeMotionTime/makeMotionTime.web.ts","../../src/utils/makeSpace/makeSpace.ts","../../src/utils/makeTypographySize/makeTypographySize.web.ts","../../src/utils/makeSize/makeSize.ts","../../src/utils/toTitleCase/toTitleCase.ts","../../src/utils/usePrevious/usePrevious.ts","../../src/components/BladeProvider/useTheme.ts"],"sourcesContent":["import type { ColorSchemeNames, ColorSchemeNamesInput } from '~tokens/theme';\n\nexport const getColorScheme = (colorScheme: ColorSchemeNamesInput = 'light'): ColorSchemeNames => {\n // @TODO: create a useMediaQuery hook with an event listener which will subscribe to changes and move all this logic there\n const colorSchemeMediaQueryMap = {\n light: '(prefers-color-scheme: light)',\n dark: '(prefers-color-scheme: dark)',\n system: 'default',\n };\n const supportsMatchMedia =\n typeof window !== 'undefined' && typeof window.matchMedia === 'function';\n\n if (colorScheme === 'light' || colorScheme === 'dark') {\n return colorScheme;\n }\n\n if (\n colorScheme === 'system' &&\n supportsMatchMedia &&\n window.matchMedia(colorSchemeMediaQueryMap.dark).matches\n ) {\n return 'dark';\n }\n\n return 'light';\n};\n","export const getMediaQuery = ({ min, max }: { min: number; max?: number }): string => {\n return `screen and (min-width: ${min}px)${max ? ` and (max-width: ${max}px)` : ''}`;\n};\n","export type PlatformTypes = 'browser' | 'node' | 'react-native' | 'unknown';\n\nexport const getPlatformType = (): PlatformTypes => {\n if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {\n return 'react-native';\n }\n\n if (typeof document !== 'undefined') {\n return 'browser';\n }\n\n if (typeof process !== 'undefined') {\n return 'node';\n }\n\n return 'unknown';\n};\n","/* eslint-disable @typescript-eslint/restrict-plus-operands */\nimport { useEffect, useState, useCallback, useMemo } from 'react';\nimport { getPlatformType } from '../getPlatformType';\nimport { getMediaQuery } from '../getMediaQuery';\nimport type { Breakpoints } from '~tokens/global';\n\nconst deviceType = {\n desktop: 'desktop',\n mobile: 'mobile',\n} as const;\n\ntype DeviceType = keyof typeof deviceType;\ntype Breakpoint = keyof Breakpoints | undefined;\n\ntype BreakpointAndDevice = {\n matchedBreakpoint: Breakpoint;\n matchedDeviceType: DeviceType;\n};\n\nexport const useBreakpoint = ({\n breakpoints,\n}: {\n breakpoints: Breakpoints;\n}): BreakpointAndDevice => {\n const supportsMatchMedia =\n typeof document !== 'undefined' &&\n typeof window !== 'undefined' &&\n typeof window?.matchMedia === 'function';\n\n const breakpointsTokenAndQueryCollection = useMemo(\n () =>\n (supportsMatchMedia\n ? Object.entries(breakpoints).map(([token, screenSize], index, breakpointsArray) => {\n const min = screenSize;\n const maxValue = breakpointsArray[index + 1]?.[1];\n const mediaQuery = getMediaQuery({ min, max: maxValue ? maxValue - 1 : undefined });\n return { token, screenSize, mediaQuery };\n })\n : []) as {\n token: keyof Breakpoints;\n screenSize: number;\n mediaQuery: string;\n }[],\n [breakpoints, supportsMatchMedia],\n );\n\n const getMatchedDeviceType = useCallback((matchedBreakpoint: Breakpoint): DeviceType => {\n let matchedDeviceType: DeviceType = deviceType.mobile;\n const platform = getPlatformType();\n if (platform === 'react-native') {\n matchedDeviceType = deviceType.mobile;\n } else if (platform === 'browser') {\n if (matchedBreakpoint && ['base', 'xs', 's'].includes(matchedBreakpoint)) {\n // tablet is also categorised as mobile\n matchedDeviceType = deviceType.mobile;\n } else {\n matchedDeviceType = deviceType.desktop;\n }\n } else if (platform === 'node') {\n //@TODO: Check for useragent for node\n matchedDeviceType = deviceType.desktop;\n }\n return matchedDeviceType;\n }, []);\n\n const getMatchedBreakpoint = useCallback(\n (event?: MediaQueryListEvent): Breakpoint => {\n const matchedBreakpoint =\n breakpointsTokenAndQueryCollection.find(({ mediaQuery = '' }) => {\n // this will run whenever mediaQuery change event is triggered\n if (event?.media === mediaQuery) {\n return true;\n }\n // 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\n if (window.matchMedia(mediaQuery).matches) {\n return true;\n }\n return false;\n })?.token ?? undefined;\n\n return matchedBreakpoint;\n },\n [breakpointsTokenAndQueryCollection],\n );\n\n const [breakpointAndDevice, setBreakpointAndDevice] = useState(() => {\n const matchedBreakpoint = getMatchedBreakpoint();\n const matchedDeviceType = getMatchedDeviceType(matchedBreakpoint);\n return {\n matchedBreakpoint,\n matchedDeviceType,\n };\n });\n\n useEffect(() => {\n if (!supportsMatchMedia) {\n return undefined;\n }\n\n const handleMediaQueryChange = (event: MediaQueryListEvent): void => {\n setBreakpointAndDevice(() => {\n const matchedBreakpoint = getMatchedBreakpoint(event);\n const matchedDeviceType = getMatchedDeviceType(matchedBreakpoint);\n\n return { matchedBreakpoint, matchedDeviceType };\n });\n };\n\n const mediaQueryInstances = breakpointsTokenAndQueryCollection.map(({ mediaQuery = '' }) => {\n const mediaQueryInstance = window.matchMedia(mediaQuery);\n /**\n * the mediaquery event listener is available on mediaQuery instances and not `window`\n * we iterate over all the breakpoints we have, register each instance and store them as `mediaQueryInstances` so we can later unregister all of them.\n */\n if (mediaQueryInstance.addEventListener) {\n mediaQueryInstance.addEventListener('change', handleMediaQueryChange);\n } else {\n // In older browsers MediaQueryList do not yet inherit from EventTarget, So using addListener as fallback - https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/addListener\n mediaQueryInstance.addListener(handleMediaQueryChange);\n }\n return mediaQueryInstance;\n });\n\n return (): void => {\n mediaQueryInstances.forEach((mediaQueryInstance) => {\n if (mediaQueryInstance.removeEventListener) {\n mediaQueryInstance.removeEventListener('change', handleMediaQueryChange);\n } else {\n // In older browsers MediaQueryList do not yet inherit from EventTarget, So using removeListener as fallback - https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/removeListener\n mediaQueryInstance.removeListener(handleMediaQueryChange);\n }\n });\n };\n }, [\n breakpointsTokenAndQueryCollection,\n getMatchedBreakpoint,\n getMatchedDeviceType,\n supportsMatchMedia,\n ]);\n\n // @TODO: handle SSR scenarios\n return breakpointAndDevice;\n};\n","import type { StringWithAutocomplete } from '~utils/types';\nimport type {\n Border,\n Breakpoints,\n Motion,\n Spacing,\n TypographyWithPlatforms,\n ElevationWithColorModes,\n} from '~tokens/global';\n\nexport type ColorSchemeNames = 'dark' | 'light';\nexport type ColorSchemeNamesInput = ColorSchemeNames | 'system';\n\nexport type ColorSchemeModes = 'onDark' | 'onLight';\n\nexport type TextTypes = 'muted' | 'normal' | 'placeholder' | 'subdued' | 'subtle';\n\nexport type ColorContrastTypes = 'low' | 'high';\n\nexport type Feedback = 'information' | 'negative' | 'neutral' | 'notice' | 'positive';\n\nexport type ColorContrast = {\n [K in ColorContrastTypes as `${Extract<K, string>}Contrast`]: string;\n};\n\n// @TODO: this shall rather be Surface = 'level1' | 'level2' | 'level3' to keep in sync with color tokens\nexport type SurfaceLevels = 1 | 2 | 3;\n\nexport type ActionStates = {\n default: string;\n hover: string;\n focus: string;\n active: string;\n disabled: string;\n};\n\nexport type LinkActionStates = ActionStates & {\n visited: string;\n};\n\nexport type ActionStatesWithContrast = {\n default: ColorContrast;\n hover: ColorContrast;\n focus: ColorContrast;\n active: ColorContrast;\n disabled: ColorContrast;\n};\n\nexport type LinkActionStatesWithContrast = ActionStatesWithContrast & {\n visited: ColorContrast;\n};\n\nexport type ActionVariants = {\n primary: ActionStates;\n secondary: ActionStates;\n tertiary: ActionStates;\n link: LinkActionStates;\n};\n\nexport type ActionVariantsWithContrast = {\n primary: ActionStatesWithContrast;\n secondary: ActionStatesWithContrast;\n tertiary: ActionStatesWithContrast;\n link: ActionStatesWithContrast;\n};\n\n// export type ActionProperties = {\n// background: ActionVariants;\n// border: ActionVariants;\n// text: ActionVariants;\n// icon: ActionVariants;\n// };\n\nexport type FeedbackActions = {\n background: Pick<ActionVariantsWithContrast, 'primary'>;\n border: Pick<ActionVariantsWithContrast, 'primary'>;\n text: Pick<ActionVariantsWithContrast, 'link' | 'primary'>;\n icon: Pick<ActionVariantsWithContrast, 'link' | 'primary'>;\n};\n\nexport type Colors = {\n brand: {\n primary: Record<300 | 400 | 500 | 600 | 700 | 800, string>;\n secondary: Record<500, string>;\n gray: Record<200 | 300 | 400 | 500 | 600 | 700 | 'a50' | 'a100', ColorContrast>;\n };\n feedback: {\n background: Record<Feedback, ColorContrast>;\n border: Record<Feedback, ColorContrast>;\n text: Record<Feedback, ColorContrast>;\n icon: Record<Feedback, ColorContrast>;\n positive: {\n action: FeedbackActions;\n };\n negative: {\n action: FeedbackActions;\n };\n information: {\n action: FeedbackActions;\n };\n notice: {\n action: FeedbackActions;\n };\n neutral: {\n action: FeedbackActions;\n };\n };\n surface: {\n background: Record<'level1' | 'level2' | 'level3', ColorContrast>;\n border: Record<'normal' | 'subtle', ColorContrast>;\n text: Record<TextTypes, ColorContrast>;\n action: {\n icon: ActionStatesWithContrast;\n };\n };\n overlay: Record<'background', string>;\n action: {\n background: Omit<ActionVariants, 'link'>;\n border: Omit<ActionVariants, 'link'>;\n text: ActionVariants;\n icon: ActionVariants;\n };\n badge: {\n background: {\n blue: ColorContrast;\n };\n border: {\n blue: ColorContrast;\n };\n text: {\n blue: ColorContrast;\n };\n icon: {\n blue: ColorContrast;\n };\n };\n};\n\nexport type ColorsWithModes = Record<ColorSchemeModes, Colors>;\n\nexport type ThemeTokens = {\n name: 'paymentTheme' | 'bankingTheme' | StringWithAutocomplete; // Can be used to watch over state changes between theme without watching over entire theme object\n border: Border;\n breakpoints: Breakpoints;\n colors: ColorsWithModes;\n motion: Motion;\n elevation: ElevationWithColorModes;\n spacing: Spacing;\n typography: TypographyWithPlatforms;\n};\n\nexport type SpacingValues = `${Spacing[keyof Spacing]}px`;\nexport type BorderWidthValues = `${Border['width'][keyof Border['width']]}px`;\nexport type BorderRadiusValues =\n | `${Border['radius'][Exclude<keyof Border['radius'], 'round'>]}px`\n | `${Border['radius'][Extract<keyof Border['radius'], 'round'>]}`;\n\nexport const colorSchemeNamesInput: ColorSchemeNamesInput[] = ['light', 'dark', 'system'];\n","type LogType = 'error' | 'warn' | 'log';\n\ntype LoggerOptions = {\n message: string;\n moduleName?: string;\n type: LogType;\n};\n\ntype ThrowBladeErrorOptions = {\n message: string;\n moduleName?: string;\n};\n\nconst PREFIX = '[Blade]:';\n\nconst throwBladeError = ({ message, moduleName }: ThrowBladeErrorOptions): void | never => {\n if (__DEV__) {\n const prefix = moduleName ? `[Blade: ${moduleName}]:` : PREFIX;\n throw new Error(`${prefix} ${message}`);\n }\n};\n\nconst getCommonLogger = (\n type: LogType,\n): typeof console.log | typeof console.error | typeof console.warn => {\n switch (type) {\n case 'error':\n return console.error;\n case 'warn':\n return console.warn;\n case 'log':\n default:\n return console.log;\n }\n};\n\nconst logger = ({ message, moduleName, type }: LoggerOptions): void => {\n if (__DEV__) {\n const prefix = moduleName ? `[Blade: ${moduleName}]:` : PREFIX;\n getCommonLogger(type)(`${prefix} ${message}`);\n }\n};\n\nexport { throwBladeError, logger };\n","import { useState, useCallback } from 'react';\nimport { getColorScheme } from '../getColorScheme';\nimport { colorSchemeNamesInput } from '~tokens/theme/theme';\nimport type { ColorSchemeNames, ColorSchemeNamesInput } from '~tokens/theme';\nimport { throwBladeError } from '~utils/logger';\n\nexport type UseColorScheme = {\n colorScheme: ColorSchemeNames;\n setColorScheme: (colorScheme: ColorSchemeNamesInput) => void;\n};\n\nexport const useColorScheme = (\n initialColorScheme: ColorSchemeNamesInput = 'light',\n): UseColorScheme => {\n // if colorScheme defined use that else fallback to 'light'\n const [colorSchemeState, setColorSchemeState] = useState<ColorSchemeNames>(() =>\n getColorScheme(initialColorScheme),\n );\n\n const setColorScheme = useCallback(function setThemeMode(colorScheme: ColorSchemeNamesInput) {\n if (__DEV__) {\n if (!colorSchemeNamesInput.includes(colorScheme)) {\n throwBladeError({\n message: `Expected color scheme to be one of [${colorSchemeNamesInput.toString()}] but received ${colorScheme}`,\n moduleName: 'useColorScheme',\n });\n }\n }\n setColorSchemeState(getColorScheme(colorScheme));\n }, []);\n\n return {\n colorScheme: colorSchemeState,\n setColorScheme,\n };\n};\n","/* eslint-disable @typescript-eslint/no-namespace */\nimport { getPlatformType } from '../getPlatformType';\n\nconst isReactNative = (): boolean => {\n return getPlatformType() === 'react-native';\n};\n\nexport { isReactNative };\n","import type { Platform } from 'react-native';\n\nexport const getOS = (): typeof Platform.OS => {\n return 'web';\n};\n\nexport const isAndroid = (): boolean => false;\n","/* eslint-disable @typescript-eslint/no-namespace */\nimport type { Brand, NativeOrWebBrand } from './types';\n\nnamespace Platform {\n export type Name = 'web';\n /**\n * Right now, the module resolution is set to resolve `.web` files,\n *\n * Thus Platform.Select<> type will return the `web` type\n */\n export type Select<Options extends { web: unknown; native: unknown }> = Brand<\n Options[Name],\n 'platform-web'\n >;\n\n export type CastNative<T extends NativeOrWebBrand | undefined> = Extract<\n T,\n { __brand__?: 'platform-native' | 'platform-all' }\n >;\n\n export type CastWeb<T extends NativeOrWebBrand | undefined> = Extract<\n T,\n { __brand__?: 'platform-web' | 'platform-all' }\n >;\n}\n\nexport { Platform };\n","import type { Platform } from '.';\n\n/**\n * @description\n *\n * Casts a Platform.Select<> type to web type\n *\n * @example\n *\n * ```ts\n * type Example = Platform.Select<{ web: string; native: number }>;\n *\n * const extractedWebType = castWebType('' as Example);\n * // ^ string\n * ```\n */\nconst castWebType = <T>(value: T): Platform.CastWeb<T> => {\n return value as Platform.CastWeb<typeof value>;\n};\n\n/**\n * @description\n *\n * Casts a Platform.Select<> type to native type\n *\n * @example\n *\n * ```ts\n * type Example = Platform.Select<{ web: string; native: number }>;\n *\n * const extractedNativeType = castNativeType('' as Example);\n * // ^ number\n * ```\n */\nconst castNativeType = <T>(value: T): Platform.CastNative<T> => {\n return value as Platform.CastNative<typeof value>;\n};\n\nexport { castWebType, castNativeType };\n","export function makeBorderSize<T extends number>(size: T): `${T}px`;\nexport function makeBorderSize<T extends string>(size: T): T;\nexport function makeBorderSize<T extends number | string>(size: T): `${T}px` | T {\n if (typeof size === 'number') {\n return `${size}px`;\n }\n return size;\n}\n","import type { MakeMotionTime } from './types';\nimport type { Platform } from '~utils';\n\nexport const makeMotionTime = <T extends number>(time: T): Platform.CastWeb<MakeMotionTime<T>> => {\n return `${time}ms`;\n};\n","export const makeSpace = <T extends number>(size: T): `${T}px` => {\n return `${size}px`;\n};\n","export const makeTypographySize = (size: number): `${number}rem` => {\n const remValue = size / 16;\n return `${remValue}rem`;\n};\n","export type MakeSize<T extends number> = `${T}px`;\n\nexport const makeSize = <T extends number>(size: T): `${T}px` => {\n return `${size}px`;\n};\n","/**\n * @deprecated This utility will be deprecated in subsequent version.\n */\nexport const toTitleCase = (inputString: string): string =>\n inputString\n .toLowerCase()\n .split(' ')\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' ');\n","import type { MutableRefObject } from 'react';\nimport { useEffect, useRef } from 'react';\n\n/**\n * a type-safe version of the `usePrevious` hook described here:\n * @see {@link https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state}\n * @deprecated This utility will be deprecated in subsequent version.\n */\nexport function usePrevious<T>(value: T): MutableRefObject<T | undefined>['current'] {\n const ref = useRef<T>();\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n","import { useContext, createContext } from 'react';\nimport type { UseColorScheme } from '../../utils/useColorScheme';\nimport type { Theme } from './';\nimport type { TypographyPlatforms } from '~tokens/global';\nimport { throwBladeError } from '~utils/logger';\n\nexport type ThemeContext = UseColorScheme & {\n theme: Theme;\n platform: TypographyPlatforms;\n};\n\nexport const ThemeContext = createContext<ThemeContext>({\n // @ts-expect-error set null\n theme: null,\n colorScheme: 'light',\n platform: 'onDesktop',\n setColorScheme: () => null,\n});\n\nconst useTheme = (): ThemeContext => {\n const themeContext = useContext<ThemeContext>(ThemeContext);\n if (__DEV__) {\n if (!themeContext.theme) {\n throwBladeError({\n message: 'BladeProvider is missing theme',\n moduleName: 'BladeProvider',\n });\n }\n if (themeContext === undefined) {\n throwBladeError({\n message: 'useTheme must be used within BladeProvider',\n moduleName: 'BladeProvider',\n });\n }\n }\n return themeContext;\n};\n\nexport default useTheme;\n"],"names":["getColorScheme","colorScheme","arguments","length","undefined","colorSchemeMediaQueryMap","light","dark","system","supportsMatchMedia","window","matchMedia","matches","getMediaQuery","_ref","min","max","concat","getPlatformType","navigator","product","document","process","deviceType","desktop","mobile","useBreakpoint","_window","breakpoints","breakpointsTokenAndQueryCollection","useMemo","Object","entries","map","_ref2","index","breakpointsArray","_breakpointsArray","_ref3","_slicedToArray","token","screenSize","maxValue","mediaQuery","getMatchedDeviceType","useCallback","matchedBreakpoint","matchedDeviceType","platform","includes","getMatchedBreakpoint","event","_breakpointsTokenAndQ","_breakpointsTokenAndQ2","find","_ref4","_ref4$mediaQuery","media","_useState","useState","_useState2","breakpointAndDevice","setBreakpointAndDevice","useEffect","handleMediaQueryChange","mediaQueryInstances","_ref5","_ref5$mediaQuery","mediaQueryInstance","addEventListener","addListener","forEach","removeEventListener","removeListener","colorSchemeNamesInput","PREFIX","throwBladeError","message","moduleName","prefix","Error","useColorScheme","initialColorScheme","colorSchemeState","setColorSchemeState","setColorScheme","setThemeMode","toString","isReactNative","getOS","isAndroid","Platform","_Platform","castWebType","value","castNativeType","makeBorderSize","size","makeMotionTime","time","makeSpace","makeTypographySize","remValue","makeSize","toTitleCase","inputString","toLowerCase","split","word","charAt","toUpperCase","slice","join","usePrevious","ref","useRef","current","ThemeContext","createContext","theme","useTheme","themeContext","useContext"],"mappings":";;;IAEaA,cAAc,GAAG,SAAjBA,cAAcA,GAAuE;EAAA,IAAnEC,WAAkC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,OAAO;;EAEzE,IAAMG,wBAAwB,GAAG;IAC/BC,KAAK,EAAE,+BAA+B;IACtCC,IAAI,EAAE,8BAA8B;IACpCC,MAAM,EAAE;GACT;EACD,IAAMC,kBAAkB,GACtB,OAAOC,MAAM,KAAK,WAAW,IAAI,OAAOA,MAAM,CAACC,UAAU,KAAK,UAAU;EAE1E,IAAIV,WAAW,KAAK,OAAO,IAAIA,WAAW,KAAK,MAAM,EAAE;IACrD,OAAOA,WAAW;;EAGpB,IACEA,WAAW,KAAK,QAAQ,IACxBQ,kBAAkB,IAClBC,MAAM,CAACC,UAAU,CAACN,wBAAwB,CAACE,IAAI,CAAC,CAACK,OAAO,EACxD;IACA,OAAO,MAAM;;EAGf,OAAO,OAAO;AAChB;;ICzBaC,aAAa,GAAG,SAAhBA,aAAaA,CAAAC,IAAA,EAA4D;EAAA,IAAtDC,GAAG,GAAAD,IAAA,CAAHC,GAAG;IAAEC,GAAG,GAAAF,IAAA,CAAHE,GAAG;EACtC,iCAAAC,MAAA,CAAiCF,GAAG,SAAAE,MAA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AC;EAEX,OAAOoB,GAAG,CAACE,OAAO;AACpB;;ICLaC,YAAY,gBAAGC,aAAa,CAAe;;EAEtDC,KAAK,EAAE,IAAI;EACXtH,WAAW,EAAE,OAAO;EACpB+C,QAAQ,EAAE,WAAW;EACrBqC,cAAc,EAAE,SAAAA;IAAA,OAAM,IAAI;;AAC5B,CAAC;IAEKmC,QAAQ,GAAG,SAAXA,QAAQA,GAAuB;EACnC,IAAMC,YAAY,GAAGC,UAAU,CAAeL,YAAY,CAAC;EAC9C;IACX,IAAI,CAACI,YAAY,CAACF,KAAK,EAAE;MACvB3C,eAAe,CAAC;QACdC,OAAO,EAAE,gCAAgC;QACzCC,UAAU,EAAE;OACb,CAAC;;IAEJ,IAAI2C,YAAY,KAAKrH,SAAS,EAAE;MAC9BwE,eAAe,CAAC;QACdC,OAAO,EAAE,4CAA4C;QACrDC,UAAU,EAAE;OACb,CAAC;;;EAGN,OAAO2C,YAAY;AACrB;;;;"}
|
|
@@ -418,10 +418,10 @@ type Delay = {
|
|
|
418
418
|
xlong: 5000;
|
|
419
419
|
};
|
|
420
420
|
|
|
421
|
-
type
|
|
421
|
+
type EasingFactoryFn = { factory: () => (value: number) => number }; // similar to EasingFactoryFn of `react-native-reanimated`
|
|
422
422
|
type EasingType<Value extends string> = Platform$1.Select<{
|
|
423
423
|
web: Value;
|
|
424
|
-
native:
|
|
424
|
+
native: EasingFactoryFn;
|
|
425
425
|
}>;
|
|
426
426
|
|
|
427
427
|
type Easing = {
|
|
@@ -429,49 +429,49 @@ type Easing = {
|
|
|
429
429
|
standard: {
|
|
430
430
|
/** `cubic-bezier(0.5, 0, 0.3, 1.5)`
|
|
431
431
|
*
|
|
432
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
432
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
433
433
|
attentive: EasingType<'cubic-bezier(0.5, 0, 0.3, 1.5)'>;
|
|
434
434
|
/** `cubic-bezier(0.3, 0, 0.2, 1)`
|
|
435
435
|
*
|
|
436
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
436
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
437
437
|
effective: EasingType<'cubic-bezier(0.3, 0, 0.2, 1)'>;
|
|
438
438
|
/** `cubic-bezier(0.5, 0, 0, 1)`
|
|
439
439
|
*
|
|
440
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
440
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
441
441
|
revealing: EasingType<'cubic-bezier(0.5, 0, 0, 1)'>;
|
|
442
442
|
/** `cubic-bezier(1, 0.5, 0, 0.5)`
|
|
443
443
|
*
|
|
444
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
444
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
445
445
|
wary: EasingType<'cubic-bezier(1, 0.5, 0, 0.5)'>;
|
|
446
446
|
};
|
|
447
447
|
/** Easings for all entrance animations*/
|
|
448
448
|
entrance: {
|
|
449
449
|
/** `cubic-bezier(0.5, 0, 0.3, 1.5)`
|
|
450
450
|
*
|
|
451
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
451
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
452
452
|
attentive: EasingType<'cubic-bezier(0.5, 0, 0.3, 1.5)'>;
|
|
453
453
|
/** `cubic-bezier(0, 0, 0.2, 1)`
|
|
454
454
|
*
|
|
455
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
455
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
456
456
|
effective: EasingType<'cubic-bezier(0, 0, 0.2, 1)'>;
|
|
457
457
|
/** `cubic-bezier(0, 0, 0, 1)`
|
|
458
458
|
*
|
|
459
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
459
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
460
460
|
revealing: EasingType<'cubic-bezier(0, 0, 0, 1)'>;
|
|
461
461
|
};
|
|
462
462
|
/** Easings for all exit animations*/
|
|
463
463
|
exit: {
|
|
464
464
|
/** `cubic-bezier(0.7, 0, 0.5, 1)`
|
|
465
465
|
*
|
|
466
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
466
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
467
467
|
attentive: EasingType<'cubic-bezier(0.7, 0, 0.5, 1)'>;
|
|
468
468
|
/** `cubic-bezier(0.17, 0, 1, 1)`
|
|
469
469
|
*
|
|
470
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
470
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
471
471
|
effective: EasingType<'cubic-bezier(0.17, 0, 1, 1)'>;
|
|
472
472
|
/** `cubic-bezier(0.5, 0, 1, 1)`
|
|
473
473
|
*
|
|
474
|
-
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `
|
|
474
|
+
* Returns a `string` of `"cubic-bezier(...)"` for web & react-native-reanimated's Easing Function of type `EasingFactoryFn` for native */
|
|
475
475
|
revealing: EasingType<'cubic-bezier(0.5, 0, 1, 1)'>;
|
|
476
476
|
};
|
|
477
477
|
};
|
|
@@ -4,7 +4,7 @@ import { useMemo, useCallback, useState, useEffect, useRef, createContext, useCo
|
|
|
4
4
|
|
|
5
5
|
var getColorScheme=function getColorScheme(){var colorScheme=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'light';if(colorScheme==='light'||colorScheme==='dark'){return colorScheme;}if(colorScheme==='system'){var _Appearance$getColorS;return (_Appearance$getColorS=Appearance.getColorScheme())!=null?_Appearance$getColorS:'light';}return 'light';};
|
|
6
6
|
|
|
7
|
-
var getMediaQuery=function getMediaQuery(_ref){var min=_ref.min,max=_ref.max;return
|
|
7
|
+
var getMediaQuery=function getMediaQuery(_ref){var min=_ref.min,max=_ref.max;return `screen and (min-width: ${min}px)${max?` and (max-width: ${max}px)`:''}`;};
|
|
8
8
|
|
|
9
9
|
var getPlatformType=function getPlatformType(){if(typeof navigator!=='undefined'&&navigator.product==='ReactNative'){return 'react-native';}if(typeof document!=='undefined'){return 'browser';}if(typeof process!=='undefined'){return 'node';}return 'unknown';};
|
|
10
10
|
|
|
@@ -12,9 +12,9 @@ var deviceType={desktop:'desktop',mobile:'mobile'};var useBreakpoint=function us
|
|
|
12
12
|
|
|
13
13
|
var colorSchemeNamesInput=['light','dark','system'];
|
|
14
14
|
|
|
15
|
-
var PREFIX='[Blade]:';var throwBladeError=function throwBladeError(_ref){var message=_ref.message,moduleName=_ref.moduleName;if(__DEV__){var prefix=moduleName
|
|
15
|
+
var PREFIX='[Blade]:';var throwBladeError=function throwBladeError(_ref){var message=_ref.message,moduleName=_ref.moduleName;if(__DEV__){var prefix=moduleName?`[Blade: ${moduleName}]:`:PREFIX;throw new Error(`${prefix} ${message}`);}};
|
|
16
16
|
|
|
17
|
-
var useColorScheme=function useColorScheme(){var initialColorScheme=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'light';var _useState=useState(function(){return getColorScheme(initialColorScheme);}),_useState2=_slicedToArray(_useState,2),colorSchemeState=_useState2[0],setColorSchemeState=_useState2[1];var setColorScheme=useCallback(function setThemeMode(colorScheme){if(__DEV__){if(!colorSchemeNamesInput.includes(colorScheme)){throwBladeError({message
|
|
17
|
+
var useColorScheme=function useColorScheme(){var initialColorScheme=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'light';var _useState=useState(function(){return getColorScheme(initialColorScheme);}),_useState2=_slicedToArray(_useState,2),colorSchemeState=_useState2[0],setColorSchemeState=_useState2[1];var setColorScheme=useCallback(function setThemeMode(colorScheme){if(__DEV__){if(!colorSchemeNamesInput.includes(colorScheme)){throwBladeError({message:`Expected color scheme to be one of [${colorSchemeNamesInput.toString()}] but received ${colorScheme}`,moduleName:'useColorScheme'});}}setColorSchemeState(getColorScheme(colorScheme));},[]);return {colorScheme:colorSchemeState,setColorScheme:setColorScheme};};
|
|
18
18
|
|
|
19
19
|
var isReactNative=function isReactNative(){return getPlatformType()==='react-native';};
|
|
20
20
|
|
|
@@ -24,15 +24,15 @@ var Platform;(function(_Platform){})(Platform||(Platform={}));
|
|
|
24
24
|
|
|
25
25
|
var castWebType=function castWebType(value){return value;};var castNativeType=function castNativeType(value){return value;};
|
|
26
26
|
|
|
27
|
-
function makeBorderSize(size){if(typeof size==='number'){return size
|
|
27
|
+
function makeBorderSize(size){if(typeof size==='number'){return `${size}px`;}return size;}
|
|
28
28
|
|
|
29
29
|
var makeMotionTime=function makeMotionTime(time){return time;};
|
|
30
30
|
|
|
31
|
-
var makeSpace=function makeSpace(size){return size
|
|
31
|
+
var makeSpace=function makeSpace(size){return `${size}px`;};
|
|
32
32
|
|
|
33
|
-
var makeTypographySize=function makeTypographySize(size){return size
|
|
33
|
+
var makeTypographySize=function makeTypographySize(size){return `${size}px`;};
|
|
34
34
|
|
|
35
|
-
var makeSize=function makeSize(size){return size
|
|
35
|
+
var makeSize=function makeSize(size){return `${size}px`;};
|
|
36
36
|
|
|
37
37
|
var toTitleCase=function toTitleCase(inputString){return inputString.toLowerCase().split(' ').map(function(word){return word.charAt(0).toUpperCase()+word.slice(1);}).join(' ');};
|
|
38
38
|
|