terra-spacer
Advanced tools
Comparing version 3.59.2 to 3.60.0
@@ -5,2 +5,7 @@ # Changelog | ||
## 3.60.0 - (December 7, 2022) | ||
* Changed | ||
* Minor dependency version bump | ||
## 3.59.2 - (January 4, 2022) | ||
@@ -7,0 +12,0 @@ |
@@ -7,7 +7,7 @@ "use strict"; | ||
exports.SpacerSizes = exports.SpacerClassMappings = void 0; | ||
var _SpacerClassMappings; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
var SpacerSizes = { | ||
@@ -14,0 +14,0 @@ NONE: 'none', |
@@ -7,7 +7,7 @@ "use strict"; | ||
exports.shorthandValidator = exports.mapShorthandToObject = exports.ShorthandPropErrors = void 0; | ||
var _spacerConstants = require("./_spacerConstants"); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
var SHORTHAND_DELIMITER = ' '; | ||
@@ -18,3 +18,2 @@ var shLengthBoundaries = { | ||
}; | ||
var conflictingPropNamesError = function conflictingPropNamesError() { | ||
@@ -26,3 +25,2 @@ var propName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '<SUPPLY SHORTHAND PROP NAME>'; | ||
}; | ||
var invalidShArgsLengthError = function invalidShArgsLengthError() { | ||
@@ -36,3 +34,2 @@ var propName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '<SUPPLY SHORTHAND PROP NAME>'; | ||
}; | ||
var invalidShArgValuesError = function invalidShArgValuesError() { | ||
@@ -45,3 +42,2 @@ var propName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '<SUPPLY SHORTHAND PROP NAME>'; | ||
}; | ||
var ShorthandPropErrors = { | ||
@@ -53,3 +49,2 @@ conflictingPropName: conflictingPropNamesError, | ||
exports.ShorthandPropErrors = ShorthandPropErrors; | ||
var mapShorthandToObject = function mapShorthandToObject() { | ||
@@ -59,22 +54,15 @@ var propName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | ||
var shValues = propVal.split(SHORTHAND_DELIMITER); | ||
var generateShObject = function generateShObject(top, right, bottom, left) { | ||
var _ref; | ||
return _ref = {}, _defineProperty(_ref, "".concat(propName, "Top"), top), _defineProperty(_ref, "".concat(propName, "Right"), right), _defineProperty(_ref, "".concat(propName, "Bottom"), bottom), _defineProperty(_ref, "".concat(propName, "Left"), left), _ref; | ||
}; | ||
switch (shValues.length) { | ||
case 1: | ||
return generateShObject(shValues[0], shValues[0], shValues[0], shValues[0]); | ||
case 2: | ||
return generateShObject(shValues[0], shValues[1], shValues[0], shValues[1]); | ||
case 3: | ||
return generateShObject(shValues[0], shValues[1], shValues[2], shValues[1]); | ||
case 4: | ||
return generateShObject(shValues[0], shValues[1], shValues[2], shValues[3]); | ||
default: | ||
@@ -84,5 +72,3 @@ return {}; | ||
}; | ||
exports.mapShorthandToObject = mapShorthandToObject; | ||
var shorthandValidator = function shorthandValidator() { | ||
@@ -92,7 +78,5 @@ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var propVal = props[propName]; | ||
if (propVal === undefined || propVal === _spacerConstants.SpacerSizes.NONE) { | ||
return null; | ||
} | ||
var conflictingPropName = function () { | ||
@@ -102,11 +86,8 @@ var propertyConflicts = function propertyConflicts(dir) { | ||
}; | ||
var conflictProp = (propertyConflicts('Top') ? "".concat(propName, "Top") : undefined) || (propertyConflicts('Right') ? "".concat(propName, "Right") : undefined) || (propertyConflicts('Bottom') ? "".concat(propName, "Bottom") : undefined) || (propertyConflicts('Left') ? "".concat(propName, "Left") : undefined); | ||
return conflictProp; | ||
}(); | ||
if (conflictingPropName) { | ||
return conflictingPropNamesError(propName, conflictingPropName); | ||
} | ||
var shValuesUnfiltered = propVal.split(SHORTHAND_DELIMITER); | ||
@@ -116,9 +97,6 @@ var shValues = shValuesUnfiltered.filter(function (val) { | ||
}); // Remove any falsey values (including empty strings) | ||
var shValueCountValid = shValues.length >= shLengthBoundaries.min && shValues.length <= shLengthBoundaries.max; | ||
if (!shValueCountValid) { | ||
return invalidShArgsLengthError(propName, shValues.length); | ||
} | ||
var invalidShValues = function () { | ||
@@ -131,10 +109,7 @@ var sizes = Object.values(_spacerConstants.SpacerSizes); | ||
}(); | ||
if (invalidShValues) { | ||
return invalidShArgValuesError(propName, invalidShValues); | ||
} | ||
return null; | ||
}; | ||
exports.shorthandValidator = shorthandValidator; |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,36 +8,22 @@ value: true | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _bind = _interopRequireDefault(require("classnames/bind")); | ||
var _terraThemeContext = _interopRequireDefault(require("terra-theme-context")); | ||
var _SpacerModule = _interopRequireDefault(require("./Spacer.module.scss")); | ||
var _spacerShorthandUtils = require("./_spacerShorthandUtils"); | ||
var _spacerConstants = require("./_spacerConstants"); | ||
var _excluded = ["margin", "marginTop", "marginBottom", "marginLeft", "marginRight", "padding", "paddingTop", "paddingBottom", "paddingLeft", "paddingRight", "isInlineBlock", "children"]; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
var cx = _bind.default.bind(_SpacerModule.default); | ||
var cx = _bind.default.bind(_SpacerModule.default); | ||
/* | ||
@@ -47,4 +34,2 @@ NOTE: this is needed in order to ensure that the types `marginTop`, `marginRight`, `paddingTop`, `paddingRight`, etc. are recognized by terra-props-table | ||
*/ | ||
var arrayOfSpacerSizes = ['none', 'small-2', 'small-1', 'small', 'medium', 'large', 'large+1', 'large+2', 'large+3', 'large+4']; | ||
@@ -56,3 +41,2 @@ var propTypes = { | ||
children: _propTypes.default.node.isRequired, | ||
/** | ||
@@ -62,3 +46,2 @@ * Sets margin in a syntax similar to the standard CSS spec https://developer.mozilla.org/en-US/docs/Web/CSS/margin. One of 'none', 'small-2', 'small-1', 'small', 'medium', 'large', 'large+1', 'large+2', 'large+3', 'large+4'. | ||
margin: _spacerShorthandUtils.shorthandValidator, | ||
/** | ||
@@ -68,3 +51,2 @@ * Sets top margin. One of 'none', 'small-2', 'small-1', 'small', 'medium', 'large', 'large+1', 'large+2', 'large+3', 'large+4'. | ||
marginTop: _propTypes.default.oneOf(arrayOfSpacerSizes), | ||
/** | ||
@@ -74,3 +56,2 @@ * Sets bottom margin. One of 'none', 'small-2', 'small-1', 'small', 'medium', 'large', 'large+1', 'large+2', 'large+3', 'large+4'. | ||
marginBottom: _propTypes.default.oneOf(arrayOfSpacerSizes), | ||
/** | ||
@@ -80,3 +61,2 @@ * Sets left margin One of 'none', 'small-2', 'small-1', 'small', 'medium', 'large', 'large+1', 'large+2', 'large+3', 'large+4'. | ||
marginLeft: _propTypes.default.oneOf(arrayOfSpacerSizes), | ||
/** | ||
@@ -86,3 +66,2 @@ * Sets right margin. One of 'none', 'small-2', 'small-1', 'small', 'medium', 'large', 'large+1', 'large+2', 'large+3', 'large+4'. | ||
marginRight: _propTypes.default.oneOf(arrayOfSpacerSizes), | ||
/** | ||
@@ -92,3 +71,2 @@ * Sets padding in a syntax similar to the standard CSS spec https://developer.mozilla.org/en-US/docs/Web/CSS/padding. One of 'none', 'small-2', 'small-1', 'small', 'medium', 'large', 'large+1', 'large+2', 'large+3', 'large+4'. | ||
padding: _spacerShorthandUtils.shorthandValidator, | ||
/** | ||
@@ -98,3 +76,2 @@ * Sets top padding. One of 'none', 'small-2', 'small-1', 'small', 'medium', 'large', 'large+1', 'large+2', 'large+3', 'large+4'. | ||
paddingTop: _propTypes.default.oneOf(arrayOfSpacerSizes), | ||
/** | ||
@@ -104,3 +81,2 @@ * Sets bottom padding. One of 'none', 'small-2', 'small-1', 'small', 'medium', 'large', 'large+1', 'large+2', 'large+3', 'large+4'. | ||
paddingBottom: _propTypes.default.oneOf(arrayOfSpacerSizes), | ||
/** | ||
@@ -110,3 +86,2 @@ * Sets left padding. One of 'none', 'small-2', 'small-1', 'small', 'medium', 'large', 'large+1', 'large+2', 'large+3', 'large+4'. | ||
paddingLeft: _propTypes.default.oneOf(arrayOfSpacerSizes), | ||
/** | ||
@@ -116,3 +91,2 @@ * Sets right padding. One of 'none', 'small-2', 'small-1', 'small', 'medium', 'large', 'large+1', 'large+2', 'large+3', 'large+4'. | ||
paddingRight: _propTypes.default.oneOf(arrayOfSpacerSizes), | ||
/** | ||
@@ -136,23 +110,19 @@ * Sets the display to be inline-block. | ||
}; | ||
var Spacer = function Spacer(_ref) { | ||
var margin = _ref.margin, | ||
marginTop = _ref.marginTop, | ||
marginBottom = _ref.marginBottom, | ||
marginLeft = _ref.marginLeft, | ||
marginRight = _ref.marginRight, | ||
padding = _ref.padding, | ||
paddingTop = _ref.paddingTop, | ||
paddingBottom = _ref.paddingBottom, | ||
paddingLeft = _ref.paddingLeft, | ||
paddingRight = _ref.paddingRight, | ||
isInlineBlock = _ref.isInlineBlock, | ||
children = _ref.children, | ||
customProps = _objectWithoutProperties(_ref, _excluded); | ||
marginTop = _ref.marginTop, | ||
marginBottom = _ref.marginBottom, | ||
marginLeft = _ref.marginLeft, | ||
marginRight = _ref.marginRight, | ||
padding = _ref.padding, | ||
paddingTop = _ref.paddingTop, | ||
paddingBottom = _ref.paddingBottom, | ||
paddingLeft = _ref.paddingLeft, | ||
paddingRight = _ref.paddingRight, | ||
isInlineBlock = _ref.isInlineBlock, | ||
children = _ref.children, | ||
customProps = _objectWithoutProperties(_ref, _excluded); | ||
var theme = _react.default.useContext(_terraThemeContext.default); | ||
var marginShorthand = margin ? (0, _spacerShorthandUtils.mapShorthandToObject)('margin', margin) : {}; | ||
var paddingShorthand = padding ? (0, _spacerShorthandUtils.mapShorthandToObject)('padding', padding) : {}; | ||
var marginAttributes = _objectSpread({ | ||
@@ -164,3 +134,2 @@ marginTop: marginTop, | ||
}, marginShorthand); | ||
var paddingAttributes = _objectSpread({ | ||
@@ -172,3 +141,2 @@ paddingTop: paddingTop, | ||
}, paddingShorthand); | ||
var SpacerClassNames = (0, _classnames.default)(cx("margin-top-".concat(_spacerConstants.SpacerClassMappings[marginAttributes.marginTop]), "margin-bottom-".concat(_spacerConstants.SpacerClassMappings[marginAttributes.marginBottom]), "margin-left-".concat(_spacerConstants.SpacerClassMappings[marginAttributes.marginLeft]), "margin-right-".concat(_spacerConstants.SpacerClassMappings[marginAttributes.marginRight]), "padding-top-".concat(_spacerConstants.SpacerClassMappings[paddingAttributes.paddingTop]), "padding-bottom-".concat(_spacerConstants.SpacerClassMappings[paddingAttributes.paddingBottom]), "padding-left-".concat(_spacerConstants.SpacerClassMappings[paddingAttributes.paddingLeft]), "padding-right-".concat(_spacerConstants.SpacerClassMappings[paddingAttributes.paddingRight]), { | ||
@@ -181,3 +149,2 @@ 'is-inline-block': isInlineBlock | ||
}; | ||
var opts = { | ||
@@ -184,0 +151,0 @@ Sizes: _spacerConstants.SpacerSizes |
{ | ||
"name": "terra-spacer", | ||
"main": "lib/Spacer.js", | ||
"version": "3.59.2", | ||
"version": "3.60.0", | ||
"description": "This component is used to provide margin and/or padding space between two components based on the given values.", | ||
@@ -31,3 +31,3 @@ "repository": { | ||
"prop-types": "^15.5.8", | ||
"terra-image": "^3.35.1", | ||
"terra-image": "^3.36.0", | ||
"terra-theme-context": "^1.0.0" | ||
@@ -48,3 +48,3 @@ }, | ||
}, | ||
"gitHead": "2b761729af5655a49c1f1cf8b6f4130d57f4ae30" | ||
"gitHead": "421b2643a58e6de628aa789a9cdd0778b0a942a2" | ||
} |
@@ -10,3 +10,3 @@ # Terra Spacer | ||
- [Getting Started](#getting-started) | ||
- [Documentation](https://engineering.cerner.com/terra-ui/components/terra-spacer/spacer/spacer) | ||
- [Documentation](https://engineering.cerner.com/terra-ui/components/cerner-terra-core-docs/spacer/about) | ||
- [LICENSE](#license) | ||
@@ -13,0 +13,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82146
731
1
Updatedterra-image@^3.36.0