@hig/radio-button
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -1,15 +0,119 @@ | ||
import { cx, css } from 'emotion'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { ControlBehavior } from '@hig/behaviors'; | ||
import { cx, css } from 'emotion'; | ||
import { ThemeContext } from '@hig/theme-context'; | ||
import { ControlBehavior } from '@hig/behaviors'; | ||
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
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; }; | ||
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 _objectSpread2(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 _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; | ||
} | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
/** | ||
* lodash (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
* Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
* Released under MIT license <https://lodash.com/license> | ||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | ||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
*/ | ||
/** Used to stand-in for `undefined` hash values. */ | ||
var HASH_UNDEFINED = '__lodash_hash_undefined__'; | ||
/** `Object#toString` result references. */ | ||
var funcTag = '[object Function]', | ||
genTag = '[object GeneratorFunction]'; | ||
/** | ||
@@ -19,16 +123,16 @@ * Used to match `RegExp` | ||
*/ | ||
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; | ||
/** Used to detect host constructors (Safari). */ | ||
/** Used to detect host constructors (Safari). */ | ||
var reIsHostCtor = /^\[object .+?Constructor\]$/; | ||
/** Detect free variable `global` from Node.js. */ | ||
var freeGlobal = (typeof commonjsGlobal === 'undefined' ? 'undefined' : _typeof(commonjsGlobal)) == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; | ||
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; | ||
/** Detect free variable `self`. */ | ||
var freeSelf = (typeof self === 'undefined' ? 'undefined' : _typeof(self)) == 'object' && self && self.Object === Object && self; | ||
var freeSelf = typeof self == 'object' && self && self.Object === Object && self; | ||
/** Used as a reference to the global object. */ | ||
var root = freeGlobal || freeSelf || Function('return this')(); | ||
/** | ||
@@ -42,6 +146,6 @@ * Gets the value at `key` of `object`. | ||
*/ | ||
function getValue(object, key) { | ||
return object == null ? undefined : object[key]; | ||
} | ||
/** | ||
@@ -54,2 +158,4 @@ * Checks if `value` is a host object in IE < 9. | ||
*/ | ||
function isHostObject(value) { | ||
@@ -59,2 +165,3 @@ // Many host objects are `Object` objects that can coerce to strings | ||
var result = false; | ||
if (value != null && typeof value.toString != 'function') { | ||
@@ -65,13 +172,16 @@ try { | ||
} | ||
return result; | ||
} | ||
/** Used for built-in method references. */ | ||
/** Used for built-in method references. */ | ||
var funcProto = Function.prototype, | ||
var arrayProto = Array.prototype, | ||
funcProto = Function.prototype, | ||
objectProto = Object.prototype; | ||
/** Used to detect overreaching core-js shims. */ | ||
/** Used to detect overreaching core-js shims. */ | ||
var coreJsData = root['__core-js_shared__']; | ||
/** Used to detect methods masquerading as native. */ | ||
/** Used to detect methods masquerading as native. */ | ||
var maskSrcKey = function () { | ||
@@ -81,9 +191,9 @@ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); | ||
}(); | ||
/** Used to resolve the decompiled source of functions. */ | ||
/** Used to resolve the decompiled source of functions. */ | ||
var funcToString = funcProto.toString; | ||
/** Used to check objects for own properties. */ | ||
/** Used to check objects for own properties. */ | ||
var hasOwnProperty = objectProto.hasOwnProperty; | ||
/** | ||
@@ -94,12 +204,359 @@ * Used to resolve the | ||
*/ | ||
var objectToString = objectProto.toString; | ||
/** Used to detect if a method is native. */ | ||
/** Used to detect if a method is native. */ | ||
var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'); | ||
/** Built-in value references. */ | ||
var splice = arrayProto.splice; | ||
/* Built-in method references that are verified to be native. */ | ||
var Map = getNative(root, 'Map'), | ||
nativeCreate = getNative(Object, 'create'); | ||
/** | ||
* Creates a hash object. | ||
* | ||
* @private | ||
* @constructor | ||
* @param {Array} [entries] The key-value pairs to cache. | ||
*/ | ||
function Hash(entries) { | ||
var index = -1, | ||
length = entries ? entries.length : 0; | ||
this.clear(); | ||
while (++index < length) { | ||
var entry = entries[index]; | ||
this.set(entry[0], entry[1]); | ||
} | ||
} | ||
/** | ||
* Removes all key-value entries from the hash. | ||
* | ||
* @private | ||
* @name clear | ||
* @memberOf Hash | ||
*/ | ||
function hashClear() { | ||
this.__data__ = nativeCreate ? nativeCreate(null) : {}; | ||
} | ||
/** | ||
* Removes `key` and its value from the hash. | ||
* | ||
* @private | ||
* @name delete | ||
* @memberOf Hash | ||
* @param {Object} hash The hash to modify. | ||
* @param {string} key The key of the value to remove. | ||
* @returns {boolean} Returns `true` if the entry was removed, else `false`. | ||
*/ | ||
function hashDelete(key) { | ||
return this.has(key) && delete this.__data__[key]; | ||
} | ||
/** | ||
* Gets the hash value for `key`. | ||
* | ||
* @private | ||
* @name get | ||
* @memberOf Hash | ||
* @param {string} key The key of the value to get. | ||
* @returns {*} Returns the entry value. | ||
*/ | ||
function hashGet(key) { | ||
var data = this.__data__; | ||
if (nativeCreate) { | ||
var result = data[key]; | ||
return result === HASH_UNDEFINED ? undefined : result; | ||
} | ||
return hasOwnProperty.call(data, key) ? data[key] : undefined; | ||
} | ||
/** | ||
* Checks if a hash value for `key` exists. | ||
* | ||
* @private | ||
* @name has | ||
* @memberOf Hash | ||
* @param {string} key The key of the entry to check. | ||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. | ||
*/ | ||
function hashHas(key) { | ||
var data = this.__data__; | ||
return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key); | ||
} | ||
/** | ||
* Sets the hash `key` to `value`. | ||
* | ||
* @private | ||
* @name set | ||
* @memberOf Hash | ||
* @param {string} key The key of the value to set. | ||
* @param {*} value The value to set. | ||
* @returns {Object} Returns the hash instance. | ||
*/ | ||
function hashSet(key, value) { | ||
var data = this.__data__; | ||
data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value; | ||
return this; | ||
} // Add methods to `Hash`. | ||
Hash.prototype.clear = hashClear; | ||
Hash.prototype['delete'] = hashDelete; | ||
Hash.prototype.get = hashGet; | ||
Hash.prototype.has = hashHas; | ||
Hash.prototype.set = hashSet; | ||
/** | ||
* Creates an list cache object. | ||
* | ||
* @private | ||
* @constructor | ||
* @param {Array} [entries] The key-value pairs to cache. | ||
*/ | ||
function ListCache(entries) { | ||
var index = -1, | ||
length = entries ? entries.length : 0; | ||
this.clear(); | ||
while (++index < length) { | ||
var entry = entries[index]; | ||
this.set(entry[0], entry[1]); | ||
} | ||
} | ||
/** | ||
* Removes all key-value entries from the list cache. | ||
* | ||
* @private | ||
* @name clear | ||
* @memberOf ListCache | ||
*/ | ||
function listCacheClear() { | ||
this.__data__ = []; | ||
} | ||
/** | ||
* Removes `key` and its value from the list cache. | ||
* | ||
* @private | ||
* @name delete | ||
* @memberOf ListCache | ||
* @param {string} key The key of the value to remove. | ||
* @returns {boolean} Returns `true` if the entry was removed, else `false`. | ||
*/ | ||
function listCacheDelete(key) { | ||
var data = this.__data__, | ||
index = assocIndexOf(data, key); | ||
if (index < 0) { | ||
return false; | ||
} | ||
var lastIndex = data.length - 1; | ||
if (index == lastIndex) { | ||
data.pop(); | ||
} else { | ||
splice.call(data, index, 1); | ||
} | ||
return true; | ||
} | ||
/** | ||
* Gets the list cache value for `key`. | ||
* | ||
* @private | ||
* @name get | ||
* @memberOf ListCache | ||
* @param {string} key The key of the value to get. | ||
* @returns {*} Returns the entry value. | ||
*/ | ||
function listCacheGet(key) { | ||
var data = this.__data__, | ||
index = assocIndexOf(data, key); | ||
return index < 0 ? undefined : data[index][1]; | ||
} | ||
/** | ||
* Checks if a list cache value for `key` exists. | ||
* | ||
* @private | ||
* @name has | ||
* @memberOf ListCache | ||
* @param {string} key The key of the entry to check. | ||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. | ||
*/ | ||
function listCacheHas(key) { | ||
return assocIndexOf(this.__data__, key) > -1; | ||
} | ||
/** | ||
* Sets the list cache `key` to `value`. | ||
* | ||
* @private | ||
* @name set | ||
* @memberOf ListCache | ||
* @param {string} key The key of the value to set. | ||
* @param {*} value The value to set. | ||
* @returns {Object} Returns the list cache instance. | ||
*/ | ||
function listCacheSet(key, value) { | ||
var data = this.__data__, | ||
index = assocIndexOf(data, key); | ||
if (index < 0) { | ||
data.push([key, value]); | ||
} else { | ||
data[index][1] = value; | ||
} | ||
return this; | ||
} // Add methods to `ListCache`. | ||
ListCache.prototype.clear = listCacheClear; | ||
ListCache.prototype['delete'] = listCacheDelete; | ||
ListCache.prototype.get = listCacheGet; | ||
ListCache.prototype.has = listCacheHas; | ||
ListCache.prototype.set = listCacheSet; | ||
/** | ||
* Creates a map cache object to store key-value pairs. | ||
* | ||
* @private | ||
* @constructor | ||
* @param {Array} [entries] The key-value pairs to cache. | ||
*/ | ||
function MapCache(entries) { | ||
var index = -1, | ||
length = entries ? entries.length : 0; | ||
this.clear(); | ||
while (++index < length) { | ||
var entry = entries[index]; | ||
this.set(entry[0], entry[1]); | ||
} | ||
} | ||
/** | ||
* Removes all key-value entries from the map. | ||
* | ||
* @private | ||
* @name clear | ||
* @memberOf MapCache | ||
*/ | ||
function mapCacheClear() { | ||
this.__data__ = { | ||
'hash': new Hash(), | ||
'map': new (Map || ListCache)(), | ||
'string': new Hash() | ||
}; | ||
} | ||
/** | ||
* Removes `key` and its value from the map. | ||
* | ||
* @private | ||
* @name delete | ||
* @memberOf MapCache | ||
* @param {string} key The key of the value to remove. | ||
* @returns {boolean} Returns `true` if the entry was removed, else `false`. | ||
*/ | ||
function mapCacheDelete(key) { | ||
return getMapData(this, key)['delete'](key); | ||
} | ||
/** | ||
* Gets the map value for `key`. | ||
* | ||
* @private | ||
* @name get | ||
* @memberOf MapCache | ||
* @param {string} key The key of the value to get. | ||
* @returns {*} Returns the entry value. | ||
*/ | ||
function mapCacheGet(key) { | ||
return getMapData(this, key).get(key); | ||
} | ||
/** | ||
* Checks if a map value for `key` exists. | ||
* | ||
* @private | ||
* @name has | ||
* @memberOf MapCache | ||
* @param {string} key The key of the entry to check. | ||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. | ||
*/ | ||
function mapCacheHas(key) { | ||
return getMapData(this, key).has(key); | ||
} | ||
/** | ||
* Sets the map `key` to `value`. | ||
* | ||
* @private | ||
* @name set | ||
* @memberOf MapCache | ||
* @param {string} key The key of the value to set. | ||
* @param {*} value The value to set. | ||
* @returns {Object} Returns the map cache instance. | ||
*/ | ||
function mapCacheSet(key, value) { | ||
getMapData(this, key).set(key, value); | ||
return this; | ||
} // Add methods to `MapCache`. | ||
MapCache.prototype.clear = mapCacheClear; | ||
MapCache.prototype['delete'] = mapCacheDelete; | ||
MapCache.prototype.get = mapCacheGet; | ||
MapCache.prototype.has = mapCacheHas; | ||
MapCache.prototype.set = mapCacheSet; | ||
/** | ||
* Gets the index at which the `key` is found in `array` of key-value pairs. | ||
* | ||
* @private | ||
* @param {Array} array The array to inspect. | ||
* @param {*} key The key to search for. | ||
* @returns {number} Returns the index of the matched value, else `-1`. | ||
*/ | ||
function assocIndexOf(array, key) { | ||
var length = array.length; | ||
while (length--) { | ||
if (eq(array[length][0], key)) { | ||
return length; | ||
} | ||
} | ||
return -1; | ||
} | ||
/** | ||
* The base implementation of `_.isNative` without bad shim checks. | ||
@@ -112,2 +569,4 @@ * | ||
*/ | ||
function baseIsNative(value) { | ||
@@ -117,6 +576,20 @@ if (!isObject(value) || isMasked(value)) { | ||
} | ||
var pattern = isFunction(value) || isHostObject(value) ? reIsNative : reIsHostCtor; | ||
return pattern.test(toSource(value)); | ||
} | ||
/** | ||
* Gets the data for `map`. | ||
* | ||
* @private | ||
* @param {Object} map The map to query. | ||
* @param {string} key The reference key. | ||
* @returns {*} Returns the map data. | ||
*/ | ||
function getMapData(map, key) { | ||
var data = map.__data__; | ||
return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map; | ||
} | ||
/** | ||
@@ -130,2 +603,4 @@ * Gets the native function at `key` of `object`. | ||
*/ | ||
function getNative(object, key) { | ||
@@ -135,3 +610,15 @@ var value = getValue(object, key); | ||
} | ||
/** | ||
* Checks if `value` is suitable for use as unique object key. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is suitable, else `false`. | ||
*/ | ||
function isKeyable(value) { | ||
var type = typeof value; | ||
return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null; | ||
} | ||
/** | ||
@@ -144,6 +631,7 @@ * Checks if `func` has its source masked. | ||
*/ | ||
function isMasked(func) { | ||
return !!maskSrcKey && maskSrcKey in func; | ||
} | ||
/** | ||
@@ -156,2 +644,4 @@ * Converts `func` to its source code. | ||
*/ | ||
function toSource(func) { | ||
@@ -162,2 +652,3 @@ if (func != null) { | ||
} catch (e) {} | ||
try { | ||
@@ -167,5 +658,41 @@ return func + ''; | ||
} | ||
return ''; | ||
} | ||
/** | ||
* Performs a | ||
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) | ||
* comparison between two values to determine if they are equivalent. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to compare. | ||
* @param {*} other The other value to compare. | ||
* @returns {boolean} Returns `true` if the values are equivalent, else `false`. | ||
* @example | ||
* | ||
* var object = { 'a': 1 }; | ||
* var other = { 'a': 1 }; | ||
* | ||
* _.eq(object, object); | ||
* // => true | ||
* | ||
* _.eq(object, other); | ||
* // => false | ||
* | ||
* _.eq('a', 'a'); | ||
* // => true | ||
* | ||
* _.eq('a', Object('a')); | ||
* // => false | ||
* | ||
* _.eq(NaN, NaN); | ||
* // => true | ||
*/ | ||
function eq(value, other) { | ||
return value === other || value !== value && other !== other; | ||
} | ||
/** | ||
@@ -188,2 +715,4 @@ * Checks if `value` is classified as a `Function` object. | ||
*/ | ||
function isFunction(value) { | ||
@@ -195,3 +724,2 @@ // The use of `Object#toString` avoids issues with the `typeof` operator | ||
} | ||
/** | ||
@@ -222,4 +750,6 @@ * Checks if `value` is the | ||
*/ | ||
function isObject(value) { | ||
var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); | ||
var type = typeof value; | ||
return !!value && (type == 'object' || type == 'function'); | ||
@@ -236,34 +766,32 @@ } | ||
function createCustomClassNames(className, appendedString) { | ||
return className && className.split(" ").reduce(function (acc, cur) { | ||
return cx(acc, cur.trim() + "__" + appendedString); | ||
}, ""); | ||
return className && className.split(" ").reduce((acc, cur) => cx(acc, `${cur.trim()}__${appendedString}`), ""); | ||
} | ||
function stylesheet(props, themeData) { | ||
var isPressed = props.isPressed, | ||
hasFocus = props.hasFocus, | ||
hasHover = props.hasHover, | ||
disabled = props.disabled, | ||
customStylesheet = props.stylesheet; | ||
var opacity = disabled ? themeData["colorScheme.opacity.disabled"] : "1.0"; | ||
// because we don't have access to the checked status in react, we need to | ||
const { | ||
isPressed, | ||
hasFocus, | ||
hasHover, | ||
disabled, | ||
stylesheet: customStylesheet | ||
} = props; | ||
const opacity = disabled ? themeData["colorScheme.opacity.disabled"] : "1.0"; // because we don't have access to the checked status in react, we need to | ||
// write css rules to handle both cases | ||
var borderColor = hasFocus && !hasHover ? themeData["checkbox.unchecked.focus.borderColor"] : themeData["checkbox.unchecked.default.borderColor"]; | ||
var checkedInnerShadow = "inset 0 0 0 " + themeData["checkbox.pressed.haloWidth"] + " " + themeData["checkbox.checked.default.backgroundColor"]; | ||
var uncheckedInnerShadow = "inset 0 0 0 " + themeData["checkbox.borderWidth"] + " \n " + borderColor + "\n "; | ||
var outerShadow = "0 0 0 0px transparent"; | ||
if (disabled) { | ||
// do nothing | ||
} else if (isPressed) { | ||
outerShadow = "0 0 0 " + themeData["checkbox.pressed.haloWidth"] + " " + themeData["checkbox.pressed.haloColor"]; | ||
const borderColor = hasFocus && !hasHover ? themeData["checkbox.unchecked.focus.borderColor"] : themeData["checkbox.unchecked.default.borderColor"]; | ||
const checkedInnerShadow = `inset 0 0 0 ${themeData["checkbox.pressed.haloWidth"]} ${themeData["checkbox.checked.default.backgroundColor"]}`; | ||
const uncheckedInnerShadow = `inset 0 0 0 ${themeData["checkbox.borderWidth"]} ${borderColor}`; | ||
let outerShadow = "0 0 0 0px transparent"; | ||
if (disabled) ; else if (isPressed) { | ||
outerShadow = `0 0 0 ${themeData["checkbox.pressed.haloWidth"]} ${themeData["checkbox.pressed.haloColor"]}`; | ||
} else if (hasHover) { | ||
outerShadow = "0 0 0 " + themeData["checkbox.hover.haloWidth"] + " " + themeData["checkbox.hover.haloColor"]; | ||
outerShadow = `0 0 0 ${themeData["checkbox.hover.haloWidth"]} ${themeData["checkbox.hover.haloColor"]}`; | ||
} else if (hasFocus) { | ||
outerShadow = "0 0 0 " + themeData["checkbox.focus.haloWidth"] + " " + themeData["checkbox.focus.haloColor"]; | ||
outerShadow = `0 0 0 ${themeData["checkbox.focus.haloWidth"]} ${themeData["checkbox.focus.haloColor"]}`; | ||
} | ||
var styles = { | ||
const styles = { | ||
radioButtonContainer: { | ||
@@ -275,9 +803,8 @@ position: "relative", | ||
}, | ||
radioButtonWrapper: { | ||
opacity: opacity, | ||
opacity, | ||
position: "relative", | ||
color: "transparent", | ||
border: "none", | ||
backgroundColor: "transparent", | ||
backgroundColor: themeData["checkbox.unchecked.default.backgroundColor"], | ||
textAlign: "center", | ||
@@ -289,3 +816,3 @@ fontSize: "25px", | ||
borderRadius: "50%", | ||
boxShadow: uncheckedInnerShadow + "," + outerShadow, | ||
boxShadow: `${uncheckedInnerShadow},${outerShadow}`, | ||
transitionDuration: "0.3s, 0.3s", | ||
@@ -295,3 +822,2 @@ transitionProperty: "box-shadow, background-color", | ||
}, | ||
// this maps to .radio-button__input | ||
@@ -309,43 +835,37 @@ radioButtonInput: { | ||
zIndex: "1", | ||
"&:checked + span": { | ||
boxShadow: checkedInnerShadow + "," + outerShadow | ||
boxShadow: `${checkedInnerShadow},${outerShadow}` | ||
} | ||
} | ||
}; | ||
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$2 = ["stylesheet"]; | ||
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 ButtonPresenter = props => { | ||
const { | ||
stylesheet: customStylesheet | ||
} = props, | ||
otherProps = _objectWithoutProperties(props, _excluded$2); | ||
var ButtonPresenter = function ButtonPresenter(props) { | ||
var customStylesheet = props.stylesheet, | ||
otherProps = _objectWithoutProperties(props, ["stylesheet"]); | ||
var className = otherProps.className; | ||
var radioButtonWrapperClassName = createCustomClassNames(className, "radio-button-wrapper"); | ||
return React.createElement( | ||
ThemeContext.Consumer, | ||
null, | ||
function (_ref) { | ||
var resolvedRoles = _ref.resolvedRoles, | ||
metadata = _ref.metadata; | ||
var styles = stylesheet(_extends({ | ||
stylesheet: customStylesheet | ||
}, props), resolvedRoles, metadata.colorSchemeId); | ||
return React.createElement("span", { | ||
className: cx(css(styles.radioButtonWrapper), radioButtonWrapperClassName) | ||
}); | ||
} | ||
); | ||
const { | ||
className | ||
} = otherProps; | ||
const radioButtonWrapperClassName = createCustomClassNames(className, "radio-button-wrapper"); | ||
return /*#__PURE__*/React.createElement(ThemeContext.Consumer, null, _ref => { | ||
let { | ||
resolvedRoles, | ||
metadata | ||
} = _ref; | ||
const styles = stylesheet(_objectSpread2({ | ||
stylesheet: customStylesheet | ||
}, props), resolvedRoles, metadata.colorSchemeId); | ||
return /*#__PURE__*/React.createElement("span", { | ||
className: cx(css(styles.radioButtonWrapper), radioButtonWrapperClassName) | ||
}); | ||
}); | ||
}; | ||
ButtonPresenter.displayName = "ButtonPresenter"; | ||
ButtonPresenter.propTypes = { | ||
@@ -371,55 +891,67 @@ /** | ||
var _extends$1 = 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$1 = ["disabled", "hasFocus", "hasHover", "isPressed", "stylesheet"]; | ||
function _objectWithoutProperties$1(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 RadioButtonPresenter = props => { | ||
const { | ||
disabled, | ||
hasFocus, | ||
hasHover, | ||
isPressed, | ||
stylesheet: customStylesheet | ||
} = props, | ||
otherProps = _objectWithoutProperties(props, _excluded$1); | ||
var RadioButtonPresenter = function RadioButtonPresenter(props) { | ||
var disabled = props.disabled, | ||
hasFocus = props.hasFocus, | ||
hasHover = props.hasHover, | ||
isPressed = props.isPressed, | ||
customStylesheet = props.stylesheet, | ||
otherProps = _objectWithoutProperties$1(props, ["disabled", "hasFocus", "hasHover", "isPressed", "stylesheet"]); | ||
return /*#__PURE__*/React.createElement(ThemeContext.Consumer, null, _ref => { | ||
let { | ||
resolvedRoles | ||
} = _ref; | ||
const styles = stylesheet(_objectSpread2({ | ||
isPressed, | ||
hasFocus, | ||
hasHover, | ||
disabled, | ||
stylesheet: customStylesheet | ||
}, props), resolvedRoles); | ||
const { | ||
className | ||
} = otherProps; | ||
const radioButtonInputClassName = createCustomClassNames(className, "radio-button-input"); | ||
return /*#__PURE__*/React.createElement("div", { | ||
className: cx(css(styles.radioButtonContainer), className) | ||
}, /*#__PURE__*/React.createElement("input", _extends({}, otherProps, { | ||
disabled: disabled, | ||
type: "radio", | ||
className: cx(css(styles.radioButtonInput), radioButtonInputClassName) | ||
})), /*#__PURE__*/React.createElement(ButtonPresenter, _extends({}, otherProps, { | ||
hasFocus: hasFocus, | ||
hasHover: hasHover, | ||
isPressed: isPressed, | ||
disabled: disabled, | ||
stylesheet: customStylesheet | ||
}))); | ||
}); | ||
}; | ||
return React.createElement( | ||
ThemeContext.Consumer, | ||
null, | ||
function (_ref) { | ||
var resolvedRoles = _ref.resolvedRoles; | ||
RadioButtonPresenter.displayName = "RadioButtonPresenter"; | ||
RadioButtonPresenter.propTypes = { | ||
/** | ||
* Sets the component to a disabled state | ||
*/ | ||
disabled: PropTypes.bool, | ||
var styles = stylesheet(_extends$1({ | ||
isPressed: isPressed, | ||
hasFocus: hasFocus, | ||
hasHover: hasHover, | ||
disabled: disabled, | ||
stylesheet: customStylesheet | ||
}, props), resolvedRoles); | ||
/** | ||
* Returns whether or not the button is currently focused | ||
*/ | ||
hasFocus: PropTypes.bool, | ||
var className = otherProps.className; | ||
/** | ||
* Returns whether or not the button is currently hovered | ||
*/ | ||
hasHover: PropTypes.bool, | ||
var radioButtonInputClassName = createCustomClassNames(className, "radio-button-input"); | ||
/** | ||
* Returns whether or not the button is currently pressed | ||
*/ | ||
isPressed: PropTypes.bool, | ||
return React.createElement( | ||
"div", | ||
{ className: cx(css(styles.radioButtonContainer), className) }, | ||
React.createElement("input", _extends$1({}, otherProps, { | ||
disabled: disabled, | ||
type: "radio", | ||
className: cx(css(styles.radioButtonInput), radioButtonInputClassName) | ||
})), | ||
React.createElement(ButtonPresenter, _extends$1({}, otherProps, { | ||
hasFocus: hasFocus, | ||
hasHover: hasHover, | ||
isPressed: isPressed, | ||
disabled: disabled, | ||
stylesheet: customStylesheet | ||
})) | ||
); | ||
} | ||
); | ||
}; | ||
RadioButtonPresenter.displayName = "RadioButtonPresenter"; | ||
RadioButtonPresenter.propTypes = { | ||
/** | ||
@@ -429,2 +961,3 @@ * Called when user moves focus from the field | ||
onBlur: PropTypes.func, | ||
/** | ||
@@ -434,2 +967,3 @@ * Called when user changes the value of the field | ||
onChange: PropTypes.func, | ||
/** | ||
@@ -439,2 +973,3 @@ * Called when user clicks on the field | ||
onClick: PropTypes.func, | ||
/** | ||
@@ -444,15 +979,4 @@ * Called when user puts focus on the field | ||
onFocus: PropTypes.func, | ||
/** | ||
* Returns whether or not the button is currently focused | ||
*/ | ||
hasFocus: PropTypes.bool, | ||
/** | ||
* Returns whether or not the button is currently hovered | ||
*/ | ||
hasHover: PropTypes.bool, | ||
/** | ||
* Returns whether or not the button is currently pressed | ||
*/ | ||
isPressed: PropTypes.bool, | ||
/** | ||
* Adds custom/overriding styles | ||
@@ -466,2 +990,30 @@ */ | ||
"props": { | ||
"disabled": { | ||
"type": { | ||
"name": "bool" | ||
}, | ||
"required": false, | ||
"description": "Sets the component to a disabled state" | ||
}, | ||
"hasFocus": { | ||
"type": { | ||
"name": "bool" | ||
}, | ||
"required": false, | ||
"description": "Returns whether or not the button is currently focused" | ||
}, | ||
"hasHover": { | ||
"type": { | ||
"name": "bool" | ||
}, | ||
"required": false, | ||
"description": "Returns whether or not the button is currently hovered" | ||
}, | ||
"isPressed": { | ||
"type": { | ||
"name": "bool" | ||
}, | ||
"required": false, | ||
"description": "Returns whether or not the button is currently pressed" | ||
}, | ||
"onBlur": { | ||
@@ -495,23 +1047,140 @@ "type": { | ||
}, | ||
"hasFocus": { | ||
"stylesheet": { | ||
"type": { | ||
"name": "bool" | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Returns whether or not the button is currently focused" | ||
"description": "Adds custom/overriding styles" | ||
} | ||
} | ||
}; | ||
const _excluded = ["onBlur", "onFocus", "onMouseDown", "onMouseEnter", "onMouseLeave", "onMouseUp", "stylesheet"]; | ||
function RadioButton(props) { | ||
const { | ||
onBlur, | ||
onFocus, | ||
onMouseDown, | ||
onMouseEnter, | ||
onMouseLeave, | ||
onMouseUp, | ||
stylesheet | ||
} = props, | ||
otherProps = _objectWithoutProperties(props, _excluded); | ||
return /*#__PURE__*/React.createElement(ControlBehavior, { | ||
onBlur: onBlur, | ||
onFocus: onFocus, | ||
onMouseDown: onMouseDown, | ||
onMouseEnter: onMouseEnter, | ||
onMouseLeave: onMouseLeave, | ||
onMouseUp: onMouseUp | ||
}, _ref => { | ||
let { | ||
hasFocus, | ||
hasHover, | ||
isPressed, | ||
onBlur: handleBlur, | ||
onFocus: handleFocus, | ||
onMouseDown: handleMouseDown, | ||
onMouseEnter: handleMouseEnter, | ||
onMouseLeave: handleMouseLeave, | ||
onMouseUp: handleMouseUp | ||
} = _ref; | ||
return /*#__PURE__*/React.createElement(RadioButtonPresenter, _extends({ | ||
hasFocus: hasFocus, | ||
hasHover: hasHover, | ||
isPressed: isPressed, | ||
onBlur: handleBlur, | ||
onFocus: handleFocus, | ||
onMouseDown: handleMouseDown, | ||
onMouseEnter: handleMouseEnter, | ||
onMouseLeave: handleMouseLeave, | ||
onMouseUp: handleMouseUp, | ||
stylesheet: stylesheet | ||
}, otherProps)); | ||
}); | ||
} | ||
RadioButton.propTypes = { | ||
/** | ||
* Triggers blur when focus is moved away from icon | ||
*/ | ||
onBlur: PropTypes.func, | ||
/** | ||
* Triggers when focus is moved to button | ||
*/ | ||
onFocus: PropTypes.func, | ||
/** | ||
* Triggers when the user's mouse is pressed over the button | ||
*/ | ||
onMouseDown: PropTypes.func, | ||
/** | ||
* Triggers when the user's mouse is over the button | ||
*/ | ||
onMouseEnter: PropTypes.func, | ||
/** | ||
* Triggers when the user's mouse is no longer over the button | ||
*/ | ||
onMouseLeave: PropTypes.func, | ||
/** | ||
* Triggers when the user's mouse is no longer pressed over the button | ||
*/ | ||
onMouseUp: PropTypes.func, | ||
/** | ||
* Function to modify the component's styles | ||
* */ | ||
stylesheet: PropTypes.func | ||
}; | ||
RadioButton.__docgenInfo = { | ||
"description": "", | ||
"displayName": "RadioButton", | ||
"props": { | ||
"onBlur": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Triggers blur when focus is moved away from icon" | ||
}, | ||
"hasHover": { | ||
"onFocus": { | ||
"type": { | ||
"name": "bool" | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Returns whether or not the button is currently hovered" | ||
"description": "Triggers when focus is moved to button" | ||
}, | ||
"isPressed": { | ||
"onMouseDown": { | ||
"type": { | ||
"name": "bool" | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Returns whether or not the button is currently pressed" | ||
"description": "Triggers when the user's mouse is pressed over the button" | ||
}, | ||
"onMouseEnter": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Triggers when the user's mouse is over the button" | ||
}, | ||
"onMouseLeave": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Triggers when the user's mouse is no longer over the button" | ||
}, | ||
"onMouseUp": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Triggers when the user's mouse is no longer pressed over the button" | ||
}, | ||
"stylesheet": { | ||
@@ -522,3 +1191,3 @@ "type": { | ||
"required": false, | ||
"description": "Adds custom/overriding styles" | ||
"description": "Function to modify the component's styles" | ||
} | ||
@@ -528,54 +1197,2 @@ } | ||
var _extends$2 = 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; }; | ||
function _objectWithoutProperties$2(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; } | ||
function RadioButton(props) { | ||
var onBlur = props.onBlur, | ||
onFocus = props.onFocus, | ||
onMouseDown = props.onMouseDown, | ||
onMouseEnter = props.onMouseEnter, | ||
onMouseLeave = props.onMouseLeave, | ||
onMouseUp = props.onMouseUp, | ||
otherProps = _objectWithoutProperties$2(props, ["onBlur", "onFocus", "onMouseDown", "onMouseEnter", "onMouseLeave", "onMouseUp"]); | ||
return React.createElement( | ||
ControlBehavior, | ||
{ | ||
onBlur: onBlur, | ||
onFocus: onFocus, | ||
onMouseDown: onMouseDown, | ||
onMouseEnter: onMouseEnter, | ||
onMouseLeave: onMouseLeave, | ||
onMouseUp: onMouseUp | ||
}, | ||
function (_ref) { | ||
var hasFocus = _ref.hasFocus, | ||
hasHover = _ref.hasHover, | ||
isPressed = _ref.isPressed, | ||
handleBlur = _ref.onBlur, | ||
handleFocus = _ref.onFocus, | ||
handleMouseDown = _ref.onMouseDown, | ||
handleMouseEnter = _ref.onMouseEnter, | ||
handleMouseLeave = _ref.onMouseLeave, | ||
handleMouseUp = _ref.onMouseUp; | ||
return React.createElement(RadioButtonPresenter, _extends$2({ | ||
hasFocus: hasFocus, | ||
hasHover: hasHover, | ||
isPressed: isPressed, | ||
onBlur: handleBlur, | ||
onFocus: handleFocus, | ||
onMouseDown: handleMouseDown, | ||
onMouseEnter: handleMouseEnter, | ||
onMouseLeave: handleMouseLeave, | ||
onMouseUp: handleMouseUp | ||
}, otherProps)); | ||
} | ||
); | ||
} | ||
RadioButton.__docgenInfo = { | ||
"description": "", | ||
"displayName": "RadioButton" | ||
}; | ||
export default RadioButton; | ||
export { RadioButton as default }; |
1034
build/index.js
@@ -5,18 +5,125 @@ 'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var React = require('react'); | ||
var PropTypes = require('prop-types'); | ||
var behaviors = require('@hig/behaviors'); | ||
var emotion = require('emotion'); | ||
var React = _interopDefault(require('react')); | ||
var PropTypes = _interopDefault(require('prop-types')); | ||
var themeContext = require('@hig/theme-context'); | ||
var behaviors = require('@hig/behaviors'); | ||
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
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; }; | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes); | ||
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 _objectSpread2(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 _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; | ||
} | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
/** | ||
* lodash (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
* Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
* Released under MIT license <https://lodash.com/license> | ||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | ||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
*/ | ||
/** Used to stand-in for `undefined` hash values. */ | ||
var HASH_UNDEFINED = '__lodash_hash_undefined__'; | ||
/** `Object#toString` result references. */ | ||
var funcTag = '[object Function]', | ||
genTag = '[object GeneratorFunction]'; | ||
/** | ||
@@ -26,16 +133,16 @@ * Used to match `RegExp` | ||
*/ | ||
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; | ||
/** Used to detect host constructors (Safari). */ | ||
/** Used to detect host constructors (Safari). */ | ||
var reIsHostCtor = /^\[object .+?Constructor\]$/; | ||
/** Detect free variable `global` from Node.js. */ | ||
var freeGlobal = (typeof commonjsGlobal === 'undefined' ? 'undefined' : _typeof(commonjsGlobal)) == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; | ||
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; | ||
/** Detect free variable `self`. */ | ||
var freeSelf = (typeof self === 'undefined' ? 'undefined' : _typeof(self)) == 'object' && self && self.Object === Object && self; | ||
var freeSelf = typeof self == 'object' && self && self.Object === Object && self; | ||
/** Used as a reference to the global object. */ | ||
var root = freeGlobal || freeSelf || Function('return this')(); | ||
/** | ||
@@ -49,6 +156,6 @@ * Gets the value at `key` of `object`. | ||
*/ | ||
function getValue(object, key) { | ||
return object == null ? undefined : object[key]; | ||
} | ||
/** | ||
@@ -61,2 +168,4 @@ * Checks if `value` is a host object in IE < 9. | ||
*/ | ||
function isHostObject(value) { | ||
@@ -66,2 +175,3 @@ // Many host objects are `Object` objects that can coerce to strings | ||
var result = false; | ||
if (value != null && typeof value.toString != 'function') { | ||
@@ -72,13 +182,16 @@ try { | ||
} | ||
return result; | ||
} | ||
/** Used for built-in method references. */ | ||
/** Used for built-in method references. */ | ||
var funcProto = Function.prototype, | ||
var arrayProto = Array.prototype, | ||
funcProto = Function.prototype, | ||
objectProto = Object.prototype; | ||
/** Used to detect overreaching core-js shims. */ | ||
/** Used to detect overreaching core-js shims. */ | ||
var coreJsData = root['__core-js_shared__']; | ||
/** Used to detect methods masquerading as native. */ | ||
/** Used to detect methods masquerading as native. */ | ||
var maskSrcKey = function () { | ||
@@ -88,9 +201,9 @@ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); | ||
}(); | ||
/** Used to resolve the decompiled source of functions. */ | ||
/** Used to resolve the decompiled source of functions. */ | ||
var funcToString = funcProto.toString; | ||
/** Used to check objects for own properties. */ | ||
/** Used to check objects for own properties. */ | ||
var hasOwnProperty = objectProto.hasOwnProperty; | ||
/** | ||
@@ -101,12 +214,359 @@ * Used to resolve the | ||
*/ | ||
var objectToString = objectProto.toString; | ||
/** Used to detect if a method is native. */ | ||
/** Used to detect if a method is native. */ | ||
var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'); | ||
/** Built-in value references. */ | ||
var splice = arrayProto.splice; | ||
/* Built-in method references that are verified to be native. */ | ||
var Map = getNative(root, 'Map'), | ||
nativeCreate = getNative(Object, 'create'); | ||
/** | ||
* Creates a hash object. | ||
* | ||
* @private | ||
* @constructor | ||
* @param {Array} [entries] The key-value pairs to cache. | ||
*/ | ||
function Hash(entries) { | ||
var index = -1, | ||
length = entries ? entries.length : 0; | ||
this.clear(); | ||
while (++index < length) { | ||
var entry = entries[index]; | ||
this.set(entry[0], entry[1]); | ||
} | ||
} | ||
/** | ||
* Removes all key-value entries from the hash. | ||
* | ||
* @private | ||
* @name clear | ||
* @memberOf Hash | ||
*/ | ||
function hashClear() { | ||
this.__data__ = nativeCreate ? nativeCreate(null) : {}; | ||
} | ||
/** | ||
* Removes `key` and its value from the hash. | ||
* | ||
* @private | ||
* @name delete | ||
* @memberOf Hash | ||
* @param {Object} hash The hash to modify. | ||
* @param {string} key The key of the value to remove. | ||
* @returns {boolean} Returns `true` if the entry was removed, else `false`. | ||
*/ | ||
function hashDelete(key) { | ||
return this.has(key) && delete this.__data__[key]; | ||
} | ||
/** | ||
* Gets the hash value for `key`. | ||
* | ||
* @private | ||
* @name get | ||
* @memberOf Hash | ||
* @param {string} key The key of the value to get. | ||
* @returns {*} Returns the entry value. | ||
*/ | ||
function hashGet(key) { | ||
var data = this.__data__; | ||
if (nativeCreate) { | ||
var result = data[key]; | ||
return result === HASH_UNDEFINED ? undefined : result; | ||
} | ||
return hasOwnProperty.call(data, key) ? data[key] : undefined; | ||
} | ||
/** | ||
* Checks if a hash value for `key` exists. | ||
* | ||
* @private | ||
* @name has | ||
* @memberOf Hash | ||
* @param {string} key The key of the entry to check. | ||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. | ||
*/ | ||
function hashHas(key) { | ||
var data = this.__data__; | ||
return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key); | ||
} | ||
/** | ||
* Sets the hash `key` to `value`. | ||
* | ||
* @private | ||
* @name set | ||
* @memberOf Hash | ||
* @param {string} key The key of the value to set. | ||
* @param {*} value The value to set. | ||
* @returns {Object} Returns the hash instance. | ||
*/ | ||
function hashSet(key, value) { | ||
var data = this.__data__; | ||
data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value; | ||
return this; | ||
} // Add methods to `Hash`. | ||
Hash.prototype.clear = hashClear; | ||
Hash.prototype['delete'] = hashDelete; | ||
Hash.prototype.get = hashGet; | ||
Hash.prototype.has = hashHas; | ||
Hash.prototype.set = hashSet; | ||
/** | ||
* Creates an list cache object. | ||
* | ||
* @private | ||
* @constructor | ||
* @param {Array} [entries] The key-value pairs to cache. | ||
*/ | ||
function ListCache(entries) { | ||
var index = -1, | ||
length = entries ? entries.length : 0; | ||
this.clear(); | ||
while (++index < length) { | ||
var entry = entries[index]; | ||
this.set(entry[0], entry[1]); | ||
} | ||
} | ||
/** | ||
* Removes all key-value entries from the list cache. | ||
* | ||
* @private | ||
* @name clear | ||
* @memberOf ListCache | ||
*/ | ||
function listCacheClear() { | ||
this.__data__ = []; | ||
} | ||
/** | ||
* Removes `key` and its value from the list cache. | ||
* | ||
* @private | ||
* @name delete | ||
* @memberOf ListCache | ||
* @param {string} key The key of the value to remove. | ||
* @returns {boolean} Returns `true` if the entry was removed, else `false`. | ||
*/ | ||
function listCacheDelete(key) { | ||
var data = this.__data__, | ||
index = assocIndexOf(data, key); | ||
if (index < 0) { | ||
return false; | ||
} | ||
var lastIndex = data.length - 1; | ||
if (index == lastIndex) { | ||
data.pop(); | ||
} else { | ||
splice.call(data, index, 1); | ||
} | ||
return true; | ||
} | ||
/** | ||
* Gets the list cache value for `key`. | ||
* | ||
* @private | ||
* @name get | ||
* @memberOf ListCache | ||
* @param {string} key The key of the value to get. | ||
* @returns {*} Returns the entry value. | ||
*/ | ||
function listCacheGet(key) { | ||
var data = this.__data__, | ||
index = assocIndexOf(data, key); | ||
return index < 0 ? undefined : data[index][1]; | ||
} | ||
/** | ||
* Checks if a list cache value for `key` exists. | ||
* | ||
* @private | ||
* @name has | ||
* @memberOf ListCache | ||
* @param {string} key The key of the entry to check. | ||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. | ||
*/ | ||
function listCacheHas(key) { | ||
return assocIndexOf(this.__data__, key) > -1; | ||
} | ||
/** | ||
* Sets the list cache `key` to `value`. | ||
* | ||
* @private | ||
* @name set | ||
* @memberOf ListCache | ||
* @param {string} key The key of the value to set. | ||
* @param {*} value The value to set. | ||
* @returns {Object} Returns the list cache instance. | ||
*/ | ||
function listCacheSet(key, value) { | ||
var data = this.__data__, | ||
index = assocIndexOf(data, key); | ||
if (index < 0) { | ||
data.push([key, value]); | ||
} else { | ||
data[index][1] = value; | ||
} | ||
return this; | ||
} // Add methods to `ListCache`. | ||
ListCache.prototype.clear = listCacheClear; | ||
ListCache.prototype['delete'] = listCacheDelete; | ||
ListCache.prototype.get = listCacheGet; | ||
ListCache.prototype.has = listCacheHas; | ||
ListCache.prototype.set = listCacheSet; | ||
/** | ||
* Creates a map cache object to store key-value pairs. | ||
* | ||
* @private | ||
* @constructor | ||
* @param {Array} [entries] The key-value pairs to cache. | ||
*/ | ||
function MapCache(entries) { | ||
var index = -1, | ||
length = entries ? entries.length : 0; | ||
this.clear(); | ||
while (++index < length) { | ||
var entry = entries[index]; | ||
this.set(entry[0], entry[1]); | ||
} | ||
} | ||
/** | ||
* Removes all key-value entries from the map. | ||
* | ||
* @private | ||
* @name clear | ||
* @memberOf MapCache | ||
*/ | ||
function mapCacheClear() { | ||
this.__data__ = { | ||
'hash': new Hash(), | ||
'map': new (Map || ListCache)(), | ||
'string': new Hash() | ||
}; | ||
} | ||
/** | ||
* Removes `key` and its value from the map. | ||
* | ||
* @private | ||
* @name delete | ||
* @memberOf MapCache | ||
* @param {string} key The key of the value to remove. | ||
* @returns {boolean} Returns `true` if the entry was removed, else `false`. | ||
*/ | ||
function mapCacheDelete(key) { | ||
return getMapData(this, key)['delete'](key); | ||
} | ||
/** | ||
* Gets the map value for `key`. | ||
* | ||
* @private | ||
* @name get | ||
* @memberOf MapCache | ||
* @param {string} key The key of the value to get. | ||
* @returns {*} Returns the entry value. | ||
*/ | ||
function mapCacheGet(key) { | ||
return getMapData(this, key).get(key); | ||
} | ||
/** | ||
* Checks if a map value for `key` exists. | ||
* | ||
* @private | ||
* @name has | ||
* @memberOf MapCache | ||
* @param {string} key The key of the entry to check. | ||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. | ||
*/ | ||
function mapCacheHas(key) { | ||
return getMapData(this, key).has(key); | ||
} | ||
/** | ||
* Sets the map `key` to `value`. | ||
* | ||
* @private | ||
* @name set | ||
* @memberOf MapCache | ||
* @param {string} key The key of the value to set. | ||
* @param {*} value The value to set. | ||
* @returns {Object} Returns the map cache instance. | ||
*/ | ||
function mapCacheSet(key, value) { | ||
getMapData(this, key).set(key, value); | ||
return this; | ||
} // Add methods to `MapCache`. | ||
MapCache.prototype.clear = mapCacheClear; | ||
MapCache.prototype['delete'] = mapCacheDelete; | ||
MapCache.prototype.get = mapCacheGet; | ||
MapCache.prototype.has = mapCacheHas; | ||
MapCache.prototype.set = mapCacheSet; | ||
/** | ||
* Gets the index at which the `key` is found in `array` of key-value pairs. | ||
* | ||
* @private | ||
* @param {Array} array The array to inspect. | ||
* @param {*} key The key to search for. | ||
* @returns {number} Returns the index of the matched value, else `-1`. | ||
*/ | ||
function assocIndexOf(array, key) { | ||
var length = array.length; | ||
while (length--) { | ||
if (eq(array[length][0], key)) { | ||
return length; | ||
} | ||
} | ||
return -1; | ||
} | ||
/** | ||
* The base implementation of `_.isNative` without bad shim checks. | ||
@@ -119,2 +579,4 @@ * | ||
*/ | ||
function baseIsNative(value) { | ||
@@ -124,6 +586,20 @@ if (!isObject(value) || isMasked(value)) { | ||
} | ||
var pattern = isFunction(value) || isHostObject(value) ? reIsNative : reIsHostCtor; | ||
return pattern.test(toSource(value)); | ||
} | ||
/** | ||
* Gets the data for `map`. | ||
* | ||
* @private | ||
* @param {Object} map The map to query. | ||
* @param {string} key The reference key. | ||
* @returns {*} Returns the map data. | ||
*/ | ||
function getMapData(map, key) { | ||
var data = map.__data__; | ||
return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map; | ||
} | ||
/** | ||
@@ -137,2 +613,4 @@ * Gets the native function at `key` of `object`. | ||
*/ | ||
function getNative(object, key) { | ||
@@ -142,3 +620,15 @@ var value = getValue(object, key); | ||
} | ||
/** | ||
* Checks if `value` is suitable for use as unique object key. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is suitable, else `false`. | ||
*/ | ||
function isKeyable(value) { | ||
var type = typeof value; | ||
return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null; | ||
} | ||
/** | ||
@@ -151,6 +641,7 @@ * Checks if `func` has its source masked. | ||
*/ | ||
function isMasked(func) { | ||
return !!maskSrcKey && maskSrcKey in func; | ||
} | ||
/** | ||
@@ -163,2 +654,4 @@ * Converts `func` to its source code. | ||
*/ | ||
function toSource(func) { | ||
@@ -169,2 +662,3 @@ if (func != null) { | ||
} catch (e) {} | ||
try { | ||
@@ -174,5 +668,41 @@ return func + ''; | ||
} | ||
return ''; | ||
} | ||
/** | ||
* Performs a | ||
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) | ||
* comparison between two values to determine if they are equivalent. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to compare. | ||
* @param {*} other The other value to compare. | ||
* @returns {boolean} Returns `true` if the values are equivalent, else `false`. | ||
* @example | ||
* | ||
* var object = { 'a': 1 }; | ||
* var other = { 'a': 1 }; | ||
* | ||
* _.eq(object, object); | ||
* // => true | ||
* | ||
* _.eq(object, other); | ||
* // => false | ||
* | ||
* _.eq('a', 'a'); | ||
* // => true | ||
* | ||
* _.eq('a', Object('a')); | ||
* // => false | ||
* | ||
* _.eq(NaN, NaN); | ||
* // => true | ||
*/ | ||
function eq(value, other) { | ||
return value === other || value !== value && other !== other; | ||
} | ||
/** | ||
@@ -195,2 +725,4 @@ * Checks if `value` is classified as a `Function` object. | ||
*/ | ||
function isFunction(value) { | ||
@@ -202,3 +734,2 @@ // The use of `Object#toString` avoids issues with the `typeof` operator | ||
} | ||
/** | ||
@@ -229,4 +760,6 @@ * Checks if `value` is the | ||
*/ | ||
function isObject(value) { | ||
var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); | ||
var type = typeof value; | ||
return !!value && (type == 'object' || type == 'function'); | ||
@@ -243,34 +776,32 @@ } | ||
function createCustomClassNames(className, appendedString) { | ||
return className && className.split(" ").reduce(function (acc, cur) { | ||
return emotion.cx(acc, cur.trim() + "__" + appendedString); | ||
}, ""); | ||
return className && className.split(" ").reduce((acc, cur) => emotion.cx(acc, `${cur.trim()}__${appendedString}`), ""); | ||
} | ||
function stylesheet(props, themeData) { | ||
var isPressed = props.isPressed, | ||
hasFocus = props.hasFocus, | ||
hasHover = props.hasHover, | ||
disabled = props.disabled, | ||
customStylesheet = props.stylesheet; | ||
var opacity = disabled ? themeData["colorScheme.opacity.disabled"] : "1.0"; | ||
// because we don't have access to the checked status in react, we need to | ||
const { | ||
isPressed, | ||
hasFocus, | ||
hasHover, | ||
disabled, | ||
stylesheet: customStylesheet | ||
} = props; | ||
const opacity = disabled ? themeData["colorScheme.opacity.disabled"] : "1.0"; // because we don't have access to the checked status in react, we need to | ||
// write css rules to handle both cases | ||
var borderColor = hasFocus && !hasHover ? themeData["checkbox.unchecked.focus.borderColor"] : themeData["checkbox.unchecked.default.borderColor"]; | ||
var checkedInnerShadow = "inset 0 0 0 " + themeData["checkbox.pressed.haloWidth"] + " " + themeData["checkbox.checked.default.backgroundColor"]; | ||
var uncheckedInnerShadow = "inset 0 0 0 " + themeData["checkbox.borderWidth"] + " \n " + borderColor + "\n "; | ||
var outerShadow = "0 0 0 0px transparent"; | ||
if (disabled) { | ||
// do nothing | ||
} else if (isPressed) { | ||
outerShadow = "0 0 0 " + themeData["checkbox.pressed.haloWidth"] + " " + themeData["checkbox.pressed.haloColor"]; | ||
const borderColor = hasFocus && !hasHover ? themeData["checkbox.unchecked.focus.borderColor"] : themeData["checkbox.unchecked.default.borderColor"]; | ||
const checkedInnerShadow = `inset 0 0 0 ${themeData["checkbox.pressed.haloWidth"]} ${themeData["checkbox.checked.default.backgroundColor"]}`; | ||
const uncheckedInnerShadow = `inset 0 0 0 ${themeData["checkbox.borderWidth"]} ${borderColor}`; | ||
let outerShadow = "0 0 0 0px transparent"; | ||
if (disabled) ; else if (isPressed) { | ||
outerShadow = `0 0 0 ${themeData["checkbox.pressed.haloWidth"]} ${themeData["checkbox.pressed.haloColor"]}`; | ||
} else if (hasHover) { | ||
outerShadow = "0 0 0 " + themeData["checkbox.hover.haloWidth"] + " " + themeData["checkbox.hover.haloColor"]; | ||
outerShadow = `0 0 0 ${themeData["checkbox.hover.haloWidth"]} ${themeData["checkbox.hover.haloColor"]}`; | ||
} else if (hasFocus) { | ||
outerShadow = "0 0 0 " + themeData["checkbox.focus.haloWidth"] + " " + themeData["checkbox.focus.haloColor"]; | ||
outerShadow = `0 0 0 ${themeData["checkbox.focus.haloWidth"]} ${themeData["checkbox.focus.haloColor"]}`; | ||
} | ||
var styles = { | ||
const styles = { | ||
radioButtonContainer: { | ||
@@ -282,9 +813,8 @@ position: "relative", | ||
}, | ||
radioButtonWrapper: { | ||
opacity: opacity, | ||
opacity, | ||
position: "relative", | ||
color: "transparent", | ||
border: "none", | ||
backgroundColor: "transparent", | ||
backgroundColor: themeData["checkbox.unchecked.default.backgroundColor"], | ||
textAlign: "center", | ||
@@ -296,3 +826,3 @@ fontSize: "25px", | ||
borderRadius: "50%", | ||
boxShadow: uncheckedInnerShadow + "," + outerShadow, | ||
boxShadow: `${uncheckedInnerShadow},${outerShadow}`, | ||
transitionDuration: "0.3s, 0.3s", | ||
@@ -302,3 +832,2 @@ transitionProperty: "box-shadow, background-color", | ||
}, | ||
// this maps to .radio-button__input | ||
@@ -316,43 +845,37 @@ radioButtonInput: { | ||
zIndex: "1", | ||
"&:checked + span": { | ||
boxShadow: checkedInnerShadow + "," + outerShadow | ||
boxShadow: `${checkedInnerShadow},${outerShadow}` | ||
} | ||
} | ||
}; | ||
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$2 = ["stylesheet"]; | ||
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 ButtonPresenter = props => { | ||
const { | ||
stylesheet: customStylesheet | ||
} = props, | ||
otherProps = _objectWithoutProperties(props, _excluded$2); | ||
var ButtonPresenter = function ButtonPresenter(props) { | ||
var customStylesheet = props.stylesheet, | ||
otherProps = _objectWithoutProperties(props, ["stylesheet"]); | ||
var className = otherProps.className; | ||
var radioButtonWrapperClassName = createCustomClassNames(className, "radio-button-wrapper"); | ||
return React.createElement( | ||
themeContext.ThemeContext.Consumer, | ||
null, | ||
function (_ref) { | ||
var resolvedRoles = _ref.resolvedRoles, | ||
metadata = _ref.metadata; | ||
var styles = stylesheet(_extends({ | ||
stylesheet: customStylesheet | ||
}, props), resolvedRoles, metadata.colorSchemeId); | ||
return React.createElement("span", { | ||
className: emotion.cx(emotion.css(styles.radioButtonWrapper), radioButtonWrapperClassName) | ||
}); | ||
} | ||
); | ||
const { | ||
className | ||
} = otherProps; | ||
const radioButtonWrapperClassName = createCustomClassNames(className, "radio-button-wrapper"); | ||
return /*#__PURE__*/React__default["default"].createElement(themeContext.ThemeContext.Consumer, null, _ref => { | ||
let { | ||
resolvedRoles, | ||
metadata | ||
} = _ref; | ||
const styles = stylesheet(_objectSpread2({ | ||
stylesheet: customStylesheet | ||
}, props), resolvedRoles, metadata.colorSchemeId); | ||
return /*#__PURE__*/React__default["default"].createElement("span", { | ||
className: emotion.cx(emotion.css(styles.radioButtonWrapper), radioButtonWrapperClassName) | ||
}); | ||
}); | ||
}; | ||
ButtonPresenter.displayName = "ButtonPresenter"; | ||
ButtonPresenter.propTypes = { | ||
@@ -362,3 +885,3 @@ /** | ||
*/ | ||
stylesheet: PropTypes.func | ||
stylesheet: PropTypes__default["default"].func | ||
}; | ||
@@ -379,87 +902,91 @@ ButtonPresenter.__docgenInfo = { | ||
var _extends$1 = 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$1 = ["disabled", "hasFocus", "hasHover", "isPressed", "stylesheet"]; | ||
function _objectWithoutProperties$1(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 RadioButtonPresenter = props => { | ||
const { | ||
disabled, | ||
hasFocus, | ||
hasHover, | ||
isPressed, | ||
stylesheet: customStylesheet | ||
} = props, | ||
otherProps = _objectWithoutProperties(props, _excluded$1); | ||
var RadioButtonPresenter = function RadioButtonPresenter(props) { | ||
var disabled = props.disabled, | ||
hasFocus = props.hasFocus, | ||
hasHover = props.hasHover, | ||
isPressed = props.isPressed, | ||
customStylesheet = props.stylesheet, | ||
otherProps = _objectWithoutProperties$1(props, ["disabled", "hasFocus", "hasHover", "isPressed", "stylesheet"]); | ||
return React.createElement( | ||
themeContext.ThemeContext.Consumer, | ||
null, | ||
function (_ref) { | ||
var resolvedRoles = _ref.resolvedRoles; | ||
var styles = stylesheet(_extends$1({ | ||
isPressed: isPressed, | ||
hasFocus: hasFocus, | ||
hasHover: hasHover, | ||
disabled: disabled, | ||
stylesheet: customStylesheet | ||
}, props), resolvedRoles); | ||
var className = otherProps.className; | ||
var radioButtonInputClassName = createCustomClassNames(className, "radio-button-input"); | ||
return React.createElement( | ||
"div", | ||
{ className: emotion.cx(emotion.css(styles.radioButtonContainer), className) }, | ||
React.createElement("input", _extends$1({}, otherProps, { | ||
disabled: disabled, | ||
type: "radio", | ||
className: emotion.cx(emotion.css(styles.radioButtonInput), radioButtonInputClassName) | ||
})), | ||
React.createElement(ButtonPresenter, _extends$1({}, otherProps, { | ||
hasFocus: hasFocus, | ||
hasHover: hasHover, | ||
isPressed: isPressed, | ||
disabled: disabled, | ||
stylesheet: customStylesheet | ||
})) | ||
); | ||
} | ||
); | ||
return /*#__PURE__*/React__default["default"].createElement(themeContext.ThemeContext.Consumer, null, _ref => { | ||
let { | ||
resolvedRoles | ||
} = _ref; | ||
const styles = stylesheet(_objectSpread2({ | ||
isPressed, | ||
hasFocus, | ||
hasHover, | ||
disabled, | ||
stylesheet: customStylesheet | ||
}, props), resolvedRoles); | ||
const { | ||
className | ||
} = otherProps; | ||
const radioButtonInputClassName = createCustomClassNames(className, "radio-button-input"); | ||
return /*#__PURE__*/React__default["default"].createElement("div", { | ||
className: emotion.cx(emotion.css(styles.radioButtonContainer), className) | ||
}, /*#__PURE__*/React__default["default"].createElement("input", _extends({}, otherProps, { | ||
disabled: disabled, | ||
type: "radio", | ||
className: emotion.cx(emotion.css(styles.radioButtonInput), radioButtonInputClassName) | ||
})), /*#__PURE__*/React__default["default"].createElement(ButtonPresenter, _extends({}, otherProps, { | ||
hasFocus: hasFocus, | ||
hasHover: hasHover, | ||
isPressed: isPressed, | ||
disabled: disabled, | ||
stylesheet: customStylesheet | ||
}))); | ||
}); | ||
}; | ||
RadioButtonPresenter.displayName = "RadioButtonPresenter"; | ||
RadioButtonPresenter.propTypes = { | ||
/** | ||
* Called when user moves focus from the field | ||
* Sets the component to a disabled state | ||
*/ | ||
onBlur: PropTypes.func, | ||
disabled: PropTypes__default["default"].bool, | ||
/** | ||
* Called when user changes the value of the field | ||
* Returns whether or not the button is currently focused | ||
*/ | ||
onChange: PropTypes.func, | ||
hasFocus: PropTypes__default["default"].bool, | ||
/** | ||
* Called when user clicks on the field | ||
* Returns whether or not the button is currently hovered | ||
*/ | ||
onClick: PropTypes.func, | ||
hasHover: PropTypes__default["default"].bool, | ||
/** | ||
* Called when user puts focus on the field | ||
* Returns whether or not the button is currently pressed | ||
*/ | ||
onFocus: PropTypes.func, | ||
isPressed: PropTypes__default["default"].bool, | ||
/** | ||
* Returns whether or not the button is currently focused | ||
* Called when user moves focus from the field | ||
*/ | ||
hasFocus: PropTypes.bool, | ||
onBlur: PropTypes__default["default"].func, | ||
/** | ||
* Returns whether or not the button is currently hovered | ||
* Called when user changes the value of the field | ||
*/ | ||
hasHover: PropTypes.bool, | ||
onChange: PropTypes__default["default"].func, | ||
/** | ||
* Returns whether or not the button is currently pressed | ||
* Called when user clicks on the field | ||
*/ | ||
isPressed: PropTypes.bool, | ||
onClick: PropTypes__default["default"].func, | ||
/** | ||
* Called when user puts focus on the field | ||
*/ | ||
onFocus: PropTypes__default["default"].func, | ||
/** | ||
* Adds custom/overriding styles | ||
*/ | ||
stylesheet: PropTypes.func | ||
stylesheet: PropTypes__default["default"].func | ||
}; | ||
@@ -470,2 +997,30 @@ RadioButtonPresenter.__docgenInfo = { | ||
"props": { | ||
"disabled": { | ||
"type": { | ||
"name": "bool" | ||
}, | ||
"required": false, | ||
"description": "Sets the component to a disabled state" | ||
}, | ||
"hasFocus": { | ||
"type": { | ||
"name": "bool" | ||
}, | ||
"required": false, | ||
"description": "Returns whether or not the button is currently focused" | ||
}, | ||
"hasHover": { | ||
"type": { | ||
"name": "bool" | ||
}, | ||
"required": false, | ||
"description": "Returns whether or not the button is currently hovered" | ||
}, | ||
"isPressed": { | ||
"type": { | ||
"name": "bool" | ||
}, | ||
"required": false, | ||
"description": "Returns whether or not the button is currently pressed" | ||
}, | ||
"onBlur": { | ||
@@ -499,23 +1054,140 @@ "type": { | ||
}, | ||
"hasFocus": { | ||
"stylesheet": { | ||
"type": { | ||
"name": "bool" | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Returns whether or not the button is currently focused" | ||
"description": "Adds custom/overriding styles" | ||
} | ||
} | ||
}; | ||
const _excluded = ["onBlur", "onFocus", "onMouseDown", "onMouseEnter", "onMouseLeave", "onMouseUp", "stylesheet"]; | ||
function RadioButton(props) { | ||
const { | ||
onBlur, | ||
onFocus, | ||
onMouseDown, | ||
onMouseEnter, | ||
onMouseLeave, | ||
onMouseUp, | ||
stylesheet | ||
} = props, | ||
otherProps = _objectWithoutProperties(props, _excluded); | ||
return /*#__PURE__*/React__default["default"].createElement(behaviors.ControlBehavior, { | ||
onBlur: onBlur, | ||
onFocus: onFocus, | ||
onMouseDown: onMouseDown, | ||
onMouseEnter: onMouseEnter, | ||
onMouseLeave: onMouseLeave, | ||
onMouseUp: onMouseUp | ||
}, _ref => { | ||
let { | ||
hasFocus, | ||
hasHover, | ||
isPressed, | ||
onBlur: handleBlur, | ||
onFocus: handleFocus, | ||
onMouseDown: handleMouseDown, | ||
onMouseEnter: handleMouseEnter, | ||
onMouseLeave: handleMouseLeave, | ||
onMouseUp: handleMouseUp | ||
} = _ref; | ||
return /*#__PURE__*/React__default["default"].createElement(RadioButtonPresenter, _extends({ | ||
hasFocus: hasFocus, | ||
hasHover: hasHover, | ||
isPressed: isPressed, | ||
onBlur: handleBlur, | ||
onFocus: handleFocus, | ||
onMouseDown: handleMouseDown, | ||
onMouseEnter: handleMouseEnter, | ||
onMouseLeave: handleMouseLeave, | ||
onMouseUp: handleMouseUp, | ||
stylesheet: stylesheet | ||
}, otherProps)); | ||
}); | ||
} | ||
RadioButton.propTypes = { | ||
/** | ||
* Triggers blur when focus is moved away from icon | ||
*/ | ||
onBlur: PropTypes__default["default"].func, | ||
/** | ||
* Triggers when focus is moved to button | ||
*/ | ||
onFocus: PropTypes__default["default"].func, | ||
/** | ||
* Triggers when the user's mouse is pressed over the button | ||
*/ | ||
onMouseDown: PropTypes__default["default"].func, | ||
/** | ||
* Triggers when the user's mouse is over the button | ||
*/ | ||
onMouseEnter: PropTypes__default["default"].func, | ||
/** | ||
* Triggers when the user's mouse is no longer over the button | ||
*/ | ||
onMouseLeave: PropTypes__default["default"].func, | ||
/** | ||
* Triggers when the user's mouse is no longer pressed over the button | ||
*/ | ||
onMouseUp: PropTypes__default["default"].func, | ||
/** | ||
* Function to modify the component's styles | ||
* */ | ||
stylesheet: PropTypes__default["default"].func | ||
}; | ||
RadioButton.__docgenInfo = { | ||
"description": "", | ||
"displayName": "RadioButton", | ||
"props": { | ||
"onBlur": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Triggers blur when focus is moved away from icon" | ||
}, | ||
"hasHover": { | ||
"onFocus": { | ||
"type": { | ||
"name": "bool" | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Returns whether or not the button is currently hovered" | ||
"description": "Triggers when focus is moved to button" | ||
}, | ||
"isPressed": { | ||
"onMouseDown": { | ||
"type": { | ||
"name": "bool" | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Returns whether or not the button is currently pressed" | ||
"description": "Triggers when the user's mouse is pressed over the button" | ||
}, | ||
"onMouseEnter": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Triggers when the user's mouse is over the button" | ||
}, | ||
"onMouseLeave": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Triggers when the user's mouse is no longer over the button" | ||
}, | ||
"onMouseUp": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Triggers when the user's mouse is no longer pressed over the button" | ||
}, | ||
"stylesheet": { | ||
@@ -526,3 +1198,3 @@ "type": { | ||
"required": false, | ||
"description": "Adds custom/overriding styles" | ||
"description": "Function to modify the component's styles" | ||
} | ||
@@ -532,54 +1204,2 @@ } | ||
var _extends$2 = 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; }; | ||
function _objectWithoutProperties$2(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; } | ||
function RadioButton(props) { | ||
var onBlur = props.onBlur, | ||
onFocus = props.onFocus, | ||
onMouseDown = props.onMouseDown, | ||
onMouseEnter = props.onMouseEnter, | ||
onMouseLeave = props.onMouseLeave, | ||
onMouseUp = props.onMouseUp, | ||
otherProps = _objectWithoutProperties$2(props, ["onBlur", "onFocus", "onMouseDown", "onMouseEnter", "onMouseLeave", "onMouseUp"]); | ||
return React.createElement( | ||
behaviors.ControlBehavior, | ||
{ | ||
onBlur: onBlur, | ||
onFocus: onFocus, | ||
onMouseDown: onMouseDown, | ||
onMouseEnter: onMouseEnter, | ||
onMouseLeave: onMouseLeave, | ||
onMouseUp: onMouseUp | ||
}, | ||
function (_ref) { | ||
var hasFocus = _ref.hasFocus, | ||
hasHover = _ref.hasHover, | ||
isPressed = _ref.isPressed, | ||
handleBlur = _ref.onBlur, | ||
handleFocus = _ref.onFocus, | ||
handleMouseDown = _ref.onMouseDown, | ||
handleMouseEnter = _ref.onMouseEnter, | ||
handleMouseLeave = _ref.onMouseLeave, | ||
handleMouseUp = _ref.onMouseUp; | ||
return React.createElement(RadioButtonPresenter, _extends$2({ | ||
hasFocus: hasFocus, | ||
hasHover: hasHover, | ||
isPressed: isPressed, | ||
onBlur: handleBlur, | ||
onFocus: handleFocus, | ||
onMouseDown: handleMouseDown, | ||
onMouseEnter: handleMouseEnter, | ||
onMouseLeave: handleMouseLeave, | ||
onMouseUp: handleMouseUp | ||
}, otherProps)); | ||
} | ||
); | ||
} | ||
RadioButton.__docgenInfo = { | ||
"description": "", | ||
"displayName": "RadioButton" | ||
}; | ||
exports.default = RadioButton; | ||
exports["default"] = RadioButton; |
@@ -0,1 +1,8 @@ | ||
# [@hig/radio-button-v2.2.0](https://github.com/Autodesk/hig/compare/@hig/radio-button@2.1.0...@hig/radio-button@2.2.0) (2022-08-23) | ||
### Features | ||
* update background color ([0955678](https://github.com/Autodesk/hig/commit/0955678)) | ||
# [@hig/radio-button-v2.1.0](https://github.com/Autodesk/hig/compare/@hig/radio-button@2.0.0...@hig/radio-button@2.1.0) (2022-01-24) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "@hig/radio-button", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "HIG Radio Button", | ||
@@ -22,8 +22,7 @@ "author": "Autodesk Inc.", | ||
"emotion": "^10.0.0", | ||
"prop-types": "^15.7.1", | ||
"react-lifecycles-compat": "^3.0.4" | ||
"prop-types": "^15.7.1" | ||
}, | ||
"peerDependencies": { | ||
"@hig/theme-context": "^4.1.0", | ||
"@hig/theme-data": "^2.22.1", | ||
"@hig/theme-context": "^4.2.0", | ||
"@hig/theme-data": "^3.1.0", | ||
"react": "^17.0.0" | ||
@@ -30,0 +29,0 @@ }, |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
67930
6
2037
3
- Removedreact-lifecycles-compat@^3.0.4
- Removed@hig/theme-data@2.26.0(transitive)
- Removedreact-lifecycles-compat@3.0.4(transitive)