Socket
Socket
Sign inDemoInstall

@instructure/ui-utils

Package Overview
Dependencies
Maintainers
30
Versions
1980
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@instructure/ui-utils - npm Package Compare versions

Comparing version 5.0.0-dev.10 to 5.0.0-dev.11

36

es/Decimal.js

@@ -1,7 +0,1 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/*

@@ -31,11 +25,4 @@ * The MIT License (MIT)

import { default as DecimalBase } from 'decimal.js/decimal';
import warning from './warning';
import { changedPackageWarning } from './react/deprecated';
import Decimal from 'decimal.js/decimal';
DecimalBase.set({
precision: 100,
toExpPos: 100
});
/**

@@ -49,18 +36,7 @@ * ---

*/
Decimal.set({
precision: 100,
toExpPos: 100
});
var Decimal = function (_DecimalBase) {
_inherits(Decimal, _DecimalBase);
function Decimal() {
_classCallCheck(this, Decimal);
var _this = _possibleConstructorReturn(this, (Decimal.__proto__ || Object.getPrototypeOf(Decimal)).call(this));
warning(false, '[%s] was deprecated in version %s. %s', 'Decimal', '5.0.0', changedPackageWarning('ui-utils', 'ui-i18n') || '');
return _this;
}
return Decimal;
}(DecimalBase);
export { Decimal as default };
export default Decimal;

11

es/dom/addResizeListener.js

