@schrodinger/ui-checkbox
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -12,33 +12,2 @@ 'use strict'; | ||
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | ||
_typeof = function (obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
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; | ||
} | ||
var Theme; | ||
@@ -51,3 +20,3 @@ | ||
var UIContext = /*#__PURE__*/React.createContext({ | ||
const UIContext = /*#__PURE__*/React.createContext({ | ||
theme: Theme.LIGHT | ||
@@ -63,3 +32,3 @@ }); | ||
str += mix; | ||
} else if (_typeof(mix) === 'object') { | ||
} else if (typeof mix === 'object') { | ||
if (Array.isArray(mix)) { | ||
@@ -147,44 +116,39 @@ for (k = 0; k < mix.length; k++) { | ||
var Checkbox = /*#__PURE__*/React__default["default"].memo(function (props) { | ||
return /*#__PURE__*/React__default["default"].createElement(UIContext.Consumer, null, function (context) { | ||
var children = props.children && /*#__PURE__*/React__default["default"].createElement("span", { | ||
className: textClassNames() | ||
}, props.children); | ||
return /*#__PURE__*/React__default["default"].createElement("label", { | ||
className: labelClassNames(props, context), | ||
title: props.title, | ||
onMouseEnter: props.onMouseEnter, | ||
onMouseLeave: props.onMouseLeave | ||
}, /*#__PURE__*/React__default["default"].createElement("input", { | ||
checked: props.checked === true, | ||
type: props.type === exports.CheckboxType.RADIO ? 'radio' : 'checkbox', | ||
name: props.name, | ||
value: props.value, | ||
"data-name": props.name, | ||
onChange: props.onChange, | ||
disabled: props.disabled, | ||
readOnly: props.readonly || !lodash.isFunction(props.onChange) | ||
}), /*#__PURE__*/React__default["default"].createElement("span", { | ||
className: checkmarkClassNames(props) | ||
}), children); | ||
}); | ||
const Checkbox = /*#__PURE__*/React__default["default"].memo(props => /*#__PURE__*/React__default["default"].createElement(UIContext.Consumer, null, context => { | ||
const children = props.children && /*#__PURE__*/React__default["default"].createElement("span", { | ||
className: textClassNames() | ||
}, props.children); | ||
return /*#__PURE__*/React__default["default"].createElement("label", { | ||
className: labelClassNames(props, context), | ||
title: props.title, | ||
onMouseEnter: props.onMouseEnter, | ||
onMouseLeave: props.onMouseLeave | ||
}, /*#__PURE__*/React__default["default"].createElement("input", { | ||
checked: props.checked === true, | ||
type: props.type === exports.CheckboxType.RADIO ? 'radio' : 'checkbox', | ||
name: props.name, | ||
value: props.value, | ||
"data-name": props.name, | ||
onChange: props.onChange, | ||
disabled: props.disabled, | ||
readOnly: props.readonly || !lodash.isFunction(props.onChange) | ||
}), /*#__PURE__*/React__default["default"].createElement("span", { | ||
className: checkmarkClassNames(props) | ||
}), children); | ||
})); | ||
const labelClassNames = (props, context) => clsx(props.className, styles.Checkbox, styles[props.theme || context.theme || Theme.LIGHT], { | ||
[styles.disabled]: props.disabled | ||
}); | ||
var labelClassNames = function labelClassNames(props, context) { | ||
return clsx(props.className, styles.Checkbox, styles[props.theme || context.theme || Theme.LIGHT], _defineProperty({}, styles.disabled, props.disabled)); | ||
}; | ||
const checkmarkClassNames = ({ | ||
type = exports.CheckboxType.TICK, | ||
checked | ||
}) => clsx(styles.checkmark, styles[type], { | ||
[styles.checked]: checked === true, | ||
[styles.indeterminate]: checked === null | ||
}); | ||
var checkmarkClassNames = function checkmarkClassNames(_ref) { | ||
var _clsx2; | ||
const textClassNames = () => clsx(styles.text); | ||
var _ref$type = _ref.type, | ||
type = _ref$type === void 0 ? exports.CheckboxType.TICK : _ref$type, | ||
checked = _ref.checked; | ||
return clsx(styles.checkmark, styles[type], (_clsx2 = {}, _defineProperty(_clsx2, styles.checked, checked === true), _defineProperty(_clsx2, styles.indeterminate, checked === null), _clsx2)); | ||
}; | ||
var textClassNames = function textClassNames() { | ||
return clsx(styles.text); | ||
}; | ||
exports.Checkbox = Checkbox; |
import React, { createContext } from 'react'; | ||
import { isFunction } from 'lodash'; | ||
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | ||
_typeof = function (obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
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; | ||
} | ||
var Theme; | ||
@@ -42,3 +11,3 @@ | ||
var UIContext = /*#__PURE__*/createContext({ | ||
const UIContext = /*#__PURE__*/createContext({ | ||
theme: Theme.LIGHT | ||
@@ -54,3 +23,3 @@ }); | ||
str += mix; | ||
} else if (_typeof(mix) === 'object') { | ||
} else if (typeof mix === 'object') { | ||
if (Array.isArray(mix)) { | ||
@@ -138,44 +107,39 @@ for (k = 0; k < mix.length; k++) { | ||
var Checkbox = /*#__PURE__*/React.memo(function (props) { | ||
return /*#__PURE__*/React.createElement(UIContext.Consumer, null, function (context) { | ||
var children = props.children && /*#__PURE__*/React.createElement("span", { | ||
className: textClassNames() | ||
}, props.children); | ||
return /*#__PURE__*/React.createElement("label", { | ||
className: labelClassNames(props, context), | ||
title: props.title, | ||
onMouseEnter: props.onMouseEnter, | ||
onMouseLeave: props.onMouseLeave | ||
}, /*#__PURE__*/React.createElement("input", { | ||
checked: props.checked === true, | ||
type: props.type === CheckboxType.RADIO ? 'radio' : 'checkbox', | ||
name: props.name, | ||
value: props.value, | ||
"data-name": props.name, | ||
onChange: props.onChange, | ||
disabled: props.disabled, | ||
readOnly: props.readonly || !isFunction(props.onChange) | ||
}), /*#__PURE__*/React.createElement("span", { | ||
className: checkmarkClassNames(props) | ||
}), children); | ||
}); | ||
const Checkbox = /*#__PURE__*/React.memo(props => /*#__PURE__*/React.createElement(UIContext.Consumer, null, context => { | ||
const children = props.children && /*#__PURE__*/React.createElement("span", { | ||
className: textClassNames() | ||
}, props.children); | ||
return /*#__PURE__*/React.createElement("label", { | ||
className: labelClassNames(props, context), | ||
title: props.title, | ||
onMouseEnter: props.onMouseEnter, | ||
onMouseLeave: props.onMouseLeave | ||
}, /*#__PURE__*/React.createElement("input", { | ||
checked: props.checked === true, | ||
type: props.type === CheckboxType.RADIO ? 'radio' : 'checkbox', | ||
name: props.name, | ||
value: props.value, | ||
"data-name": props.name, | ||
onChange: props.onChange, | ||
disabled: props.disabled, | ||
readOnly: props.readonly || !isFunction(props.onChange) | ||
}), /*#__PURE__*/React.createElement("span", { | ||
className: checkmarkClassNames(props) | ||
}), children); | ||
})); | ||
const labelClassNames = (props, context) => clsx(props.className, styles.Checkbox, styles[props.theme || context.theme || Theme.LIGHT], { | ||
[styles.disabled]: props.disabled | ||
}); | ||
var labelClassNames = function labelClassNames(props, context) { | ||
return clsx(props.className, styles.Checkbox, styles[props.theme || context.theme || Theme.LIGHT], _defineProperty({}, styles.disabled, props.disabled)); | ||
}; | ||
const checkmarkClassNames = ({ | ||
type = CheckboxType.TICK, | ||
checked | ||
}) => clsx(styles.checkmark, styles[type], { | ||
[styles.checked]: checked === true, | ||
[styles.indeterminate]: checked === null | ||
}); | ||
var checkmarkClassNames = function checkmarkClassNames(_ref) { | ||
var _clsx2; | ||
const textClassNames = () => clsx(styles.text); | ||
var _ref$type = _ref.type, | ||
type = _ref$type === void 0 ? CheckboxType.TICK : _ref$type, | ||
checked = _ref.checked; | ||
return clsx(styles.checkmark, styles[type], (_clsx2 = {}, _defineProperty(_clsx2, styles.checked, checked === true), _defineProperty(_clsx2, styles.indeterminate, checked === null), _clsx2)); | ||
}; | ||
var textClassNames = function textClassNames() { | ||
return clsx(styles.text); | ||
}; | ||
export { Checkbox, CheckboxType }; |
{ | ||
"name": "@schrodinger/ui-checkbox", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "description", | ||
@@ -30,4 +30,5 @@ "keywords": [], | ||
"devDependencies": { | ||
"@schrodinger/ui-context": "^1.1.2", | ||
"@schrodinger/ui-context": "^1.1.3", | ||
"@schrodinger/ui-scripts": "^1.1.2", | ||
"@types/react": "^16.9.49", | ||
"react": "16.x" | ||
@@ -41,3 +42,3 @@ }, | ||
}, | ||
"gitHead": "87c019ddb8494ad534622bde627fd007e5b4397c" | ||
"gitHead": "53dc452ae15bd00f131a0de407dc55df412bd8d5" | ||
} |
44619
4
510