@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.
@@ -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: T) => T;
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 declare function createWindowSizeHelper(currentWidth: number): WindowSizeHelper;
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":"AAAA,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,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,KAAK,CAAC,CAAC;IAEtH;;;;;;;;;;;;;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,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,gBAAgB,CAyB7E"}
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: number;
3
+ minWidth?: number;
3
4
  maxWidth?: number;
5
+ minHeight?: number;
6
+ maxHeight?: number;
4
7
  }
5
- export declare function matchWindowSize(currentWidth: number, { minWidth, maxWidth }: MatchWindowSizeOptions): boolean;
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":"AAEA,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AACD,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,sBAAsB,GAAG,OAAO,CAE7G;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAG3E"}
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(currentWidth, _ref) {
3372
- var minWidth = _ref.minWidth,
3373
- maxWidth = _ref.maxWidth;
3374
- return currentWidth >= minWidth && (!maxWidth || currentWidth <= maxWidth);
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(width, options);
3387
+ return matchWindowSize({
3388
+ width: width,
3389
+ height: height
3390
+ }, options);
3381
3391
  }
3382
3392
 
3383
- function createWindowSizeHelper(currentWidth) {
3393
+ function createWindowSizeHelper(dimensions) {
3384
3394
  return {
3385
3395
  matchWindowSize: function matchWindowSize$1(options) {
3386
- return matchWindowSize(currentWidth, options);
3396
+ return matchWindowSize(dimensions, options);
3387
3397
  },
3388
3398
  ifWindowSizeMatches: function ifWindowSizeMatches(options, valueIfTrue, valueIfFalse) {
3389
- return matchWindowSize(currentWidth, options) ? valueIfTrue : valueIfFalse;
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(currentWidth, {
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 _useWindowSize = useWindowDimensions(),
3426
- width = _useWindowSize.width;
3427
-
3435
+ var dimensions = useWindowDimensions();
3428
3436
  return useMemo(function () {
3429
3437
  return {
3430
3438
  kitt: theme,
3431
- responsive: createWindowSizeHelper(width),
3439
+ responsive: createWindowSizeHelper(dimensions),
3432
3440
  breakpoints: breakpoints
3433
3441
  };
3434
- }, [width]);
3442
+ }, [dimensions]);
3435
3443
  }
3436
3444
 
3437
3445
  function KittThemeProvider(_ref) {