@quintoandar-tokko/radio 1.2.317

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +157 -0
  2. package/package.json +20 -0
package/lib/index.js ADDED
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Radio = void 0;
7
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _box = require("@quintoandar-tokko/box");
10
+ var _icons = require("@quintoandar-tokko/icons");
11
+ var _excluded = ["borderColor", "backgroundColor", "tick", "tickColor", "isMedium"],
12
+ _excluded2 = ["isMedium"],
13
+ _excluded3 = ["isMedium"],
14
+ _excluded4 = ["isMedium"],
15
+ _excluded5 = ["isMedium"],
16
+ _excluded6 = ["isMedium", "sx", "variant"];
17
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
18
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
19
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
20
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
21
+ var RadioBox = function RadioBox(_ref) {
22
+ var borderColor = _ref.borderColor,
23
+ backgroundColor = _ref.backgroundColor,
24
+ tick = _ref.tick,
25
+ tickColor = _ref.tickColor,
26
+ isMedium = _ref.isMedium,
27
+ props = _objectWithoutProperties(_ref, _excluded);
28
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_icons.Svg, _extends({
29
+ width: isMedium ? 20 : 16,
30
+ height: isMedium ? 20 : 16,
31
+ viewBox: isMedium ? '0 0 20 20' : '0 0 16 16',
32
+ fill: "none"
33
+ }, props), /*#__PURE__*/_react["default"].createElement("circle", {
34
+ cx: isMedium ? 10 : 8,
35
+ cy: isMedium ? 10 : 8,
36
+ r: isMedium ? 10 : 8,
37
+ fill: backgroundColor
38
+ }), /*#__PURE__*/_react["default"].createElement("circle", {
39
+ cx: isMedium ? 10 : 8,
40
+ cy: isMedium ? 10 : 8,
41
+ r: isMedium ? 9.5 : 7.5,
42
+ stroke: borderColor
43
+ }), tick && /*#__PURE__*/_react["default"].createElement("circle", {
44
+ cx: isMedium ? 10 : 8,
45
+ cy: isMedium ? 10 : 8,
46
+ r: isMedium ? 5 : 4,
47
+ fill: tickColor
48
+ })));
49
+ };
50
+ var RadioChecked = function RadioChecked(_ref2) {
51
+ var isMedium = _ref2.isMedium,
52
+ props = _objectWithoutProperties(_ref2, _excluded2);
53
+ return /*#__PURE__*/_react["default"].createElement(RadioBox, _extends({
54
+ borderColor: "#6A88F2",
55
+ backgroundColor: "#6A88F2",
56
+ tick: true,
57
+ tickColor: "white",
58
+ isMedium: isMedium
59
+ }, props));
60
+ };
61
+ var _StyledRadioChecked = (0, _styledComponents["default"])(RadioChecked)({
62
+ display: 'none',
63
+ 'input:checked:not(:disabled) ~ &': {
64
+ display: 'block'
65
+ }
66
+ });
67
+ var RadioUnchecked = function RadioUnchecked(_ref3) {
68
+ var isMedium = _ref3.isMedium,
69
+ props = _objectWithoutProperties(_ref3, _excluded3);
70
+ return /*#__PURE__*/_react["default"].createElement(RadioBox, _extends({
71
+ borderColor: "#D4DBDE",
72
+ backgroundColor: "white",
73
+ tick: true,
74
+ tickColor: "white",
75
+ isMedium: isMedium
76
+ }, props));
77
+ };
78
+ var _StyledRadioUnchecked = (0, _styledComponents["default"])(RadioUnchecked)({
79
+ display: 'none',
80
+ 'input:not(:checked):not(:disabled) ~ &': {
81
+ display: 'block'
82
+ }
83
+ });
84
+ var RadioDisabled = function RadioDisabled(_ref4) {
85
+ var isMedium = _ref4.isMedium,
86
+ props = _objectWithoutProperties(_ref4, _excluded4);
87
+ return /*#__PURE__*/_react["default"].createElement(RadioBox, _extends({
88
+ borderColor: "white",
89
+ backgroundColor: "white",
90
+ tick: true,
91
+ tickColor: "#C1CCD0",
92
+ isMedium: isMedium
93
+ }, props));
94
+ };
95
+ var _StyledRadioDisabled = (0, _styledComponents["default"])(RadioDisabled).withConfig({
96
+ componentId: "sc-1gnsfn2-0"
97
+ })({
98
+ display: 'none',
99
+ 'input:disabled:not(:checked) ~ &': {
100
+ display: 'block'
101
+ }
102
+ });
103
+ var RadioIcon = function RadioIcon(_ref5) {
104
+ var isMedium = _ref5.isMedium,
105
+ props = _objectWithoutProperties(_ref5, _excluded5);
106
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_StyledRadioChecked, _extends({
107
+ isMedium: isMedium
108
+ }, props)), /*#__PURE__*/_react["default"].createElement(_StyledRadioUnchecked, _extends({
109
+ isMedium: isMedium
110
+ }, props)), /*#__PURE__*/_react["default"].createElement(_StyledRadioDisabled, _extends({
111
+ isMedium: isMedium
112
+ }, props)));
113
+ };
114
+ var Radio = exports.Radio = function Radio(_ref6) {
115
+ var _ref6$isMedium = _ref6.isMedium,
116
+ isMedium = _ref6$isMedium === void 0 ? false : _ref6$isMedium,
117
+ sx = _ref6.sx,
118
+ _ref6$variant = _ref6.variant,
119
+ variant = _ref6$variant === void 0 ? 'radio' : _ref6$variant,
120
+ props = _objectWithoutProperties(_ref6, _excluded6);
121
+ return /*#__PURE__*/_react["default"].createElement(_box.Box, {
122
+ sx: {
123
+ position: 'relative',
124
+ width: 18,
125
+ height: 18
126
+ }
127
+ }, /*#__PURE__*/_react["default"].createElement(_box.Box, _extends({
128
+ as: "input",
129
+ type: "radio"
130
+ }, props, {
131
+ sx: {
132
+ position: 'absolute',
133
+ opacity: 0,
134
+ overflow: 'hidden',
135
+ width: '100%',
136
+ height: '100%'
137
+ }
138
+ })), /*#__PURE__*/_react["default"].createElement(_box.Box, {
139
+ as: RadioIcon,
140
+ "aria-hidden": "true",
141
+ tx: "forms",
142
+ variant: variant,
143
+ isMedium: isMedium,
144
+ sx: sx,
145
+ __css: {
146
+ mr: 2,
147
+ borderRadius: 'circle',
148
+ color: 'gray',
149
+ 'input:checked ~ &': {
150
+ color: 'primary'
151
+ },
152
+ 'input:focus ~ &': {
153
+ boxShadow: 'active'
154
+ }
155
+ }
156
+ }));
157
+ };
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@quintoandar-tokko/radio",
3
+ "version": "1.2.317",
4
+ "main": "lib/index.js",
5
+ "module": "src/index.js",
6
+ "files": [
7
+ "lib"
8
+ ],
9
+ "dependencies": {
10
+ "@quintoandar-tokko/box": "^1.2.286",
11
+ "@quintoandar-tokko/icons": "^1.2.317"
12
+ },
13
+ "peerDependencies": {
14
+ "react": "^16.8.0"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "gitHead": "3c5995a3482c9cd1b428a69e135c934c37bce2ae"
20
+ }