UNPKG

remeasure

Version:

Get position and size of the DOM element for any React Component

589 lines 217 kB
{ "errors": [], "warnings": [], "version": "3.10.0", "hash": "f25940fdcda5f7e50c69", "time": 1897, "publicPath": "", "assetsByChunkName": { "main": "remeasure.min.js" }, "assets": [ { "name": "remeasure.min.js", "size": 21455, "chunks": [ 0 ], "chunkNames": [ "main" ], "emitted": true } ], "filteredAssets": 0, "entrypoints": { "main": { "chunks": [ 0 ], "assets": [ "remeasure.min.js" ] } }, "chunks": [ { "id": 0, "rendered": true, "initial": true, "entry": true, "extraAsync": false, "size": 75973, "names": [ "main" ], "files": [ "remeasure.min.js" ], "hash": "07f300baa33ee65971d5", "parents": [], "modules": [ { "id": 0, "identifier": "/home/tquetano/git/remeasure/node_modules/babel-loader/lib/index.js!/home/tquetano/git/remeasure/node_modules/eslint-loader/index.js??ref--0!/home/tquetano/git/remeasure/src/constants.js", "name": "./src/constants.js", "index": 7, "index2": 5, "size": 2641, "cacheable": true, "built": true, "optional": false, "prefetched": false, "chunks": [ 0 ], "assets": [], "issuer": "/home/tquetano/git/remeasure/node_modules/babel-loader/lib/index.js!/home/tquetano/git/remeasure/node_modules/eslint-loader/index.js??ref--0!/home/tquetano/git/remeasure/src/index.js", "issuerId": 5, "issuerName": "./src/index.js", "failed": false, "errors": 0, "warnings": 0, "reasons": [ { "moduleId": 2, "moduleIdentifier": "/home/tquetano/git/remeasure/node_modules/babel-loader/lib/index.js!/home/tquetano/git/remeasure/node_modules/eslint-loader/index.js??ref--0!/home/tquetano/git/remeasure/src/utils.js", "module": "./src/utils.js", "moduleName": "./src/utils.js", "type": "harmony import", "userRequest": "./constants", "loc": "9:0-237" }, { "moduleId": 5, "moduleIdentifier": "/home/tquetano/git/remeasure/node_modules/babel-loader/lib/index.js!/home/tquetano/git/remeasure/node_modules/eslint-loader/index.js??ref--0!/home/tquetano/git/remeasure/src/index.js", "module": "./src/index.js", "moduleName": "./src/index.js", "type": "harmony import", "userRequest": "./constants", "loc": "7:0-54" }, { "moduleId": 10, "moduleIdentifier": "/home/tquetano/git/remeasure/node_modules/babel-loader/lib/index.js!/home/tquetano/git/remeasure/node_modules/eslint-loader/index.js??ref--0!/home/tquetano/git/remeasure/src/getMeasuredComponent.js", "module": "./src/getMeasuredComponent.js", "moduleName": "./src/getMeasuredComponent.js", "type": "harmony import", "userRequest": "./constants", "loc": "14:0-46" } ], "usedExports": [ "ALL_BOUNDING_CLIENT_RECT_KEYS", "ALL_DOM_ELEMENT_KEYS", "ALL_KEYS", "ALL_POSITION_KEYS", "ALL_SIZE_KEYS", "CLIENT_RECT_TYPE", "DEFAULT_OPTIONS", "ELEMENT_TYPE", "FUNCTION_NAME_REGEXP", "NATURAL_REGEXP", "OPTIONS_SHAPE", "VOID_ELEMENT_TAG_NAMES" ], "providedExports": [ "DEFAULT_OPTIONS", "BOUNDING_CLIENT_RECT_SIZE_KEYS", "BOUNDING_CLIENT_RECT_POSITION_KEYS", "ALL_BOUNDING_CLIENT_RECT_KEYS", "DOM_ELEMENT_POSITION_KEYS", "DOM_ELEMENT_SIZE_KEYS", "FUNCTION_NAME_REGEXP", "NATURAL_REGEXP", "VOID_ELEMENT_TAG_NAMES", "ALL_DOM_ELEMENT_KEYS", "ALL_POSITION_KEYS", "ALL_SIZE_KEYS", "ALL_KEYS", "CLIENT_RECT_TYPE", "ELEMENT_TYPE", "OPTIONS_SHAPE" ], "optimizationBailout": [], "depth": 2, "source": "// external dependencies\nimport PropTypes from 'prop-types';\n\n/**\n * @constant {Object} DEFAULT_OPTIONS\n */\nexport var DEFAULT_OPTIONS = {\n debounce: 0,\n flatten: false,\n inheritedMethods: [],\n positionProp: 'position',\n renderOnResize: true,\n sizeProp: 'size'\n};\n\n/**\n * @constant {Array<string>} BOUNDING_CLIENT_RECT_SIZE_KEYS\n */\nexport var BOUNDING_CLIENT_RECT_SIZE_KEYS = ['height', 'width'];\n\n/**\n * @constant {Array<string>} BOUNDING_CLIENT_RECT_POSITION_KEYS\n */\nexport var BOUNDING_CLIENT_RECT_POSITION_KEYS = ['bottom', 'left', 'right', 'top'];\n\n/**\n * @constant {Array<string>} ALL_BOUNDING_CLIENT_RECT_KEYS\n */\nexport var ALL_BOUNDING_CLIENT_RECT_KEYS = [].concat(BOUNDING_CLIENT_RECT_POSITION_KEYS, BOUNDING_CLIENT_RECT_SIZE_KEYS);\n\n/**\n * @constant {Array<string>} DOM_ELEMENT_POSITION_KEYS\n */\nexport var DOM_ELEMENT_POSITION_KEYS = ['clientLeft', 'clientTop', 'offsetLeft', 'offsetTop', 'scrollLeft', 'scrollTop'];\n\n/**\n * @constant {Array<string>} DOM_ELEMENT_SIZE_KEYS\n */\nexport var DOM_ELEMENT_SIZE_KEYS = ['clientHeight', 'clientWidth', 'naturalHeight', 'naturalWidth', 'offsetHeight', 'offsetWidth', 'scrollHeight', 'scrollWidth'];\n\n/**\n * @constant {RegExp} FUNCTION_NAME_REGEXP\n */\nexport var FUNCTION_NAME_REGEXP = /^\\s*function\\s*([^\\(]*)/i;\n\n/**\n * @constant {RegExp} NATURAL_REGEXP\n */\nexport var NATURAL_REGEXP = /natural/;\n\n/**\n * @constant {Array<string>} VOID_ELEMENT_TAG_NAMES\n */\nexport var VOID_ELEMENT_TAG_NAMES = ['AREA', 'BASE', 'BR', 'COL', 'EMBED', 'HR', 'IMG', 'INPUT', 'LINK', 'MENUITEM', 'META', 'PARAM', 'SOURCE', 'TRACK', 'WBR'];\n\n/**\n * @constant {Array<string>} ALL_DOM_ELEMENT_KEYS\n */\nexport var ALL_DOM_ELEMENT_KEYS = [].concat(DOM_ELEMENT_POSITION_KEYS, DOM_ELEMENT_SIZE_KEYS);\n\n/**\n * @constant {Array<string>} ALL_POSITION_KEYS\n */\nexport var ALL_POSITION_KEYS = [].concat(DOM_ELEMENT_POSITION_KEYS, BOUNDING_CLIENT_RECT_POSITION_KEYS);\n\n/**\n * @constant {Array<string>} ALL_SIZE_KEYS\n */\nexport var ALL_SIZE_KEYS = [].concat(DOM_ELEMENT_SIZE_KEYS, BOUNDING_CLIENT_RECT_SIZE_KEYS);\n\n/**\n * @constant {Array<string>} ALL_KEYS\n */\nexport var ALL_KEYS = [].concat(ALL_POSITION_KEYS, ALL_SIZE_KEYS);\n\n/**\n * @constant {string} CLIENT_RECT_TYPE\n */\nexport var CLIENT_RECT_TYPE = 'clientRect';\n\n/**\n * @constant {string} ELEMENT_TYPE\n */\nexport var ELEMENT_TYPE = 'element';\n\n/**\n * @constant {Object} OPTIONS_SHAPE\n */\nexport var OPTIONS_SHAPE = {\n debounce: PropTypes.number,\n flatten: PropTypes.bool,\n inheritedMethods: PropTypes.arrayOf(PropTypes.string),\n isPure: PropTypes.bool,\n positionProp: PropTypes.string,\n renderOnResize: PropTypes.bool,\n sizeProp: PropTypes.string\n};" }, { "id": 1, "identifier": "/home/tquetano/git/remeasure/node_modules/prop-types/index.js", "name": "./node_modules/prop-types/index.js", "index": 2, "index2": 4, "size": 956, "cacheable": true, "built": true, "optional": false, "prefetched": false, "chunks": [ 0 ], "assets": [], "issuer": "/home/tquetano/git/remeasure/node_modules/babel-loader/lib/index.js!/home/tquetano/git/remeasure/node_modules/eslint-loader/index.js??ref--0!/home/tquetano/git/remeasure/src/index.js", "issuerId": 5, "issuerName": "./src/index.js", "failed": false, "errors": 0, "warnings": 0, "reasons": [ { "moduleId": 0, "moduleIdentifier": "/home/tquetano/git/remeasure/node_modules/babel-loader/lib/index.js!/home/tquetano/git/remeasure/node_modules/eslint-loader/index.js??ref--0!/home/tquetano/git/remeasure/src/constants.js", "module": "./src/constants.js", "moduleName": "./src/constants.js", "type": "harmony import", "userRequest": "prop-types", "loc": "2:0-35" }, { "moduleId": 5, "moduleIdentifier": "/home/tquetano/git/remeasure/node_modules/babel-loader/lib/index.js!/home/tquetano/git/remeasure/node_modules/eslint-loader/index.js??ref--0!/home/tquetano/git/remeasure/src/index.js", "module": "./src/index.js", "moduleName": "./src/index.js", "type": "harmony import", "userRequest": "prop-types", "loc": "4:0-35" } ], "usedExports": [ "default" ], "providedExports": null, "optimizationBailout": [], "depth": 2, "source": "/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nif (process.env.NODE_ENV !== 'production') {\n var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&\n Symbol.for &&\n Symbol.for('react.element')) ||\n 0xeac7;\n\n var isValidElement = function(object) {\n return typeof object === 'object' &&\n object !== null &&\n object.$$typeof === REACT_ELEMENT_TYPE;\n };\n\n // By explicitly using `prop-types` you are opting into new development behavior.\n // http://fb.me/prop-types-in-prod\n var throwOnDirectAccess = true;\n module.exports = require('./factoryWithTypeCheckers')(isValidElement, throwOnDirectAccess);\n} else {\n // By explicitly using `prop-types` you are opting into new production behavior.\n // http://fb.me/prop-types-in-prod\n module.exports = require('./factoryWithThrowingShims')();\n}\n" }, { "id": 2, "identifier": "/home/tquetano/git/remeasure/node_modules/babel-loader/lib/index.js!/home/tquetano/git/remeasure/node_modules/eslint-loader/index.js??ref--0!/home/tquetano/git/remeasure/src/utils.js", "name": "./src/utils.js", "index": 11, "index2": 14, "size": 17214, "cacheable": true, "built": true, "optional": false, "prefetched": false, "chunks": [ 0 ], "assets": [], "issuer": "/home/tquetano/git/remeasure/node_modules/babel-loader/lib/index.js!/home/tquetano/git/remeasure/node_modules/eslint-loader/index.js??ref--0!/home/tquetano/git/remeasure/src/index.js", "issuerId": 5, "issuerName": "./src/index.js", "failed": false, "errors": 0, "warnings": 0, "reasons": [ { "moduleId": 5, "moduleIdentifier": "/home/tquetano/git/remeasure/node_modules/babel-loader/lib/index.js!/home/tquetano/git/remeasure/node_modules/eslint-loader/index.js??ref--0!/home/tquetano/git/remeasure/src/index.js", "module": "./src/index.js", "moduleName": "./src/index.js", "type": "harmony import", "userRequest": "./utils", "loc": "13:0-76" }, { "moduleId": 10, "moduleIdentifier": "/home/tquetano/git/remeasure/node_modules/babel-loader/lib/index.js!/home/tquetano/git/remeasure/node_modules/eslint-loader/index.js??ref--0!/home/tquetano/git/remeasure/src/getMeasuredComponent.js", "module": "./src/getMeasuredComponent.js", "moduleName": "./src/getMeasuredComponent.js", "type": "harmony import", "userRequest": "./utils", "loc": "17:0-245" } ], "usedExports": [ "clearValues", "createFlattenConvenienceFunction", "getComponentName", "getElementValues", "getKeysWithSourceAndType", "getMeasuredKeys", "getScopedValues", "reduceMeasurementsToMatchingKeys", "removeElementResize", "setElement", "setInheritedMethods", "setValuesIfChanged", "updateValuesViaRaf" ], "providedExports": [ "some", "getComponentName", "haveValuesChanged", "setValuesIfChanged", "reduceMeasurementsToMatchingKeys", "getShouldClear", "clearValues", "createUpdateValuesViaDebounce", "updateValuesViaRaf", "isElementVoidTag", "setElementResize", "removeElementResize", "setElement", "createIsKeyType", "createFlattenConvenienceFunction", "getScopedValues", "getNaturalDimensionValue", "getElementValues", "getPropKeyNames", "isPositionKey", "isSizeKey", "getKeyType", "getKeysFromStringKey", "getKeysSubsetWithType", "getKeysWithSourceAndType", "getValidKeys", "getMeasuredKeys", "setInheritedMethods" ], "optimizationBailout": [], "depth": 2, "source": "var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\n// external dependencies\nimport debounce from 'debounce';\nimport raf from 'raf';\nimport ResizeObserver from 'resize-observer-polyfill';\n\n// constants\nimport { ALL_BOUNDING_CLIENT_RECT_KEYS, ALL_DOM_ELEMENT_KEYS, ALL_KEYS, ALL_POSITION_KEYS, ALL_SIZE_KEYS, CLIENT_RECT_TYPE, DEFAULT_OPTIONS, ELEMENT_TYPE, FUNCTION_NAME_REGEXP, NATURAL_REGEXP, VOID_ELEMENT_TAG_NAMES } from './constants';\n\n/**\n * @private\n *\n * @function some\n *\n * @description\n * does any item in the array create a truthy result of calling fn\n *\n * @param {Array<*>} array the array to test\n * @param {function} fn the function to perform the test with\n * @returns {boolean} does any item in the array match\n */\nexport var some = function some(array, fn) {\n for (var index = 0; index < array.length; index++) {\n if (fn(array[index])) {\n return true;\n }\n }\n\n return false;\n};\n\n/**\n * @private\n *\n * @function getComponentName\n *\n * @description\n * get the name of the component from displayName, the internal name, or fallback\n *\n * @param {Component} Component component to get the display name from\n * @returns {string} Component name\n */\nexport var getComponentName = function getComponentName(Component) {\n if (Component.displayName) {\n return Component.displayName;\n }\n\n if (Component.name) {\n return Component.name;\n }\n\n var match = Component.toString().match(FUNCTION_NAME_REGEXP);\n\n return match && match[1] || 'Component';\n};\n\n/**\n * @private\n *\n * @function haveValuesChanged\n *\n * @description\n * iterate through keys and determine if the values have\n * changed compared to what is stored in state\n *\n * @param {Array<Object>} keys keys to get from the state\n * @param {Object} values the new values to test\n * @param {Object} currentState the current values in state\n * @returns {boolean} have any of the keys changed\n */\nexport var haveValuesChanged = function haveValuesChanged(keys, values, currentState) {\n return some(keys, function (_ref) {\n var key = _ref.key;\n\n return values[key] !== currentState[key];\n });\n};\n\n/**\n * @private\n *\n * @function setValuesIfChanged\n *\n * @description\n * if the values have changed and the instance is mounted then set the values in state\n *\n * @param {MeasuredComponent} instance component instance\n * @param {function} instance.setState setState method of instance component\n * @param {Array<string>} keys keys to store in state\n * @param {Object} values updated values to store in state\n */\nexport var setValuesIfChanged = function setValuesIfChanged(instance, keys, values) {\n if (haveValuesChanged(keys, values, instance.measurements)) {\n instance.setMeasurements(values);\n }\n};\n\n/**\n * @private\n *\n * @function reduceMeasurementsToMatchingKeys\n *\n * @description\n * based on desiredKeys, build the initial measurements object\n *\n * @param {Array<string>} keys the keys requested from the decorator\n * @returns {Array<T>} the object of key: 0 default values\n */\nexport var reduceMeasurementsToMatchingKeys = function reduceMeasurementsToMatchingKeys(keys) {\n return keys.reduce(function (accumulatedInitialState, _ref2) {\n var key = _ref2.key;\n\n accumulatedInitialState[key] = 0;\n\n return accumulatedInitialState;\n }, {});\n};\n\n/**\n * @private\n *\n * @function getShouldClear\n *\n * @description\n * get whether the values should be cleared or not based on values in state\n *\n * @param {Object} measurements the current measurement values\n * @param {Array<Object>} selectedKeys the keys to iterate over\n * @returns {boolean} should the values be cleared or not\n */\nexport var getShouldClear = function getShouldClear(measurements, selectedKeys) {\n return some(selectedKeys, function (_ref3) {\n var key = _ref3.key;\n\n return !!measurements[key];\n });\n};\n\n/**\n * @private\n *\n * @function clearValues\n *\n * @description\n * create function to reset all values to 0 if there is no element present\n *\n * @param {MeasuredComponent} instance component instance\n * @param {Array<string>} selectedKeys keys to store in state\n */\nexport var clearValues = function clearValues(instance, selectedKeys) {\n if (getShouldClear(instance.measurements, selectedKeys)) {\n instance.setMeasurements(reduceMeasurementsToMatchingKeys(selectedKeys));\n }\n};\n\n/**\n * @private\n *\n * @function createUpdateValuesViaDebounce\n *\n * @description\n * create the function to update the values via debounce value\n *\n * @param {MeasuredComponent} instance component instance\n * @param {number} debounceValue debounce value for the instance provided\n * @returns {function(): void} function to update the values after debounce timing has passed\n */\nexport var createUpdateValuesViaDebounce = function createUpdateValuesViaDebounce(instance, debounceValue) {\n return debounce(instance.updateValuesIfChanged, debounceValue);\n};\n\n/**\n * @private\n *\n * @function createUpdateValuesViaRaf\n *\n * @description\n * create the function to update the values via requestAnimationFrame\n *\n * @param {MeasuredComponent} instance component instance\n */\nexport var updateValuesViaRaf = function updateValuesViaRaf(instance) {\n raf(instance.updateValuesIfChanged);\n};\n\n/**\n * @private\n *\n * @function isElementVoidTag\n *\n * @description\n * is the element passed a void tag name\n *\n * @param {HTMLElement} element\n * @returns {boolean}\n */\nexport var isElementVoidTag = function isElementVoidTag(element) {\n return !!~VOID_ELEMENT_TAG_NAMES.indexOf(element.tagName.toUpperCase());\n};\n\n/**\n * @private\n *\n * @function setElementResize\n *\n * @description\n * create the function to assign the onResize listener to the element\n *\n * @param {MeasuredComponent} instance component instance\n * @param {number} debounceValue debounce value for the instance provided\n */\nexport var setElementResize = function setElementResize(instance, debounceValue) {\n var element = instance.element;\n\n if (element && !isElementVoidTag(element)) {\n var resizeFn = debounceValue ? createUpdateValuesViaDebounce(instance, debounceValue) : updateValuesViaRaf.bind(null, instance);\n\n instance.resizeListener = resizeFn;\n instance.resizeObserver = new ResizeObserver(resizeFn);\n\n instance.resizeObserver.observe(element);\n }\n};\n\n/**\n * @private\n *\n * @function removeElementResize\n *\n * @description\n * remove listeners from the given element\n *\n * @param {MeasuredComponent} instance component instance\n * @param {HTMLElement} element element to remove listeners from\n */\nexport var removeElementResize = function removeElementResize(instance, element) {\n if (element) {\n instance.resizeObserver.disconnect(element);\n }\n\n instance.resizeListener = null;\n instance.resizeObserver = null;\n};\n\n/**\n * @private\n *\n * @function setElement\n *\n * @description\n * assign the element to the instance\n *\n * @param {MeasuredComponent} instance component instance\n * @param {HTMLElement|null} element element to assign to instance\n * @param {number} debounceValue debounce value for the instance provided\n * @param {boolean} renderOnResize should the component rerender on resize\n * @returns {void}\n */\nexport var setElement = function setElement(instance, element, debounceValue, renderOnResize) {\n var currentElement = instance.element;\n\n instance.element = element;\n\n if (!element) {\n return removeElementResize(instance, currentElement);\n }\n\n if (renderOnResize && !instance.resizeListener) {\n setElementResize(instance, debounceValue);\n }\n};\n\n/**\n * @private\n *\n * @function createIsKeyType\n *\n * @description\n * create a key type checker function\n *\n * @param {Array<string>} typeArray\n * @returns {function(string): boolean}\n */\nexport var createIsKeyType = function createIsKeyType(typeArray) {\n return function (key) {\n return !!~typeArray.indexOf(key);\n };\n};\n\n/**\n * @private\n *\n * @function createFlattenConvenienceFunction\n *\n * @description\n * create a convenience function that will flatten the values returned (specific to property if passed)\n *\n * @param {function} measure main measure function to get the decorator from\n * @param {string} property specific property to build convenience function for\n * @returns {function((function|Object), Object): function} decorator with flatten added as option\n */\nexport var createFlattenConvenienceFunction = function createFlattenConvenienceFunction(measure, property) {\n return function (component) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n var isComponentFunction = typeof component === 'function';\n var decoratorOptions = isComponentFunction ? options : component;\n var decorator = measure(property, _extends({}, decoratorOptions, {\n flatten: true\n }));\n\n return isComponentFunction ? decorator(component) : decorator;\n };\n};\n\n/**\n * @private\n *\n * @function getScopedValues\n *\n * @description\n * based on the keys passed, create an object with either position\n * or size or both properties that are objects containing the respective\n * values for the associated keys\n *\n * @param {Object} values values to reduce by type\n * @param {Array<string>} keys the keys to assign to scopedValues\n * @param {boolean} flatten should the object be flat or not\n * @returns {Object} reduced scoped values\n */\nexport var getScopedValues = function getScopedValues(values, keys, _ref4) {\n var flatten = _ref4.flatten;\n\n return flatten ? values : keys.reduce(function (scopedValues, value) {\n if (!scopedValues[value.type]) {\n scopedValues[value.type] = {};\n }\n\n scopedValues[value.type][value.key] = values[value.key];\n\n return scopedValues;\n }, {});\n};\n\n/**\n * @private\n *\n * @function getNaturalDimensionValue\n *\n * @description\n * For naturalHeight and naturalWidth, coalesce the values\n * with scrollHeight and scrollWIdth if the element does not\n * natively support it\n *\n * @param {HTMLElement} source the element to get the size / position value from\n * @param {string} key the size / position value to retrieve from source\n * @returns {number}\n */\nexport var getNaturalDimensionValue = function getNaturalDimensionValue(source, key) {\n return source.hasOwnProperty(key) ? source[key] : source[key.replace(NATURAL_REGEXP, 'scroll')];\n};\n\n/**\n * @private\n *\n * @function getElementValues\n *\n * @description\n * get the values of the element or its bounding client rect\n *\n * @param {HTMLElement} element\n * @param {Array<Object>} keys\n * @returns {Object}\n */\nexport var getElementValues = function getElementValues(element, keys) {\n var boundingClientRect = element.getBoundingClientRect();\n\n return keys.reduce(function (values, value) {\n values[value.key] = value.source === CLIENT_RECT_TYPE ? boundingClientRect[value.key] : getNaturalDimensionValue(element, value.key);\n\n return values;\n }, {});\n};\n\n/**\n * @private\n *\n * @function getPropKeyNames\n *\n * @description\n * get the positionProp and sizeProp properties from options with defaults applied\n *\n * @param {string} [positionProp=DEFAULT_OPTIONS.positionProp] position property name\n * @param {string} [sizeProp=DEFAULT_OPTIONS.sizeProp] size property name\n * @returns {{positionProp, sizeProp}} object of positionProp and sizeProp\n */\nexport var getPropKeyNames = function getPropKeyNames(_ref5) {\n var _ref5$positionProp = _ref5.positionProp,\n positionProp = _ref5$positionProp === undefined ? DEFAULT_OPTIONS.positionProp : _ref5$positionProp,\n _ref5$sizeProp = _ref5.sizeProp,\n sizeProp = _ref5$sizeProp === undefined ? DEFAULT_OPTIONS.sizeProp : _ref5$sizeProp;\n\n return {\n positionProp: positionProp,\n sizeProp: sizeProp\n };\n};\n\n/**\n * @private\n *\n * @function isPositionKey\n *\n * @description\n * is the key passed a position key\n *\n * @param {string} key\n * @returns {boolean}\n */\nexport var isPositionKey = createIsKeyType(ALL_POSITION_KEYS);\n\n/**\n * @private\n *\n * @function isSizeKey\n *\n * @description\n * is the key passed a size key\n *\n * @param {string} key\n * @returns {boolean}\n */\nexport var isSizeKey = createIsKeyType(ALL_SIZE_KEYS);\n\n/**\n * @private\n *\n * @function getKeyType\n *\n * @description\n * get the type (position or size) of the key passed\n *\n * @param {string} key\n * @param {string} positionProp\n * @param {string} sizeProp\n * @returns {string}\n */\nexport var getKeyType = function getKeyType(key, _ref6) {\n var positionProp = _ref6.positionProp,\n sizeProp = _ref6.sizeProp;\n\n if (isPositionKey(key)) {\n return positionProp;\n }\n\n if (isSizeKey(key)) {\n return sizeProp;\n }\n\n return null;\n};\n\n/**\n * @private\n *\n * @function getKeysFromStringKey\n *\n * @description\n * get the keys to store in state based on the key and options passed\n *\n * @param {string} key string key passed to decorator\n * @param {string} [positionProp=DEFAULT_OPTIONS.positionProp] name of position property requested in options\n * @param {string} [sizeProp=DEFAULT_OPTIONS.sizeProp] name of position property requested in options\n * @returns {Array<string>} keys to store in state\n */\nexport var getKeysFromStringKey = function getKeysFromStringKey(key, _ref7) {\n var _ref7$positionProp = _ref7.positionProp,\n positionProp = _ref7$positionProp === undefined ? DEFAULT_OPTIONS.positionProp : _ref7$positionProp,\n _ref7$sizeProp = _ref7.sizeProp,\n sizeProp = _ref7$sizeProp === undefined ? DEFAULT_OPTIONS.sizeProp : _ref7$sizeProp;\n\n if (key === positionProp) {\n return ALL_POSITION_KEYS;\n }\n\n if (key === sizeProp) {\n return ALL_SIZE_KEYS;\n }\n\n return [key];\n};\n\n/**\n * @private\n *\n * @function getKeysSubsetWithType\n *\n * @description\n * get subset of array1 based on items existing in array2\n *\n * @param {Array<*>} sourceArray the array to filter\n * @param {Array<*>} valuesToExtract the array to find matches in\n * @param {string} source the source of the value the key relates to\n * @param {{positionProp: string, sizeProp: string}} propTypes the names of the scope categories\n * @returns {Array<T>} the resulting array of matching values from array1 and array2\n */\nexport var getKeysSubsetWithType = function getKeysSubsetWithType(sourceArray, valuesToExtract, source, propTypes) {\n return sourceArray.reduce(function (valuesWithTypes, key) {\n if (~valuesToExtract.indexOf(key)) {\n var type = getKeyType(key, propTypes);\n\n if (type !== null) {\n valuesWithTypes.push({\n key: key,\n source: source,\n type: type\n });\n }\n }\n\n return valuesWithTypes;\n }, []);\n};\n\n/**\n * @private\n *\n * @function getKeysWithSourceAndType\n *\n * @description\n * get the keys with mapped source (rect or element) and type (position or size)\n *\n * @param {Array<string>} keys keys to return mapped values for\n * @param {Object} options options passed to instance\n * @returns {Array<{key: string, source: string, type: string}>} keys with source and type mapped\n */\nexport var getKeysWithSourceAndType = function getKeysWithSourceAndType(keys, options) {\n var propKeyNames = getPropKeyNames(options);\n\n return [].concat(getKeysSubsetWithType(ALL_BOUNDING_CLIENT_RECT_KEYS, keys, CLIENT_RECT_TYPE, propKeyNames), getKeysSubsetWithType(ALL_DOM_ELEMENT_KEYS, keys, ELEMENT_TYPE, propKeyNames));\n};\n\n/**\n * @private\n *\n * @description\n * based on their existence in keysToTestAgainst, determine which of the keys\n * passed are considered valid\n *\n * @param {Array<string>} keys the keys to test\n * @param {Array<string>} keysToTestAgainst the keys to find matches from\n * @returns {Array<string>} the resulting matching key set\n */\nexport var getValidKeys = function getValidKeys(keys, keysToTestAgainst) {\n return keys.filter(function (key) {\n return ~keysToTestAgainst.indexOf(key);\n });\n};\n\n/**\n * @private\n *\n * @function getMeasuredKeys\n *\n * @description\n * based on the passed keys and options, get the keys that will be measured\n *\n * @param {Array<string>|string} passedKeys the keys passed to the decorator\n * @param {Object} options the options passed to the decorator\n * @returns {Array<string>} the keys to measure\n */\nexport var getMeasuredKeys = function getMeasuredKeys(passedKeys, options) {\n if (Array.isArray(passedKeys)) {\n return getValidKeys(passedKeys, ALL_KEYS);\n }\n\n if (typeof passedKeys === 'string') {\n return getKeysFromStringKey(passedKeys, options);\n }\n\n return ALL_KEYS;\n};\n\n/**\n * @private\n *\n * @description\n * set methods on this instance that will call the inherited instance method\n *\n * @param {ReactComponent} instance the instance to assign to\n * @param {Array<string>} inheritedMethods the names of inherited methods\n */\nexport var setInheritedMethods = function setInheritedMethods(instance, inheritedMethods) {\n inheritedMethods.forEach(function (method) {\n if (instance[method]) {\n throw new ReferenceError('You cannot have the method ' + method + ' inherited, as it is already taken by the MeasuredComponent HOC.');\n }\n\n instance[method] = function () {\n var _instance$originalCom;\n\n return (_instance$originalCom = instance.originalComponent)[method].apply(_instance$originalCom, arguments);\n };\n });\n};" }, { "id": 3, "identifier": "/home/tquetano/git/remeasure/node_modules/webpack/buildin/global.js", "name": "(webpack)/buildin/global.js", "index": 14, "index2": 9, "size": 509, "cacheable": true, "built": true, "optional": false, "prefetched": false, "chunks": [ 0 ], "assets": [], "issuer": "/home/tquetano/git/remeasure/node_modules/raf/index.js", "issuerId": 14, "issuerName": "./node_modules/raf/index.js", "failed": false, "errors": 0, "warnings": 0, "reasons": [ { "moduleId": 14, "moduleIdentifier": "/home/tquetano/git/remeasure/node_modules/raf/index.js", "module": "./node_modules/raf/index.js", "moduleName": "./node_modules/raf/index.js", "type": "cjs require", "userRequest": "global", "loc": "1:0-41" }, { "moduleId": 17, "moduleIdentifier": "/home/tquetano/git/remeasure/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js", "module": "./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js", "moduleName": "./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js", "type": "cjs require", "userRequest": "global", "loc": "1:0-44" } ], "usedExports": true, "providedExports": null, "optimizationBailout": [], "depth": 4, "source": "var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\r\n} catch(e) {\r\n\t// This works if the window reference is available\r\n\tif(typeof window === \"object\")\r\n\t\tg = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n" }, { "id": 4, "identifier": "multi /home/tquetano/git/remeasure/src/index.js", "name": "multi ./src/index.js", "index": 0, "index2": 17, "size": 28, "cacheable": true, "built": true, "optional": false, "prefetched": false, "chunks": [ 0 ], "assets": [], "issuer": null, "issuerId": null, "issuerName": null, "failed": false, "errors": 0, "warnings": 0, "reasons": [], "usedExports": true, "providedExports": null, "optimizationBailout": [], "depth": 0 }, { "id": 5, "identifier": "/home/tquetano/git/remeasure/node_modules/babel-loader/lib/index.js!/home/tquetano/git/remeasure/node_modules/eslint-loader/index.js??ref--0!/home/tquetano/git/remeasure/src/index.js", "name": "./src/index.js", "index": 1, "index2": 16, "size": 1892, "cacheable": true, "built": true, "optional": false, "prefetched": false, "chunks": [ 0 ], "assets": [], "issuer": "multi /home/tquetano/git/remeasure/src/index.js", "issuerId": 4, "issuerName": "multi ./src/index.js", "failed": false, "errors": 0, "warnings": 0, "reasons": [ { "moduleId": 4, "moduleIdentifier": "multi /home/tquetano/git/remeasure/src/index.js", "module": "multi ./src/index.js", "moduleName": "multi ./src/index.js", "type": "single entry", "userRequest": "/home/tquetano/git/remeasure/src/index.js", "loc": "main:100000" } ], "usedExports": true, "providedExports": [ "default" ], "optimizationBailout": [], "depth": 1, "source": "var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\n// external dependencies\nimport PropTypes from 'prop-types';\n\n// constants\nimport { ALL_KEYS, OPTIONS_SHAPE } from './constants';\n\n// component\nimport getMeasuredComponent from './getMeasuredComponent';\n\n// utils\nimport { createFlattenConvenienceFunction, getMeasuredKeys } from './utils';\n\n/**\n * @module remeasure\n */\n\n/**\n * @function measure\n *\n * @description\n * create higher-order component that injects size and position properties\n * into OriginalComponent as an object under the prop name size and position\n *\n * @param {ReactComponent|Array<string>|Object|string} passedKeys if used without parameters, the component that will be\n * measured, else either single key or array of keys to watch for measurement, or an object of options\n * @param {Object} [passedOptions={}] an object of options to apply for measuring\n * @returns {ReactComponent} the higher-order component that will measure the child and pass down size and\n *\n * position values as props\n */\nvar measure = function measure(passedKeys) {\n var passedOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (typeof passedKeys === 'function') {\n return getMeasuredComponent(ALL_KEYS, passedOptions)(passedKeys);\n }\n\n var options = passedKeys && passedKeys.constructor === Object ? _extends({}, passedKeys) : _extends({}, passedOptions);\n\n PropTypes.checkPropTypes(OPTIONS_SHAPE, options, 'property', 'options');\n\n return getMeasuredComponent(getMeasuredKeys(passedKeys, options), options);\n};\n\nALL_KEYS.forEach(function (key) {\n measure[key] = createFlattenConvenienceFunction(measure, key);\n});\n\nexport default measure;" }, { "id": 6, "identifier": "/home/tquetano/git/remeasure/node_modules/prop-types/factoryWithThrowingShims.js", "name": "./node_modules/prop-types/factoryWithThrowingShims.js", "index": 3, "index2": 3, "size": 1492, "cacheable": true, "built": true, "optional": false, "prefetched": false, "chunks": [ 0 ], "assets": [], "issuer": "/home/tquetano/git/remeasure/node_modules/prop-types/index.js", "issuerId": 1, "issuerName": "./node_modules/prop-types/index.js", "failed": false, "errors": 0, "warnings": 0, "reasons": [ { "moduleId": 1, "moduleIdentifier": "/home/tquetano/git/remeasure/node_modules/prop-types/index.js", "module": "./node_modules/prop-types/index.js", "moduleName": "./node_modules/prop-types/index.js", "type": "cjs require", "userRequest": "./factoryWithThrowingShims", "loc": "27:19-56" } ], "usedExports": true, "providedExports": null, "optimizationBailout": [], "depth": 3, "source": "/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar emptyFunction = require('fbjs/lib/emptyFunction');\nvar invariant = require('fbjs/lib/invariant');\nvar ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');\n\nmodule.exports = function() {\n function shim(props, propName, componentName, location, propFullName, secret) {\n if (secret === ReactPropTypesSecret) {\n // It is still safe when called from React.\n return;\n }\n invariant(\n false,\n 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +\n 'Use PropTypes.checkPropTypes() to call them. ' +\n 'Read more at http://fb.me/use-check-prop-types'\n );\n };\n shim.isRequired = shim;\n function getShim() {\n return shim;\n };\n // Important!\n // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.\n var ReactPropTypes = {\n array: shim,\n bool: shim,\n func: shim,\n number: shim,\n object: shim,\n string: shim,\n symbol: shim,\n\n any: shim,\n arrayOf: getShim,\n element: shim,\n instanceOf: getShim,\n node: shim,\n objectOf: getShim,\n oneOf: getShim,\n oneOfType: getShim,\n shape: getShim,\n exact: getShim\n };\n\n ReactPropTypes.checkPropTypes = emptyFunction;\n ReactPropTypes.PropTypes = ReactPropTypes;\n\n return ReactPropTypes;\n};\n" }, { "id": 7, "identifier": "/home/tquetano/git/remeasure/node_modules/fbjs/lib/emptyFunction.js", "name": "./node_modules/fbjs/lib/emptyFunction.js", "index": 4, "index2": 0, "size": 959, "cacheable": true, "built": true, "optional": false, "prefetched": false, "chunks": [ 0 ], "assets": [], "issuer": "/home/tquetano/git/remeasure/node_modules/prop-types/factoryWithThrowingShims.js", "issuerId": 6, "issuerName": "./node_modules/prop-types/factoryWithThrowingShims.js", "failed": false, "errors": 0, "warnings": 0, "reasons": [ { "moduleId": 6, "moduleIdentifier": "/home/tquetano/git/remeasure/node_modules/prop-types/factoryWithThrowingShims.js", "module": "./node_modules/prop-types/factoryWithThrowingShims.js", "moduleName": "./node_modules/prop-types/factoryWithThrowingShims.js", "type": "cjs require", "userRequest": "fbjs/lib/emptyFunction", "loc": "10:20-53" } ], "usedExports": true, "providedExports": null, "optimizationBailout": [], "depth": 4, "source": "\"use strict\";\n\n/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * \n */\n\nfunction makeEmptyFunction(arg) {\n return function () {\n return arg;\n };\n}\n\n/**\n * This function accepts and discards inputs; it has no side effects. This is\n * primarily useful idiomatically for overridable function endpoints which\n * always need to be callable, since JS lacks a null-call idiom ala Cocoa.\n */\nvar emptyFunction = function emptyFunction() {};\n\nemptyFunction.thatReturns = makeEmptyFunction;\nemptyFunction.thatReturnsFalse = makeEmptyFunction(false);\nemptyFunction.thatReturnsTrue = makeEmptyFunction(true);\nemptyFunction.thatReturnsNull = makeEmptyFunction(null);\nemptyFunction.thatReturnsThis = function () {\n return this;\n};\nemptyFunction.thatReturnsArgument = function (arg) {\n return arg;\n};\n\nmodule.exports = emptyFunction;" }, { "id": 8, "identifier": "/home/tquetano/git/remeasure/node_modules/fbjs/lib/invariant.js", "name": "./node_modules/fbjs/lib/invariant.js", "index": 5, "index2": 1, "size": 1506, "cacheable": true, "built": true, "optional": false, "prefetched": false, "chunks": [ 0 ], "assets": [], "issuer": "/home/tquetano/git/remeasure/node_modules/prop-types/factoryWithThrowingShims.js", "issuerId": 6, "issuerName": "./node_modules/prop-types/factoryWithThrowingShims.js", "failed": false, "errors": 0, "warnings": 0, "reasons": [ { "moduleId": 6, "moduleIdentifier": "/home/tquetano/git/remeasure/node_modules/prop-types/factoryWithThrowingShims.js", "module": "./node_modules/prop-types/factoryWithThrowingShims.js", "moduleName": "./node_modules/prop-types/factoryWithThrowingShims.js", "type": "cjs require", "userRequest": "fbjs/lib/invariant", "loc": "11:16-45" } ], "usedExports": true, "providedExports": null, "optimizationBailout": [], "depth": 4, "source": "/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n'use strict';\n\n/**\n * Use invariant() to assert state which your program assumes to be true.\n *\n * Provide sprintf-style format (only %s is supported) and arguments\n * to provide information about what broke and what you were\n * expecting.\n *\n * The invariant message will be stripped in production, but the invariant\n * will remain to ensure logic does not differ in production.\n */\n\nvar validateFormat = function validateFormat(format) {};\n\nif (process.env.NODE_ENV !== 'production') {\n validateFormat = function validateFormat(format) {\n if (format === undefined) {\n throw new Error('invariant requires an error message argument');\n }\n };\n}\n\nfunction invariant(condition, format, a, b, c, d, e, f) {\n validateFormat(format);\n\n if (!condition) {\n var error;\n if (format === undefined) {\n error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');\n } else {\n var args = [a, b, c, d, e, f];\n var argIndex = 0;\n error = new Error(format.replace(/%s/g, function () {\n return args[argIndex++];\n }));\n error.name = 'Invariant Violation';\n }\n\n error.framesToPop = 1; // we don't care about invariant's own frame\n throw error;\n }\n}\n\nmodule.exports = invariant;" }, { "id": 9, "identifier": "/home/tquetano/git/remeasure/node_modules/prop-types/lib/ReactPropTypesSecret.js", "name": "./node_modules/prop-types/lib/ReactPropTypesSecret.js", "index": 6, "index2": 2, "size": 314, "cacheable": true, "built": true, "optional": false, "prefetched": false, "chunks": [ 0 ], "assets": [], "issuer": "/home/tquetano/git/remeasure/node_modules/prop-types/factoryWithThrowingShims.js", "issuerId": 6, "issuerName": "./node_modules/prop-types/factoryWithThrowingShims.js", "failed": false, "errors": 0, "warnings": 0, "reasons": [ { "moduleId": 6, "moduleIdentifier": "/home/tquetano/git/remeasure/node_modules/prop-types/factoryWithThrowingShims.js", "module": "./node_modules/prop-types/factoryWithThrowingShims.js", "moduleName": "./node_modules/prop-types/factoryWithThrowingShims.js", "type": "cjs require", "userRequest": "./lib/ReactPropTypesSecret", "loc": "12:27-64" } ], "usedExports": true, "providedExports": null, "optimizationBailout": [], "depth": 4, "source": "/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';\n\nmodule.exports = ReactPropTypesSecret;\n" }, { "id": 10, "identifier": "/home/tquetano/git/remeasure/node_modules/babel-loader/lib/index.js!/home/tquetano/git/remeasure/node_modules/eslint-loader/index.js??ref--0!/home/tquetano/git/remeasure/src/getMeasuredComponent.js", "name": "./src/getMeasuredComponent.js", "index": 8, "index2": 15, "size": 8379, "cacheable": true, "built": true, "optional": false, "prefetched": false, "chunks": [ 0 ], "assets": [], "issuer": "/home/tquetano/git/remeasure/node_modules/babel-loader/lib/index.js!/home/tquetano/git/remeasure/node_modules/eslint-loader/index.js??ref--0!/home/tquetano/git/remeasure/src/index.js", "issuerId": 5, "issuerName": "./src/index.js", "failed": false, "errors": 0, "warnings": 0, "reasons": [ { "moduleId": 5, "moduleIdentifier": "/home/tquetano/git/remeasure/node_modules/babel-loader/lib/index.js!/home/tquetano/git/remeasure/node_modules/eslint-loader/index.js??ref--0!/home/tquetano/git/remeasure/src/index.js", "module": "./src/index.js", "moduleName": "./src/index.js", "type": "harmony import", "userRequest": "./getMeasuredComponent", "loc": "10:0-58" } ], "usedExports": [ "default" ], "providedExports": [ "createComponentDidMount", "createComponentDidUpdate", "createComponentWillUnmount", "createSetMeasurements", "createSetOriginalRef", "createUpdateValuesIfChanged", "default" ], "optimizationBailout": [], "depth": 2, "source": "var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new