rc-resize-observer
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -33,6 +33,6 @@ import * as React from 'react'; | ||
onResize: ResizeObserverCallback; | ||
setChildNode: (node: RefNode) => void; | ||
setChildNode: (node: Element | HTMLElement | React.Component<any, {}, any>) => void; | ||
destroyObserver(): void; | ||
render(): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | React.ReactElement<unknown, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>[] | null; | ||
render(): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)>) | (new (props: any) => React.Component<any, any, any>)> | React.ReactElement<unknown, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)>) | (new (props: any) => React.Component<any, any, any>)>[]; | ||
} | ||
export default ReactResizeObserver; |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
@@ -27,34 +25,8 @@ | ||
var __importStar = this && this.__importStar || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) { | ||
if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
} | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var __importDefault = this && this.__importDefault || function (mod) { | ||
return mod && mod.__esModule ? mod : { | ||
"default": mod | ||
}; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var React = __importStar(require("react")); | ||
var findDOMNode_1 = __importDefault(require("rc-util/lib/Dom/findDOMNode")); | ||
var toArray_1 = __importDefault(require("rc-util/lib/Children/toArray")); | ||
var warning_1 = __importDefault(require("rc-util/lib/warning")); | ||
var ref_1 = require("rc-util/lib/ref"); | ||
var resize_observer_polyfill_1 = __importDefault(require("resize-observer-polyfill")); | ||
import * as React from 'react'; | ||
import findDOMNode from "rc-util/es/Dom/findDOMNode"; | ||
import toArray from "rc-util/es/Children/toArray"; | ||
import warning from "rc-util/es/warning"; | ||
import { composeRef, supportRef } from "rc-util/es/ref"; | ||
import ResizeObserver from 'resize-observer-polyfill'; | ||
var INTERNAL_PREFIX_KEY = 'rc-observer-key'; // Still need to be compatible with React 15, we use class component here | ||
@@ -150,3 +122,3 @@ | ||
var element = findDOMNode_1.default(this.childNode || this); | ||
var element = findDOMNode(this.childNode || this); | ||
var elementChanged = element !== this.currentElement; | ||
@@ -160,3 +132,3 @@ | ||
if (!this.resizeObserver && element) { | ||
this.resizeObserver = new resize_observer_polyfill_1.default(this.onResize); | ||
this.resizeObserver = new ResizeObserver(this.onResize); | ||
this.resizeObserver.observe(element); | ||
@@ -177,8 +149,8 @@ } | ||
var children = this.props.children; | ||
var childNodes = toArray_1.default(children); | ||
var childNodes = toArray(children); | ||
if (childNodes.length > 1) { | ||
warning_1.default(false, 'Find more than one child node with `children` in ResizeObserver. Will only observe first one.'); | ||
warning(false, 'Find more than one child node with `children` in ResizeObserver. Will only observe first one.'); | ||
} else if (childNodes.length === 0) { | ||
warning_1.default(false, '`children` of ResizeObserver is empty. Nothing is in observe.'); | ||
warning(false, '`children` of ResizeObserver is empty. Nothing is in observe.'); | ||
return null; | ||
@@ -189,6 +161,6 @@ } | ||
if (React.isValidElement(childNode) && ref_1.supportRef(childNode)) { | ||
if (React.isValidElement(childNode) && supportRef(childNode)) { | ||
var ref = childNode.ref; | ||
childNodes[0] = React.cloneElement(childNode, { | ||
ref: ref_1.composeRef(ref, this.setChildNode) | ||
ref: composeRef(ref, this.setChildNode) | ||
}); | ||
@@ -213,2 +185,2 @@ } | ||
ReactResizeObserver.displayName = 'ResizeObserver'; | ||
exports.default = ReactResizeObserver; | ||
export default ReactResizeObserver; |
@@ -33,6 +33,6 @@ import * as React from 'react'; | ||
onResize: ResizeObserverCallback; | ||
setChildNode: (node: RefNode) => void; | ||
setChildNode: (node: Element | HTMLElement | React.Component<any, {}, any>) => void; | ||
destroyObserver(): void; | ||
render(): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | React.ReactElement<unknown, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>[] | null; | ||
render(): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)>) | (new (props: any) => React.Component<any, any, any>)> | React.ReactElement<unknown, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)>) | (new (props: any) => React.Component<any, any, any>)>[]; | ||
} | ||
export default ReactResizeObserver; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var React = _interopRequireWildcard(require("react")); | ||
var _findDOMNode = _interopRequireDefault(require("rc-util/lib/Dom/findDOMNode")); | ||
var _toArray = _interopRequireDefault(require("rc-util/lib/Children/toArray")); | ||
var _warning = _interopRequireDefault(require("rc-util/lib/warning")); | ||
var _ref = require("rc-util/lib/ref"); | ||
var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
@@ -27,34 +50,2 @@ | ||
var __importStar = void 0 && (void 0).__importStar || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) { | ||
if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
} | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var __importDefault = void 0 && (void 0).__importDefault || function (mod) { | ||
return mod && mod.__esModule ? mod : { | ||
"default": mod | ||
}; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var React = __importStar(require("react")); | ||
var findDOMNode_1 = __importDefault(require("rc-util/lib/Dom/findDOMNode")); | ||
var toArray_1 = __importDefault(require("rc-util/lib/Children/toArray")); | ||
var warning_1 = __importDefault(require("rc-util/lib/warning")); | ||
var ref_1 = require("rc-util/lib/ref"); | ||
var resize_observer_polyfill_1 = __importDefault(require("resize-observer-polyfill")); | ||
var INTERNAL_PREFIX_KEY = 'rc-observer-key'; // Still need to be compatible with React 15, we use class component here | ||
@@ -150,3 +141,3 @@ | ||
var element = findDOMNode_1.default(this.childNode || this); | ||
var element = (0, _findDOMNode.default)(this.childNode || this); | ||
var elementChanged = element !== this.currentElement; | ||
@@ -160,3 +151,3 @@ | ||
if (!this.resizeObserver && element) { | ||
this.resizeObserver = new resize_observer_polyfill_1.default(this.onResize); | ||
this.resizeObserver = new _resizeObserverPolyfill.default(this.onResize); | ||
this.resizeObserver.observe(element); | ||
@@ -177,8 +168,8 @@ } | ||
var children = this.props.children; | ||
var childNodes = toArray_1.default(children); | ||
var childNodes = (0, _toArray.default)(children); | ||
if (childNodes.length > 1) { | ||
warning_1.default(false, 'Find more than one child node with `children` in ResizeObserver. Will only observe first one.'); | ||
(0, _warning.default)(false, 'Find more than one child node with `children` in ResizeObserver. Will only observe first one.'); | ||
} else if (childNodes.length === 0) { | ||
warning_1.default(false, '`children` of ResizeObserver is empty. Nothing is in observe.'); | ||
(0, _warning.default)(false, '`children` of ResizeObserver is empty. Nothing is in observe.'); | ||
return null; | ||
@@ -189,6 +180,6 @@ } | ||
if (React.isValidElement(childNode) && ref_1.supportRef(childNode)) { | ||
if (React.isValidElement(childNode) && (0, _ref.supportRef)(childNode)) { | ||
var ref = childNode.ref; | ||
childNodes[0] = React.cloneElement(childNode, { | ||
ref: ref_1.composeRef(ref, this.setChildNode) | ||
ref: (0, _ref.composeRef)(ref, this.setChildNode) | ||
}); | ||
@@ -213,2 +204,3 @@ } | ||
ReactResizeObserver.displayName = 'ResizeObserver'; | ||
exports.default = ReactResizeObserver; | ||
var _default = ReactResizeObserver; | ||
exports.default = _default; |
{ | ||
"name": "rc-resize-observer", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Resize observer for React", | ||
@@ -34,3 +34,4 @@ "keywords": [ | ||
"gh-pages": "npm run build && father doc deploy", | ||
"prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish && npm run gh-pages", | ||
"prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish", | ||
"postpublish": "npm run gh-pages", | ||
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", | ||
@@ -37,0 +38,0 @@ "prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"", |
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
30134
491
0