1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | var _react = _interopRequireDefault(require("react"));
|
9 |
|
10 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
11 |
|
12 | var _withStyles = require("../helpers/withStyles");
|
13 |
|
14 | var _reactWithStyles = require("react-with-styles");
|
15 |
|
16 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17 |
|
18 | 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); }
|
19 |
|
20 | function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
21 |
|
22 | 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; }
|
23 |
|
24 | var propTypes = _objectSpread({}, _reactWithStyles.withStylesPropTypes, {
|
25 | checked: _propTypes.default.bool,
|
26 | disabled: _propTypes.default.bool,
|
27 | id: _propTypes.default.string,
|
28 | invalid: _propTypes.default.bool,
|
29 | name: _propTypes.default.string,
|
30 | onBlur: _propTypes.default.func,
|
31 | onChange: _propTypes.default.func,
|
32 | onFocus: _propTypes.default.func,
|
33 | refForFocus: _propTypes.default.func
|
34 | });
|
35 |
|
36 | var CheckboxOnly = function CheckboxOnly(_ref) {
|
37 | var checked = _ref.checked,
|
38 | css = _ref.css,
|
39 | disabled = _ref.disabled,
|
40 | id = _ref.id,
|
41 | invalid = _ref.invalid,
|
42 | name = _ref.name,
|
43 | onBlur = _ref.onBlur,
|
44 | onChange = _ref.onChange,
|
45 | onFocus = _ref.onFocus,
|
46 | refForFocus = _ref.refForFocus,
|
47 | styles = _ref.styles;
|
48 | return _react.default.createElement("div", css(styles.container), _react.default.createElement("div", css(styles.checkbox, disabled && styles.checkbox_disabled, invalid && styles.checkbox_invalid), _react.default.createElement("input", _extends({}, css(styles.checkbox__input), {
|
49 | type: "checkbox",
|
50 | id: id,
|
51 | name: name,
|
52 | checked: checked,
|
53 | disabled: disabled,
|
54 | "aria-invalid": invalid,
|
55 | onBlur: onBlur,
|
56 | onChange: onChange,
|
57 | onFocus: onFocus
|
58 | })), _react.default.createElement("div", _extends({}, css(styles.checkbox__markContainer), {
|
59 | "data-fake-checkbox": !invalid && !disabled
|
60 | }), checked && _react.default.createElement("div", css(styles.checkbox__checkMark), _react.default.createElement("svg", _extends({}, css(styles.checkbox__checkMark__icon), {
|
61 | xmlns: "http://www.w3.org/2000/svg",
|
62 | viewBox: "0 0 54.19 42.05"
|
63 | }), _react.default.createElement("path", {
|
64 | d: "M48,0a6,6,0,0,0-4.12,1.81c-9.36,9.38-16.58,17.25-25.16,26L10,20.47a6,6,0,0,0-8,8.92l.28.23,13,11a6,6,0,0,0,8.13-.34c10.79-10.81,18.46-19.43,29-30A6,6,0,0,0,48,0Z"
|
65 | }))))));
|
66 | };
|
67 |
|
68 | CheckboxOnly.propTypes = propTypes;
|
69 | var CheckboxOnlyWithStyles = (0, _withStyles.withStyles)(function (_ref2) {
|
70 | var units = _ref2.units,
|
71 | color = _ref2.color,
|
72 | input = _ref2.input;
|
73 | return {
|
74 | container: {
|
75 | display: 'inline-block',
|
76 | position: 'relative',
|
77 | cursor: 'pointer',
|
78 | overflow: 'hidden',
|
79 | borderRadius: input.checkbox.borderRadius,
|
80 | marginTop: 2,
|
81 | ':focus-within': {
|
82 | boxShadow: "0 0 2px ".concat(color.secondary)
|
83 | }
|
84 | },
|
85 | checkbox: _objectSpread({
|
86 | width: input.checkbox.size,
|
87 | height: input.checkbox.size,
|
88 | background: input.checkbox.background,
|
89 | textAlign: 'center'
|
90 | }, input.checkbox.border, {
|
91 | boxSizing: 'border-box'
|
92 | }),
|
93 | checkbox_disabled: _objectSpread({
|
94 | background: input.checkbox.disabled.background
|
95 | }, input.checkbox.disabled.border),
|
96 | checkbox_invalid: _objectSpread({
|
97 | background: input.checkbox.invalid.background
|
98 | }, input.checkbox.invalid.border),
|
99 | checkbox__input: {
|
100 | width: '100%',
|
101 | height: '100%',
|
102 | margin: 0,
|
103 | padding: 0,
|
104 | opacity: 0,
|
105 | position: 'absolute',
|
106 | top: 0,
|
107 | right: 0,
|
108 | bottom: 0,
|
109 | left: 0,
|
110 | ':focus + [data-fake-checkbox]': {
|
111 | zIndex: 1,
|
112 | borderWidth: 1,
|
113 | borderStyle: 'solid',
|
114 | borderColor: color.secondary,
|
115 | boxSizing: 'border-box'
|
116 | }
|
117 | },
|
118 | checkbox__markContainer: {
|
119 | display: 'flex',
|
120 | position: 'absolute',
|
121 | width: '100%',
|
122 | height: '100%',
|
123 | top: 0,
|
124 | right: 0,
|
125 | bottom: 0,
|
126 | left: 0,
|
127 | alignItems: 'center',
|
128 | justifyContent: 'center',
|
129 | borderRadius: input.checkbox.borderRadius
|
130 | },
|
131 | checkbox__checkMark: {
|
132 | background: color.secondary,
|
133 | width: '100%',
|
134 | height: '100%',
|
135 | display: 'flex',
|
136 | alignItems: 'center',
|
137 | justifyContent: 'center'
|
138 | },
|
139 | checkbox__checkMark__icon: {
|
140 | fill: color.white,
|
141 | width: '60%'
|
142 | }
|
143 | };
|
144 | })(CheckboxOnly);
|
145 | var _default = CheckboxOnlyWithStyles;
|
146 | exports.default = _default; |
\ | No newline at end of file |