@os-design/media 1.0.24 → 1.0.26
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.map +1 -0
- package/dist/{esm/index.js → index.js} +1 -2
- package/dist/media/index.d.ts.map +1 -0
- package/dist/{esm/media → media}/index.js +1 -2
- package/dist/useIsMaxWidth/index.d.ts +8 -0
- package/dist/useIsMaxWidth/index.d.ts.map +1 -0
- package/dist/{esm/useIsMaxWidth → useIsMaxWidth}/index.js +1 -2
- package/dist/useIsMinWidth/index.d.ts +8 -0
- package/dist/useIsMinWidth/index.d.ts.map +1 -0
- package/dist/{esm/useIsMinWidth → useIsMinWidth}/index.js +1 -2
- package/dist/useIsWidth/index.d.ts +7 -0
- package/dist/useIsWidth/index.d.ts.map +1 -0
- package/dist/{esm/useIsWidth → useIsWidth}/index.js +1 -2
- package/package.json +7 -8
- package/src/media/index.mdx +50 -0
- package/src/useIsMaxWidth/index.mdx +30 -0
- package/src/useIsMaxWidth/index.ts +1 -1
- package/src/useIsMinWidth/index.mdx +30 -0
- package/src/useIsMinWidth/index.ts +1 -1
- package/src/useIsWidth/index.mdx +30 -0
- package/dist/cjs/index.js +0 -55
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/media/index.js +0 -39
- package/dist/cjs/media/index.js.map +0 -1
- package/dist/cjs/useIsMaxWidth/index.js +0 -23
- package/dist/cjs/useIsMaxWidth/index.js.map +0 -1
- package/dist/cjs/useIsMinWidth/index.js +0 -23
- package/dist/cjs/useIsMinWidth/index.js.map +0 -1
- package/dist/cjs/useIsWidth/index.js +0 -43
- package/dist/cjs/useIsWidth/index.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/media/index.js.map +0 -1
- package/dist/esm/useIsMaxWidth/index.js.map +0 -1
- package/dist/esm/useIsMinWidth/index.js.map +0 -1
- package/dist/esm/useIsWidth/index.js.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/media/index.d.ts.map +0 -1
- package/dist/types/useIsMaxWidth/index.d.ts +0 -4
- package/dist/types/useIsMaxWidth/index.d.ts.map +0 -1
- package/dist/types/useIsMinWidth/index.d.ts +0 -4
- package/dist/types/useIsMinWidth/index.d.ts.map +0 -1
- package/dist/types/useIsWidth/index.d.ts +0 -3
- package/dist/types/useIsWidth/index.d.ts.map +0 -1
- /package/dist/{types/index.d.ts → index.d.ts} +0 -0
- /package/dist/{types/media → media}/index.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,CAAC,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AAErD,cAAc,SAAS,CAAC"}
|
|
@@ -2,5 +2,4 @@ export { default as m } from './media';
|
|
|
2
2
|
export { default as useIsMaxWidth } from './useIsMaxWidth';
|
|
3
3
|
export { default as useIsMinWidth } from './useIsMinWidth';
|
|
4
4
|
export { default as useIsWidth } from './useIsWidth';
|
|
5
|
-
export * from './media';
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
5
|
+
export * from './media';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/media/index.ts"],"names":[],"mappings":"AAAA,UAAU,WAAW;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AAED,KAAK,KAAK,CAAC,CAAC,IAAI;KACb,GAAG,IAAI,MAAM,CAAC,GAAG,MAAM;CACzB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AACtD,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AAEtD,eAAO,MAAM,cAAc,EAAE,cAO5B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cAO5B,CAAC;AAkBF,QAAA,MAAM,CAAC;;;CAGN,CAAC;AAEF,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type MaxBreakpoints } from '../media';
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether the width of the screen is less than or equal to
|
|
4
|
+
* the specified media breakpoint (for example, sm).
|
|
5
|
+
*/
|
|
6
|
+
declare const useIsMaxWidth: (breakpoint: keyof MaxBreakpoints) => boolean;
|
|
7
|
+
export default useIsMaxWidth;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useIsMaxWidth/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/D;;;GAGG;AACH,QAAA,MAAM,aAAa,eAAgB,MAAM,cAAc,KAAG,OAMzD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -10,5 +10,4 @@ const useIsMaxWidth = breakpoint => {
|
|
|
10
10
|
const detector = useCallback(width => width <= maxBreakpoints[breakpoint], [breakpoint]);
|
|
11
11
|
return useIsWidth(detector);
|
|
12
12
|
};
|
|
13
|
-
export default useIsMaxWidth;
|
|
14
|
-
//# sourceMappingURL=index.js.map
|
|
13
|
+
export default useIsMaxWidth;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type MinBreakpoints } from '../media';
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether the width of the screen is greater than or equal to
|
|
4
|
+
* the specified media breakpoint (for example, md).
|
|
5
|
+
*/
|
|
6
|
+
declare const useIsMinWidth: (breakpoint: keyof MinBreakpoints) => boolean;
|
|
7
|
+
export default useIsMinWidth;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useIsMinWidth/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,UAAU,CAAC;AAG/D;;;GAGG;AACH,QAAA,MAAM,aAAa,eAAgB,MAAM,cAAc,KAAG,OAMzD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -10,5 +10,4 @@ const useIsMinWidth = breakpoint => {
|
|
|
10
10
|
const detector = useCallback(width => width >= minBreakpoints[breakpoint], [breakpoint]);
|
|
11
11
|
return useIsWidth(detector);
|
|
12
12
|
};
|
|
13
|
-
export default useIsMinWidth;
|
|
14
|
-
//# sourceMappingURL=index.js.map
|
|
13
|
+
export default useIsMinWidth;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useIsWidth/index.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,QAAA,MAAM,UAAU,aAAc,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,KAAG,OAqB1D,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@os-design/media",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"repository": "git@gitlab.com:os-team/libs/os-design.git",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"types": "dist/
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
11
|
"src",
|
|
@@ -20,9 +20,8 @@
|
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"scripts": {
|
|
22
22
|
"clean": "rimraf dist",
|
|
23
|
-
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx --out-dir dist
|
|
24
|
-
"build:
|
|
25
|
-
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
|
|
23
|
+
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx --out-dir dist",
|
|
24
|
+
"build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly --declaration --declarationDir dist",
|
|
26
25
|
"build": "yarn clean && npm-run-all 'build:*'",
|
|
27
26
|
"ncu": "ncu -u"
|
|
28
27
|
},
|
|
@@ -32,5 +31,5 @@
|
|
|
32
31
|
"peerDependencies": {
|
|
33
32
|
"react": ">=18"
|
|
34
33
|
},
|
|
35
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "86a83e87297a07afe132782ca2c95023b7139276"
|
|
36
35
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Meta } from '@storybook/blocks';
|
|
2
|
+
import MediaExample from './index.example';
|
|
3
|
+
|
|
4
|
+
<Meta title='Media/m' />
|
|
5
|
+
|
|
6
|
+
# m
|
|
7
|
+
|
|
8
|
+
Generates media queries.
|
|
9
|
+
|
|
10
|
+
## Example of usage
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import styled from '@emotion/styled';
|
|
14
|
+
import { m } from '@os-design/media';
|
|
15
|
+
|
|
16
|
+
const MediaExample = styled.div`
|
|
17
|
+
width: 10em;
|
|
18
|
+
height: 10em;
|
|
19
|
+
background-color: hsl(0, 0%, 90%);
|
|
20
|
+
${m.min.md} {
|
|
21
|
+
background-color: hsl(0, 0%, 0%);
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
export default MediaExample;
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
<MediaExample />
|
|
29
|
+
|
|
30
|
+
If the screen width is greater than or equal to 786px (md), the square will be black, otherwise gray.
|
|
31
|
+
|
|
32
|
+
## Possible media queries
|
|
33
|
+
|
|
34
|
+
### Min width
|
|
35
|
+
|
|
36
|
+
- `m.min.xs` – @media (min-width: 480px)
|
|
37
|
+
- `m.min.sm` – @media (min-width: 576px)
|
|
38
|
+
- `m.min.md` – @media (min-width: 786px)
|
|
39
|
+
- `m.min.lg` – @media (min-width: 992px)
|
|
40
|
+
- `m.min.xl` – @media (min-width: 1200px)
|
|
41
|
+
- `m.min.xxl` – @media (min-width: 1600px)
|
|
42
|
+
|
|
43
|
+
### Max width
|
|
44
|
+
|
|
45
|
+
- `m.max.xxs` – @media (min-width: 479px)
|
|
46
|
+
- `m.max.xs` – @media (min-width: 575px)
|
|
47
|
+
- `m.max.sm` – @media (min-width: 785px)
|
|
48
|
+
- `m.max.md` – @media (min-width: 991px)
|
|
49
|
+
- `m.max.lg` – @media (min-width: 1199px)
|
|
50
|
+
- `m.max.xl` – @media (min-width: 1599px)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Meta } from '@storybook/blocks';
|
|
2
|
+
import UseIsMaxWidthExample from './index.example';
|
|
3
|
+
|
|
4
|
+
<Meta title='Media/useIsMaxWidth' />
|
|
5
|
+
|
|
6
|
+
# useIsMaxWidth
|
|
7
|
+
|
|
8
|
+
Checks whether the width of the screen is less than or equal to the specified media breakpoint (for example, `sm`).
|
|
9
|
+
|
|
10
|
+
## Example of usage
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { useIsMaxWidth } from '@os-design/media';
|
|
15
|
+
|
|
16
|
+
const UseIsMaxWidthExample: React.FC = () => {
|
|
17
|
+
const isMaxSm = useIsMaxWidth('sm');
|
|
18
|
+
return (
|
|
19
|
+
<div>
|
|
20
|
+
{isMaxSm
|
|
21
|
+
? 'Less than or equal to 785px (sm). Try to increase the width of the screen.'
|
|
22
|
+
: 'Greater than 785px (sm). Try to reduce the width of the screen.'}
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default UseIsMaxWidthExample;
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
<UseIsMaxWidthExample />
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Meta } from '@storybook/blocks';
|
|
2
|
+
import UseIsMinWidthExample from './index.example';
|
|
3
|
+
|
|
4
|
+
<Meta title='Media/useIsMinWidth' />
|
|
5
|
+
|
|
6
|
+
# useIsMinWidth
|
|
7
|
+
|
|
8
|
+
Checks whether the width of the screen is greater than or equal to the specified media breakpoint (for example, `md`).
|
|
9
|
+
|
|
10
|
+
## Example of usage
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { useIsMinWidth } from '@os-design/media';
|
|
15
|
+
|
|
16
|
+
const UseIsMinWidthExample: React.FC = () => {
|
|
17
|
+
const isMinMd = useIsMinWidth('md');
|
|
18
|
+
return (
|
|
19
|
+
<div>
|
|
20
|
+
{isMinMd
|
|
21
|
+
? 'Greater than or equal to 786px (md). Try to reduce the width of the screen.'
|
|
22
|
+
: 'Less than 786px (md). Try to increase the width of the screen.'}
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default UseIsMinWidthExample;
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
<UseIsMinWidthExample />
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Meta } from '@storybook/blocks';
|
|
2
|
+
import UseIsWidthExample from './index.example';
|
|
3
|
+
|
|
4
|
+
<Meta title='Media/useIsWidth' />
|
|
5
|
+
|
|
6
|
+
# useIsWidth
|
|
7
|
+
|
|
8
|
+
Checks whether the width of the screen matches the condition defined by the specified function.
|
|
9
|
+
|
|
10
|
+
## Example of usage
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { useIsWidth } from '@os-design/media';
|
|
15
|
+
|
|
16
|
+
const UseIsWidthExample: React.FC = () => {
|
|
17
|
+
const isMinMd = useIsWidth((width) => width >= 786);
|
|
18
|
+
return (
|
|
19
|
+
<div>
|
|
20
|
+
{isMinMd
|
|
21
|
+
? 'Greater than or equal to 786px. Try to reduce the width of the screen.'
|
|
22
|
+
: 'Less than 786px. Try to increase the width of the screen.'}
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default UseIsWidthExample;
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
<UseIsWidthExample />
|
package/dist/cjs/index.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
var _exportNames = {
|
|
8
|
-
m: true,
|
|
9
|
-
useIsMaxWidth: true,
|
|
10
|
-
useIsMinWidth: true,
|
|
11
|
-
useIsWidth: true
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "m", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function get() {
|
|
16
|
-
return _media["default"];
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "useIsMaxWidth", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function get() {
|
|
22
|
-
return _useIsMaxWidth["default"];
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(exports, "useIsMinWidth", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function get() {
|
|
28
|
-
return _useIsMinWidth["default"];
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(exports, "useIsWidth", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function get() {
|
|
34
|
-
return _useIsWidth["default"];
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
var _media = _interopRequireWildcard(require("./media"));
|
|
38
|
-
Object.keys(_media).forEach(function (key) {
|
|
39
|
-
if (key === "default" || key === "__esModule") return;
|
|
40
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
41
|
-
if (key in exports && exports[key] === _media[key]) return;
|
|
42
|
-
Object.defineProperty(exports, key, {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function get() {
|
|
45
|
-
return _media[key];
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
var _useIsMaxWidth = _interopRequireDefault(require("./useIsMaxWidth"));
|
|
50
|
-
var _useIsMinWidth = _interopRequireDefault(require("./useIsMinWidth"));
|
|
51
|
-
var _useIsWidth = _interopRequireDefault(require("./useIsWidth"));
|
|
52
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
53
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
54
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
55
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_media","_interopRequireWildcard","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_useIsMaxWidth","_interopRequireDefault","_useIsMinWidth","_useIsWidth","obj","__esModule","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","_typeof","cache","has","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","desc","set"],"sources":["../../src/index.ts"],"sourcesContent":["export { default as m } from './media';\nexport { default as useIsMaxWidth } from './useIsMaxWidth';\nexport { default as useIsMinWidth } from './useIsMinWidth';\nexport { default as useIsWidth } from './useIsWidth';\n\nexport * from './media';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAKAC,MAAA,CAAAC,IAAA,CAAAJ,MAAA,EAAAK,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAN,MAAA,CAAAM,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,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B,IAAA,YAAAH,MAAA,CAAAvB,GAAA,IAAAa,GAAA,CAAAb,GAAA,SAAAuB,MAAA,cAAAV,GAAA,MAAAQ,KAAA,IAAAA,KAAA,CAAAM,GAAA,CAAAd,GAAA,EAAAU,MAAA,YAAAA,MAAA"}
|
package/dist/cjs/media/index.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.minBreakpoints = exports.maxBreakpoints = exports["default"] = void 0;
|
|
7
|
-
var minBreakpoints = {
|
|
8
|
-
xs: 480,
|
|
9
|
-
sm: 576,
|
|
10
|
-
md: 786,
|
|
11
|
-
lg: 992,
|
|
12
|
-
xl: 1200,
|
|
13
|
-
xxl: 1600
|
|
14
|
-
};
|
|
15
|
-
exports.minBreakpoints = minBreakpoints;
|
|
16
|
-
var maxBreakpoints = {
|
|
17
|
-
xxs: minBreakpoints.xs - 1,
|
|
18
|
-
xs: minBreakpoints.sm - 1,
|
|
19
|
-
sm: minBreakpoints.md - 1,
|
|
20
|
-
md: minBreakpoints.lg - 1,
|
|
21
|
-
lg: minBreakpoints.xl - 1,
|
|
22
|
-
xl: minBreakpoints.xxl - 1
|
|
23
|
-
};
|
|
24
|
-
exports.maxBreakpoints = maxBreakpoints;
|
|
25
|
-
var min = Object.keys(minBreakpoints).reduce(function (res, key) {
|
|
26
|
-
res[key] = "@media (min-width: ".concat(minBreakpoints[key], "px)");
|
|
27
|
-
return res;
|
|
28
|
-
}, {});
|
|
29
|
-
var max = Object.keys(maxBreakpoints).reduce(function (res, key) {
|
|
30
|
-
res[key] = "@media (max-width: ".concat(maxBreakpoints[key], "px)");
|
|
31
|
-
return res;
|
|
32
|
-
}, {});
|
|
33
|
-
var m = {
|
|
34
|
-
min: min,
|
|
35
|
-
max: max
|
|
36
|
-
};
|
|
37
|
-
var _default = m;
|
|
38
|
-
exports["default"] = _default;
|
|
39
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["minBreakpoints","xs","sm","md","lg","xl","xxl","exports","maxBreakpoints","xxs","min","Object","keys","reduce","res","key","concat","max","m","_default"],"sources":["../../../src/media/index.ts"],"sourcesContent":["interface Breakpoints {\n xxs: number;\n xs: number;\n sm: number;\n md: number;\n lg: number;\n xl: number;\n xxl: number;\n}\n\ntype Index<T> = {\n [key in keyof T]: string;\n};\n\nexport type MinBreakpoints = Omit<Breakpoints, 'xxs'>;\nexport type MaxBreakpoints = Omit<Breakpoints, 'xxl'>;\n\nexport const minBreakpoints: MinBreakpoints = {\n xs: 480,\n sm: 576,\n md: 786,\n lg: 992,\n xl: 1200,\n xxl: 1600,\n};\n\nexport const maxBreakpoints: MaxBreakpoints = {\n xxs: minBreakpoints.xs - 1,\n xs: minBreakpoints.sm - 1,\n sm: minBreakpoints.md - 1,\n md: minBreakpoints.lg - 1,\n lg: minBreakpoints.xl - 1,\n xl: minBreakpoints.xxl - 1,\n};\n\nconst min = Object.keys(minBreakpoints).reduce<Index<MinBreakpoints>>(\n (res, key) => {\n res[key] = `@media (min-width: ${minBreakpoints[key]}px)`;\n return res;\n },\n {} as Index<MinBreakpoints>\n);\n\nconst max = Object.keys(maxBreakpoints).reduce<Index<MaxBreakpoints>>(\n (res, key) => {\n res[key] = `@media (max-width: ${maxBreakpoints[key]}px)`;\n return res;\n },\n {} as Index<MaxBreakpoints>\n);\n\nconst m = {\n min,\n max,\n};\n\nexport default m;\n"],"mappings":";;;;;;AAiBO,IAAMA,cAA8B,GAAG;EAC5CC,EAAE,EAAE,GAAG;EACPC,EAAE,EAAE,GAAG;EACPC,EAAE,EAAE,GAAG;EACPC,EAAE,EAAE,GAAG;EACPC,EAAE,EAAE,IAAI;EACRC,GAAG,EAAE;AACP,CAAC;AAACC,OAAA,CAAAP,cAAA,GAAAA,cAAA;AAEK,IAAMQ,cAA8B,GAAG;EAC5CC,GAAG,EAAET,cAAc,CAACC,EAAE,GAAG,CAAC;EAC1BA,EAAE,EAAED,cAAc,CAACE,EAAE,GAAG,CAAC;EACzBA,EAAE,EAAEF,cAAc,CAACG,EAAE,GAAG,CAAC;EACzBA,EAAE,EAAEH,cAAc,CAACI,EAAE,GAAG,CAAC;EACzBA,EAAE,EAAEJ,cAAc,CAACK,EAAE,GAAG,CAAC;EACzBA,EAAE,EAAEL,cAAc,CAACM,GAAG,GAAG;AAC3B,CAAC;AAACC,OAAA,CAAAC,cAAA,GAAAA,cAAA;AAEF,IAAME,GAAG,GAAGC,MAAM,CAACC,IAAI,CAACZ,cAAc,CAAC,CAACa,MAAM,CAC5C,UAACC,GAAG,EAAEC,GAAG,EAAK;EACZD,GAAG,CAACC,GAAG,CAAC,yBAAAC,MAAA,CAAyBhB,cAAc,CAACe,GAAG,CAAC,QAAK;EACzD,OAAOD,GAAG;AACZ,CAAC,EACD,CAAC,CACH,CAAC;AAED,IAAMG,GAAG,GAAGN,MAAM,CAACC,IAAI,CAACJ,cAAc,CAAC,CAACK,MAAM,CAC5C,UAACC,GAAG,EAAEC,GAAG,EAAK;EACZD,GAAG,CAACC,GAAG,CAAC,yBAAAC,MAAA,CAAyBR,cAAc,CAACO,GAAG,CAAC,QAAK;EACzD,OAAOD,GAAG;AACZ,CAAC,EACD,CAAC,CACH,CAAC;AAED,IAAMI,CAAC,GAAG;EACRR,GAAG,EAAHA,GAAG;EACHO,GAAG,EAAHA;AACF,CAAC;AAAC,IAAAE,QAAA,GAEaD,CAAC;AAAAX,OAAA,cAAAY,QAAA"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _media = require("../media");
|
|
9
|
-
var _useIsWidth = _interopRequireDefault(require("../useIsWidth"));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
/**
|
|
12
|
-
* Checks whether the width of the screen is less than or equal to
|
|
13
|
-
* the specified media breakpoint (for example, sm).
|
|
14
|
-
*/
|
|
15
|
-
var useIsMaxWidth = function useIsMaxWidth(breakpoint) {
|
|
16
|
-
var detector = (0, _react.useCallback)(function (width) {
|
|
17
|
-
return width <= _media.maxBreakpoints[breakpoint];
|
|
18
|
-
}, [breakpoint]);
|
|
19
|
-
return (0, _useIsWidth["default"])(detector);
|
|
20
|
-
};
|
|
21
|
-
var _default = useIsMaxWidth;
|
|
22
|
-
exports["default"] = _default;
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","require","_media","_useIsWidth","_interopRequireDefault","obj","__esModule","useIsMaxWidth","breakpoint","detector","useCallback","width","maxBreakpoints","useIsWidth","_default","exports"],"sources":["../../../src/useIsMaxWidth/index.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { maxBreakpoints, MaxBreakpoints } from '../media';\nimport useIsWidth from '../useIsWidth';\n\n/**\n * Checks whether the width of the screen is less than or equal to\n * the specified media breakpoint (for example, sm).\n */\nconst useIsMaxWidth = (breakpoint: keyof MaxBreakpoints): boolean => {\n const detector = useCallback(\n (width) => width <= maxBreakpoints[breakpoint],\n [breakpoint]\n );\n return useIsWidth(detector);\n};\n\nexport default useIsMaxWidth;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAuC,SAAAG,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAEvC;AACA;AACA;AACA;AACA,IAAME,aAAa,GAAG,SAAhBA,aAAaA,CAAIC,UAAgC,EAAc;EACnE,IAAMC,QAAQ,GAAG,IAAAC,kBAAW,EAC1B,UAACC,KAAK;IAAA,OAAKA,KAAK,IAAIC,qBAAc,CAACJ,UAAU,CAAC;EAAA,GAC9C,CAACA,UAAU,CACb,CAAC;EACD,OAAO,IAAAK,sBAAU,EAACJ,QAAQ,CAAC;AAC7B,CAAC;AAAC,IAAAK,QAAA,GAEaP,aAAa;AAAAQ,OAAA,cAAAD,QAAA"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _media = require("../media");
|
|
9
|
-
var _useIsWidth = _interopRequireDefault(require("../useIsWidth"));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
/**
|
|
12
|
-
* Checks whether the width of the screen is greater than or equal to
|
|
13
|
-
* the specified media breakpoint (for example, md).
|
|
14
|
-
*/
|
|
15
|
-
var useIsMinWidth = function useIsMinWidth(breakpoint) {
|
|
16
|
-
var detector = (0, _react.useCallback)(function (width) {
|
|
17
|
-
return width >= _media.minBreakpoints[breakpoint];
|
|
18
|
-
}, [breakpoint]);
|
|
19
|
-
return (0, _useIsWidth["default"])(detector);
|
|
20
|
-
};
|
|
21
|
-
var _default = useIsMinWidth;
|
|
22
|
-
exports["default"] = _default;
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","require","_media","_useIsWidth","_interopRequireDefault","obj","__esModule","useIsMinWidth","breakpoint","detector","useCallback","width","minBreakpoints","useIsWidth","_default","exports"],"sources":["../../../src/useIsMinWidth/index.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { MinBreakpoints, minBreakpoints } from '../media';\nimport useIsWidth from '../useIsWidth';\n\n/**\n * Checks whether the width of the screen is greater than or equal to\n * the specified media breakpoint (for example, md).\n */\nconst useIsMinWidth = (breakpoint: keyof MinBreakpoints): boolean => {\n const detector = useCallback(\n (width) => width >= minBreakpoints[breakpoint],\n [breakpoint]\n );\n return useIsWidth(detector);\n};\n\nexport default useIsMinWidth;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAuC,SAAAG,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAEvC;AACA;AACA;AACA;AACA,IAAME,aAAa,GAAG,SAAhBA,aAAaA,CAAIC,UAAgC,EAAc;EACnE,IAAMC,QAAQ,GAAG,IAAAC,kBAAW,EAC1B,UAACC,KAAK;IAAA,OAAKA,KAAK,IAAIC,qBAAc,CAACJ,UAAU,CAAC;EAAA,GAC9C,CAACA,UAAU,CACb,CAAC;EACD,OAAO,IAAAK,sBAAU,EAACJ,QAAQ,CAAC;AAC7B,CAAC;AAAC,IAAAK,QAAA,GAEaP,aAAa;AAAAQ,OAAA,cAAAD,QAAA"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
13
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
-
/**
|
|
15
|
-
* Checks whether the width of the screen matches the condition
|
|
16
|
-
* defined by the specified function.
|
|
17
|
-
*/
|
|
18
|
-
var useIsWidth = function useIsWidth(detector) {
|
|
19
|
-
var detectorRef = (0, _react.useRef)(detector);
|
|
20
|
-
var _useState = (0, _react.useState)(function () {
|
|
21
|
-
return detector(typeof window !== 'undefined' ? window.innerWidth : 0);
|
|
22
|
-
}),
|
|
23
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
-
flag = _useState2[0],
|
|
25
|
-
setFlag = _useState2[1];
|
|
26
|
-
var updateFlag = (0, _react.useCallback)(function () {
|
|
27
|
-
setFlag(detectorRef.current(window.innerWidth));
|
|
28
|
-
}, []);
|
|
29
|
-
(0, _react.useEffect)(function () {
|
|
30
|
-
detectorRef.current = detector;
|
|
31
|
-
updateFlag();
|
|
32
|
-
}, [detector, updateFlag]);
|
|
33
|
-
(0, _react.useEffect)(function () {
|
|
34
|
-
window.addEventListener('resize', updateFlag);
|
|
35
|
-
return function () {
|
|
36
|
-
return window.removeEventListener('resize', updateFlag);
|
|
37
|
-
};
|
|
38
|
-
}, [updateFlag]);
|
|
39
|
-
return flag;
|
|
40
|
-
};
|
|
41
|
-
var _default = useIsWidth;
|
|
42
|
-
exports["default"] = _default;
|
|
43
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","require","_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","n","Object","prototype","toString","call","slice","constructor","name","Array","from","test","len","length","arr2","_i","Symbol","iterator","_s","_e","_x","_r","_arr","_n","_d","next","done","push","value","err","isArray","useIsWidth","detector","detectorRef","useRef","_useState","useState","window","innerWidth","_useState2","flag","setFlag","updateFlag","useCallback","current","useEffect","addEventListener","removeEventListener","_default","exports"],"sources":["../../../src/useIsWidth/index.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\n/**\n * Checks whether the width of the screen matches the condition\n * defined by the specified function.\n */\nconst useIsWidth = (detector: (width: number) => boolean): boolean => {\n const detectorRef = useRef<(width: number) => boolean>(detector);\n const [flag, setFlag] = useState(() =>\n detector(typeof window !== 'undefined' ? window.innerWidth : 0)\n );\n\n const updateFlag = useCallback(() => {\n setFlag(detectorRef.current(window.innerWidth));\n }, []);\n\n useEffect(() => {\n detectorRef.current = detector;\n updateFlag();\n }, [detector, updateFlag]);\n\n useEffect(() => {\n window.addEventListener('resize', updateFlag);\n return () => window.removeEventListener('resize', updateFlag);\n }, [updateFlag]);\n\n return flag;\n};\n\nexport default useIsWidth;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAiE,SAAAC,eAAAC,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AE,CAACV,QAAQ,EAAEU,UAAU,CAAC,CAAC;EAE1B,IAAAG,gBAAS,EAAC,YAAM;IACdR,MAAM,CAACS,gBAAgB,CAAC,QAAQ,EAAEJ,UAAU,CAAC;IAC7C,OAAO;MAAA,OAAML,MAAM,CAACU,mBAAmB,CAAC,QAAQ,EAAEL,UAAU,CAAC;IAAA;EAC/D,CAAC,EAAE,CAACA,UAAU,CAAC,CAAC;EAEhB,OAAOF,IAAI;AACb,CAAC;AAAC,IAAAQ,QAAA,GAEajB,UAAU;AAAAkB,OAAA,cAAAD,QAAA"}
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","m","useIsMaxWidth","useIsMinWidth","useIsWidth"],"sources":["../../src/index.ts"],"sourcesContent":["export { default as m } from './media';\nexport { default as useIsMaxWidth } from './useIsMaxWidth';\nexport { default as useIsMinWidth } from './useIsMinWidth';\nexport { default as useIsWidth } from './useIsWidth';\n\nexport * from './media';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,CAAC,QAAQ,SAAS;AACtC,SAASD,OAAO,IAAIE,aAAa,QAAQ,iBAAiB;AAC1D,SAASF,OAAO,IAAIG,aAAa,QAAQ,iBAAiB;AAC1D,SAASH,OAAO,IAAII,UAAU,QAAQ,cAAc;AAEpD,cAAc,SAAS"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["minBreakpoints","xs","sm","md","lg","xl","xxl","maxBreakpoints","xxs","min","Object","keys","reduce","res","key","max","m"],"sources":["../../../src/media/index.ts"],"sourcesContent":["interface Breakpoints {\n xxs: number;\n xs: number;\n sm: number;\n md: number;\n lg: number;\n xl: number;\n xxl: number;\n}\n\ntype Index<T> = {\n [key in keyof T]: string;\n};\n\nexport type MinBreakpoints = Omit<Breakpoints, 'xxs'>;\nexport type MaxBreakpoints = Omit<Breakpoints, 'xxl'>;\n\nexport const minBreakpoints: MinBreakpoints = {\n xs: 480,\n sm: 576,\n md: 786,\n lg: 992,\n xl: 1200,\n xxl: 1600,\n};\n\nexport const maxBreakpoints: MaxBreakpoints = {\n xxs: minBreakpoints.xs - 1,\n xs: minBreakpoints.sm - 1,\n sm: minBreakpoints.md - 1,\n md: minBreakpoints.lg - 1,\n lg: minBreakpoints.xl - 1,\n xl: minBreakpoints.xxl - 1,\n};\n\nconst min = Object.keys(minBreakpoints).reduce<Index<MinBreakpoints>>(\n (res, key) => {\n res[key] = `@media (min-width: ${minBreakpoints[key]}px)`;\n return res;\n },\n {} as Index<MinBreakpoints>\n);\n\nconst max = Object.keys(maxBreakpoints).reduce<Index<MaxBreakpoints>>(\n (res, key) => {\n res[key] = `@media (max-width: ${maxBreakpoints[key]}px)`;\n return res;\n },\n {} as Index<MaxBreakpoints>\n);\n\nconst m = {\n min,\n max,\n};\n\nexport default m;\n"],"mappings":"AAiBA,OAAO,MAAMA,cAA8B,GAAG;EAC5CC,EAAE,EAAE,GAAG;EACPC,EAAE,EAAE,GAAG;EACPC,EAAE,EAAE,GAAG;EACPC,EAAE,EAAE,GAAG;EACPC,EAAE,EAAE,IAAI;EACRC,GAAG,EAAE;AACP,CAAC;AAED,OAAO,MAAMC,cAA8B,GAAG;EAC5CC,GAAG,EAAER,cAAc,CAACC,EAAE,GAAG,CAAC;EAC1BA,EAAE,EAAED,cAAc,CAACE,EAAE,GAAG,CAAC;EACzBA,EAAE,EAAEF,cAAc,CAACG,EAAE,GAAG,CAAC;EACzBA,EAAE,EAAEH,cAAc,CAACI,EAAE,GAAG,CAAC;EACzBA,EAAE,EAAEJ,cAAc,CAACK,EAAE,GAAG,CAAC;EACzBA,EAAE,EAAEL,cAAc,CAACM,GAAG,GAAG;AAC3B,CAAC;AAED,MAAMG,GAAG,GAAGC,MAAM,CAACC,IAAI,CAACX,cAAc,CAAC,CAACY,MAAM,CAC5C,CAACC,GAAG,EAAEC,GAAG,KAAK;EACZD,GAAG,CAACC,GAAG,CAAC,GAAI,sBAAqBd,cAAc,CAACc,GAAG,CAAE,KAAI;EACzD,OAAOD,GAAG;AACZ,CAAC,EACD,CAAC,CACH,CAAC;AAED,MAAME,GAAG,GAAGL,MAAM,CAACC,IAAI,CAACJ,cAAc,CAAC,CAACK,MAAM,CAC5C,CAACC,GAAG,EAAEC,GAAG,KAAK;EACZD,GAAG,CAACC,GAAG,CAAC,GAAI,sBAAqBP,cAAc,CAACO,GAAG,CAAE,KAAI;EACzD,OAAOD,GAAG;AACZ,CAAC,EACD,CAAC,CACH,CAAC;AAED,MAAMG,CAAC,GAAG;EACRP,GAAG;EACHM;AACF,CAAC;AAED,eAAeC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useCallback","maxBreakpoints","useIsWidth","useIsMaxWidth","breakpoint","detector","width"],"sources":["../../../src/useIsMaxWidth/index.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { maxBreakpoints, MaxBreakpoints } from '../media';\nimport useIsWidth from '../useIsWidth';\n\n/**\n * Checks whether the width of the screen is less than or equal to\n * the specified media breakpoint (for example, sm).\n */\nconst useIsMaxWidth = (breakpoint: keyof MaxBreakpoints): boolean => {\n const detector = useCallback(\n (width) => width <= maxBreakpoints[breakpoint],\n [breakpoint]\n );\n return useIsWidth(detector);\n};\n\nexport default useIsMaxWidth;\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,OAAO;AACnC,SAASC,cAAc,QAAwB,UAAU;AACzD,OAAOC,UAAU,MAAM,eAAe;;AAEtC;AACA;AACA;AACA;AACA,MAAMC,aAAa,GAAIC,UAAgC,IAAc;EACnE,MAAMC,QAAQ,GAAGL,WAAW,CACzBM,KAAK,IAAKA,KAAK,IAAIL,cAAc,CAACG,UAAU,CAAC,EAC9C,CAACA,UAAU,CACb,CAAC;EACD,OAAOF,UAAU,CAACG,QAAQ,CAAC;AAC7B,CAAC;AAED,eAAeF,aAAa"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useCallback","minBreakpoints","useIsWidth","useIsMinWidth","breakpoint","detector","width"],"sources":["../../../src/useIsMinWidth/index.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { MinBreakpoints, minBreakpoints } from '../media';\nimport useIsWidth from '../useIsWidth';\n\n/**\n * Checks whether the width of the screen is greater than or equal to\n * the specified media breakpoint (for example, md).\n */\nconst useIsMinWidth = (breakpoint: keyof MinBreakpoints): boolean => {\n const detector = useCallback(\n (width) => width >= minBreakpoints[breakpoint],\n [breakpoint]\n );\n return useIsWidth(detector);\n};\n\nexport default useIsMinWidth;\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,OAAO;AACnC,SAAyBC,cAAc,QAAQ,UAAU;AACzD,OAAOC,UAAU,MAAM,eAAe;;AAEtC;AACA;AACA;AACA;AACA,MAAMC,aAAa,GAAIC,UAAgC,IAAc;EACnE,MAAMC,QAAQ,GAAGL,WAAW,CACzBM,KAAK,IAAKA,KAAK,IAAIL,cAAc,CAACG,UAAU,CAAC,EAC9C,CAACA,UAAU,CACb,CAAC;EACD,OAAOF,UAAU,CAACG,QAAQ,CAAC;AAC7B,CAAC;AAED,eAAeF,aAAa"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useCallback","useEffect","useRef","useState","useIsWidth","detector","detectorRef","flag","setFlag","window","innerWidth","updateFlag","current","addEventListener","removeEventListener"],"sources":["../../../src/useIsWidth/index.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\n/**\n * Checks whether the width of the screen matches the condition\n * defined by the specified function.\n */\nconst useIsWidth = (detector: (width: number) => boolean): boolean => {\n const detectorRef = useRef<(width: number) => boolean>(detector);\n const [flag, setFlag] = useState(() =>\n detector(typeof window !== 'undefined' ? window.innerWidth : 0)\n );\n\n const updateFlag = useCallback(() => {\n setFlag(detectorRef.current(window.innerWidth));\n }, []);\n\n useEffect(() => {\n detectorRef.current = detector;\n updateFlag();\n }, [detector, updateFlag]);\n\n useEffect(() => {\n window.addEventListener('resize', updateFlag);\n return () => window.removeEventListener('resize', updateFlag);\n }, [updateFlag]);\n\n return flag;\n};\n\nexport default useIsWidth;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;;AAEhE;AACA;AACA;AACA;AACA,MAAMC,UAAU,GAAIC,QAAoC,IAAc;EACpE,MAAMC,WAAW,GAAGJ,MAAM,CAA6BG,QAAQ,CAAC;EAChE,MAAM,CAACE,IAAI,EAAEC,OAAO,CAAC,GAAGL,QAAQ,CAAC,MAC/BE,QAAQ,CAAC,OAAOI,MAAM,KAAK,WAAW,GAAGA,MAAM,CAACC,UAAU,GAAG,CAAC,CAChE,CAAC;EAED,MAAMC,UAAU,GAAGX,WAAW,CAAC,MAAM;IACnCQ,OAAO,CAACF,WAAW,CAACM,OAAO,CAACH,MAAM,CAACC,UAAU,CAAC,CAAC;EACjD,CAAC,EAAE,EAAE,CAAC;EAENT,SAAS,CAAC,MAAM;IACdK,WAAW,CAACM,OAAO,GAAGP,QAAQ;IAC9BM,UAAU,CAAC,CAAC;EACd,CAAC,EAAE,CAACN,QAAQ,EAAEM,UAAU,CAAC,CAAC;EAE1BV,SAAS,CAAC,MAAM;IACdQ,MAAM,CAACI,gBAAgB,CAAC,QAAQ,EAAEF,UAAU,CAAC;IAC7C,OAAO,MAAMF,MAAM,CAACK,mBAAmB,CAAC,QAAQ,EAAEH,UAAU,CAAC;EAC/D,CAAC,EAAE,CAACA,UAAU,CAAC,CAAC;EAEhB,OAAOJ,IAAI;AACb,CAAC;AAED,eAAeH,UAAU"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,CAAC,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AAErD,cAAc,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/media/index.ts"],"names":[],"mappings":"AAAA,UAAU,WAAW;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AAED,KAAK,KAAK,CAAC,CAAC,IAAI;KACb,GAAG,IAAI,MAAM,CAAC,GAAG,MAAM;CACzB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AACtD,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AAEtD,eAAO,MAAM,cAAc,EAAE,cAO5B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cAO5B,CAAC;AAkBF,QAAA,MAAM,CAAC;;;CAGN,CAAC;AAEF,eAAe,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/useIsMaxWidth/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,cAAc,EAAE,MAAM,UAAU,CAAC;AAO1D,QAAA,MAAM,aAAa,eAAgB,MAAM,cAAc,KAAG,OAMzD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/useIsMinWidth/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAkB,MAAM,UAAU,CAAC;AAO1D,QAAA,MAAM,aAAa,eAAgB,MAAM,cAAc,KAAG,OAMzD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/useIsWidth/index.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,UAAU,qBAAsB,MAAM,KAAK,OAAO,KAAG,OAqB1D,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
File without changes
|
|
File without changes
|