arui-feather
Advanced tools
Comparing version 9.10.3 to 9.10.4
@@ -0,1 +1,11 @@ | ||
<a name="9.10.4"></a> | ||
## [9.10.4](https://github.com/alfa-laboratory/arui-feather/compare/v9.10.3...v9.10.4) (2017-09-29) | ||
### Bug Fixes | ||
* **mq:** move match media utils functions to lib ([#228](https://github.com/alfa-laboratory/arui-feather/issues/228)) ([52acf1d](https://github.com/alfa-laboratory/arui-feather/commit/52acf1d)) | ||
<a name="9.10.3"></a> | ||
@@ -2,0 +12,0 @@ ## [9.10.3](https://github.com/alfa-laboratory/arui-feather/compare/v9.10.2...v9.10.3) (2017-09-29) |
import { Component, ReactNode } from 'react'; | ||
export type MqChildrenFieldType = Array<ReactNode> | ReactNode; | ||
export interface MqProps { | ||
@@ -20,3 +20,3 @@ | ||
*/ | ||
children?: MqChildrenFieldType; | ||
children?: ReactNode; | ||
/** | ||
@@ -23,0 +23,0 @@ * Обработчик изменений в совпадении запросов |
37
mq/mq.js
@@ -27,6 +27,4 @@ 'use strict'; | ||
var _mq = require('./mq.json'); | ||
var _matchMedia = require('../lib/match-media'); | ||
var _mq2 = _interopRequireDefault(_mq); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -72,29 +70,2 @@ | ||
var pool = {}; | ||
var refCounters = {}; | ||
function getMatchMedia(queryProp) { | ||
var query = _mq2.default[queryProp] || queryProp; | ||
if (!pool[query]) { | ||
pool[query] = window.matchMedia(query); | ||
refCounters[query] = 1; | ||
} else { | ||
refCounters[query] += 1; | ||
} | ||
return pool[query]; | ||
} | ||
function releaseMatchMedia(queryProp) { | ||
var query = _mq2.default[queryProp] || queryProp; | ||
refCounters[query] -= 1; | ||
if (pool[query] && refCounters[query] === 0) { | ||
delete pool[query]; | ||
delete refCounters[query]; | ||
} | ||
} | ||
/** | ||
@@ -129,3 +100,3 @@ * Компонент, имплементирующий поддержку медиа запросов в шаблонах. | ||
value: function componentDidMount() { | ||
this.mql = getMatchMedia(this.props.query); | ||
this.mql = (0, _matchMedia.getMatchMedia)(this.props.query); | ||
this.mql.addListener(this.handleMatch); | ||
@@ -137,3 +108,3 @@ this.handleMatch(this.mql); | ||
value: function componentWillUnmount() { | ||
releaseMatchMedia(this.props.query); | ||
(0, _matchMedia.releaseMatchMedia)(this.props.query); | ||
this.mql.removeListener(this.handleMatch); | ||
@@ -188,3 +159,3 @@ this.mql = null; | ||
/** Дочерние элементы `Mq` */ | ||
children: _propTypes2.default.oneOfType([_propTypes2.default.arrayOf(_propTypes2.default.node), _propTypes2.default.node]), | ||
children: _propTypes2.default.node, | ||
/** Обработчик изменений в совпадении запросов */ | ||
@@ -191,0 +162,0 @@ onMatchChange: _propTypes2.default.func |
{ | ||
"name": "arui-feather", | ||
"version": "9.10.3", | ||
"version": "9.10.4", | ||
"description": "Alfa-Bank UI lightweight library", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3337494
979
34026