@hig/label
Advanced tools
Comparing version 2.1.0 to 2.2.0
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { css, cx } from 'emotion'; | ||
import { cx, css } from 'emotion'; | ||
import { ThemeContext } from '@hig/theme-context'; | ||
var variants = Object.freeze({ | ||
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 _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; | ||
} | ||
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; | ||
} | ||
const variants = Object.freeze({ | ||
SIDE: "side", | ||
TOP: "top" | ||
}); | ||
const availableVariants = Object.freeze(Object.values(variants)); | ||
var availableVariants = Object.freeze(Object.values(variants)); | ||
function stylesheet(props, themeData) { | ||
var disabled = props.disabled, | ||
customStylesheet = props.stylesheet, | ||
variant = props.variant; | ||
var styles = { | ||
const { | ||
disabled, | ||
stylesheet: customStylesheet, | ||
variant | ||
} = props; | ||
const styles = { | ||
label: { | ||
@@ -28,46 +82,39 @@ fontSize: variant === "side" ? themeData["label.fontSize"] : themeData["label.top.fontSize"], | ||
}; | ||
return customStylesheet ? customStylesheet(styles, props, themeData) : styles; | ||
} | ||
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; }; | ||
const _excluded = ["children", "disabled", "stylesheet", "variant"]; | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
const Label = props => { | ||
const { | ||
children, | ||
disabled, | ||
stylesheet: customStylesheet, | ||
variant | ||
} = props, | ||
otherProps = _objectWithoutProperties(props, _excluded); | ||
var Label = function Label(props) { | ||
var children = props.children, | ||
disabled = props.disabled, | ||
customStylesheet = props.stylesheet, | ||
variant = props.variant, | ||
otherProps = _objectWithoutProperties(props, ["children", "disabled", "stylesheet", "variant"]); | ||
var className = otherProps.className; | ||
return React.createElement( | ||
ThemeContext.Consumer, | ||
null, | ||
function (_ref) { | ||
var resolvedRoles = _ref.resolvedRoles; | ||
var styles = stylesheet({ | ||
disabled: disabled, | ||
stylesheet: customStylesheet, | ||
variant: variant | ||
}, resolvedRoles); | ||
return ( | ||
// eslint-disable-next-line jsx-a11y/label-has-for | ||
React.createElement( | ||
"label", | ||
_extends({}, otherProps, { className: cx([className, css(styles.label)]) }), | ||
children | ||
) | ||
); | ||
} | ||
); | ||
const { | ||
className | ||
} = otherProps; | ||
return /*#__PURE__*/React.createElement(ThemeContext.Consumer, null, _ref => { | ||
let { | ||
resolvedRoles | ||
} = _ref; | ||
const styles = stylesheet({ | ||
disabled, | ||
stylesheet: customStylesheet, | ||
variant | ||
}, resolvedRoles); | ||
return ( | ||
/*#__PURE__*/ | ||
// eslint-disable-next-line jsx-a11y/label-has-associated-control, jsx-a11y/label-has-for | ||
React.createElement("label", _extends({}, otherProps, { | ||
className: cx([className, css(styles.label)]) | ||
}), children) | ||
); | ||
}); | ||
}; | ||
Label.displayName = "Label"; | ||
Label.propTypes = { | ||
@@ -78,2 +125,3 @@ /** | ||
children: PropTypes.node, | ||
/** | ||
@@ -83,2 +131,3 @@ * Dims label text, signifying the related input or control is disabled | ||
disabled: PropTypes.bool, | ||
/** | ||
@@ -88,2 +137,3 @@ * Adds custom/overriding styles | ||
stylesheet: PropTypes.func, | ||
/** | ||
@@ -94,3 +144,2 @@ * The visual variant of the label | ||
}; | ||
Label.defaultProps = { | ||
@@ -140,2 +189,2 @@ variant: variants.SIDE | ||
export default Label; | ||
export { Label as default }; |
@@ -5,22 +5,79 @@ 'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var React = _interopDefault(require('react')); | ||
var PropTypes = _interopDefault(require('prop-types')); | ||
var React = require('react'); | ||
var PropTypes = require('prop-types'); | ||
var emotion = require('emotion'); | ||
var themeContext = require('@hig/theme-context'); | ||
var variants = Object.freeze({ | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes); | ||
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 _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; | ||
} | ||
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; | ||
} | ||
const variants = Object.freeze({ | ||
SIDE: "side", | ||
TOP: "top" | ||
}); | ||
const availableVariants = Object.freeze(Object.values(variants)); | ||
var availableVariants = Object.freeze(Object.values(variants)); | ||
function stylesheet(props, themeData) { | ||
var disabled = props.disabled, | ||
customStylesheet = props.stylesheet, | ||
variant = props.variant; | ||
var styles = { | ||
const { | ||
disabled, | ||
stylesheet: customStylesheet, | ||
variant | ||
} = props; | ||
const styles = { | ||
label: { | ||
@@ -35,46 +92,39 @@ fontSize: variant === "side" ? themeData["label.fontSize"] : themeData["label.top.fontSize"], | ||
}; | ||
return customStylesheet ? customStylesheet(styles, props, themeData) : styles; | ||
} | ||
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; }; | ||
const _excluded = ["children", "disabled", "stylesheet", "variant"]; | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
const Label = props => { | ||
const { | ||
children, | ||
disabled, | ||
stylesheet: customStylesheet, | ||
variant | ||
} = props, | ||
otherProps = _objectWithoutProperties(props, _excluded); | ||
var Label = function Label(props) { | ||
var children = props.children, | ||
disabled = props.disabled, | ||
customStylesheet = props.stylesheet, | ||
variant = props.variant, | ||
otherProps = _objectWithoutProperties(props, ["children", "disabled", "stylesheet", "variant"]); | ||
var className = otherProps.className; | ||
return React.createElement( | ||
themeContext.ThemeContext.Consumer, | ||
null, | ||
function (_ref) { | ||
var resolvedRoles = _ref.resolvedRoles; | ||
var styles = stylesheet({ | ||
disabled: disabled, | ||
stylesheet: customStylesheet, | ||
variant: variant | ||
}, resolvedRoles); | ||
return ( | ||
// eslint-disable-next-line jsx-a11y/label-has-for | ||
React.createElement( | ||
"label", | ||
_extends({}, otherProps, { className: emotion.cx([className, emotion.css(styles.label)]) }), | ||
children | ||
) | ||
); | ||
} | ||
); | ||
const { | ||
className | ||
} = otherProps; | ||
return /*#__PURE__*/React__default["default"].createElement(themeContext.ThemeContext.Consumer, null, _ref => { | ||
let { | ||
resolvedRoles | ||
} = _ref; | ||
const styles = stylesheet({ | ||
disabled, | ||
stylesheet: customStylesheet, | ||
variant | ||
}, resolvedRoles); | ||
return ( | ||
/*#__PURE__*/ | ||
// eslint-disable-next-line jsx-a11y/label-has-associated-control, jsx-a11y/label-has-for | ||
React__default["default"].createElement("label", _extends({}, otherProps, { | ||
className: emotion.cx([className, emotion.css(styles.label)]) | ||
}), children) | ||
); | ||
}); | ||
}; | ||
Label.displayName = "Label"; | ||
Label.propTypes = { | ||
@@ -84,17 +134,19 @@ /** | ||
*/ | ||
children: PropTypes.node, | ||
children: PropTypes__default["default"].node, | ||
/** | ||
* Dims label text, signifying the related input or control is disabled | ||
*/ | ||
disabled: PropTypes.bool, | ||
disabled: PropTypes__default["default"].bool, | ||
/** | ||
* Adds custom/overriding styles | ||
*/ | ||
stylesheet: PropTypes.func, | ||
stylesheet: PropTypes__default["default"].func, | ||
/** | ||
* The visual variant of the label | ||
*/ | ||
variant: PropTypes.oneOf(availableVariants) | ||
variant: PropTypes__default["default"].oneOf(availableVariants) | ||
}; | ||
Label.defaultProps = { | ||
@@ -144,2 +196,2 @@ variant: variants.SIDE | ||
exports.default = Label; | ||
exports["default"] = Label; |
@@ -0,1 +1,8 @@ | ||
# [@hig/label-v2.2.0](https://github.com/Autodesk/hig/compare/@hig/label@2.1.0...@hig/label@2.2.0) (2022-08-26) | ||
### Features | ||
* use latest theme-data ([daa1b5f](https://github.com/Autodesk/hig/commit/daa1b5f)) | ||
# [@hig/label-v2.1.0](https://github.com/Autodesk/hig/compare/@hig/label@2.0.0...@hig/label@2.1.0) (2022-01-24) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "@hig/label", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "HIG Label", | ||
@@ -25,3 +25,3 @@ "author": "Autodesk Inc.", | ||
"@hig/theme-context": "^4.0.0", | ||
"@hig/theme-data": "^2.22.1", | ||
"@hig/theme-data": "^3.1.0", | ||
"react": "^17.0.0" | ||
@@ -28,0 +28,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
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
15858
327