@semcore/radio 6.9.2-prerelease.0 → 6.10.0-prerelease.0
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 +10 -1
- package/lib/cjs/Radio.js +245 -106
- package/lib/cjs/Radio.js.map +1 -1
- package/lib/cjs/index.d.js.map +1 -1
- package/lib/cjs/style/radio.shadow.css +7 -7
- package/lib/es6/Radio.js +246 -105
- package/lib/es6/Radio.js.map +1 -1
- package/lib/es6/index.d.js.map +1 -1
- package/lib/es6/style/radio.shadow.css +7 -7
- package/lib/types/index.d.ts +43 -8
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
-
## [6.
|
|
5
|
+
## [6.10.0-prerelease.0] - 2023-09-29
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- simplified use: `<Radio />`.
|
|
10
|
+
- advanced use with new sub-components `<Radio.Value.Control />` and `<Radio.Value.RadioMark />`
|
|
11
|
+
- added warning about using `disabled` prop on `Radio.Value` with recommendation to use `disabled` prop on root `Radio` because it may cause SSR related issues.
|
|
12
|
+
- input tag now gets `aria-invalid` if `state` prop is `invalid`.
|
|
13
|
+
|
|
14
|
+
## [6.9.2] - 2023-09-20
|
|
6
15
|
|
|
7
16
|
### Changed
|
|
8
17
|
|
package/lib/cjs/Radio.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "inputProps", {
|
|
|
12
12
|
return _inputProps.inputProps;
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
16
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
16
17
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
17
18
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
@@ -23,24 +24,28 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
23
24
|
var _core = _interopRequireWildcard(require("@semcore/core"));
|
|
24
25
|
var _react = _interopRequireDefault(require("react"));
|
|
25
26
|
var _flexBox = require("@semcore/flex-box");
|
|
26
|
-
var
|
|
27
|
+
var _assignProps8 = _interopRequireWildcard(require("@semcore/utils/lib/assignProps"));
|
|
27
28
|
var _keyboardFocusEnhance = _interopRequireDefault(require("@semcore/utils/lib/enhances/keyboardFocusEnhance"));
|
|
28
29
|
var _color = _interopRequireDefault(require("@semcore/utils/lib/color"));
|
|
29
30
|
var _inputProps = _interopRequireWildcard(require("@semcore/utils/lib/inputProps"));
|
|
31
|
+
var _logger = _interopRequireDefault(require("@semcore/utils/lib/logger"));
|
|
32
|
+
var _typography = require("@semcore/typography");
|
|
33
|
+
var _excluded = ["size", "state", "theme", "keyboardFocused", "value", "tag", "disabled", "includeInputProps"],
|
|
34
|
+
_excluded2 = ["children", "Children"];
|
|
30
35
|
/*__reshadow-styles__:"./style/radio.shadow.css"*/
|
|
31
|
-
var style = ( /*__reshadow_css_start__*/_core.sstyled.insert( /*__inner_css_start__*/".
|
|
32
|
-
"__SRadio": "
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"_state_normal": "
|
|
39
|
-
"_state_invalid": "
|
|
40
|
-
"__SControl": "
|
|
41
|
-
"_keyboardFocused": "
|
|
42
|
-
"_theme": "
|
|
43
|
-
"--theme": "--
|
|
36
|
+
var style = ( /*__reshadow_css_start__*/_core.sstyled.insert( /*__inner_css_start__*/".___SRadio_14o54_gg_{display:inline-flex;align-items:flex-start;cursor:pointer}.___SText_14o54_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);color:var(--intergalactic-text-primary, #191b23)}.___SText_14o54_gg_._size_m_14o54_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___SText_14o54_gg_._size_l_14o54_gg_{font-size:var(--intergalactic-fs-300, 16px);line-height:var(--intergalactic-lh-300, 150%)}.___SValue_14o54_gg_{position:relative;flex-shrink:0;padding:0;outline:0;z-index:0;margin-top:var(--intergalactic-spacing-05x, 2px)}.___SValue_14o54_gg_::after,.___SValue_14o54_gg_::before{content:\"\";position:absolute;right:0;bottom:0;border-radius:50%;background:var(--intergalactic-bg-primary-neutral, #ffffff)}.___SValue_14o54_gg_::before{top:0;left:0;border:1px solid;transition:calc(var(--intergalactic-duration-control, 200)*1ms) all ease-in-out}.___SValue_14o54_gg_::after{top:50%;left:50%;transform:translate(-50%,-50%);width:0;height:0}.___SValue_14o54_gg_.__disabled_14o54_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.___SValue_14o54_gg_._size_m_14o54_gg_{width:16px;height:16px}.___SValue_14o54_gg_._size_l_14o54_gg_{width:20px;height:20px}.___SValue_14o54_gg_._state_normal_14o54_gg_::before{border-color:var(--intergalactic-border-primary, #c4c7cf)}.___SValue_14o54_gg_._state_invalid_14o54_gg_::before{border-color:var(--intergalactic-border-critical-active, #d1002f)}.___SControl_14o54_gg_{position:absolute;clip:rect(1px,1px,1px,1px)}.___SControl_14o54_gg_:checked~.___SValue_14o54_gg_::before{border-color:var(--intergalactic-control-primary-info, #008ff8);background-color:var(--intergalactic-control-primary-info, #008ff8)}.___SControl_14o54_gg_:checked~.___SValue_14o54_gg_._size_m_14o54_gg_::after{width:6px;height:6px}.___SControl_14o54_gg_:checked~.___SValue_14o54_gg_._size_l_14o54_gg_::after{width:8px;height:8px}.___SValue_14o54_gg_._state_normal_14o54_gg_.__keyboardFocused_14o54_gg_::before{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5));border-color:var(--intergalactic-border-info-active, #006dca)}.___SValue_14o54_gg_._state_invalid_14o54_gg_.__keyboardFocused_14o54_gg_::before{box-shadow:var(--intergalactic-keyboard-focus-invalid, 0px 0px 0px 3px rgba(255, 73, 83, 0.5))}.___SControl_14o54_gg_:checked~.___SValue_14o54_gg_.__theme_14o54_gg_::before{border-color:var(--theme_14o54);background-color:var(--theme_14o54)}.___SValue_14o54_gg_._state_normal_14o54_gg_.__theme_14o54_gg_::before{border-color:var(--theme_14o54)}" /*__inner_css_end__*/, "14o54_gg_") /*__reshadow_css_end__*/, {
|
|
37
|
+
"__SRadio": "___SRadio_14o54_gg_",
|
|
38
|
+
"__SText": "___SText_14o54_gg_",
|
|
39
|
+
"_size_m": "_size_m_14o54_gg_",
|
|
40
|
+
"_size_l": "_size_l_14o54_gg_",
|
|
41
|
+
"__SValue": "___SValue_14o54_gg_",
|
|
42
|
+
"_disabled": "__disabled_14o54_gg_",
|
|
43
|
+
"_state_normal": "_state_normal_14o54_gg_",
|
|
44
|
+
"_state_invalid": "_state_invalid_14o54_gg_",
|
|
45
|
+
"__SControl": "___SControl_14o54_gg_",
|
|
46
|
+
"_keyboardFocused": "__keyboardFocused_14o54_gg_",
|
|
47
|
+
"_theme": "__theme_14o54_gg_",
|
|
48
|
+
"--theme": "--theme_14o54"
|
|
44
49
|
});
|
|
45
50
|
var RadioGroupRoot = /*#__PURE__*/function (_Component) {
|
|
46
51
|
(0, _inherits2["default"])(RadioGroupRoot, _Component);
|
|
@@ -97,91 +102,116 @@ var RadioGroupRoot = /*#__PURE__*/function (_Component) {
|
|
|
97
102
|
});
|
|
98
103
|
var RadioGroup = (0, _core["default"])(RadioGroupRoot);
|
|
99
104
|
exports.RadioGroup = RadioGroup;
|
|
100
|
-
var
|
|
101
|
-
(0, _inherits2["default"])(
|
|
102
|
-
var _super2 = (0, _createSuper2["default"])(
|
|
103
|
-
function
|
|
105
|
+
var RadioRoot = /*#__PURE__*/function (_Component2) {
|
|
106
|
+
(0, _inherits2["default"])(RadioRoot, _Component2);
|
|
107
|
+
var _super2 = (0, _createSuper2["default"])(RadioRoot);
|
|
108
|
+
function RadioRoot() {
|
|
104
109
|
var _this;
|
|
105
|
-
(0, _classCallCheck2["default"])(this,
|
|
110
|
+
(0, _classCallCheck2["default"])(this, RadioRoot);
|
|
106
111
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
107
112
|
args[_key] = arguments[_key];
|
|
108
113
|
}
|
|
109
114
|
_this = _super2.call.apply(_super2, [this].concat(args));
|
|
110
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
116
|
+
hoistedDisabled: undefined
|
|
117
|
+
});
|
|
118
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "hoistDisabled", function (disabled) {
|
|
119
|
+
_logger["default"].warn(true, "Don't set disabled on Radio.Value or Radio.Text, set it on Radio or on RadioGroup (for all items) instead. Otherwise it will produce wrong SSR output.", _this.asProps['data-ui-name']);
|
|
120
|
+
_this.setState({
|
|
121
|
+
hoistedDisabled: disabled
|
|
122
|
+
});
|
|
114
123
|
});
|
|
115
124
|
return _this;
|
|
116
125
|
}
|
|
117
|
-
(0, _createClass2["default"])(
|
|
118
|
-
key: "
|
|
119
|
-
value: function
|
|
126
|
+
(0, _createClass2["default"])(RadioRoot, [{
|
|
127
|
+
key: "getTextProps",
|
|
128
|
+
value: function getTextProps() {
|
|
120
129
|
// The default values are here, since you cannot rewrite out of context
|
|
121
|
-
var
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
disabled = _assignProps4.disabled;
|
|
129
|
-
var value = this.context.value;
|
|
130
|
-
var other = {};
|
|
131
|
-
// if used with the context
|
|
132
|
-
if (value !== undefined) {
|
|
133
|
-
other['checked'] = value === props.value;
|
|
134
|
-
other['onChange'] = this.bindHandlerChange(props.value);
|
|
135
|
-
if (this.asProps.tag !== 'label') {
|
|
136
|
-
other['onClick'] = this.bindHandlerChange(props.value);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, other), {}, {
|
|
140
|
-
state: state,
|
|
130
|
+
var _assignProps6 = (0, _assignProps8["default"])(this.asProps, this.context),
|
|
131
|
+
_assignProps6$size = _assignProps6.size,
|
|
132
|
+
size = _assignProps6$size === void 0 ? 'm' : _assignProps6$size,
|
|
133
|
+
disabled = _assignProps6.disabled,
|
|
134
|
+
label = _assignProps6.label;
|
|
135
|
+
var hoistedDisabled = this.state.hoistedDisabled;
|
|
136
|
+
var textProps = {
|
|
141
137
|
size: size,
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
138
|
+
children: label,
|
|
139
|
+
disabled: disabled !== null && disabled !== void 0 ? disabled : hoistedDisabled,
|
|
140
|
+
hoistDisabled: this.hoistDisabled,
|
|
141
|
+
rootDisabled: this.props.disabled
|
|
142
|
+
};
|
|
143
|
+
return textProps;
|
|
146
144
|
}
|
|
147
145
|
}, {
|
|
148
|
-
key: "
|
|
149
|
-
value: function
|
|
146
|
+
key: "getValueProps",
|
|
147
|
+
value: function getValueProps() {
|
|
148
|
+
var _this$props$size;
|
|
150
149
|
// The default values are here, since you cannot rewrite out of context
|
|
151
|
-
var
|
|
152
|
-
|
|
153
|
-
size =
|
|
150
|
+
var _assignProps7 = (0, _assignProps8["default"])(this.context, this.asProps),
|
|
151
|
+
_assignProps7$size = _assignProps7.size,
|
|
152
|
+
size = _assignProps7$size === void 0 ? 'm' : _assignProps7$size,
|
|
153
|
+
_assignProps7$state = _assignProps7.state,
|
|
154
|
+
state = _assignProps7$state === void 0 ? 'normal' : _assignProps7$state,
|
|
155
|
+
theme = _assignProps7.theme,
|
|
156
|
+
disabled = _assignProps7.disabled,
|
|
157
|
+
name = _assignProps7.name;
|
|
158
|
+
var _this$asProps2 = this.asProps,
|
|
159
|
+
value = _this$asProps2.value,
|
|
160
|
+
checked = _this$asProps2.checked;
|
|
161
|
+
var hoistedDisabled = this.state.hoistedDisabled;
|
|
154
162
|
return {
|
|
155
|
-
size: size
|
|
163
|
+
size: (_this$props$size = this.props.size) !== null && _this$props$size !== void 0 ? _this$props$size : size,
|
|
164
|
+
disabled: disabled !== null && disabled !== void 0 ? disabled : hoistedDisabled,
|
|
165
|
+
state: state,
|
|
166
|
+
theme: theme,
|
|
167
|
+
value: value,
|
|
168
|
+
checked: checked,
|
|
169
|
+
name: name,
|
|
170
|
+
hoistDisabled: this.hoistDisabled,
|
|
171
|
+
rootDisabled: this.props.disabled
|
|
156
172
|
};
|
|
157
173
|
}
|
|
158
174
|
}, {
|
|
159
175
|
key: "render",
|
|
160
176
|
value: function render() {
|
|
161
177
|
var _ref2 = this.asProps,
|
|
162
|
-
|
|
178
|
+
_ref6;
|
|
163
179
|
var SRadio = _flexBox.Box;
|
|
164
|
-
var _this$
|
|
165
|
-
styles = _this$
|
|
166
|
-
Children = _this$
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
180
|
+
var _this$asProps3 = this.asProps,
|
|
181
|
+
styles = _this$asProps3.styles,
|
|
182
|
+
Children = _this$asProps3.Children,
|
|
183
|
+
hasChildren = _this$asProps3.children;
|
|
184
|
+
return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SRadio, _ref6.cn("SRadio", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
185
|
+
"tag": 'label',
|
|
186
|
+
"__excludeProps": ['onChange', 'label', 'disabled']
|
|
187
|
+
}, _ref2))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children, _ref6.cn("Children", {})) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(Radio.Value, null), /*#__PURE__*/_react["default"].createElement(Radio.Text, null)));
|
|
170
188
|
}
|
|
171
189
|
}]);
|
|
172
|
-
return
|
|
190
|
+
return RadioRoot;
|
|
173
191
|
}(_core.Component);
|
|
174
|
-
(0, _defineProperty2["default"])(
|
|
175
|
-
(0, _defineProperty2["default"])(
|
|
176
|
-
(0, _defineProperty2["default"])(
|
|
177
|
-
var
|
|
178
|
-
(0, _inherits2["default"])(
|
|
179
|
-
var _super3 = (0, _createSuper2["default"])(
|
|
180
|
-
function
|
|
181
|
-
|
|
182
|
-
|
|
192
|
+
(0, _defineProperty2["default"])(RadioRoot, "displayName", 'Radio');
|
|
193
|
+
(0, _defineProperty2["default"])(RadioRoot, "style", style);
|
|
194
|
+
(0, _defineProperty2["default"])(RadioRoot, "contextType", RadioGroup[_core.CONTEXT_COMPONENT]);
|
|
195
|
+
var ValueRoot = /*#__PURE__*/function (_Component3) {
|
|
196
|
+
(0, _inherits2["default"])(ValueRoot, _Component3);
|
|
197
|
+
var _super3 = (0, _createSuper2["default"])(ValueRoot);
|
|
198
|
+
function ValueRoot() {
|
|
199
|
+
var _this2;
|
|
200
|
+
(0, _classCallCheck2["default"])(this, ValueRoot);
|
|
201
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
202
|
+
args[_key2] = arguments[_key2];
|
|
203
|
+
}
|
|
204
|
+
_this2 = _super3.call.apply(_super3, [this].concat(args));
|
|
205
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this2), "bindHandlerChange", function (value) {
|
|
206
|
+
return function (e) {
|
|
207
|
+
if (typeof _this2.context.onChange === 'function') {
|
|
208
|
+
_this2.context.onChange(value, e);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
});
|
|
212
|
+
return _this2;
|
|
183
213
|
}
|
|
184
|
-
(0, _createClass2["default"])(
|
|
214
|
+
(0, _createClass2["default"])(ValueRoot, [{
|
|
185
215
|
key: "uncontrolledProps",
|
|
186
216
|
value: function uncontrolledProps() {
|
|
187
217
|
return {
|
|
@@ -190,48 +220,157 @@ var Value = /*#__PURE__*/function (_Component3) {
|
|
|
190
220
|
}
|
|
191
221
|
};
|
|
192
222
|
}
|
|
223
|
+
}, {
|
|
224
|
+
key: "getControlProps",
|
|
225
|
+
value: function getControlProps() {
|
|
226
|
+
var currentValue = this.context.value;
|
|
227
|
+
var _this$asProps4 = this.asProps,
|
|
228
|
+
forwardRef = _this$asProps4.forwardRef,
|
|
229
|
+
includeInputProps = _this$asProps4.includeInputProps,
|
|
230
|
+
state = _this$asProps4.state,
|
|
231
|
+
value = _this$asProps4.value;
|
|
232
|
+
var _getInputProps = (0, _inputProps["default"])(this.asProps, includeInputProps),
|
|
233
|
+
_getInputProps2 = (0, _slicedToArray2["default"])(_getInputProps, 1),
|
|
234
|
+
commonControlProps = _getInputProps2[0];
|
|
235
|
+
var inputValue = value !== null && value !== void 0 ? value : '';
|
|
236
|
+
var controlProps = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
|
|
237
|
+
ref: forwardRef,
|
|
238
|
+
state: state
|
|
239
|
+
}, commonControlProps), {}, {
|
|
240
|
+
value: inputValue
|
|
241
|
+
});
|
|
242
|
+
if (currentValue !== undefined) {
|
|
243
|
+
var _this$props = this.props,
|
|
244
|
+
onChange = _this$props.onChange,
|
|
245
|
+
onClick = _this$props.onClick;
|
|
246
|
+
controlProps.checked = currentValue === inputValue;
|
|
247
|
+
controlProps.onChange = (0, _assignProps8.callAllEventHandlers)(onChange, this.bindHandlerChange(inputValue));
|
|
248
|
+
}
|
|
249
|
+
return controlProps;
|
|
250
|
+
}
|
|
251
|
+
}, {
|
|
252
|
+
key: "getRadioMarkProps",
|
|
253
|
+
value: function getRadioMarkProps() {
|
|
254
|
+
var currentValue = this.context.value;
|
|
255
|
+
var _this$asProps5 = this.asProps,
|
|
256
|
+
size = _this$asProps5.size,
|
|
257
|
+
state = _this$asProps5.state,
|
|
258
|
+
theme = _this$asProps5.theme,
|
|
259
|
+
keyboardFocused = _this$asProps5.keyboardFocused,
|
|
260
|
+
value = _this$asProps5.value,
|
|
261
|
+
tag = _this$asProps5.tag,
|
|
262
|
+
disabled = _this$asProps5.disabled,
|
|
263
|
+
includeInputProps = _this$asProps5.includeInputProps,
|
|
264
|
+
other = (0, _objectWithoutProperties2["default"])(_this$asProps5, _excluded);
|
|
265
|
+
var _getInputProps3 = (0, _inputProps["default"])(other, includeInputProps),
|
|
266
|
+
_getInputProps4 = (0, _slicedToArray2["default"])(_getInputProps3, 2),
|
|
267
|
+
radioMarkProps = _getInputProps4[1];
|
|
268
|
+
var children = radioMarkProps.children,
|
|
269
|
+
Children = radioMarkProps.Children,
|
|
270
|
+
propsWithoutChildren = (0, _objectWithoutProperties2["default"])(radioMarkProps, _excluded2);
|
|
271
|
+
var inputValue = value !== null && value !== void 0 ? value : '';
|
|
272
|
+
var markProps = (0, _objectSpread2["default"])({
|
|
273
|
+
theme: theme,
|
|
274
|
+
size: size,
|
|
275
|
+
state: state,
|
|
276
|
+
keyboardFocused: keyboardFocused,
|
|
277
|
+
disabled: disabled
|
|
278
|
+
}, propsWithoutChildren);
|
|
279
|
+
if (currentValue !== undefined) {
|
|
280
|
+
var onClick = this.props.onClick;
|
|
281
|
+
if (tag !== 'label') {
|
|
282
|
+
markProps.onClick = (0, _assignProps8.callAllEventHandlers)(onClick, this.bindHandlerChange(inputValue));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return markProps;
|
|
286
|
+
}
|
|
287
|
+
}, {
|
|
288
|
+
key: "componentDidUpdate",
|
|
289
|
+
value: function componentDidUpdate() {
|
|
290
|
+
if (this.asProps.rootDisabled !== this.asProps.disabled) {
|
|
291
|
+
this.asProps.hoistDisabled(this.asProps.disabled);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}, {
|
|
295
|
+
key: "componentDidMount",
|
|
296
|
+
value: function componentDidMount() {
|
|
297
|
+
if (this.asProps.rootDisabled !== this.asProps.disabled) {
|
|
298
|
+
this.asProps.hoistDisabled(this.asProps.disabled);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
193
301
|
}, {
|
|
194
302
|
key: "render",
|
|
195
303
|
value: function render() {
|
|
196
|
-
var
|
|
197
|
-
var
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
controlProps = _getInputProps2[0],
|
|
207
|
-
boxProps = _getInputProps2[1];
|
|
208
|
-
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"])({
|
|
209
|
-
"tag": 'input',
|
|
210
|
-
"type": 'radio'
|
|
211
|
-
}, controlProps))), /*#__PURE__*/_react["default"].createElement(SValue, _ref5.cn("SValue", (0, _objectSpread2["default"])({
|
|
212
|
-
"ref": forwardRef,
|
|
213
|
-
"use:theme": (0, _color["default"])(theme)
|
|
214
|
-
}, boxProps))));
|
|
304
|
+
var _ref8;
|
|
305
|
+
var _this$asProps6 = this.asProps,
|
|
306
|
+
styles = _this$asProps6.styles,
|
|
307
|
+
hasChildren = _this$asProps6.children,
|
|
308
|
+
Children = _this$asProps6.Children;
|
|
309
|
+
if (!hasChildren) {
|
|
310
|
+
var _ref7;
|
|
311
|
+
return _ref7 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(Radio.Value.Control, null), /*#__PURE__*/_react["default"].createElement(Radio.Value.RadioMark, null));
|
|
312
|
+
}
|
|
313
|
+
return _ref8 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(Children, _ref8.cn("Children", {}));
|
|
215
314
|
}
|
|
216
315
|
}]);
|
|
217
|
-
return
|
|
316
|
+
return ValueRoot;
|
|
218
317
|
}(_core.Component);
|
|
219
|
-
(0, _defineProperty2["default"])(
|
|
318
|
+
(0, _defineProperty2["default"])(ValueRoot, "defaultProps", {
|
|
220
319
|
includeInputProps: _inputProps.inputProps,
|
|
221
320
|
defaultChecked: false
|
|
222
321
|
});
|
|
223
|
-
(0, _defineProperty2["default"])(
|
|
224
|
-
(0, _defineProperty2["default"])(
|
|
225
|
-
|
|
322
|
+
(0, _defineProperty2["default"])(ValueRoot, "enhance", [(0, _keyboardFocusEnhance["default"])()]);
|
|
323
|
+
(0, _defineProperty2["default"])(ValueRoot, "displayName", 'Value');
|
|
324
|
+
(0, _defineProperty2["default"])(ValueRoot, "contextType", RadioGroup[_core.CONTEXT_COMPONENT]);
|
|
325
|
+
(0, _defineProperty2["default"])(ValueRoot, "style", style);
|
|
326
|
+
var Control = function Control(props) {
|
|
226
327
|
var _ref3 = arguments[0],
|
|
227
|
-
|
|
228
|
-
var
|
|
328
|
+
_ref9;
|
|
329
|
+
var SControl = _flexBox.Box;
|
|
330
|
+
var styles = props.styles,
|
|
331
|
+
state = props.state;
|
|
332
|
+
return _ref9 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SControl, _ref9.cn("SControl", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
333
|
+
"tag": 'input',
|
|
334
|
+
"type": 'radio',
|
|
335
|
+
"aria-invalid": state === 'invalid'
|
|
336
|
+
}, _ref3))));
|
|
337
|
+
};
|
|
338
|
+
Control.displayName = 'Control';
|
|
339
|
+
var RadioMark = function RadioMark(props) {
|
|
340
|
+
var _ref4 = arguments[0],
|
|
341
|
+
_ref10;
|
|
342
|
+
var SValue = _flexBox.Box;
|
|
343
|
+
var theme = props.theme,
|
|
344
|
+
styles = props.styles;
|
|
345
|
+
return _ref10 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SValue, _ref10.cn("SValue", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
346
|
+
"tag": 'div',
|
|
347
|
+
"use:theme": (0, _color["default"])(theme)
|
|
348
|
+
}, _ref4))));
|
|
349
|
+
};
|
|
350
|
+
RadioMark.displayName = 'RadioMark';
|
|
351
|
+
var Text = function Text(props) {
|
|
352
|
+
var _ref5 = arguments[0],
|
|
353
|
+
_ref11;
|
|
354
|
+
var SText = _typography.Text;
|
|
229
355
|
var styles = props.styles;
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
356
|
+
_react["default"].useEffect(function () {
|
|
357
|
+
if (props.rootDisabled !== props.disabled) {
|
|
358
|
+
props.hoistDisabled(props.disabled);
|
|
359
|
+
}
|
|
360
|
+
}, [props.rootDisabled, props.disabled, props.hoistDisabled]);
|
|
361
|
+
return _ref11 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SText, _ref11.cn("SText", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
362
|
+
"tag": 'span'
|
|
363
|
+
}, _ref5))));
|
|
364
|
+
};
|
|
365
|
+
Text.displayName = 'Text';
|
|
366
|
+
var Value = (0, _core["default"])(ValueRoot, {
|
|
367
|
+
Control: Control,
|
|
368
|
+
RadioMark: RadioMark
|
|
369
|
+
});
|
|
370
|
+
var Radio = (0, _core["default"])(RadioRoot, {
|
|
371
|
+
Text: Text,
|
|
372
|
+
Value: Value
|
|
235
373
|
});
|
|
374
|
+
var _default = Radio;
|
|
236
375
|
exports["default"] = _default;
|
|
237
376
|
//# sourceMappingURL=Radio.js.map
|
package/lib/cjs/Radio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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","disabled","render","_ref","Children","createElement","Flex","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","tag","_objectSpread2","getTextProps","_assignProps5","_assignProps5$size","_ref2","_ref4","SRadio","Box","_this$asProps2","styles","cn","CONTEXT_COMPONENT","Value","_Component3","_super3","target","_ref5","SValue","SControl","_this$asProps3","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 { Flex, 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, disabled } = this.asProps;\n return {\n onChange,\n value,\n theme,\n size,\n name,\n disabled,\n };\n }\n\n render() {\n const { Children } = this.asProps;\n\n return (\n <Root render={Flex} direction='column' role='radiogroup' __excludeProps={['onChange']}>\n <Children />\n </Root>\n );\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 {\n state = 'normal',\n size = 'm',\n theme,\n name,\n disabled,\n } = 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 if (this.asProps.tag !== 'label') {\n other['onClick'] = this.bindHandlerChange(props.value);\n }\n }\n return {\n ...other,\n state,\n size,\n theme,\n name,\n disabled,\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(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,QAAA"}
|
|
1
|
+
{"version":3,"file":"Radio.js","names":["_core","_interopRequireWildcard","require","_react","_interopRequireDefault","_flexBox","_assignProps8","_keyboardFocusEnhance","_color","_inputProps","_logger","_typography","_excluded","_excluded2","style","sstyled","insert","RadioGroupRoot","_Component","_inherits2","_super","_createSuper2","_classCallCheck2","apply","arguments","_createClass2","key","value","uncontrolledProps","setContext","_this$asProps","asProps","theme","size","name","onChange","disabled","render","_ref","Children","createElement","Flex","assignProps","Component","_defineProperty2","state","defaultValue","RadioGroup","createComponent","exports","RadioRoot","_Component2","_super2","_this","_len","length","args","Array","_key","call","concat","_assertThisInitialized2","hoistedDisabled","undefined","logger","warn","setState","getTextProps","_assignProps6","context","_assignProps6$size","label","textProps","children","hoistDisabled","rootDisabled","props","getValueProps","_this$props$size","_assignProps7","_assignProps7$size","_assignProps7$state","_this$asProps2","checked","_ref2","_ref6","SRadio","Box","_this$asProps3","styles","hasChildren","cn","_objectSpread2","Fragment","Radio","Value","Text","CONTEXT_COMPONENT","ValueRoot","_Component3","_super3","_this2","_len2","_key2","e","target","getControlProps","currentValue","_this$asProps4","forwardRef","includeInputProps","_getInputProps","getInputProps","_getInputProps2","_slicedToArray2","commonControlProps","inputValue","controlProps","ref","_this$props","onClick","callAllEventHandlers","bindHandlerChange","getRadioMarkProps","_this$asProps5","keyboardFocused","tag","other","_objectWithoutProperties2","_getInputProps3","_getInputProps4","radioMarkProps","propsWithoutChildren","markProps","componentDidUpdate","componentDidMount","_ref8","_this$asProps6","_ref7","Control","RadioMark","inputProps","defaultChecked","keyboardFocusEnhance","_ref3","arguments[0]","_ref9","SControl","displayName","_ref4","_ref10","SValue","resolveColor","_ref5","_ref11","SText","TypographyText","React","useEffect","_default"],"sources":["../../src/Radio.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, CONTEXT_COMPONENT, sstyled, Root } from '@semcore/core';\nimport { Flex, Box } from '@semcore/flex-box';\nimport assignProps, { callAllEventHandlers } 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';\nimport logger from '@semcore/utils/lib/logger';\nimport { Text as TypographyText } from '@semcore/typography';\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, disabled } = this.asProps;\n\n return {\n onChange,\n value,\n theme,\n size,\n name,\n disabled,\n };\n }\n\n render() {\n const { Children } = this.asProps;\n\n return (\n <Root render={Flex} direction='column' role='radiogroup' __excludeProps={['onChange']}>\n <Children />\n </Root>\n );\n }\n}\n\nconst RadioGroup = createComponent(RadioGroupRoot);\n\nclass RadioRoot extends Component {\n static displayName = 'Radio';\n static style = style;\n static contextType = RadioGroup[CONTEXT_COMPONENT];\n\n state = {\n hoistedDisabled: undefined,\n };\n\n hoistDisabled = (disabled) => {\n logger.warn(\n true,\n `Don't set disabled on Radio.Value or Radio.Text, set it on Radio or on RadioGroup (for all items) instead. Otherwise it will produce wrong SSR output.`,\n this.asProps['data-ui-name'],\n );\n this.setState({ hoistedDisabled: disabled });\n };\n\n getTextProps() {\n // The default values are here, since you cannot rewrite out of context\n const { size = 'm', disabled, label } = assignProps(this.asProps, this.context);\n const { hoistedDisabled } = this.state;\n\n const textProps = {\n size,\n children: label,\n disabled: disabled ?? hoistedDisabled,\n hoistDisabled: this.hoistDisabled,\n rootDisabled: this.props.disabled,\n };\n\n return textProps;\n }\n\n getValueProps() {\n // The default values are here, since you cannot rewrite out of context\n const {\n size = 'm',\n state = 'normal',\n theme,\n disabled,\n name,\n } = assignProps(this.context, this.asProps);\n const { value, checked } = this.asProps;\n const { hoistedDisabled } = this.state;\n\n return {\n size: this.props.size ?? size,\n disabled: disabled ?? hoistedDisabled,\n state: state,\n theme,\n value,\n checked,\n name,\n hoistDisabled: this.hoistDisabled,\n rootDisabled: this.props.disabled,\n };\n }\n\n render() {\n const SRadio = Root;\n const { styles, Children, children: hasChildren } = this.asProps;\n\n return sstyled(styles)(\n <SRadio render={Box} tag='label' __excludeProps={['onChange', 'label', 'disabled']}>\n {hasChildren ? (\n <Children />\n ) : (\n <>\n <Radio.Value />\n <Radio.Text />\n </>\n )}\n </SRadio>,\n );\n }\n}\n\nclass ValueRoot extends Component {\n static defaultProps = {\n includeInputProps: inputProps,\n defaultChecked: false,\n };\n static enhance = [keyboardFocusEnhance()];\n static displayName = 'Value';\n static contextType = RadioGroup[CONTEXT_COMPONENT];\n static style = style;\n\n bindHandlerChange = (value) => (e) => {\n if (typeof this.context.onChange === 'function') {\n this.context.onChange(value, e);\n }\n };\n\n uncontrolledProps() {\n return {\n checked: (e) => e.target.checked,\n };\n }\n\n getControlProps() {\n const currentValue = this.context.value;\n const { forwardRef, includeInputProps, state, value } = this.asProps;\n const [commonControlProps] = getInputProps(this.asProps, includeInputProps);\n const inputValue = value ?? '';\n\n const controlProps = {\n ref: forwardRef,\n state,\n ...commonControlProps,\n value: inputValue,\n };\n\n if (currentValue !== undefined) {\n const { onChange, onClick } = this.props;\n\n controlProps.checked = currentValue === inputValue;\n controlProps.onChange = callAllEventHandlers(onChange, this.bindHandlerChange(inputValue));\n }\n\n return controlProps;\n }\n\n getRadioMarkProps() {\n const currentValue = this.context.value;\n const {\n size,\n state,\n theme,\n keyboardFocused,\n value,\n tag,\n disabled,\n includeInputProps,\n ...other\n } = this.asProps;\n const [, radioMarkProps] = getInputProps(other, includeInputProps);\n const { children, Children, ...propsWithoutChildren } = radioMarkProps;\n const inputValue = value ?? '';\n\n const markProps = {\n theme,\n size,\n state,\n keyboardFocused,\n disabled,\n ...propsWithoutChildren,\n };\n\n if (currentValue !== undefined) {\n const { onClick } = this.props;\n\n if (tag !== 'label') {\n markProps.onClick = callAllEventHandlers(onClick, this.bindHandlerChange(inputValue));\n }\n }\n\n return markProps;\n }\n\n componentDidUpdate() {\n if (this.asProps.rootDisabled !== this.asProps.disabled) {\n this.asProps.hoistDisabled(this.asProps.disabled);\n }\n }\n componentDidMount() {\n if (this.asProps.rootDisabled !== this.asProps.disabled) {\n this.asProps.hoistDisabled(this.asProps.disabled);\n }\n }\n\n render() {\n const { styles, children: hasChildren, Children } = this.asProps;\n\n if (!hasChildren) {\n return sstyled(styles)(\n <>\n <Radio.Value.Control />\n <Radio.Value.RadioMark />\n </>,\n );\n }\n\n return sstyled(styles)(<Children />);\n }\n}\n\nconst Control = (props) => {\n const SControl = Root;\n const { styles, state } = props;\n\n return sstyled(styles)(\n <SControl render={Box} tag='input' type='radio' aria-invalid={state === 'invalid'} />,\n );\n};\nControl.displayName = 'Control';\n\nconst RadioMark = (props) => {\n const SValue = Root;\n const { theme, styles } = props;\n\n return sstyled(styles)(<SValue render={Box} tag='div' use:theme={resolveColor(theme)} />);\n};\nRadioMark.displayName = 'RadioMark';\n\nconst Text = (props) => {\n const SText = Root;\n const { styles } = props;\n\n React.useEffect(() => {\n if (props.rootDisabled !== props.disabled) {\n props.hoistDisabled(props.disabled);\n }\n }, [props.rootDisabled, props.disabled, props.hoistDisabled]);\n\n return sstyled(styles)(<SText render={TypographyText} tag='span' />);\n};\nText.displayName = 'Text';\n\nexport { inputProps, RadioGroup };\n\nconst Value = createComponent(ValueRoot, {\n Control,\n RadioMark,\n});\n\nconst Radio = createComponent(RadioRoot, {\n Text,\n Value,\n});\n\nexport default Radio;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AADA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAL,uBAAA,CAAAC,OAAA;AACA,IAAAK,qBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAA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,CAAC;IACrC;EACF,CAAC,EAAE,CAACwC,KAAK,CAACD,YAAY,EAAEC,KAAK,CAACxC,QAAQ,EAAEwC,KAAK,CAACF,aAAa,CAAC,CAAC;EAE7D,OAAAgF,MAAA,GAAO,IAAA3I,aAAO,EAAC0E,MAAM,CAAC,eAACtF,MAAA,YAAAqC,aAAA,CAACmH,KAAK,EAAAD,MAAA,CAAA/D,EAAA,cAAAC,cAAA,qBAAA5F,KAAA,CAAA0C,WAAA;IAAA,OAA6B;EAAM,GAAA+G,KAAA,IAAG;AACrE,CAAC;AACDzD,IAAI,CAACoD,WAAW,GAAG,MAAM;AAIzB,IAAMrD,KAAK,GAAG,IAAA/C,gBAAe,EAACkD,SAAS,EAAE;EACvCyC,OAAO,EAAPA,OAAO;EACPC,SAAS,EAATA;AACF,CAAC,CAAC;AAEF,IAAM9C,KAAK,GAAG,IAAA9C,gBAAe,EAACE,SAAS,EAAE;EACvC8C,IAAI,EAAJA,IAAI;EACJD,KAAK,EAALA;AACF,CAAC,CAAC;AAAC,IAAAgE,QAAA,GAEYjE,KAAK;AAAA7C,OAAA,cAAA8G,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 React from 'react';\nimport { PropGetterFn, UnknownProperties, Intergalactic } from '@semcore/core';\nimport { BoxProps, Flex } from '@semcore/flex-box';\nimport { KeyboardFocusProps } 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\n/** @deprecated */\nexport interface IRadioProps extends RadioProps, UnknownProperties {}\nexport type RadioProps = BoxProps & {\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\n/** @deprecated */\nexport interface IRadioGroupProps extends RadioGroupProps, UnknownProperties {\n /**\n * HTML tag name for the displayed item\n */\n tag?: React.ElementType | string;\n}\nexport type RadioGroupProps<T extends RadioValue = RadioValue> = {\n /** Radio group name */\n name?: string;\n /** Active default value */\n defaultValue?: T;\n /** Active value */\n value?: T;\n /** Called when the selected element is changed */\n onChange?:\n | ((value: T, e?: React.SyntheticEvent<HTMLInputElement>) => void)\n | React.Dispatch<React.SetStateAction<T>>;\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\n/** @deprecated */\nexport interface IRadioValueProps extends RadioValueProps, UnknownProperties {}\nexport type RadioValueProps = BoxProps &\n KeyboardFocusProps & {\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
|
|
1
|
+
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { PropGetterFn, UnknownProperties, Intergalactic } from '@semcore/core';\nimport { Box, BoxProps, Flex } from '@semcore/flex-box';\nimport { KeyboardFocusProps } 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\n/** @deprecated */\nexport interface IRadioProps extends RadioProps, UnknownProperties {}\nexport type RadioProps = BoxProps & {\n /** Radio item value **/\n value?: string;\n\n /** Radio item checked flag **/\n checked?: boolean;\n\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 /** Radio item text **/\n label?: string;\n /** Blocks access and changes to the radio item **/\n disabled?: boolean;\n};\n\n/** @deprecated */\nexport interface IRadioGroupProps extends RadioGroupProps, UnknownProperties {\n /**\n * HTML tag name for the displayed item\n */\n tag?: React.ElementType | string;\n}\nexport type RadioGroupProps<T extends RadioValue = RadioValue> = {\n /** Radio group name */\n name?: string;\n /** Active default value */\n defaultValue?: T;\n /** Active value */\n value?: T;\n /** Called when the selected element is changed */\n onChange?:\n | ((value: T, e?: React.SyntheticEvent<HTMLInputElement>) => void)\n | React.Dispatch<React.SetStateAction<T>>;\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\n/** @deprecated */\nexport interface IRadioValueProps extends RadioValueProps, UnknownProperties {}\nexport type RadioValueProps = BoxProps &\n KeyboardFocusProps & {\n /** List of elements that can be put on a hidden input */\n includeInputProps?: string[];\n /**\n * @deprecated set `state` on root Radio instead\n * The value displaying the state of the component\n * @default normal\n */\n state?: RadioState;\n /**\n * @deprecated\n * The theme of the radio button that you can send your color to\n */\n theme?: string;\n /**\n * @deprecated set `size` on root RadioGroup instead\n * Radio button size\n */\n size?: RadioSize;\n /**\n * @deprecated set `value` on root Radio instead\n * The element value is required for RadioGroup\n */\n value?: RadioValue;\n /**\n * @deprecated set `defaultValue` on root RadioGroup instead\n * Default value if `value` property is not provided\n */\n defaultValue?: RadioValue;\n /**\n * @deprecated set `onChange` on root RadioGroup instead\n * Called when the value changes\n */\n onChange?: (value: boolean, e?: React.SyntheticEvent<HTMLInputElement>) => void;\n /**\n * @deprecated set `disabled` on root Radio instead\n * Blocks access and changes to the form field\n */\n disabled?: boolean;\n };\n\n/** @deprecated */\nexport interface IRadioCtx extends RadioCtx, UnknownProperties {}\nexport type RadioCtx = {\n getValueProps: PropGetterFn;\n getTextProps: PropGetterFn;\n};\n\ntype IntergalacticRadioGroupComponent = (<\n Value extends RadioValue,\n Tag extends Intergalactic.Tag = typeof Flex,\n>(\n props: Intergalactic.InternalTypings.ComponentProps<Tag, typeof Flex, RadioGroupProps<Value>>,\n) => Intergalactic.InternalTypings.ComponentRenderingResults) &\n Intergalactic.InternalTypings.ComponentAdditive<'div'>;\n\nexport type RadioValueControlProps = {};\nexport type RadioValueMarkProps = {};\n\ndeclare const RadioGroup: IntergalacticRadioGroupComponent;\n\nexport { RadioGroup };\n\ndeclare const Radio: Intergalactic.Component<'label', RadioProps, RadioCtx> & {\n Value: Intergalactic.Component<'input', RadioValueProps> & {\n Control: Intergalactic.Component<'input', RadioValueControlProps>;\n RadioMark: Intergalactic.Component<typeof Box, RadioValueMarkProps>;\n };\n Text: typeof Text;\n};\n\nexport default Radio;\n"],"mappings":""}
|
|
@@ -4,13 +4,6 @@ SRadio {
|
|
|
4
4
|
cursor: pointer;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
SRadio[disabled] {
|
|
8
|
-
opacity: var(--intergalactic-disabled-opacity, 0.3);
|
|
9
|
-
cursor: default;
|
|
10
|
-
pointer-events: none;
|
|
11
|
-
user-select: none;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
7
|
SText {
|
|
15
8
|
margin-left: var(--intergalactic-spacing-2x, 8px);
|
|
16
9
|
color: var(--intergalactic-text-primary, #191b23);
|
|
@@ -63,6 +56,13 @@ SValue {
|
|
|
63
56
|
}
|
|
64
57
|
}
|
|
65
58
|
|
|
59
|
+
SValue[disabled] {
|
|
60
|
+
opacity: var(--intergalactic-disabled-opacity, 0.3);
|
|
61
|
+
cursor: default;
|
|
62
|
+
pointer-events: none;
|
|
63
|
+
user-select: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
66
|
SValue[size='m'] {
|
|
67
67
|
width: 16px;
|
|
68
68
|
height: 16px;
|