@ornikar/kitt-universal 3.2.0 → 3.3.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/dist/definitions/utils/windowSize/createWindowSizeHelper.d.ts +7 -2
- package/dist/definitions/utils/windowSize/createWindowSizeHelper.d.ts.map +1 -1
- package/dist/definitions/utils/windowSize/useMatchWindowSize.d.ts +5 -2
- package/dist/definitions/utils/windowSize/useMatchWindowSize.d.ts.map +1 -1
- package/dist/index-browser-all.es.android.js +23 -15
- package/dist/index-browser-all.es.android.js.map +1 -1
- package/dist/index-browser-all.es.ios.js +23 -15
- package/dist/index-browser-all.es.ios.js.map +1 -1
- package/dist/index-browser-all.es.js +23 -15
- package/dist/index-browser-all.es.js.map +1 -1
- package/dist/index-browser-all.es.web.js +23 -15
- package/dist/index-browser-all.es.web.js.map +1 -1
- package/dist/index-node-14.17.cjs.js +24 -14
- package/dist/index-node-14.17.cjs.js.map +1 -1
- package/dist/index-node-14.17.cjs.web.js +24 -14
- package/dist/index-node-14.17.cjs.web.js.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FlattenSimpleInterpolation } from 'styled-components';
|
|
1
2
|
import type { MatchWindowSizeOptions } from './useMatchWindowSize';
|
|
2
3
|
export interface WindowSizeHelper {
|
|
3
4
|
/** Prefer using if or map variants, at it should be more web friendly */
|
|
@@ -15,7 +16,7 @@ export interface WindowSizeHelper {
|
|
|
15
16
|
* `;
|
|
16
17
|
* ```
|
|
17
18
|
*/
|
|
18
|
-
ifWindowSizeMatches: <T extends string | null>(options: MatchWindowSizeOptions, valueIfTrue: T, valueIfFalse
|
|
19
|
+
ifWindowSizeMatches: <T extends string | FlattenSimpleInterpolation | null>(options: MatchWindowSizeOptions, valueIfTrue: T, valueIfFalse?: T) => T | undefined;
|
|
19
20
|
/**
|
|
20
21
|
*
|
|
21
22
|
* @example
|
|
@@ -32,5 +33,9 @@ export interface WindowSizeHelper {
|
|
|
32
33
|
*/
|
|
33
34
|
mapWindowWidth: <V extends string>(...widthList: [number, V][]) => V | null;
|
|
34
35
|
}
|
|
35
|
-
export
|
|
36
|
+
export interface WindowDimensions {
|
|
37
|
+
width?: number;
|
|
38
|
+
height?: number;
|
|
39
|
+
}
|
|
40
|
+
export declare function createWindowSizeHelper(dimensions: WindowDimensions): WindowSizeHelper;
|
|
36
41
|
//# sourceMappingURL=createWindowSizeHelper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createWindowSizeHelper.d.ts","sourceRoot":"","sources":["../../../../src/utils/windowSize/createWindowSizeHelper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createWindowSizeHelper.d.ts","sourceRoot":"","sources":["../../../../src/utils/windowSize/createWindowSizeHelper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAGnE,MAAM,WAAW,gBAAgB;IAC/B,yEAAyE;IACzE,eAAe,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,OAAO,CAAC;IAE9D;;;;;;;;;;;;OAYG;IACH,mBAAmB,EAAE,CAAC,CAAC,SAAS,MAAM,GAAG,0BAA0B,GAAG,IAAI,EACxE,OAAO,EAAE,sBAAsB,EAC/B,WAAW,EAAE,CAAC,EACd,YAAY,CAAC,EAAE,CAAC,KACb,CAAC,GAAG,SAAS,CAAC;IAEnB;;;;;;;;;;;;;OAaG;IACH,cAAc,EAAE,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;CAC7E;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,gBAAgB,GAAG,gBAAgB,CAuBrF"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import type { WindowDimensions } from './createWindowSizeHelper';
|
|
1
2
|
export interface MatchWindowSizeOptions {
|
|
2
|
-
minWidth
|
|
3
|
+
minWidth?: number;
|
|
3
4
|
maxWidth?: number;
|
|
5
|
+
minHeight?: number;
|
|
6
|
+
maxHeight?: number;
|
|
4
7
|
}
|
|
5
|
-
export declare function matchWindowSize(
|
|
8
|
+
export declare function matchWindowSize({ width, height }: WindowDimensions, { minWidth, maxWidth, minHeight, maxHeight }: MatchWindowSizeOptions): boolean;
|
|
6
9
|
export declare function useMatchWindowSize(options: MatchWindowSizeOptions): boolean;
|
|
7
10
|
//# sourceMappingURL=useMatchWindowSize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMatchWindowSize.d.ts","sourceRoot":"","sources":["../../../../src/utils/windowSize/useMatchWindowSize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useMatchWindowSize.d.ts","sourceRoot":"","sources":["../../../../src/utils/windowSize/useMatchWindowSize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AACD,wBAAgB,eAAe,CAC7B,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,gBAAgB,EACnC,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,sBAAsB,GACnE,OAAO,CAIT;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAG3E"}
|
|
@@ -3368,25 +3368,35 @@ function TypographyLink(_ref4) {
|
|
|
3368
3368
|
}));
|
|
3369
3369
|
}
|
|
3370
3370
|
|
|
3371
|
-
function matchWindowSize(
|
|
3372
|
-
var
|
|
3373
|
-
|
|
3374
|
-
|
|
3371
|
+
function matchWindowSize(_ref, _ref2) {
|
|
3372
|
+
var width = _ref.width,
|
|
3373
|
+
height = _ref.height;
|
|
3374
|
+
var minWidth = _ref2.minWidth,
|
|
3375
|
+
maxWidth = _ref2.maxWidth,
|
|
3376
|
+
minHeight = _ref2.minHeight,
|
|
3377
|
+
maxHeight = _ref2.maxHeight;
|
|
3378
|
+
var hasWidthMatched = width ? (!minWidth || width >= minWidth) && (!maxWidth || width <= maxWidth) : true;
|
|
3379
|
+
var hasHeightMatched = height ? (!minHeight || height >= minHeight) && (!maxHeight || height <= maxHeight) : true;
|
|
3380
|
+
return hasWidthMatched && hasHeightMatched;
|
|
3375
3381
|
}
|
|
3376
3382
|
function useMatchWindowSize(options) {
|
|
3377
3383
|
var _useWindowDimensions = useWindowDimensions(),
|
|
3378
|
-
width = _useWindowDimensions.width
|
|
3384
|
+
width = _useWindowDimensions.width,
|
|
3385
|
+
height = _useWindowDimensions.height;
|
|
3379
3386
|
|
|
3380
|
-
return matchWindowSize(
|
|
3387
|
+
return matchWindowSize({
|
|
3388
|
+
width: width,
|
|
3389
|
+
height: height
|
|
3390
|
+
}, options);
|
|
3381
3391
|
}
|
|
3382
3392
|
|
|
3383
|
-
function createWindowSizeHelper(
|
|
3393
|
+
function createWindowSizeHelper(dimensions) {
|
|
3384
3394
|
return {
|
|
3385
3395
|
matchWindowSize: function matchWindowSize$1(options) {
|
|
3386
|
-
return matchWindowSize(
|
|
3396
|
+
return matchWindowSize(dimensions, options);
|
|
3387
3397
|
},
|
|
3388
3398
|
ifWindowSizeMatches: function ifWindowSizeMatches(options, valueIfTrue, valueIfFalse) {
|
|
3389
|
-
return matchWindowSize(
|
|
3399
|
+
return matchWindowSize(dimensions, options) ? valueIfTrue : valueIfFalse;
|
|
3390
3400
|
},
|
|
3391
3401
|
mapWindowWidth: function mapWindowWidth() {
|
|
3392
3402
|
for (var _len = arguments.length, widthList = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -3411,7 +3421,7 @@ function createWindowSizeHelper(currentWidth) {
|
|
|
3411
3421
|
minWidth = _ref4[0];
|
|
3412
3422
|
_ref4[1];
|
|
3413
3423
|
|
|
3414
|
-
return matchWindowSize(
|
|
3424
|
+
return matchWindowSize(dimensions, {
|
|
3415
3425
|
minWidth: Number(minWidth)
|
|
3416
3426
|
});
|
|
3417
3427
|
});
|
|
@@ -3422,16 +3432,14 @@ function createWindowSizeHelper(currentWidth) {
|
|
|
3422
3432
|
}
|
|
3423
3433
|
|
|
3424
3434
|
function useKittTheme() {
|
|
3425
|
-
var
|
|
3426
|
-
width = _useWindowSize.width;
|
|
3427
|
-
|
|
3435
|
+
var dimensions = useWindowDimensions();
|
|
3428
3436
|
return useMemo(function () {
|
|
3429
3437
|
return {
|
|
3430
3438
|
kitt: theme,
|
|
3431
|
-
responsive: createWindowSizeHelper(
|
|
3439
|
+
responsive: createWindowSizeHelper(dimensions),
|
|
3432
3440
|
breakpoints: breakpoints
|
|
3433
3441
|
};
|
|
3434
|
-
}, [
|
|
3442
|
+
}, [dimensions]);
|
|
3435
3443
|
}
|
|
3436
3444
|
|
|
3437
3445
|
function KittThemeProvider(_ref) {
|