@semcore/radio 5.4.14 → 5.5.1
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.
- package/CHANGELOG.md +8 -6
- package/lib/cjs/Radio.js +52 -46
- package/lib/cjs/Radio.js.map +1 -1
- package/lib/cjs/index.d.js.map +1 -1
- package/lib/es6/Radio.js +52 -45
- package/lib/es6/Radio.js.map +1 -1
- package/lib/es6/index.d.js.map +1 -1
- package/lib/types/index.d.ts +5 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,21 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
-
## [5.
|
|
5
|
+
## [5.5.1] - 2023-05-04
|
|
6
6
|
|
|
7
7
|
### Changed
|
|
8
8
|
|
|
9
|
-
- Version patch update due to children dependencies update (`@semcore/utils` [3.50.
|
|
9
|
+
- Version patch update due to children dependencies update (`@semcore/utils` [3.50.5 ~> 3.50.6], `@semcore/flex-box` [4.7.21 ~> 4.7.22]).
|
|
10
|
+
|
|
11
|
+
## [5.5.0] - 2023-05-04
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
### Added
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
- Added the ability to set tag for `RadioGroup`.
|
|
14
16
|
|
|
15
|
-
## [5.4.
|
|
17
|
+
## [5.4.14] - 2023-05-03
|
|
16
18
|
|
|
17
19
|
### Changed
|
|
18
20
|
|
|
19
|
-
- Version patch update due to children dependencies update (`@semcore/utils` [3.50.
|
|
21
|
+
- Version patch update due to children dependencies update (`@semcore/utils` [3.50.4 ~> 3.50.5], `@semcore/flex-box` [4.7.20 ~> 4.7.21]).
|
|
20
22
|
|
|
21
23
|
## [5.4.10] - 2023-03-28
|
|
22
24
|
|
package/lib/cjs/Radio.js
CHANGED
|
@@ -23,24 +23,24 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
23
23
|
var _core = _interopRequireWildcard(require("@semcore/core"));
|
|
24
24
|
var _react = _interopRequireDefault(require("react"));
|
|
25
25
|
var _flexBox = require("@semcore/flex-box");
|
|
26
|
-
var
|
|
26
|
+
var _assignProps6 = _interopRequireDefault(require("@semcore/utils/lib/assignProps"));
|
|
27
27
|
var _keyboardFocusEnhance = _interopRequireDefault(require("@semcore/utils/lib/enhances/keyboardFocusEnhance"));
|
|
28
28
|
var _color = _interopRequireDefault(require("@semcore/utils/lib/color"));
|
|
29
29
|
var _inputProps = _interopRequireWildcard(require("@semcore/utils/lib/inputProps"));
|
|
30
30
|
/*__reshadow-styles__:"./style/radio.shadow.css"*/
|
|
31
|
-
var style = ( /*__reshadow_css_start__*/_core.sstyled.insert( /*__inner_css_start__*/".
|
|
32
|
-
"__SRadio": "
|
|
33
|
-
"_disabled": "
|
|
34
|
-
"__SText": "
|
|
35
|
-
"_size_m": "
|
|
36
|
-
"_size_l": "
|
|
37
|
-
"__SValue": "
|
|
38
|
-
"_state_normal": "
|
|
39
|
-
"_state_invalid": "
|
|
40
|
-
"__SControl": "
|
|
41
|
-
"_keyboardFocused": "
|
|
42
|
-
"_theme": "
|
|
43
|
-
"--theme": "--
|
|
31
|
+
var style = ( /*__reshadow_css_start__*/_core.sstyled.insert( /*__inner_css_start__*/".___SRadio_1yvcn_gg_{display:inline-flex;align-items:flex-start;cursor:pointer}.___SRadio_1yvcn_gg_.__disabled_1yvcn_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.___SText_1yvcn_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);color:var(--intergalactic-text-primary, #191b23)}.___SText_1yvcn_gg_._size_m_1yvcn_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___SText_1yvcn_gg_._size_l_1yvcn_gg_{font-size:var(--intergalactic-fs-300, 16px);line-height:var(--intergalactic-lh-300, 150%)}.___SValue_1yvcn_gg_{position:relative;flex-shrink:0;padding:0;outline:0;z-index:0;margin-top:var(--intergalactic-spacing-05x, 2px)}.___SValue_1yvcn_gg_::after,.___SValue_1yvcn_gg_::before{content:\"\";position:absolute;right:0;bottom:0;border-radius:50%;background:var(--intergalactic-bg-primary-neutral, #ffffff)}.___SValue_1yvcn_gg_::before{top:0;left:0;border:1px solid;transition:calc(var(--intergalactic-duration-control, 200)*1ms) all ease-in-out}.___SValue_1yvcn_gg_::after{top:50%;left:50%;transform:translate(-50%,-50%);width:0;height:0}.___SValue_1yvcn_gg_._size_m_1yvcn_gg_{width:16px;height:16px}.___SValue_1yvcn_gg_._size_l_1yvcn_gg_{width:20px;height:20px}.___SValue_1yvcn_gg_._state_normal_1yvcn_gg_::before{border-color:var(--intergalactic-border-primary, #c4c7cf)}.___SValue_1yvcn_gg_._state_invalid_1yvcn_gg_::before{border-color:var(--intergalactic-border-critical-active, #d1002f)}.___SControl_1yvcn_gg_{position:absolute;clip:rect(1px,1px,1px,1px)}.___SControl_1yvcn_gg_:checked~.___SValue_1yvcn_gg_::before{border-color:var(--intergalactic-control-primary-info, #008ff8);background-color:var(--intergalactic-bg-primary-info, #008ff8)}.___SControl_1yvcn_gg_:checked~.___SValue_1yvcn_gg_._size_m_1yvcn_gg_::after{width:6px;height:6px}.___SControl_1yvcn_gg_:checked~.___SValue_1yvcn_gg_._size_l_1yvcn_gg_::after{width:8px;height:8px}.___SValue_1yvcn_gg_._state_normal_1yvcn_gg_.__keyboardFocused_1yvcn_gg_::before{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.3));border-color:var(--intergalactic-border-info-active, #006dca)}.___SValue_1yvcn_gg_._state_invalid_1yvcn_gg_.__keyboardFocused_1yvcn_gg_::before{box-shadow:var(--intergalactic-keyboard-focus-invalid, 0px 0px 0px 3px rgba(255, 73, 83, 0.3))}.___SControl_1yvcn_gg_:checked~.___SValue_1yvcn_gg_.__theme_1yvcn_gg_::before{border-color:var(--theme_1yvcn);background-color:var(--theme_1yvcn)}.___SValue_1yvcn_gg_._state_normal_1yvcn_gg_.__theme_1yvcn_gg_::before{border-color:var(--theme_1yvcn)}" /*__inner_css_end__*/, "1yvcn_gg_") /*__reshadow_css_end__*/, {
|
|
32
|
+
"__SRadio": "___SRadio_1yvcn_gg_",
|
|
33
|
+
"_disabled": "__disabled_1yvcn_gg_",
|
|
34
|
+
"__SText": "___SText_1yvcn_gg_",
|
|
35
|
+
"_size_m": "_size_m_1yvcn_gg_",
|
|
36
|
+
"_size_l": "_size_l_1yvcn_gg_",
|
|
37
|
+
"__SValue": "___SValue_1yvcn_gg_",
|
|
38
|
+
"_state_normal": "_state_normal_1yvcn_gg_",
|
|
39
|
+
"_state_invalid": "_state_invalid_1yvcn_gg_",
|
|
40
|
+
"__SControl": "___SControl_1yvcn_gg_",
|
|
41
|
+
"_keyboardFocused": "__keyboardFocused_1yvcn_gg_",
|
|
42
|
+
"_theme": "__theme_1yvcn_gg_",
|
|
43
|
+
"--theme": "--theme_1yvcn"
|
|
44
44
|
});
|
|
45
45
|
var RadioGroupRoot = /*#__PURE__*/function (_Component) {
|
|
46
46
|
(0, _inherits2["default"])(RadioGroupRoot, _Component);
|
|
@@ -76,7 +76,13 @@ var RadioGroupRoot = /*#__PURE__*/function (_Component) {
|
|
|
76
76
|
}, {
|
|
77
77
|
key: "render",
|
|
78
78
|
value: function render() {
|
|
79
|
-
var
|
|
79
|
+
var _ref = this.asProps;
|
|
80
|
+
var _this$asProps2 = this.asProps,
|
|
81
|
+
Children = _this$asProps2.Children,
|
|
82
|
+
Tag = _this$asProps2.tag;
|
|
83
|
+
if (Tag) return /*#__PURE__*/_react["default"].createElement(Tag, (0, _core.assignProps)({
|
|
84
|
+
"role": 'radiogroup'
|
|
85
|
+
}, _ref), /*#__PURE__*/_react["default"].createElement(Children, null));
|
|
80
86
|
return /*#__PURE__*/_react["default"].createElement(Children, null);
|
|
81
87
|
}
|
|
82
88
|
}]);
|
|
@@ -111,13 +117,13 @@ var Radio = /*#__PURE__*/function (_Component2) {
|
|
|
111
117
|
key: "getValueProps",
|
|
112
118
|
value: function getValueProps(props) {
|
|
113
119
|
// The default values are here, since you cannot rewrite out of context
|
|
114
|
-
var
|
|
115
|
-
|
|
116
|
-
state =
|
|
117
|
-
|
|
118
|
-
size =
|
|
119
|
-
theme =
|
|
120
|
-
name =
|
|
120
|
+
var _assignProps4 = (0, _assignProps6["default"])(this.props, this.context),
|
|
121
|
+
_assignProps4$state = _assignProps4.state,
|
|
122
|
+
state = _assignProps4$state === void 0 ? 'normal' : _assignProps4$state,
|
|
123
|
+
_assignProps4$size = _assignProps4.size,
|
|
124
|
+
size = _assignProps4$size === void 0 ? 'm' : _assignProps4$size,
|
|
125
|
+
theme = _assignProps4.theme,
|
|
126
|
+
name = _assignProps4.name;
|
|
121
127
|
var value = this.context.value;
|
|
122
128
|
var other = {};
|
|
123
129
|
// if used with the context
|
|
@@ -136,9 +142,9 @@ var Radio = /*#__PURE__*/function (_Component2) {
|
|
|
136
142
|
key: "getTextProps",
|
|
137
143
|
value: function getTextProps() {
|
|
138
144
|
// The default values are here, since you cannot rewrite out of context
|
|
139
|
-
var
|
|
140
|
-
|
|
141
|
-
size =
|
|
145
|
+
var _assignProps5 = (0, _assignProps6["default"])(this.props, this.context),
|
|
146
|
+
_assignProps5$size = _assignProps5.size,
|
|
147
|
+
size = _assignProps5$size === void 0 ? 'm' : _assignProps5$size;
|
|
142
148
|
return {
|
|
143
149
|
size: size
|
|
144
150
|
};
|
|
@@ -146,15 +152,15 @@ var Radio = /*#__PURE__*/function (_Component2) {
|
|
|
146
152
|
}, {
|
|
147
153
|
key: "render",
|
|
148
154
|
value: function render() {
|
|
149
|
-
var
|
|
150
|
-
|
|
155
|
+
var _ref2 = this.asProps,
|
|
156
|
+
_ref4;
|
|
151
157
|
var SRadio = _flexBox.Box;
|
|
152
|
-
var _this$
|
|
153
|
-
styles = _this$
|
|
154
|
-
Children = _this$
|
|
155
|
-
return
|
|
156
|
-
"tag":
|
|
157
|
-
},
|
|
158
|
+
var _this$asProps3 = this.asProps,
|
|
159
|
+
styles = _this$asProps3.styles,
|
|
160
|
+
Children = _this$asProps3.Children;
|
|
161
|
+
return _ref4 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SRadio, _ref4.cn("SRadio", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
162
|
+
"tag": 'label'
|
|
163
|
+
}, _ref2))), /*#__PURE__*/_react["default"].createElement(Children, _ref4.cn("Children", {})));
|
|
158
164
|
}
|
|
159
165
|
}]);
|
|
160
166
|
return Radio;
|
|
@@ -181,22 +187,22 @@ var Value = /*#__PURE__*/function (_Component3) {
|
|
|
181
187
|
}, {
|
|
182
188
|
key: "render",
|
|
183
189
|
value: function render() {
|
|
184
|
-
var
|
|
190
|
+
var _ref5;
|
|
185
191
|
var SValue = _flexBox.Box;
|
|
186
192
|
var SControl = _flexBox.Box;
|
|
187
|
-
var _this$
|
|
188
|
-
forwardRef = _this$
|
|
189
|
-
styles = _this$
|
|
190
|
-
includeInputProps = _this$
|
|
191
|
-
theme = _this$
|
|
193
|
+
var _this$asProps4 = this.asProps,
|
|
194
|
+
forwardRef = _this$asProps4.forwardRef,
|
|
195
|
+
styles = _this$asProps4.styles,
|
|
196
|
+
includeInputProps = _this$asProps4.includeInputProps,
|
|
197
|
+
theme = _this$asProps4.theme;
|
|
192
198
|
var _getInputProps = (0, _inputProps["default"])(this.asProps, includeInputProps),
|
|
193
199
|
_getInputProps2 = (0, _slicedToArray2["default"])(_getInputProps, 2),
|
|
194
200
|
controlProps = _getInputProps2[0],
|
|
195
201
|
boxProps = _getInputProps2[1];
|
|
196
|
-
return
|
|
197
|
-
"tag":
|
|
198
|
-
"type":
|
|
199
|
-
}, controlProps))), /*#__PURE__*/_react["default"].createElement(SValue,
|
|
202
|
+
return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(SControl, _ref5.cn("SControl", (0, _objectSpread2["default"])({
|
|
203
|
+
"tag": 'input',
|
|
204
|
+
"type": 'radio'
|
|
205
|
+
}, controlProps))), /*#__PURE__*/_react["default"].createElement(SValue, _ref5.cn("SValue", (0, _objectSpread2["default"])({
|
|
200
206
|
"ref": forwardRef,
|
|
201
207
|
"use:theme": (0, _color["default"])(theme)
|
|
202
208
|
}, boxProps))));
|
|
@@ -211,11 +217,11 @@ var Value = /*#__PURE__*/function (_Component3) {
|
|
|
211
217
|
(0, _defineProperty2["default"])(Value, "enhance", [(0, _keyboardFocusEnhance["default"])()]);
|
|
212
218
|
(0, _defineProperty2["default"])(Value, "hoistProps", ['disabled']);
|
|
213
219
|
function Text(props) {
|
|
214
|
-
var
|
|
215
|
-
|
|
220
|
+
var _ref3 = arguments[0],
|
|
221
|
+
_ref6;
|
|
216
222
|
var SText = _flexBox.Box;
|
|
217
223
|
var styles = props.styles;
|
|
218
|
-
return
|
|
224
|
+
return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SText, _ref6.cn("SText", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({}, _ref3))));
|
|
219
225
|
}
|
|
220
226
|
var _default = (0, _core["default"])(Radio, {
|
|
221
227
|
Value: Value,
|
package/lib/cjs/Radio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","names":["_core","_interopRequireWildcard","require","_react","_interopRequireDefault","_flexBox","_assignProps5","_keyboardFocusEnhance","_color","_inputProps","style","sstyled","insert","RadioGroupRoot","_Component","_inherits2","_super","_createSuper2","_classCallCheck2","apply","arguments","_createClass2","key","value","uncontrolledProps","setContext","_this$asProps","asProps","theme","size","name","onChange","render","Children","createElement","Component","_defineProperty2","state","defaultValue","RadioGroup","createComponent","exports","Radio","_Component2","_super2","_this","_len","length","args","Array","_key","call","concat","_assertThisInitialized2","checked","e","context","getValueProps","props","_assignProps3","assignProps","_assignProps3$state","_assignProps3$size","other","undefined","bindHandlerChange","_objectSpread2","getTextProps","_assignProps4","_assignProps4$size","_ref","_ref3","SRadio","Box","_this$asProps2","styles","cn","CONTEXT_COMPONENT","Value","_Component3","_super3","target","_ref4","SValue","SControl","_this$asProps3","forwardRef","includeInputProps","_getInputProps","getInputProps","_getInputProps2","_slicedToArray2","controlProps","boxProps","Fragment","resolveColor","inputProps","defaultChecked","keyboardFocusEnhance","Text","_ref2","arguments[0]","_ref5","SText","_default"],"sources":["../../src/Radio.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, CONTEXT_COMPONENT, sstyled, Root } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport assignProps from '@semcore/utils/lib/assignProps';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport resolveColor from '@semcore/utils/lib/color';\nimport getInputProps, { inputProps } from '@semcore/utils/lib/inputProps';\n\nimport style from './style/radio.shadow.css';\n\nclass RadioGroupRoot extends Component {\n static displayName = 'RadioGroup';\n\n static defaultProps = {\n state: 'normal',\n size: 'm',\n defaultValue: null,\n };\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n setContext() {\n const { theme, size, name, value, onChange } = this.asProps;\n return {\n onChange,\n value,\n theme,\n size,\n name,\n };\n }\n\n render() {\n const { Children } = this.asProps;\n return <Children />;\n }\n}\n\nconst RadioGroup = createComponent(RadioGroupRoot);\n\nclass Radio extends Component {\n static displayName = 'Radio';\n static style = style;\n static contextType = RadioGroup[CONTEXT_COMPONENT];\n\n bindHandlerChange = (value) => (checked, e) => {\n this.context.onChange(value, e);\n };\n\n getValueProps(props) {\n // The default values are here, since you cannot rewrite out of context\n const { state = 'normal', size = 'm', theme, name } = assignProps(this.props, this.context);\n const { value } = this.context;\n const other = {};\n // if used with the context\n if (value !== undefined) {\n other['checked'] = value === props.value;\n other['onChange'] = this.bindHandlerChange(props.value);\n }\n return {\n ...other,\n state,\n size,\n theme,\n name,\n };\n }\n\n getTextProps() {\n // The default values are here, since you cannot rewrite out of context\n const { size = 'm' } = assignProps(this.props, this.context);\n return {\n size: size,\n };\n }\n\n render() {\n const SRadio = Root;\n const { styles, Children } = this.asProps;\n\n return sstyled(styles)(\n <SRadio render={Box} tag=\"label\">\n <Children />\n </SRadio>,\n );\n }\n}\n\nclass Value extends Component {\n static defaultProps = {\n includeInputProps: inputProps,\n defaultChecked: false,\n };\n static enhance = [keyboardFocusEnhance()];\n static hoistProps = ['disabled'];\n\n uncontrolledProps() {\n return {\n checked: (e) => e.target.checked,\n };\n }\n\n render() {\n const SValue = Box;\n const SControl = Box;\n const { forwardRef, styles, includeInputProps, theme } = this.asProps;\n\n const [controlProps, boxProps] = getInputProps(this.asProps, includeInputProps);\n\n return sstyled(styles)(\n <>\n <SControl tag=\"input\" type=\"radio\" {...controlProps} />\n <SValue ref={forwardRef} use:theme={resolveColor(theme)} {...boxProps} />\n </>,\n );\n }\n}\n\nfunction Text(props) {\n const SText = Root;\n const { styles } = props;\n return sstyled(styles)(<SText render={Box} />);\n}\n\nexport { inputProps, RadioGroup };\nexport default createComponent(Radio, {\n Value,\n Text,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AADA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,qBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,MAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,WAAA,GAAAR,uBAAA,CAAAC,OAAA;AAA0E;AAAA,IAAAQ,KAAA,+BAAAV,KAAA,CAAAW,OAAA,CAAAC,MAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;E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,WAAA,MAAAwC,KAAA,IAAgB;AAC/C;AAAC,IAAAI,QAAA,GAGc,IAAAhE,gBAAe,EAACE,KAAK,EAAE;EACpCoC,KAAK,EAALA,KAAK;EACLqB,IAAI,EAAJA;AACF,CAAC,CAAC;AAAA1D,OAAA,cAAA+D,QAAA"}
|
|
1
|
+
{"version":3,"file":"Radio.js","names":["_core","_interopRequireWildcard","require","_react","_interopRequireDefault","_flexBox","_assignProps6","_keyboardFocusEnhance","_color","_inputProps","style","sstyled","insert","RadioGroupRoot","_Component","_inherits2","_super","_createSuper2","_classCallCheck2","apply","arguments","_createClass2","key","value","uncontrolledProps","setContext","_this$asProps","asProps","theme","size","name","onChange","render","_ref","_this$asProps2","Children","Tag","tag","createElement","assignProps","Component","_defineProperty2","state","defaultValue","RadioGroup","createComponent","exports","Radio","_Component2","_super2","_this","_len","length","args","Array","_key","call","concat","_assertThisInitialized2","checked","e","context","getValueProps","props","_assignProps4","_assignProps4$state","_assignProps4$size","other","undefined","bindHandlerChange","_objectSpread2","getTextProps","_assignProps5","_assignProps5$size","_ref2","_ref4","SRadio","Box","_this$asProps3","styles","cn","CONTEXT_COMPONENT","Value","_Component3","_super3","target","_ref5","SValue","SControl","_this$asProps4","forwardRef","includeInputProps","_getInputProps","getInputProps","_getInputProps2","_slicedToArray2","controlProps","boxProps","Fragment","resolveColor","inputProps","defaultChecked","keyboardFocusEnhance","Text","_ref3","arguments[0]","_ref6","SText","_default"],"sources":["../../src/Radio.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, CONTEXT_COMPONENT, sstyled, Root } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport assignProps from '@semcore/utils/lib/assignProps';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport resolveColor from '@semcore/utils/lib/color';\nimport getInputProps, { inputProps } from '@semcore/utils/lib/inputProps';\n\nimport style from './style/radio.shadow.css';\n\nclass RadioGroupRoot extends Component {\n static displayName = 'RadioGroup';\n\n static defaultProps = {\n state: 'normal',\n size: 'm',\n defaultValue: null,\n };\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n setContext() {\n const { theme, size, name, value, onChange } = this.asProps;\n return {\n onChange,\n value,\n theme,\n size,\n name,\n };\n }\n\n render() {\n const { Children, tag: Tag } = this.asProps;\n\n if (Tag)\n return (\n <Root render={Tag} role='radiogroup'>\n <Children />\n </Root>\n );\n\n return <Children />;\n }\n}\n\nconst RadioGroup = createComponent(RadioGroupRoot);\n\nclass Radio extends Component {\n static displayName = 'Radio';\n static style = style;\n static contextType = RadioGroup[CONTEXT_COMPONENT];\n\n bindHandlerChange = (value) => (checked, e) => {\n this.context.onChange(value, e);\n };\n\n getValueProps(props) {\n // The default values are here, since you cannot rewrite out of context\n const { state = 'normal', size = 'm', theme, name } = assignProps(this.props, this.context);\n const { value } = this.context;\n const other = {};\n // if used with the context\n if (value !== undefined) {\n other['checked'] = value === props.value;\n other['onChange'] = this.bindHandlerChange(props.value);\n }\n return {\n ...other,\n state,\n size,\n theme,\n name,\n };\n }\n\n getTextProps() {\n // The default values are here, since you cannot rewrite out of context\n const { size = 'm' } = assignProps(this.props, this.context);\n return {\n size: size,\n };\n }\n\n render() {\n const SRadio = Root;\n const { styles, Children } = this.asProps;\n\n return sstyled(styles)(\n <SRadio render={Box} tag='label'>\n <Children />\n </SRadio>,\n );\n }\n}\n\nclass Value extends Component {\n static defaultProps = {\n includeInputProps: inputProps,\n defaultChecked: false,\n };\n static enhance = [keyboardFocusEnhance()];\n static hoistProps = ['disabled'];\n\n uncontrolledProps() {\n return {\n checked: (e) => e.target.checked,\n };\n }\n\n render() {\n const SValue = Box;\n const SControl = Box;\n const { forwardRef, styles, includeInputProps, theme } = this.asProps;\n\n const [controlProps, boxProps] = getInputProps(this.asProps, includeInputProps);\n\n return sstyled(styles)(\n <>\n <SControl tag='input' type='radio' {...controlProps} />\n <SValue ref={forwardRef} use:theme={resolveColor(theme)} {...boxProps} />\n </>,\n );\n }\n}\n\nfunction Text(props) {\n const SText = Root;\n const { styles } = props;\n return sstyled(styles)(<SText render={Box} />);\n}\n\nexport { inputProps, RadioGroup };\nexport default createComponent(Radio, {\n Value,\n Text,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AADA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,qBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,MAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,WAAA,GAAAR,uBAAA,CAAAC,OAAA;AAA0E;AAAA,IAAAQ,KAAA,+BAAAV,KAAA,CAAAW,OAAA,CAAAC,MAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAAA,IAIpEC,cAAc,0BAAAC,UAAA;EAAA,IAAAC,UAAA,aAAAF,cAAA,EAAAC,UAAA;EAAA,IAAAE,MAAA,OAAAC,aAAA,aAAAJ,cAAA;EAAA,SAAAA,eAAA;IAAA,IAAAK,gBAAA,mBAAAL,cAAA;IAAA,OAAAG,MAAA,CAAAG,KAAA,OAAAC,SAAA;EAAA;EAAA,IAAAC,aAAA,aAAAR,cAAA;IAAAS,GAAA;IAAAC,KAAA,EASlB,SAAAC,kBAAA,EAAoB;MAClB,OAAO;QACLD,KAAK,EAAE;MACT,CAAC;IACH;EAAC;IAAAD,GAAA;IAAAC,KAAA,EAED,SAAAE,WAAA,EAAa;MACX,IAAAC,aAAA,GAA+C,IAAI,CAACC,OAAO;QAAnDC,KAAK,GAAAF,aAAA,CAALE,KAAK;QAAEC,IAAI,GAAAH,aAAA,CAAJG,IAAI;QAAEC,IAAI,GAAAJ,aAAA,CAAJI,IAAI;QAAEP,KAAK,GAAAG,a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AN,EAAA,iBAAAV,cAAA;QAAA,OAAK,OAAO;QAAA,QAAM;MAAO,GAAK0B,YAAY,GAAI,eACvD7F,MAAA,YAAAmC,aAAA,CAACiD,MAAM,EAAAD,KAAA,CAAAN,EAAA,eAAAV,cAAA;QAAA,OAAMoB,UAAU;QAAA,aAAa,IAAAS,iBAAY,EAACvE,KAAK;MAAC,GAAMqE,QAAQ,GAAI,CACxE;IAEP;EAAC;EAAA,OAAAf,KAAA;AAAA,EA3BiB1C,eAAS;AAAA,IAAAC,gBAAA,aAAvByC,KAAK,kBACa;EACpBS,iBAAiB,EAAES,sBAAU;EAC7BC,cAAc,EAAE;AAClB,CAAC;AAAA,IAAA5D,gBAAA,aAJGyC,KAAK,aAKQ,CAAC,IAAAoB,gCAAoB,GAAE,CAAC;AAAA,IAAA7D,gBAAA,aALrCyC,KAAK,gBAMW,CAAC,UAAU,CAAC;AAwBlC,SAASqB,IAAIA,CAACxC,KAAK,EAAE;EAAA,IAAAyC,KAAA,GAAAC,YAAA;IAAAC,KAAA;EACnB,IAAMC,KAAK,GAE2B9B,YAAG;EADzC,IAAQE,MAAM,GAAKhB,KAAK,CAAhBgB,MAAM;EACd,OAAA2B,KAAA,GAAO,IAAA/F,aAAO,EAACoE,MAAM,CAAC,eAAC5E,MAAA,YAAAmC,aAAA,CAACqE,KAAK,EAAAD,KAAA,CAAA1B,EAAA,cAAAV,cAAA,qBAAAtE,KAAA,CAAAuC,WAAA,MAAAiE,KAAA,IAAgB;AAC/C;AAAC,IAAAI,QAAA,GAGc,IAAA/D,gBAAe,EAACE,KAAK,EAAE;EACpCmC,KAAK,EAALA,KAAK;EACLqB,IAAI,EAAJA;AACF,CAAC,CAAC;AAAAzD,OAAA,cAAA8D,QAAA"}
|
package/lib/cjs/index.d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import { CProps, PropGetterFn, ReturnEl } from '@semcore/core';\nimport { IBoxProps } from '@semcore/flex-box';\nimport { IKeyboardFocusProps } from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport { Text } from '@semcore/typography';\n\nexport type RadioSize = 'm' | 'l';\nexport type RadioState = 'normal' | 'invalid';\nexport type RadioValue = string | number | boolean;\n\nexport interface IRadioProps extends IBoxProps {\n /**\n * The value displaying the state of the component\n * @default normal\n */\n state?: RadioState;\n /**\n * Radio button size\n * @default m\n **/\n size?: RadioSize;\n /** The theme of the radio button that you can send your color to */\n theme?: string;\n}\n\nexport interface IRadioGroupProps {\n /** Radio group name */\n name?: string;\n /** Active default value */\n defaultValue?: RadioValue;\n /** Active value */\n value?: RadioValue;\n /** Called when the selected element is changed */\n onChange?: (value: RadioValue, e?: React.SyntheticEvent<HTMLInputElement>) => void;\n /** Radio button size */\n size?: RadioSize;\n /** The theme of the radio button that you can send your color to */\n theme?: string;\n /** Blocks access and changes to the form field */\n disabled?: boolean;\n}\n\nexport interface IRadioValueProps extends IBoxProps, IKeyboardFocusProps {\n /** List of elements that can be put on a hidden input */\n includeInputProps?: string[];\n /**\n * The value displaying the state of the component\n * @default normal\n */\n state?: RadioState;\n /** The theme of the radio button that you can send your color to */\n theme?: string;\n /** Radio button size */\n size?: RadioSize;\n /** The element value is required for RadioGroup */\n value?: RadioValue;\n /** Default value if `value` property is not provided */\n defaultValue?: RadioValue;\n /** Called when the value changes */\n onChange?: (value: boolean, e?: React.SyntheticEvent<HTMLInputElement>) => void;\n /** Blocks access and changes to the form field */\n disabled?: boolean;\n}\n\nexport interface IRadioCtx {\n getValueProps: PropGetterFn;\n getTextProps: PropGetterFn;\n}\n\ndeclare const RadioGroup: <T>(props: CProps<IRadioGroupProps & T>) => ReturnEl;\n\nexport { RadioGroup };\n\ndeclare const Radio: (<T>(props: CProps<IRadioProps & T, IRadioCtx>) => ReturnEl) & {\n Value: <T>(props: IRadioValueProps & T) => ReturnEl;\n Text: typeof Text;\n};\n\nexport default Radio;\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { CProps, PropGetterFn, ReturnEl } from '@semcore/core';\nimport { IBoxProps } from '@semcore/flex-box';\nimport { IKeyboardFocusProps } from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport { Text } from '@semcore/typography';\n\nexport type RadioSize = 'm' | 'l';\nexport type RadioState = 'normal' | 'invalid';\nexport type RadioValue = string | number | boolean;\n\nexport interface IRadioProps extends IBoxProps {\n /**\n * The value displaying the state of the component\n * @default normal\n */\n state?: RadioState;\n /**\n * Radio button size\n * @default m\n **/\n size?: RadioSize;\n /** The theme of the radio button that you can send your color to */\n theme?: string;\n}\n\nexport interface IRadioGroupProps {\n /**\n * HTML tag name for the displayed item\n */\n tag?: React.ElementType | string;\n /** Radio group name */\n name?: string;\n /** Active default value */\n defaultValue?: RadioValue;\n /** Active value */\n value?: RadioValue;\n /** Called when the selected element is changed */\n onChange?: (value: RadioValue, e?: React.SyntheticEvent<HTMLInputElement>) => void;\n /** Radio button size */\n size?: RadioSize;\n /** The theme of the radio button that you can send your color to */\n theme?: string;\n /** Blocks access and changes to the form field */\n disabled?: boolean;\n}\n\nexport interface IRadioValueProps extends IBoxProps, IKeyboardFocusProps {\n /** List of elements that can be put on a hidden input */\n includeInputProps?: string[];\n /**\n * The value displaying the state of the component\n * @default normal\n */\n state?: RadioState;\n /** The theme of the radio button that you can send your color to */\n theme?: string;\n /** Radio button size */\n size?: RadioSize;\n /** The element value is required for RadioGroup */\n value?: RadioValue;\n /** Default value if `value` property is not provided */\n defaultValue?: RadioValue;\n /** Called when the value changes */\n onChange?: (value: boolean, e?: React.SyntheticEvent<HTMLInputElement>) => void;\n /** Blocks access and changes to the form field */\n disabled?: boolean;\n}\n\nexport interface IRadioCtx {\n getValueProps: PropGetterFn;\n getTextProps: PropGetterFn;\n}\n\ndeclare const RadioGroup: <T>(props: CProps<IRadioGroupProps & T>) => ReturnEl;\n\nexport { RadioGroup };\n\ndeclare const Radio: (<T>(props: CProps<IRadioProps & T, IRadioCtx>) => ReturnEl) & {\n Value: <T>(props: IRadioValueProps & T) => ReturnEl;\n Text: typeof Text;\n};\n\nexport default Radio;\n"],"mappings":""}
|
package/lib/es6/Radio.js
CHANGED
|
@@ -7,6 +7,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
7
7
|
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
9
|
import { sstyled as _sstyled } from "@semcore/core";
|
|
10
|
+
import { assignProps as _assignProps3 } from "@semcore/core";
|
|
10
11
|
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
11
12
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
12
13
|
import React from 'react';
|
|
@@ -17,19 +18,19 @@ import keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhan
|
|
|
17
18
|
import resolveColor from '@semcore/utils/lib/color';
|
|
18
19
|
import getInputProps, { inputProps } from '@semcore/utils/lib/inputProps';
|
|
19
20
|
/*__reshadow-styles__:"./style/radio.shadow.css"*/
|
|
20
|
-
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".
|
|
21
|
-
"__SRadio": "
|
|
22
|
-
"_disabled": "
|
|
23
|
-
"__SText": "
|
|
24
|
-
"_size_m": "
|
|
25
|
-
"_size_l": "
|
|
26
|
-
"__SValue": "
|
|
27
|
-
"_state_normal": "
|
|
28
|
-
"_state_invalid": "
|
|
29
|
-
"__SControl": "
|
|
30
|
-
"_keyboardFocused": "
|
|
31
|
-
"_theme": "
|
|
32
|
-
"--theme": "--
|
|
21
|
+
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SRadio_1yvcn_gg_{display:inline-flex;align-items:flex-start;cursor:pointer}.___SRadio_1yvcn_gg_.__disabled_1yvcn_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.___SText_1yvcn_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);color:var(--intergalactic-text-primary, #191b23)}.___SText_1yvcn_gg_._size_m_1yvcn_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___SText_1yvcn_gg_._size_l_1yvcn_gg_{font-size:var(--intergalactic-fs-300, 16px);line-height:var(--intergalactic-lh-300, 150%)}.___SValue_1yvcn_gg_{position:relative;flex-shrink:0;padding:0;outline:0;z-index:0;margin-top:var(--intergalactic-spacing-05x, 2px)}.___SValue_1yvcn_gg_::after,.___SValue_1yvcn_gg_::before{content:\"\";position:absolute;right:0;bottom:0;border-radius:50%;background:var(--intergalactic-bg-primary-neutral, #ffffff)}.___SValue_1yvcn_gg_::before{top:0;left:0;border:1px solid;transition:calc(var(--intergalactic-duration-control, 200)*1ms) all ease-in-out}.___SValue_1yvcn_gg_::after{top:50%;left:50%;transform:translate(-50%,-50%);width:0;height:0}.___SValue_1yvcn_gg_._size_m_1yvcn_gg_{width:16px;height:16px}.___SValue_1yvcn_gg_._size_l_1yvcn_gg_{width:20px;height:20px}.___SValue_1yvcn_gg_._state_normal_1yvcn_gg_::before{border-color:var(--intergalactic-border-primary, #c4c7cf)}.___SValue_1yvcn_gg_._state_invalid_1yvcn_gg_::before{border-color:var(--intergalactic-border-critical-active, #d1002f)}.___SControl_1yvcn_gg_{position:absolute;clip:rect(1px,1px,1px,1px)}.___SControl_1yvcn_gg_:checked~.___SValue_1yvcn_gg_::before{border-color:var(--intergalactic-control-primary-info, #008ff8);background-color:var(--intergalactic-bg-primary-info, #008ff8)}.___SControl_1yvcn_gg_:checked~.___SValue_1yvcn_gg_._size_m_1yvcn_gg_::after{width:6px;height:6px}.___SControl_1yvcn_gg_:checked~.___SValue_1yvcn_gg_._size_l_1yvcn_gg_::after{width:8px;height:8px}.___SValue_1yvcn_gg_._state_normal_1yvcn_gg_.__keyboardFocused_1yvcn_gg_::before{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.3));border-color:var(--intergalactic-border-info-active, #006dca)}.___SValue_1yvcn_gg_._state_invalid_1yvcn_gg_.__keyboardFocused_1yvcn_gg_::before{box-shadow:var(--intergalactic-keyboard-focus-invalid, 0px 0px 0px 3px rgba(255, 73, 83, 0.3))}.___SControl_1yvcn_gg_:checked~.___SValue_1yvcn_gg_.__theme_1yvcn_gg_::before{border-color:var(--theme_1yvcn);background-color:var(--theme_1yvcn)}.___SValue_1yvcn_gg_._state_normal_1yvcn_gg_.__theme_1yvcn_gg_::before{border-color:var(--theme_1yvcn)}" /*__inner_css_end__*/, "1yvcn_gg_") /*__reshadow_css_end__*/, {
|
|
22
|
+
"__SRadio": "___SRadio_1yvcn_gg_",
|
|
23
|
+
"_disabled": "__disabled_1yvcn_gg_",
|
|
24
|
+
"__SText": "___SText_1yvcn_gg_",
|
|
25
|
+
"_size_m": "_size_m_1yvcn_gg_",
|
|
26
|
+
"_size_l": "_size_l_1yvcn_gg_",
|
|
27
|
+
"__SValue": "___SValue_1yvcn_gg_",
|
|
28
|
+
"_state_normal": "_state_normal_1yvcn_gg_",
|
|
29
|
+
"_state_invalid": "_state_invalid_1yvcn_gg_",
|
|
30
|
+
"__SControl": "___SControl_1yvcn_gg_",
|
|
31
|
+
"_keyboardFocused": "__keyboardFocused_1yvcn_gg_",
|
|
32
|
+
"_theme": "__theme_1yvcn_gg_",
|
|
33
|
+
"--theme": "--theme_1yvcn"
|
|
33
34
|
});
|
|
34
35
|
var RadioGroupRoot = /*#__PURE__*/function (_Component) {
|
|
35
36
|
_inherits(RadioGroupRoot, _Component);
|
|
@@ -65,7 +66,13 @@ var RadioGroupRoot = /*#__PURE__*/function (_Component) {
|
|
|
65
66
|
}, {
|
|
66
67
|
key: "render",
|
|
67
68
|
value: function render() {
|
|
68
|
-
var
|
|
69
|
+
var _ref = this.asProps;
|
|
70
|
+
var _this$asProps2 = this.asProps,
|
|
71
|
+
Children = _this$asProps2.Children,
|
|
72
|
+
Tag = _this$asProps2.tag;
|
|
73
|
+
if (Tag) return /*#__PURE__*/React.createElement(Tag, _assignProps({
|
|
74
|
+
"role": 'radiogroup'
|
|
75
|
+
}, _ref), /*#__PURE__*/React.createElement(Children, null));
|
|
69
76
|
return /*#__PURE__*/React.createElement(Children, null);
|
|
70
77
|
}
|
|
71
78
|
}]);
|
|
@@ -99,13 +106,13 @@ var Radio = /*#__PURE__*/function (_Component2) {
|
|
|
99
106
|
key: "getValueProps",
|
|
100
107
|
value: function getValueProps(props) {
|
|
101
108
|
// The default values are here, since you cannot rewrite out of context
|
|
102
|
-
var
|
|
103
|
-
|
|
104
|
-
state =
|
|
105
|
-
|
|
106
|
-
size =
|
|
107
|
-
theme =
|
|
108
|
-
name =
|
|
109
|
+
var _assignProps4 = assignProps(this.props, this.context),
|
|
110
|
+
_assignProps4$state = _assignProps4.state,
|
|
111
|
+
state = _assignProps4$state === void 0 ? 'normal' : _assignProps4$state,
|
|
112
|
+
_assignProps4$size = _assignProps4.size,
|
|
113
|
+
size = _assignProps4$size === void 0 ? 'm' : _assignProps4$size,
|
|
114
|
+
theme = _assignProps4.theme,
|
|
115
|
+
name = _assignProps4.name;
|
|
109
116
|
var value = this.context.value;
|
|
110
117
|
var other = {};
|
|
111
118
|
// if used with the context
|
|
@@ -124,9 +131,9 @@ var Radio = /*#__PURE__*/function (_Component2) {
|
|
|
124
131
|
key: "getTextProps",
|
|
125
132
|
value: function getTextProps() {
|
|
126
133
|
// The default values are here, since you cannot rewrite out of context
|
|
127
|
-
var
|
|
128
|
-
|
|
129
|
-
size =
|
|
134
|
+
var _assignProps5 = assignProps(this.props, this.context),
|
|
135
|
+
_assignProps5$size = _assignProps5.size,
|
|
136
|
+
size = _assignProps5$size === void 0 ? 'm' : _assignProps5$size;
|
|
130
137
|
return {
|
|
131
138
|
size: size
|
|
132
139
|
};
|
|
@@ -134,15 +141,15 @@ var Radio = /*#__PURE__*/function (_Component2) {
|
|
|
134
141
|
}, {
|
|
135
142
|
key: "render",
|
|
136
143
|
value: function render() {
|
|
137
|
-
var
|
|
138
|
-
|
|
144
|
+
var _ref2 = this.asProps,
|
|
145
|
+
_ref4;
|
|
139
146
|
var SRadio = Box;
|
|
140
|
-
var _this$
|
|
141
|
-
styles = _this$
|
|
142
|
-
Children = _this$
|
|
143
|
-
return
|
|
144
|
-
"tag":
|
|
145
|
-
},
|
|
147
|
+
var _this$asProps3 = this.asProps,
|
|
148
|
+
styles = _this$asProps3.styles,
|
|
149
|
+
Children = _this$asProps3.Children;
|
|
150
|
+
return _ref4 = sstyled(styles), /*#__PURE__*/React.createElement(SRadio, _ref4.cn("SRadio", _objectSpread({}, _assignProps2({
|
|
151
|
+
"tag": 'label'
|
|
152
|
+
}, _ref2))), /*#__PURE__*/React.createElement(Children, _ref4.cn("Children", {})));
|
|
146
153
|
}
|
|
147
154
|
}]);
|
|
148
155
|
return Radio;
|
|
@@ -169,22 +176,22 @@ var Value = /*#__PURE__*/function (_Component3) {
|
|
|
169
176
|
}, {
|
|
170
177
|
key: "render",
|
|
171
178
|
value: function render() {
|
|
172
|
-
var
|
|
179
|
+
var _ref5;
|
|
173
180
|
var SValue = Box;
|
|
174
181
|
var SControl = Box;
|
|
175
|
-
var _this$
|
|
176
|
-
forwardRef = _this$
|
|
177
|
-
styles = _this$
|
|
178
|
-
includeInputProps = _this$
|
|
179
|
-
theme = _this$
|
|
182
|
+
var _this$asProps4 = this.asProps,
|
|
183
|
+
forwardRef = _this$asProps4.forwardRef,
|
|
184
|
+
styles = _this$asProps4.styles,
|
|
185
|
+
includeInputProps = _this$asProps4.includeInputProps,
|
|
186
|
+
theme = _this$asProps4.theme;
|
|
180
187
|
var _getInputProps = getInputProps(this.asProps, includeInputProps),
|
|
181
188
|
_getInputProps2 = _slicedToArray(_getInputProps, 2),
|
|
182
189
|
controlProps = _getInputProps2[0],
|
|
183
190
|
boxProps = _getInputProps2[1];
|
|
184
|
-
return
|
|
185
|
-
"tag":
|
|
186
|
-
"type":
|
|
187
|
-
}, controlProps))), /*#__PURE__*/React.createElement(SValue,
|
|
191
|
+
return _ref5 = sstyled(styles), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SControl, _ref5.cn("SControl", _objectSpread({
|
|
192
|
+
"tag": 'input',
|
|
193
|
+
"type": 'radio'
|
|
194
|
+
}, controlProps))), /*#__PURE__*/React.createElement(SValue, _ref5.cn("SValue", _objectSpread({
|
|
188
195
|
"ref": forwardRef,
|
|
189
196
|
"use:theme": resolveColor(theme)
|
|
190
197
|
}, boxProps))));
|
|
@@ -199,11 +206,11 @@ _defineProperty(Value, "defaultProps", {
|
|
|
199
206
|
_defineProperty(Value, "enhance", [keyboardFocusEnhance()]);
|
|
200
207
|
_defineProperty(Value, "hoistProps", ['disabled']);
|
|
201
208
|
function Text(props) {
|
|
202
|
-
var
|
|
203
|
-
|
|
209
|
+
var _ref3 = arguments[0],
|
|
210
|
+
_ref6;
|
|
204
211
|
var SText = Box;
|
|
205
212
|
var styles = props.styles;
|
|
206
|
-
return
|
|
213
|
+
return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(SText, _ref6.cn("SText", _objectSpread({}, _assignProps3({}, _ref3))));
|
|
207
214
|
}
|
|
208
215
|
export { inputProps, RadioGroup };
|
|
209
216
|
export default createComponent(Radio, {
|
package/lib/es6/Radio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","names":["React","createComponent","Component","CONTEXT_COMPONENT","sstyled","Root","Box","assignProps","keyboardFocusEnhance","resolveColor","getInputProps","inputProps","style","_sstyled","insert","RadioGroupRoot","_Component","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","_createClass","key","value","uncontrolledProps","setContext","_this$asProps","asProps","theme","size","name","onChange","render","Children","createElement","_defineProperty","state","defaultValue","RadioGroup","Radio","_Component2","_super2","_this","_len","length","args","Array","_key","call","concat","_assertThisInitialized","checked","e","context","getValueProps","props","_assignProps3","_assignProps3$state","_assignProps3$size","other","undefined","bindHandlerChange","_objectSpread","getTextProps","_assignProps4","_assignProps4$size","_ref","_ref3","SRadio","_this$asProps2","styles","cn","_assignProps","Value","_Component3","_super3","target","_ref4","SValue","SControl","_this$asProps3","forwardRef","includeInputProps","_getInputProps","_getInputProps2","_slicedToArray","controlProps","boxProps","Fragment","defaultChecked","Text","_ref2","arguments[0]","_ref5","SText","_assignProps2"],"sources":["../../src/Radio.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, CONTEXT_COMPONENT, sstyled, Root } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport assignProps from '@semcore/utils/lib/assignProps';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport resolveColor from '@semcore/utils/lib/color';\nimport getInputProps, { inputProps } from '@semcore/utils/lib/inputProps';\n\nimport style from './style/radio.shadow.css';\n\nclass RadioGroupRoot extends Component {\n static displayName = 'RadioGroup';\n\n static defaultProps = {\n state: 'normal',\n size: 'm',\n defaultValue: null,\n };\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n setContext() {\n const { theme, size, name, value, onChange } = this.asProps;\n return {\n onChange,\n value,\n theme,\n size,\n name,\n };\n }\n\n render() {\n const { Children } = this.asProps;\n return <Children />;\n }\n}\n\nconst RadioGroup = createComponent(RadioGroupRoot);\n\nclass Radio extends Component {\n static displayName = 'Radio';\n static style = style;\n static contextType = RadioGroup[CONTEXT_COMPONENT];\n\n bindHandlerChange = (value) => (checked, e) => {\n this.context.onChange(value, e);\n };\n\n getValueProps(props) {\n // The default values are here, since you cannot rewrite out of context\n const { state = 'normal', size = 'm', theme, name } = assignProps(this.props, this.context);\n const { value } = this.context;\n const other = {};\n // if used with the context\n if (value !== undefined) {\n other['checked'] = value === props.value;\n other['onChange'] = this.bindHandlerChange(props.value);\n }\n return {\n ...other,\n state,\n size,\n theme,\n name,\n };\n }\n\n getTextProps() {\n // The default values are here, since you cannot rewrite out of context\n const { size = 'm' } = assignProps(this.props, this.context);\n return {\n size: size,\n };\n }\n\n render() {\n const SRadio = Root;\n const { styles, Children } = this.asProps;\n\n return sstyled(styles)(\n <SRadio render={Box} tag=\"label\">\n <Children />\n </SRadio>,\n );\n }\n}\n\nclass Value extends Component {\n static defaultProps = {\n includeInputProps: inputProps,\n defaultChecked: false,\n };\n static enhance = [keyboardFocusEnhance()];\n static hoistProps = ['disabled'];\n\n uncontrolledProps() {\n return {\n checked: (e) => e.target.checked,\n };\n }\n\n render() {\n const SValue = Box;\n const SControl = Box;\n const { forwardRef, styles, includeInputProps, theme } = this.asProps;\n\n const [controlProps, boxProps] = getInputProps(this.asProps, includeInputProps);\n\n return sstyled(styles)(\n <>\n <SControl tag=\"input\" type=\"radio\" {...controlProps} />\n <SValue ref={forwardRef} use:theme={resolveColor(theme)} {...boxProps} />\n </>,\n );\n }\n}\n\nfunction Text(props) {\n const SText = Root;\n const { styles } = props;\n return sstyled(styles)(<SText render={Box} />);\n}\n\nexport { inputProps, RadioGroup };\nexport default createComponent(Radio, {\n Value,\n Text,\n});\n"],"mappings":";;;;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,eAAe,IAAIC,SAAS,EAAEC,iBAAiB,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AAC5F,SAASC,GAAG,QAAQ,mBAAmB;AACvC,OAAOC,WAAW,MAAM,gCAAgC;AACxD,OAAOC,oBAAoB,MAAM,kDAAkD;AACnF,OAAOC,YAAY,MAAM,0BAA0B;AACnD,OAAOC,aAAa,IAAIC,UAAU,QAAQ,+BAA+B;AAAC;AAAA,IAAAC,KAAA,+BAAAC,QAAA,CAAAC,MAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAAA,IAIpEC,cAAc,0BAAAC,UAAA;EAAAC,SAAA,CAAAF,cAAA,EAAAC,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F,QAAA,qBACE1F,KAAA,CAAAoC,aAAA,CAAC6C,QAAQ,EAAAF,KAAA,CAAAN,EAAA,aAAAT,aAAA;QAAA,OAAK,OAAO;QAAA,QAAM;MAAO,GAAKwB,YAAY,GAAI,eACvDxF,KAAA,CAAAoC,aAAA,CAAC4C,MAAM,EAAAD,KAAA,CAAAN,EAAA,WAAAT,aAAA;QAAA,OAAMmB,UAAU;QAAA,aAAa1E,YAAY,CAACqB,KAAK;MAAC,GAAM2D,QAAQ,GAAI,CACxE;IAEP;EAAC;EAAA,OAAAd,KAAA;AAAA,EA3BiBzE,SAAS;AAAAmC,eAAA,CAAvBsC,KAAK,kBACa;EACpBS,iBAAiB,EAAEzE,UAAU;EAC7BgF,cAAc,EAAE;AAClB,CAAC;AAAAtD,eAAA,CAJGsC,KAAK,aAKQ,CAACnE,oBAAoB,EAAE,CAAC;AAAA6B,eAAA,CALrCsC,KAAK,gBAMW,CAAC,UAAU,CAAC;AAwBlC,SAASiB,IAAIA,CAACnC,KAAK,EAAE;EAAA,IAAAoC,KAAA,GAAAC,YAAA;IAAAC,KAAA;EACnB,IAAMC,KAAK,GAE2B1F,GAAG;EADzC,IAAQkE,MAAM,GAAKf,KAAK,CAAhBe,MAAM;EACd,OAAAuB,KAAA,GAAO3F,OAAO,CAACoE,MAAM,CAAC,eAACxE,KAAA,CAAAoC,aAAA,CAAC4D,KAAK,EAAAD,KAAA,CAAAtB,EAAA,UAAAT,aAAA,KAAAiC,aAAA,KAAAJ,KAAA,IAAgB;AAC/C;AAEA,SAASlF,UAAU,EAAE6B,UAAU;AAC/B,eAAevC,eAAe,CAACwC,KAAK,EAAE;EACpCkC,KAAK,EAALA,KAAK;EACLiB,IAAI,EAAJA;AACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"Radio.js","names":["React","createComponent","Component","CONTEXT_COMPONENT","sstyled","Root","Box","assignProps","keyboardFocusEnhance","resolveColor","getInputProps","inputProps","style","_sstyled","insert","RadioGroupRoot","_Component","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","_createClass","key","value","uncontrolledProps","setContext","_this$asProps","asProps","theme","size","name","onChange","render","_ref","_this$asProps2","Children","Tag","tag","createElement","_assignProps","_defineProperty","state","defaultValue","RadioGroup","Radio","_Component2","_super2","_this","_len","length","args","Array","_key","call","concat","_assertThisInitialized","checked","e","context","getValueProps","props","_assignProps4","_assignProps4$state","_assignProps4$size","other","undefined","bindHandlerChange","_objectSpread","getTextProps","_assignProps5","_assignProps5$size","_ref2","_ref4","SRadio","_this$asProps3","styles","cn","_assignProps2","Value","_Component3","_super3","target","_ref5","SValue","SControl","_this$asProps4","forwardRef","includeInputProps","_getInputProps","_getInputProps2","_slicedToArray","controlProps","boxProps","Fragment","defaultChecked","Text","_ref3","arguments[0]","_ref6","SText","_assignProps3"],"sources":["../../src/Radio.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, CONTEXT_COMPONENT, sstyled, Root } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport assignProps from '@semcore/utils/lib/assignProps';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport resolveColor from '@semcore/utils/lib/color';\nimport getInputProps, { inputProps } from '@semcore/utils/lib/inputProps';\n\nimport style from './style/radio.shadow.css';\n\nclass RadioGroupRoot extends Component {\n static displayName = 'RadioGroup';\n\n static defaultProps = {\n state: 'normal',\n size: 'm',\n defaultValue: null,\n };\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n setContext() {\n const { theme, size, name, value, onChange } = this.asProps;\n return {\n onChange,\n value,\n theme,\n size,\n name,\n };\n }\n\n render() {\n const { Children, tag: Tag } = this.asProps;\n\n if (Tag)\n return (\n <Root render={Tag} role='radiogroup'>\n <Children />\n </Root>\n );\n\n return <Children />;\n }\n}\n\nconst RadioGroup = createComponent(RadioGroupRoot);\n\nclass Radio extends Component {\n static displayName = 'Radio';\n static style = style;\n static contextType = RadioGroup[CONTEXT_COMPONENT];\n\n bindHandlerChange = (value) => (checked, e) => {\n this.context.onChange(value, e);\n };\n\n getValueProps(props) {\n // The default values are here, since you cannot rewrite out of context\n const { state = 'normal', size = 'm', theme, name } = assignProps(this.props, this.context);\n const { value } = this.context;\n const other = {};\n // if used with the context\n if (value !== undefined) {\n other['checked'] = value === props.value;\n other['onChange'] = this.bindHandlerChange(props.value);\n }\n return {\n ...other,\n state,\n size,\n theme,\n name,\n };\n }\n\n getTextProps() {\n // The default values are here, since you cannot rewrite out of context\n const { size = 'm' } = assignProps(this.props, this.context);\n return {\n size: size,\n };\n }\n\n render() {\n const SRadio = Root;\n const { styles, Children } = this.asProps;\n\n return sstyled(styles)(\n <SRadio render={Box} tag='label'>\n <Children />\n </SRadio>,\n );\n }\n}\n\nclass Value extends Component {\n static defaultProps = {\n includeInputProps: inputProps,\n defaultChecked: false,\n };\n static enhance = [keyboardFocusEnhance()];\n static hoistProps = ['disabled'];\n\n uncontrolledProps() {\n return {\n checked: (e) => e.target.checked,\n };\n }\n\n render() {\n const SValue = Box;\n const SControl = Box;\n const { forwardRef, styles, includeInputProps, theme } = this.asProps;\n\n const [controlProps, boxProps] = getInputProps(this.asProps, includeInputProps);\n\n return sstyled(styles)(\n <>\n <SControl tag='input' type='radio' {...controlProps} />\n <SValue ref={forwardRef} use:theme={resolveColor(theme)} {...boxProps} />\n </>,\n );\n }\n}\n\nfunction Text(props) {\n const SText = Root;\n const { styles } = props;\n return sstyled(styles)(<SText render={Box} />);\n}\n\nexport { inputProps, RadioGroup };\nexport default createComponent(Radio, {\n Value,\n Text,\n});\n"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,eAAe,IAAIC,SAAS,EAAEC,iBAAiB,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AAC5F,SAASC,GAAG,QAAQ,mBAAmB;AACvC,OAAOC,WAAW,MAAM,gCAAgC;AACxD,OAAOC,oBAAoB,MAAM,kDAAkD;AACnF,OAAOC,YA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AE2B/F,GAAG;EADzC,IAAQuE,MAAM,GAAKf,KAAK,CAAhBe,MAAM;EACd,OAAAuB,KAAA,GAAOhG,OAAO,CAACyE,MAAM,CAAC,eAAC7E,KAAA,CAAAwC,aAAA,CAAC6D,KAAK,EAAAD,KAAA,CAAAtB,EAAA,UAAAT,aAAA,KAAAiC,aAAA,KAAAJ,KAAA,IAAgB;AAC/C;AAEA,SAASvF,UAAU,EAAEkC,UAAU;AAC/B,eAAe5C,eAAe,CAAC6C,KAAK,EAAE;EACpCkC,KAAK,EAALA,KAAK;EACLiB,IAAI,EAAJA;AACF,CAAC,CAAC"}
|
package/lib/es6/index.d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import { CProps, PropGetterFn, ReturnEl } from '@semcore/core';\nimport { IBoxProps } from '@semcore/flex-box';\nimport { IKeyboardFocusProps } from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport { Text } from '@semcore/typography';\n\nexport type RadioSize = 'm' | 'l';\nexport type RadioState = 'normal' | 'invalid';\nexport type RadioValue = string | number | boolean;\n\nexport interface IRadioProps extends IBoxProps {\n /**\n * The value displaying the state of the component\n * @default normal\n */\n state?: RadioState;\n /**\n * Radio button size\n * @default m\n **/\n size?: RadioSize;\n /** The theme of the radio button that you can send your color to */\n theme?: string;\n}\n\nexport interface IRadioGroupProps {\n /** Radio group name */\n name?: string;\n /** Active default value */\n defaultValue?: RadioValue;\n /** Active value */\n value?: RadioValue;\n /** Called when the selected element is changed */\n onChange?: (value: RadioValue, e?: React.SyntheticEvent<HTMLInputElement>) => void;\n /** Radio button size */\n size?: RadioSize;\n /** The theme of the radio button that you can send your color to */\n theme?: string;\n /** Blocks access and changes to the form field */\n disabled?: boolean;\n}\n\nexport interface IRadioValueProps extends IBoxProps, IKeyboardFocusProps {\n /** List of elements that can be put on a hidden input */\n includeInputProps?: string[];\n /**\n * The value displaying the state of the component\n * @default normal\n */\n state?: RadioState;\n /** The theme of the radio button that you can send your color to */\n theme?: string;\n /** Radio button size */\n size?: RadioSize;\n /** The element value is required for RadioGroup */\n value?: RadioValue;\n /** Default value if `value` property is not provided */\n defaultValue?: RadioValue;\n /** Called when the value changes */\n onChange?: (value: boolean, e?: React.SyntheticEvent<HTMLInputElement>) => void;\n /** Blocks access and changes to the form field */\n disabled?: boolean;\n}\n\nexport interface IRadioCtx {\n getValueProps: PropGetterFn;\n getTextProps: PropGetterFn;\n}\n\ndeclare const RadioGroup: <T>(props: CProps<IRadioGroupProps & T>) => ReturnEl;\n\nexport { RadioGroup };\n\ndeclare const Radio: (<T>(props: CProps<IRadioProps & T, IRadioCtx>) => ReturnEl) & {\n Value: <T>(props: IRadioValueProps & T) => ReturnEl;\n Text: typeof Text;\n};\n\nexport default Radio;\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { CProps, PropGetterFn, ReturnEl } from '@semcore/core';\nimport { IBoxProps } from '@semcore/flex-box';\nimport { IKeyboardFocusProps } from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport { Text } from '@semcore/typography';\n\nexport type RadioSize = 'm' | 'l';\nexport type RadioState = 'normal' | 'invalid';\nexport type RadioValue = string | number | boolean;\n\nexport interface IRadioProps extends IBoxProps {\n /**\n * The value displaying the state of the component\n * @default normal\n */\n state?: RadioState;\n /**\n * Radio button size\n * @default m\n **/\n size?: RadioSize;\n /** The theme of the radio button that you can send your color to */\n theme?: string;\n}\n\nexport interface IRadioGroupProps {\n /**\n * HTML tag name for the displayed item\n */\n tag?: React.ElementType | string;\n /** Radio group name */\n name?: string;\n /** Active default value */\n defaultValue?: RadioValue;\n /** Active value */\n value?: RadioValue;\n /** Called when the selected element is changed */\n onChange?: (value: RadioValue, e?: React.SyntheticEvent<HTMLInputElement>) => void;\n /** Radio button size */\n size?: RadioSize;\n /** The theme of the radio button that you can send your color to */\n theme?: string;\n /** Blocks access and changes to the form field */\n disabled?: boolean;\n}\n\nexport interface IRadioValueProps extends IBoxProps, IKeyboardFocusProps {\n /** List of elements that can be put on a hidden input */\n includeInputProps?: string[];\n /**\n * The value displaying the state of the component\n * @default normal\n */\n state?: RadioState;\n /** The theme of the radio button that you can send your color to */\n theme?: string;\n /** Radio button size */\n size?: RadioSize;\n /** The element value is required for RadioGroup */\n value?: RadioValue;\n /** Default value if `value` property is not provided */\n defaultValue?: RadioValue;\n /** Called when the value changes */\n onChange?: (value: boolean, e?: React.SyntheticEvent<HTMLInputElement>) => void;\n /** Blocks access and changes to the form field */\n disabled?: boolean;\n}\n\nexport interface IRadioCtx {\n getValueProps: PropGetterFn;\n getTextProps: PropGetterFn;\n}\n\ndeclare const RadioGroup: <T>(props: CProps<IRadioGroupProps & T>) => ReturnEl;\n\nexport { RadioGroup };\n\ndeclare const Radio: (<T>(props: CProps<IRadioProps & T, IRadioCtx>) => ReturnEl) & {\n Value: <T>(props: IRadioValueProps & T) => ReturnEl;\n Text: typeof Text;\n};\n\nexport default Radio;\n"],"mappings":""}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { CProps, PropGetterFn, ReturnEl } from '@semcore/core';
|
|
2
3
|
import { IBoxProps } from '@semcore/flex-box';
|
|
3
4
|
import { IKeyboardFocusProps } from '@semcore/utils/lib/enhances/keyboardFocusEnhance';
|
|
@@ -23,6 +24,10 @@ export interface IRadioProps extends IBoxProps {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export interface IRadioGroupProps {
|
|
27
|
+
/**
|
|
28
|
+
* HTML tag name for the displayed item
|
|
29
|
+
*/
|
|
30
|
+
tag?: React.ElementType | string;
|
|
26
31
|
/** Radio group name */
|
|
27
32
|
name?: string;
|
|
28
33
|
/** Active default value */
|