@@ -26,3 +26,2 @@ /*

import findDOMNode from './findDOMNode';
import getBoundingClientRect from './getBoundingClientRect';
import requestAnimationFrame from './requestAnimationFrame';

@@ -46,6 +45,3 @@

var node = findDOMNode(el);
var _getBoundingClientRec = getBoundingClientRect(node),
width = _getBoundingClientRec.width;
var width = node.offsetWidth;
var cancelled = false;

@@ -59,6 +55,5 @@ var raf = void 0;

var boundingRect = getBoundingClientRect(node);
var size = {
width: boundingRect.width,
height: boundingRect.height
width: node.offsetWidth,
height: node.offsetHeight
};

@@ -65,0 +60,0 @@

@@ -34,15 +34,13 @@ /*

*
* @param {ReactComponent|DomNode} el - component, DOM node, or function returning a DOM node
* @param {ReactComponent|DomNode} el - component or DOM node
* @returns {DomNode} The root node of this element
*/
export default function findDOMNode(el) {
var node = typeof el === 'function' ? el() : el;
if (node === window) {
return node;
} else if (node === document) {
if (el === window) {
return el;
} else if (el === document) {
return document.documentElement;
} else if (node) {
return ReactDOM.findDOMNode(node); // eslint-disable-line react/no-find-dom-node
} else if (el) {
return ReactDOM.findDOMNode(el); // eslint-disable-line react/no-find-dom-node
}
}

@@ -24,4 +24,5 @@ /*

*/
import UIFindTabbable from '../../../ui-a11y/lib/utils/findTabbable';
import UIFindTabbable from '@instructure/ui-a11y/lib/utils/findTabbable';
import { changedPackageWarning } from '../react/deprecated';

@@ -28,0 +29,0 @@ import warning from '../warning';

@@ -30,3 +30,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

*/
import UIFocusManager from '../../../ui-a11y/lib/utils/focusManager';
import UIFocusManager from '@instructure/ui-a11y/lib/utils/focusManager';

@@ -33,0 +33,0 @@ import { changedPackageWarning } from '../react/deprecated';

@@ -37,4 +37,3 @@ /*

* Includes parents of nodeType 1 (Element nodes such
* as <p> or <div>) that have either been transformed
* or that do not have static position.
* as <p> or <div>) that do not have static position.
*

@@ -59,7 +58,5 @@ * @param {ReactComponent|DomNode} el - component or DOM node

var style = getComputedStyle(parent);
var transform = style.getPropertyValue("-webkit-transform") || style.getPropertyValue("-moz-transform") || style.getPropertyValue("-ms-transform") || style.getPropertyValue("-o-transform") || style.getPropertyValue("transform") || 'none';
// initial value of transform can be 'none' or a matrix equivalent
var transformDefault = transform === 'none' || transform === 'matrix(1, 0, 0, 1, 0, 0)' ? true : false;
var transform = style.getPropertyValue("-webkit-transform") || style.getPropertyValue("-moz-transform") || style.getPropertyValue("-ms-transform") || style.getPropertyValue("-o-transform") || style.getPropertyValue("transform") || null;
if (style.position !== 'static' || !transformDefault) {
if (style.position !== 'static' || transform && transform !== 'none') {
parents.push(parent);

@@ -66,0 +63,0 @@ }

@@ -25,3 +25,3 @@ /*

import DateTime from '../../../ui-i18n/lib/DateTime';
import DateTime from '@instructure/ui-i18n/lib/DateTime';

@@ -28,0 +28,0 @@ import { changedPackageWarning } from '../react/deprecated';

@@ -25,3 +25,3 @@ /*

import Locale from '../../../ui-i18n/lib/Locale';
import Locale from '@instructure/ui-i18n/lib/Locale';

@@ -28,0 +28,0 @@ import { changedPackageWarning } from '../react/deprecated';

@@ -1,7 +0,1 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/*

@@ -31,4 +25,3 @@ * The MIT License (MIT)

import { default as NumeralBase } from 'numeral';
import './locales';
import Numeral from '@instructure/ui-i18n/lib/Numeral';

@@ -38,2 +31,4 @@ import { changedPackageWarning } from '../react/deprecated';

warning(false, '[%s] was deprecated in version %s. %s', 'Numeral', '5.0.0', changedPackageWarning('ui-utils', 'ui-i18n'));
/**

@@ -45,18 +40,2 @@ * ---

*/
var Numeral = function (_NumeralBase) {
_inherits(Numeral, _NumeralBase);
function Numeral() {
_classCallCheck(this, Numeral);
var _this = _possibleConstructorReturn(this, (Numeral.__proto__ || Object.getPrototypeOf(Numeral)).call(this));
warning(false, '[%s] was deprecated in version %s. %s', 'Numeral', '5.0.0', changedPackageWarning('ui-utils', 'ui-i18n') || '');
return _this;
}
return Numeral;
}(NumeralBase);
export { Numeral as default };
export default Numeral;

@@ -25,31 +25,10 @@ /*

export * from './react';
export * from './dom';
export * from './i18n';
import * as dom from './dom';
import * as i18n from './i18n';
import * as react from './react';
import _Browser from './Browser';
export { _Browser as Browser };
import _capitalizeFirstLetter from './capitalizeFirstLetter';
export { _capitalizeFirstLetter as capitalizeFirstLetter };
import _debounce from './debounce';
export { _debounce as debounce };
import _Decimal from './Decimal';
export { _Decimal as Decimal };
import _deepEqual from './deepEqual';
export { _deepEqual as deepEqual };
import _mergeDeep from './mergeDeep';
export { _mergeDeep as mergeDeep };
import _ms from './ms';
export { _ms as ms };
import _parseUnit from './parseUnit';
export { _parseUnit as parseUnit };
import _px from './px';
export { _px as px };
import _shallowEqual from './shallowEqual';
export { _shallowEqual as shallowEqual };
import _uid from './uid';
export { _uid as uid };
import _warning from './warning';
export { _warning as warning };
import _within from './within';
export { _within as within };
export default {
dom: dom,
i18n: i18n,
react: react
};

@@ -38,11 +38,8 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

import PropTypes from 'prop-types';
import getDisplayName from './getDisplayName';
import findDOMNode from '../dom/findDOMNode';
import addResizeListener from '../dom/addResizeListener';
import debounce from '../debounce';
import px from '../px';
import addResizeListener from '@instructure/ui-utils/lib/dom/addResizeListener';
import debounce from '@instructure/ui-utils/lib/debounce';
import { warnDeprecatedComponent } from '@instructure/ui-utils/lib/react/deprecated';
import findDOMNode from '@instructure/ui-utils/lib/dom/findDOMNode';
import getDisplayName from '@instructure/ui-utils/lib/react/getDisplayName';
import parseQuery from '../../../ui-layout/lib/utils/parseQuery';
/**

@@ -52,6 +49,2 @@ * ---

* ---
*
* NOTE: As of 5.0.0, containerQuery has been deprecated. Use the [Responsive](#Responsive)
* component instead.
*
* A decorator or higher order component to provide the ability to style a

@@ -152,4 +145,2 @@ * React component with container queries.

value: function componentDidMount() {
warnDeprecatedComponent('5.0.0', 'containerQuery', 'Use the `Responsive` component instead');
var node = findDOMNode(this);

@@ -200,2 +191,90 @@

function parseQuery(query, el) {
var rules = [];
// eslint-disable-next-line no-restricted-syntax
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = toPairs(query)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var _ref4 = _step2.value;
var _ref5 = _slicedToArray(_ref4, 2);
var selectorName = _ref5[0];
var _ref5$ = _ref5[1];
var minWidth = _ref5$.minWidth;
var maxWidth = _ref5$.maxWidth;
var minHeight = _ref5$.minHeight;
var maxHeight = _ref5$.maxHeight;
rules.push([selectorName, {
minWidth: px(minWidth, el) || 0,
maxWidth: px(maxWidth, el) || Infinity,
minHeight: px(minHeight, el) || 0,
maxHeight: px(maxHeight, el) || Infinity
}]);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
return function (_ref6) {
var width = _ref6.width,
height = _ref6.height;
var selectorMap = {};
// eslint-disable-next-line no-restricted-syntax
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = rules[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var _ref7 = _step3.value;
var _ref8 = _slicedToArray(_ref7, 2);
var _selectorName = _ref8[0];
var _ref8$ = _ref8[1];
var _minWidth = _ref8$.minWidth;
var _maxWidth = _ref8$.maxWidth;
var _minHeight = _ref8$.minHeight;
var _maxHeight = _ref8$.maxHeight;
selectorMap[_selectorName] = _minWidth <= width && width <= _maxWidth && _minHeight <= height && height <= _maxHeight;
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
return selectorMap;
};
}
function toPairs(obj) {

@@ -202,0 +281,0 @@ return Object.keys(obj).map(function (key) {

@@ -27,8 +27,2 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

import React from 'react';
import PropTypes from 'prop-types';
import getDisplayName from './getDisplayName';
import canUseDOM from '../dom/canUseDOM';
/**

@@ -41,2 +35,10 @@ * ---

*/
import React from 'react';
import PropTypes from 'prop-types';
import DateTime from '@instructure/ui-i18n/lib/DateTime';
import getDisplayName from './getDisplayName';
import warning from '../warning';
import canUseDOM from '../dom/canUseDOM';
export default {

@@ -369,3 +371,120 @@ Children: {

element: canUseDOM ? PropTypes.oneOfType([PropTypes.element, PropTypes.instanceOf(Element)]) : PropTypes.element
element: canUseDOM ? PropTypes.oneOfType([PropTypes.element, PropTypes.instanceOf(Element)]) : PropTypes.element,
/**
*
* Validate spacing prop constraining it to the following enumerated values
*
* - '0'
* - 'none'
* - 'auto'
* - 'xxx-small'
* - 'xx-small'
* - 'x-small'
* - 'small'
* - 'medium'
* - 'large'
* - 'x-large'
* - 'xx-large'
*
* Valid inputs include a single value or a string with CSS
* shorthand like syntax with a maximum of 4 values.
*
* Examples of valid inputs:
* 'x-small' (single value)
* 'small large' (CSS shorthand)
* '0 small large x-large' (CSS shorthand max 4 values)
*
* Examples of invalid inputs:
* '5px' (must be a string from the enumerated values)
* '0 large small 0 0' (invalid shorthand syntax w/5 values)
*
* @param {Object} props - object containing the component props
* @param {string} propName - name of the given prop
* @param {string} componentName - name of the component
* @param {string} location
* @param {string} propFullName
* @returns {Error} if is not one of the enumerated values or the shorthand syntax is incorrect
*/
spacing: function spacing(props, propName, componentName, location) {
var validValues = ['0', 'none', 'auto', 'xxx-small', 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'];
var propValue = props[propName];
if (propValue === undefined) {
return;
}
var propValueType = typeof propValue === 'undefined' ? 'undefined' : _typeof(propValue);
if (propValueType !== 'string') {
return new Error('Invalid ' + location + ' `' + propName + '` of type `' + propValueType + '` supplied to `' + componentName + '`, expected ' + 'a string.');
}
var propValues = propValue.split(' ');
var valuesLength = propValues.length;
if (valuesLength > 0 && valuesLength < 5) {
for (var i = 0; i < valuesLength; i++) {
var valueIndex = validValues.indexOf(propValues[i]);
if (valueIndex === -1) {
return new Error('Invalid ' + location + ' `' + propName + '` `' + propValues[i] + '` supplied to `' + componentName + '`, expected ' + ('a one of `' + validValues.join(', ') + '`.'));
}
}
} else {
return new Error('Invalid ' + location + ' `' + propName + '` `' + propValue + '` supplied to `' + componentName + '`, expected ' + ('between one and four of the following valid values: `' + validValues.join(', ') + '`.'));
}
},
/**
*
* Verify that the given prop is a correctly formatted ISO 8601 formatted string.
*
* @param {Object} props - object containing the component props
* @param {string} propName - name of the given prop
* @param {string} componentName - name of the component
* @param {string} location
* @param {string} propFullName
* @returns {Error} if prop is an invalid ISO 8601 string
*/
iso8601: function iso8601(props, propName, componentName, location) {
var propValue = props[propName];
if (propValue === undefined) return;
var propValueType = typeof propValue === 'undefined' ? 'undefined' : _typeof(propValue);
if (typeof propValueType !== 'string') {
return new Error('Invalid ' + location + ' `' + propName + '` of type `' + propValueType + '` supplied to `' + componentName + '`, expected ' + 'an ISO 8601 formatted string.');
}
if (!DateTime.isValid(propValue)) {
return new Error('Invalid ' + location + ' `' + propName + '` `' + propValue + '` supplied to `' + componentName + '`, expected ' + 'an ISO 8601 formatted string.');
}
},
/**
*
* Trigger a console warning if the specified prop variant is deprecated
*
* @param {function} propType - validates the prop type. Returns null if valid, error otherwise
* @param {string} deprecated - name of the deprecated variant
* @param {string} message - additional information to display with the warning
*/
deprecatedVariant: function deprecatedVariant(propType, deprecated, message) {
warning(false, '[%] was deprecated in version %s. %s', 'deprecatedVariant', '5.0.0', 'Use `deprecatePropValues` instead.');
return function (props, propName, componentName, location) {
warning(props[propName] !== deprecated, '`' + componentName + '` `' + deprecated + '` variant is deprecated. ' + (message || ''));
};
},
message: PropTypes.shape({
text: PropTypes.string,
type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
}),
placement: PropTypes.oneOf(['top', 'end', 'bottom', 'start', 'top start', 'start top', 'start center', 'start bottom', 'bottom start', 'bottom center', 'bottom end', 'end bottom', 'end center', 'end top', 'top end', 'top center', 'center end', 'center start', 'top stretch', 'bottom stretch', 'end stretch', 'start stretch', 'offscreen']),
size: PropTypes.oneOf(['x-small', 'small', 'medium', 'large', 'x-large'])
};

@@ -147,3 +147,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

export function warnDeprecatedComponent(version, componentName, message) {
function warnDeprecatedComponent(version, componentName, message) {
warning(false, '[%s] was deprecated in version %s. %s', componentName, version, message || '');

@@ -150,0 +150,0 @@ }

@@ -6,3 +6,2 @@ 'use strict';

});
exports.default = undefined;

@@ -13,43 +12,4 @@ var _decimal = require('decimal.js/decimal');

var _warning = require('./warning');
var _warning2 = _interopRequireDefault(_warning);
var _deprecated = require('./react/deprecated');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /*
* The MIT License (MIT)
*
* Copyright (c) 2015 - present Instructure, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
_decimal2.default.set({
precision: 100,
toExpPos: 100
});
/**

@@ -63,18 +23,29 @@ * ---

*/
_decimal2.default.set({
precision: 100,
toExpPos: 100
}); /*
* The MIT License (MIT)
*
* Copyright (c) 2015 - present Instructure, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
var Decimal = function (_DecimalBase) {
_inherits(Decimal, _DecimalBase);
function Decimal() {
_classCallCheck(this, Decimal);
var _this = _possibleConstructorReturn(this, (Decimal.__proto__ || Object.getPrototypeOf(Decimal)).call(this));
(0, _warning2.default)(false, '[%s] was deprecated in version %s. %s', 'Decimal', '5.0.0', (0, _deprecated.changedPackageWarning)('ui-utils', 'ui-i18n') || '');
return _this;
}
return Decimal;
}(_decimal2.default);
exports.default = Decimal;
exports.default = _decimal2.default;

@@ -12,6 +12,2 @@ 'use strict';

var _getBoundingClientRect = require('./getBoundingClientRect');
var _getBoundingClientRect2 = _interopRequireDefault(_getBoundingClientRect);
var _requestAnimationFrame = require('./requestAnimationFrame');

@@ -37,8 +33,29 @@

*/
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 - present Instructure, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
function addResizeListener(el, handler) {
var node = (0, _findDOMNode2.default)(el);
var _getBoundingClientRec = (0, _getBoundingClientRect2.default)(node),
width = _getBoundingClientRec.width;
var width = node.offsetWidth;
var cancelled = false;

@@ -52,6 +69,5 @@ var raf = void 0;

var boundingRect = (0, _getBoundingClientRect2.default)(node);
var size = {
width: boundingRect.width,
height: boundingRect.height
width: node.offsetWidth,
height: node.offsetHeight
};

@@ -76,24 +92,2 @@

};
} /*
* The MIT License (MIT)
*
* Copyright (c) 2015 - present Instructure, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
}

@@ -21,14 +21,12 @@ 'use strict';

*
* @param {ReactComponent|DomNode} el - component, DOM node, or function returning a DOM node
* @param {ReactComponent|DomNode} el - component or DOM node
* @returns {DomNode} The root node of this element
*/
function findDOMNode(el) {
var node = typeof el === 'function' ? el() : el;
if (node === window) {
return node;
} else if (node === document) {
if (el === window) {
return el;
} else if (el === document) {
return document.documentElement;
} else if (node) {
return _reactDom2.default.findDOMNode(node); // eslint-disable-line react/no-find-dom-node
} else if (el) {
return _reactDom2.default.findDOMNode(el); // eslint-disable-line react/no-find-dom-node
}

@@ -35,0 +33,0 @@ } /*

@@ -8,3 +8,3 @@ 'use strict';

var _findTabbable = require('../../../ui-a11y/lib/utils/findTabbable');
var _findTabbable = require('@instructure/ui-a11y/lib/utils/findTabbable');

@@ -11,0 +11,0 @@ var _findTabbable2 = _interopRequireDefault(_findTabbable);

@@ -8,3 +8,3 @@ 'use strict';

var _focusManager = require('../../../ui-a11y/lib/utils/focusManager');
var _focusManager = require('@instructure/ui-a11y/lib/utils/focusManager');

@@ -11,0 +11,0 @@ var _focusManager2 = _interopRequireDefault(_focusManager);

@@ -33,4 +33,3 @@ 'use strict';

* Includes parents of nodeType 1 (Element nodes such
* as <p> or <div>) that have either been transformed
* or that do not have static position.
* as <p> or <div>) that do not have static position.
*

@@ -79,7 +78,5 @@ * @param {ReactComponent|DomNode} el - component or DOM node

var style = (0, _getComputedStyle2.default)(parent);
var transform = style.getPropertyValue("-webkit-transform") || style.getPropertyValue("-moz-transform") || style.getPropertyValue("-ms-transform") || style.getPropertyValue("-o-transform") || style.getPropertyValue("transform") || 'none';
// initial value of transform can be 'none' or a matrix equivalent
var transformDefault = transform === 'none' || transform === 'matrix(1, 0, 0, 1, 0, 0)' ? true : false;
var transform = style.getPropertyValue("-webkit-transform") || style.getPropertyValue("-moz-transform") || style.getPropertyValue("-ms-transform") || style.getPropertyValue("-o-transform") || style.getPropertyValue("transform") || null;
if (style.position !== 'static' || !transformDefault) {
if (style.position !== 'static' || transform && transform !== 'none') {
parents.push(parent);

@@ -86,0 +83,0 @@ }

@@ -11,3 +11,3 @@ 'use strict';

var _DateTime = require('../../../ui-i18n/lib/DateTime');
var _DateTime = require('@instructure/ui-i18n/lib/DateTime');

@@ -14,0 +14,0 @@ var _DateTime2 = _interopRequireDefault(_DateTime);

@@ -7,3 +7,3 @@ 'use strict';

var _Locale = require('../../../ui-i18n/lib/Locale');
var _Locale = require('@instructure/ui-i18n/lib/Locale');

@@ -10,0 +10,0 @@ var _Locale2 = _interopRequireDefault(_Locale);

@@ -6,10 +6,7 @@ 'use strict';

});
exports.default = undefined;
var _numeral = require('numeral');
var _Numeral = require('@instructure/ui-i18n/lib/Numeral');
var _numeral2 = _interopRequireDefault(_numeral);
var _Numeral2 = _interopRequireDefault(_Numeral);
require('./locales');
var _deprecated = require('../react/deprecated');

@@ -23,30 +20,4 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
(0, _warning2.default)(false, '[%s] was deprecated in version %s. %s', 'Numeral', '5.0.0', (0, _deprecated.changedPackageWarning)('ui-utils', 'ui-i18n'));
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /*
* The MIT License (MIT)
*
* Copyright (c) 2015 - present Instructure, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**

@@ -58,17 +29,26 @@ * ---

*/
var Numeral = function (_NumeralBase) {
_inherits(Numeral, _NumeralBase);
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 - present Instructure, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
function Numeral() {
_classCallCheck(this, Numeral);
var _this = _possibleConstructorReturn(this, (Numeral.__proto__ || Object.getPrototypeOf(Numeral)).call(this));
(0, _warning2.default)(false, '[%s] was deprecated in version %s. %s', 'Numeral', '5.0.0', (0, _deprecated.changedPackageWarning)('ui-utils', 'ui-i18n') || '');
return _this;
}
return Numeral;
}(_numeral2.default);
exports.default = Numeral;
exports.default = _Numeral2.default;

@@ -6,130 +6,43 @@ 'use strict';

});
exports.within = exports.warning = exports.uid = exports.shallowEqual = exports.px = exports.parseUnit = exports.ms = exports.mergeDeep = exports.deepEqual = exports.Decimal = exports.debounce = exports.capitalizeFirstLetter = exports.Browser = undefined;
var _react = require('./react');
Object.keys(_react).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _react[key];
}
});
});
var _dom = require('./dom');
Object.keys(_dom).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _dom[key];
}
});
});
var dom = _interopRequireWildcard(_dom);
var _i18n = require('./i18n');
Object.keys(_i18n).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _i18n[key];
}
});
});
var i18n = _interopRequireWildcard(_i18n);
var _Browser2 = require('./Browser');
var _react = require('./react');
var _Browser3 = _interopRequireDefault(_Browser2);
var react = _interopRequireWildcard(_react);
var _capitalizeFirstLetter2 = require('./capitalizeFirstLetter');
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
var _capitalizeFirstLetter3 = _interopRequireDefault(_capitalizeFirstLetter2);
var _debounce2 = require('./debounce');
var _debounce3 = _interopRequireDefault(_debounce2);
var _Decimal2 = require('./Decimal');
var _Decimal3 = _interopRequireDefault(_Decimal2);
var _deepEqual2 = require('./deepEqual');
var _deepEqual3 = _interopRequireDefault(_deepEqual2);
var _mergeDeep2 = require('./mergeDeep');
var _mergeDeep3 = _interopRequireDefault(_mergeDeep2);
var _ms2 = require('./ms');
var _ms3 = _interopRequireDefault(_ms2);
var _parseUnit2 = require('./parseUnit');
var _parseUnit3 = _interopRequireDefault(_parseUnit2);
var _px2 = require('./px');
var _px3 = _interopRequireDefault(_px2);
var _shallowEqual2 = require('./shallowEqual');
var _shallowEqual3 = _interopRequireDefault(_shallowEqual2);
var _uid2 = require('./uid');
var _uid3 = _interopRequireDefault(_uid2);
var _warning2 = require('./warning');
var _warning3 = _interopRequireDefault(_warning2);
var _within2 = require('./within');
var _within3 = _interopRequireDefault(_within2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 - present Instructure, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
exports.Browser = _Browser3.default;
exports.capitalizeFirstLetter = _capitalizeFirstLetter3.default;
exports.debounce = _debounce3.default;
exports.Decimal = _Decimal3.default;
exports.deepEqual = _deepEqual3.default;
exports.mergeDeep = _mergeDeep3.default;
exports.ms = _ms3.default;
exports.parseUnit = _parseUnit3.default;
exports.px = _px3.default;
exports.shallowEqual = _shallowEqual3.default;
exports.uid = _uid3.default;
exports.warning = _warning3.default;
exports.within = _within3.default;
exports.default = {
dom: dom,
i18n: i18n,
react: react
}; /*
* The MIT License (MIT)
*
* Copyright (c) 2015 - present Instructure, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

@@ -19,24 +19,22 @@ 'use strict';

var _addResizeListener = require('@instructure/ui-utils/lib/dom/addResizeListener');
var _getDisplayName = require('./getDisplayName');
var _addResizeListener2 = _interopRequireDefault(_addResizeListener);
var _getDisplayName2 = _interopRequireDefault(_getDisplayName);
var _debounce = require('@instructure/ui-utils/lib/debounce');
var _findDOMNode = require('../dom/findDOMNode');
var _debounce2 = _interopRequireDefault(_debounce);
var _findDOMNode2 = _interopRequireDefault(_findDOMNode);
var _deprecated = require('@instructure/ui-utils/lib/react/deprecated');
var _addResizeListener = require('../dom/addResizeListener');
var _findDOMNode = require('@instructure/ui-utils/lib/dom/findDOMNode');
var _addResizeListener2 = _interopRequireDefault(_addResizeListener);
var _findDOMNode2 = _interopRequireDefault(_findDOMNode);
var _debounce = require('../debounce');
var _getDisplayName = require('@instructure/ui-utils/lib/react/getDisplayName');
var _debounce2 = _interopRequireDefault(_debounce);
var _getDisplayName2 = _interopRequireDefault(_getDisplayName);
var _px = require('../px');
var _parseQuery = require('../../../ui-layout/lib/utils/parseQuery');
var _px2 = _interopRequireDefault(_px);
var _parseQuery2 = _interopRequireDefault(_parseQuery);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -76,6 +74,2 @@

* ---
*
* NOTE: As of 5.0.0, containerQuery has been deprecated. Use the [Responsive](#Responsive)
* component instead.
*
* A decorator or higher order component to provide the ability to style a

@@ -98,3 +92,3 @@ * React component with container queries.

var getSelectorMap = function getSelectorMap(el) {
return query && (0, _parseQuery2.default)(query, el);
return query && parseQuery(query, el);
};

@@ -177,4 +171,2 @@

value: function componentDidMount() {
(0, _deprecated.warnDeprecatedComponent)('5.0.0', 'containerQuery', 'Use the `Responsive` component instead');
var node = (0, _findDOMNode2.default)(this);

@@ -225,2 +217,90 @@

function parseQuery(query, el) {
var rules = [];
// eslint-disable-next-line no-restricted-syntax
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = toPairs(query)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var _ref4 = _step2.value;
var _ref5 = _slicedToArray(_ref4, 2);
var selectorName = _ref5[0];
var _ref5$ = _ref5[1];
var minWidth = _ref5$.minWidth;
var maxWidth = _ref5$.maxWidth;
var minHeight = _ref5$.minHeight;
var maxHeight = _ref5$.maxHeight;
rules.push([selectorName, {
minWidth: (0, _px2.default)(minWidth, el) || 0,
maxWidth: (0, _px2.default)(maxWidth, el) || Infinity,
minHeight: (0, _px2.default)(minHeight, el) || 0,
maxHeight: (0, _px2.default)(maxHeight, el) || Infinity
}]);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
return function (_ref6) {
var width = _ref6.width,
height = _ref6.height;
var selectorMap = {};
// eslint-disable-next-line no-restricted-syntax
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = rules[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var _ref7 = _step3.value;
var _ref8 = _slicedToArray(_ref7, 2);
var _selectorName = _ref8[0];
var _ref8$ = _ref8[1];
var _minWidth = _ref8$.minWidth;
var _maxWidth = _ref8$.maxWidth;
var _minHeight = _ref8$.minHeight;
var _maxHeight = _ref8$.maxHeight;
selectorMap[_selectorName] = _minWidth <= width && width <= _maxWidth && _minHeight <= height && height <= _maxHeight;
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
return selectorMap;
};
}
function toPairs(obj) {

@@ -227,0 +307,0 @@ return Object.keys(obj).map(function (key) {

@@ -31,2 +31,11 @@ 'use strict';

/**
* ---
* category: utilities/react
* ---
* Custom prop types for React components.
* @module CustomPropTypes
*/
var _react = require('react');

@@ -40,2 +49,6 @@

var _DateTime = require('@instructure/ui-i18n/lib/DateTime');
var _DateTime2 = _interopRequireDefault(_DateTime);
var _getDisplayName = require('./getDisplayName');

@@ -45,2 +58,6 @@

var _warning = require('../warning');
var _warning2 = _interopRequireDefault(_warning);
var _canUseDOM = require('../dom/canUseDOM');

@@ -52,9 +69,2 @@

/**
* ---
* category: utilities/react
* ---
* Custom prop types for React components.
* @module CustomPropTypes
*/
exports.default = {

@@ -387,3 +397,120 @@ Children: {

element: _canUseDOM2.default ? _propTypes2.default.oneOfType([_propTypes2.default.element, _propTypes2.default.instanceOf(Element)]) : _propTypes2.default.element
element: _canUseDOM2.default ? _propTypes2.default.oneOfType([_propTypes2.default.element, _propTypes2.default.instanceOf(Element)]) : _propTypes2.default.element,
/**
*
* Validate spacing prop constraining it to the following enumerated values
*
* - '0'
* - 'none'
* - 'auto'
* - 'xxx-small'
* - 'xx-small'
* - 'x-small'
* - 'small'
* - 'medium'
* - 'large'
* - 'x-large'
* - 'xx-large'
*
* Valid inputs include a single value or a string with CSS
* shorthand like syntax with a maximum of 4 values.
*
* Examples of valid inputs:
* 'x-small' (single value)
* 'small large' (CSS shorthand)
* '0 small large x-large' (CSS shorthand max 4 values)
*
* Examples of invalid inputs:
* '5px' (must be a string from the enumerated values)
* '0 large small 0 0' (invalid shorthand syntax w/5 values)
*
* @param {Object} props - object containing the component props
* @param {string} propName - name of the given prop
* @param {string} componentName - name of the component
* @param {string} location
* @param {string} propFullName
* @returns {Error} if is not one of the enumerated values or the shorthand syntax is incorrect
*/
spacing: function spacing(props, propName, componentName, location) {
var validValues = ['0', 'none', 'auto', 'xxx-small', 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'];
var propValue = props[propName];
if (propValue === undefined) {
return;
}
var propValueType = typeof propValue === 'undefined' ? 'undefined' : _typeof(propValue);
if (propValueType !== 'string') {
return new Error('Invalid ' + location + ' `' + propName + '` of type `' + propValueType + '` supplied to `' + componentName + '`, expected ' + 'a string.');
}
var propValues = propValue.split(' ');
var valuesLength = propValues.length;
if (valuesLength > 0 && valuesLength < 5) {
for (var i = 0; i < valuesLength; i++) {
var valueIndex = validValues.indexOf(propValues[i]);
if (valueIndex === -1) {
return new Error('Invalid ' + location + ' `' + propName + '` `' + propValues[i] + '` supplied to `' + componentName + '`, expected ' + ('a one of `' + validValues.join(', ') + '`.'));
}
}
} else {
return new Error('Invalid ' + location + ' `' + propName + '` `' + propValue + '` supplied to `' + componentName + '`, expected ' + ('between one and four of the following valid values: `' + validValues.join(', ') + '`.'));
}
},
/**
*
* Verify that the given prop is a correctly formatted ISO 8601 formatted string.
*
* @param {Object} props - object containing the component props
* @param {string} propName - name of the given prop
* @param {string} componentName - name of the component
* @param {string} location
* @param {string} propFullName
* @returns {Error} if prop is an invalid ISO 8601 string
*/
iso8601: function iso8601(props, propName, componentName, location) {
var propValue = props[propName];
if (propValue === undefined) return;
var propValueType = typeof propValue === 'undefined' ? 'undefined' : _typeof(propValue);
if (typeof propValueType !== 'string') {
return new Error('Invalid ' + location + ' `' + propName + '` of type `' + propValueType + '` supplied to `' + componentName + '`, expected ' + 'an ISO 8601 formatted string.');
}
if (!_DateTime2.default.isValid(propValue)) {
return new Error('Invalid ' + location + ' `' + propName + '` `' + propValue + '` supplied to `' + componentName + '`, expected ' + 'an ISO 8601 formatted string.');
}
},
/**
*
* Trigger a console warning if the specified prop variant is deprecated
*
* @param {function} propType - validates the prop type. Returns null if valid, error otherwise
* @param {string} deprecated - name of the deprecated variant
* @param {string} message - additional information to display with the warning
*/
deprecatedVariant: function deprecatedVariant(propType, deprecated, message) {
(0, _warning2.default)(false, '[%] was deprecated in version %s. %s', 'deprecatedVariant', '5.0.0', 'Use `deprecatePropValues` instead.');
return function (props, propName, componentName, location) {
(0, _warning2.default)(props[propName] !== deprecated, '`' + componentName + '` `' + deprecated + '` variant is deprecated. ' + (message || ''));
};
},
message: _propTypes2.default.shape({
text: _propTypes2.default.string,
type: _propTypes2.default.oneOf(['error', 'hint', 'success', 'screenreader-only'])
}),
placement: _propTypes2.default.oneOf(['top', 'end', 'bottom', 'start', 'top start', 'start top', 'start center', 'start bottom', 'bottom start', 'bottom center', 'bottom end', 'end bottom', 'end center', 'end top', 'top end', 'top center', 'center end', 'center start', 'top stretch', 'bottom stretch', 'end stretch', 'start stretch', 'offscreen']),
size: _propTypes2.default.oneOf(['x-small', 'small', 'medium', 'large', 'x-large'])
};

@@ -13,3 +13,2 @@ 'use strict';

exports.default = deprecated;
exports.warnDeprecatedComponent = warnDeprecatedComponent;
exports.changedPackageWarning = changedPackageWarning;

@@ -16,0 +15,0 @@

{
"name": "@instructure/ui-utils",
"version": "5.0.0-dev.10",
"version": "5.0.0-dev.11",
"description": "A collection of utilities for UI components",

@@ -25,3 +25,3 @@ "author": "Instructure, Inc. Engineering and Product Design",

"devDependencies": {
"@instructure/ui-presets": "^5.0.0-dev.10",
"@instructure/ui-presets": "^5.0.0-dev.11",
"react": "15.6.2",

@@ -31,3 +31,4 @@ "react-dom": "15.6.2"

"dependencies": {
"bowser": "^1.9.1",
"@instructure/ui-i18n": "^5.0.0-dev.11",
"bowser": "^1.9.2",
"decimal.js": "^9.0.1",

@@ -37,3 +38,2 @@ "deep-equal": "^1.0.1",

"no-scroll": "^2.1.0",
"numeral": "^2.0.6",
"object.omit": "^3.0.0",

@@ -40,0 +40,0 @@ "object.pick": "^1.2.0",

@@ -25,11 +25,4 @@ /*

import { default as DecimalBase } from 'decimal.js/decimal'
import warning from './warning'
import { changedPackageWarning } from './react/deprecated'
import Decimal from 'decimal.js/decimal'
DecimalBase.set({
precision: 100,
toExpPos: 100
})
/**

@@ -43,10 +36,7 @@ * ---

*/
export default class Decimal extends DecimalBase {
constructor () {
super()
warning(false, '[%s] was deprecated in version %s. %s', 'Decimal', '5.0.0', changedPackageWarning(
'ui-utils',
'ui-i18n'
) || '')
}
}
Decimal.set({
precision: 100,
toExpPos: 100
})
export default Decimal

@@ -26,3 +26,2 @@ /*

import findDOMNode from './findDOMNode'
import getBoundingClientRect from './getBoundingClientRect'
import requestAnimationFrame from './requestAnimationFrame'

@@ -46,3 +45,3 @@

const node = findDOMNode(el)
let { width } = getBoundingClientRect(node)
let width = node.offsetWidth
let cancelled = false

@@ -56,6 +55,5 @@ let raf

const boundingRect = getBoundingClientRect(node)
const size = {
width: boundingRect.width,
height: boundingRect.height
width: node.offsetWidth,
height: node.offsetHeight
}

@@ -62,0 +60,0 @@

@@ -34,15 +34,13 @@ /*

*
* @param {ReactComponent|DomNode} el - component, DOM node, or function returning a DOM node
* @param {ReactComponent|DomNode} el - component or DOM node
* @returns {DomNode} The root node of this element
*/
export default function findDOMNode (el) {
const node = typeof el === 'function' ? el() : el
if (node === window) {
return node
} else if (node === document) {
if (el === window) {
return el
} else if (el === document) {
return document.documentElement
} else if (node) {
return ReactDOM.findDOMNode(node) // eslint-disable-line react/no-find-dom-node
} else if (el) {
return ReactDOM.findDOMNode(el) // eslint-disable-line react/no-find-dom-node
}
}

@@ -24,4 +24,5 @@ /*

*/
import UIFindTabbable from '../../../ui-a11y/lib/utils/findTabbable'
import UIFindTabbable from '@instructure/ui-a11y/lib/utils/findTabbable'
import { changedPackageWarning } from '../react/deprecated'

@@ -28,0 +29,0 @@ import warning from '../warning'

@@ -24,3 +24,3 @@ /*

*/
import UIFocusManager from '../../../ui-a11y/lib/utils/focusManager'
import UIFocusManager from '@instructure/ui-a11y/lib/utils/focusManager'

@@ -27,0 +27,0 @@ import { changedPackageWarning } from '../react/deprecated'

@@ -37,4 +37,3 @@ /*

* Includes parents of nodeType 1 (Element nodes such
* as <p> or <div>) that have either been transformed
* or that do not have static position.
* as <p> or <div>) that do not have static position.
*

@@ -63,7 +62,5 @@ * @param {ReactComponent|DomNode} el - component or DOM node

style.getPropertyValue("-o-transform") ||
style.getPropertyValue("transform") || 'none'
// initial value of transform can be 'none' or a matrix equivalent
const transformDefault = transform === 'none' || transform === 'matrix(1, 0, 0, 1, 0, 0)' ? true : false
style.getPropertyValue("transform") || null
if (style.position !== 'static' || !transformDefault) {
if (style.position !== 'static' || (transform && transform !== 'none')) {
parents.push(parent)

@@ -70,0 +67,0 @@ }

@@ -25,3 +25,3 @@ /*

import DateTime from '../../../ui-i18n/lib/DateTime'
import DateTime from '@instructure/ui-i18n/lib/DateTime'

@@ -28,0 +28,0 @@ import { changedPackageWarning } from '../react/deprecated'

@@ -25,3 +25,3 @@ /*

import Locale from '../../../ui-i18n/lib/Locale'
import Locale from '@instructure/ui-i18n/lib/Locale'

@@ -28,0 +28,0 @@ import { changedPackageWarning } from '../react/deprecated'

@@ -25,4 +25,3 @@ /*

import { default as NumeralBase } from 'numeral'
import './locales'
import Numeral from '@instructure/ui-i18n/lib/Numeral'

@@ -32,2 +31,10 @@ import { changedPackageWarning } from '../react/deprecated'

warning(
false,
'[%s] was deprecated in version %s. %s',
'Numeral',
'5.0.0',
changedPackageWarning('ui-utils', 'ui-i18n')
)
/**

@@ -39,10 +46,2 @@ * ---

*/
export default class Numeral extends NumeralBase {
constructor () {
super()
warning(false, '[%s] was deprecated in version %s. %s', 'Numeral', '5.0.0', changedPackageWarning(
'ui-utils',
'ui-i18n'
) || '')
}
}
export default Numeral

@@ -25,18 +25,10 @@ /*

export * from './react'
export * from './dom'
export * from './i18n'
import * as dom from './dom'
import * as i18n from './i18n'
import * as react from './react'
export Browser from './Browser'
export capitalizeFirstLetter from './capitalizeFirstLetter'
export debounce from './debounce'
export Decimal from './Decimal'
export deepEqual from './deepEqual'
export mergeDeep from './mergeDeep'
export ms from './ms'
export parseUnit from './parseUnit'
export px from './px'
export shallowEqual from './shallowEqual'
export uid from './uid'
export warning from './warning'
export within from './within'
export default {
dom,
i18n,
react
}

@@ -26,11 +26,8 @@ /*

import PropTypes from 'prop-types'
import getDisplayName from './getDisplayName'
import findDOMNode from '../dom/findDOMNode'
import addResizeListener from '../dom/addResizeListener'
import debounce from '../debounce'
import px from '../px'
import addResizeListener from '@instructure/ui-utils/lib/dom/addResizeListener'
import debounce from '@instructure/ui-utils/lib/debounce'
import { warnDeprecatedComponent } from '@instructure/ui-utils/lib/react/deprecated'
import findDOMNode from '@instructure/ui-utils/lib/dom/findDOMNode'
import getDisplayName from '@instructure/ui-utils/lib/react/getDisplayName'
import parseQuery from '../../../ui-layout/lib/utils/parseQuery'
/**

@@ -40,6 +37,2 @@ * ---

* ---
*
* NOTE: As of 5.0.0, containerQuery has been deprecated. Use the [Responsive](#Responsive)
* component instead.
*
* A decorator or higher order component to provide the ability to style a

@@ -104,4 +97,2 @@ * React component with container queries.

componentDidMount () {
warnDeprecatedComponent('5.0.0', 'containerQuery', 'Use the `Responsive` component instead')
const node = findDOMNode(this)

@@ -145,4 +136,35 @@

function parseQuery (query, el) {
const rules = []
// eslint-disable-next-line no-restricted-syntax
for (const [selectorName, {minWidth, maxWidth, minHeight, maxHeight}] of toPairs(query)) {
rules.push([
selectorName,
{
minWidth: px(minWidth, el) || 0,
maxWidth: px(maxWidth, el) || Infinity,
minHeight: px(minHeight, el) || 0,
maxHeight: px(maxHeight, el) || Infinity
}
])
}
return function ({width, height}) {
const selectorMap = {}
// eslint-disable-next-line no-restricted-syntax
for (const [selectorName, {minWidth, maxWidth, minHeight, maxHeight}] of rules) {
selectorMap[selectorName] = (
minWidth <= width && width <= maxWidth &&
minHeight <= height && height <= maxHeight
)
}
return selectorMap
}
}
function toPairs (obj) {
return Object.keys(obj).map((key) => [key, obj[key]])
}

@@ -25,8 +25,2 @@ /*

import React from 'react'
import PropTypes from 'prop-types'
import getDisplayName from './getDisplayName'
import canUseDOM from '../dom/canUseDOM'
/**

@@ -39,2 +33,10 @@ * ---

*/
import React from 'react'
import PropTypes from 'prop-types'
import DateTime from '@instructure/ui-i18n/lib/DateTime'
import getDisplayName from './getDisplayName'
import warning from '../warning'
import canUseDOM from '../dom/canUseDOM'
export default {

@@ -369,3 +371,171 @@ Children: {

element: canUseDOM ? PropTypes.oneOfType([PropTypes.element, PropTypes.instanceOf(Element)]) : PropTypes.element
element: canUseDOM ? PropTypes.oneOfType([PropTypes.element, PropTypes.instanceOf(Element)]) : PropTypes.element,
/**
*
* Validate spacing prop constraining it to the following enumerated values
*
* - '0'
* - 'none'
* - 'auto'
* - 'xxx-small'
* - 'xx-small'
* - 'x-small'
* - 'small'
* - 'medium'
* - 'large'
* - 'x-large'
* - 'xx-large'
*
* Valid inputs include a single value or a string with CSS
* shorthand like syntax with a maximum of 4 values.
*
* Examples of valid inputs:
* 'x-small' (single value)
* 'small large' (CSS shorthand)
* '0 small large x-large' (CSS shorthand max 4 values)
*
* Examples of invalid inputs:
* '5px' (must be a string from the enumerated values)
* '0 large small 0 0' (invalid shorthand syntax w/5 values)
*
* @param {Object} props - object containing the component props
* @param {string} propName - name of the given prop
* @param {string} componentName - name of the component
* @param {string} location
* @param {string} propFullName
* @returns {Error} if is not one of the enumerated values or the shorthand syntax is incorrect
*/
spacing (props, propName, componentName, location) {
const validValues = [
'0',
'none',
'auto',
'xxx-small',
'xx-small',
'x-small',
'small',
'medium',
'large',
'x-large',
'xx-large'
]
const propValue = props[propName]
if (propValue === undefined) {
return
}
const propValueType = typeof propValue
if (propValueType !== 'string') {
return new Error(
`Invalid ${location} \`${propName}\` of type \`${propValueType}\` supplied to \`${componentName}\`, expected ` +
`a string.`
)
}
const propValues = propValue.split(' ')
const valuesLength = propValues.length
if (valuesLength > 0 && valuesLength < 5) {
for (let i = 0; i < valuesLength; i++) {
const valueIndex = validValues.indexOf(propValues[i])
if (valueIndex === -1) {
return new Error(
`Invalid ${location} \`${propName}\` \`${propValues[i]}\` supplied to \`${componentName}\`, expected ` +
`a one of \`${validValues.join(', ')}\`.`
)
}
}
} else {
return new Error(
`Invalid ${location} \`${propName}\` \`${propValue}\` supplied to \`${componentName}\`, expected ` +
`between one and four of the following valid values: \`${validValues.join(', ')}\`.`
)
}
},
/**
*
* Verify that the given prop is a correctly formatted ISO 8601 formatted string.
*
* @param {Object} props - object containing the component props
* @param {string} propName - name of the given prop
* @param {string} componentName - name of the component
* @param {string} location
* @param {string} propFullName
* @returns {Error} if prop is an invalid ISO 8601 string
*/
iso8601 (props, propName, componentName, location) {
const propValue = props[propName]
if (propValue === undefined) return
const propValueType = typeof propValue
if (typeof propValueType !== 'string') {
return new Error(
`Invalid ${location} \`${propName}\` of type \`${propValueType}\` supplied to \`${componentName}\`, expected ` +
`an ISO 8601 formatted string.`
)
}
if (!DateTime.isValid(propValue)) {
return new Error(
`Invalid ${location} \`${propName}\` \`${propValue}\` supplied to \`${componentName}\`, expected ` +
`an ISO 8601 formatted string.`
)
}
},
/**
*
* Trigger a console warning if the specified prop variant is deprecated
*
* @param {function} propType - validates the prop type. Returns null if valid, error otherwise
* @param {string} deprecated - name of the deprecated variant
* @param {string} message - additional information to display with the warning
*/
deprecatedVariant (propType, deprecated, message) {
warning(false, '[%] was deprecated in version %s. %s', 'deprecatedVariant', '5.0.0', 'Use `deprecatePropValues` instead.')
return (props, propName, componentName, location) => {
warning(
(props[propName] !== deprecated),
`\`${componentName}\` \`${deprecated}\` variant is deprecated. ${message || ''}`
)
}
},
message: PropTypes.shape({
text: PropTypes.string,
type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
}),
placement: PropTypes.oneOf([
'top',
'end',
'bottom',
'start',
'top start',
'start top',
'start center',
'start bottom',
'bottom start',
'bottom center',
'bottom end',
'end bottom',
'end center',
'end top',
'top end',
'top center',
'center end',
'center start',
'top stretch',
'bottom stretch',
'end stretch',
'start stretch',
'offscreen'
]),
size: PropTypes.oneOf(['x-small', 'small', 'medium', 'large', 'x-large'])
}

@@ -124,3 +124,3 @@ /*

export function warnDeprecatedComponent (version, componentName, message) {
function warnDeprecatedComponent (version, componentName, message) {
warning(false, '[%s] was deprecated in version %s. %s', componentName, version, message || '')

@@ -127,0 +127,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc