@semcore/radio 6.9.2 → 6.10.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/lib/es6/Radio.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
3
4
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
@@ -7,31 +8,37 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
7
8
|
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
8
9
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
10
|
import { sstyled as _sstyled } from "@semcore/core";
|
|
11
|
+
import { assignProps as _assignProps5 } from "@semcore/core";
|
|
12
|
+
import { assignProps as _assignProps4 } from "@semcore/core";
|
|
10
13
|
import { assignProps as _assignProps3 } from "@semcore/core";
|
|
11
14
|
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
12
15
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
16
|
+
var _excluded = ["size", "state", "theme", "keyboardFocused", "value", "tag", "disabled", "includeInputProps"],
|
|
17
|
+
_excluded2 = ["children", "Children"];
|
|
13
18
|
import React from 'react';
|
|
14
19
|
import createComponent, { Component, CONTEXT_COMPONENT, sstyled, Root } from '@semcore/core';
|
|
15
20
|
import { Flex, Box } from '@semcore/flex-box';
|
|
16
|
-
import assignProps from '@semcore/utils/lib/assignProps';
|
|
21
|
+
import assignProps, { callAllEventHandlers } from '@semcore/utils/lib/assignProps';
|
|
17
22
|
import keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';
|
|
18
23
|
import resolveColor from '@semcore/utils/lib/color';
|
|
19
24
|
import getInputProps, { inputProps } from '@semcore/utils/lib/inputProps';
|
|
20
25
|
/*__reshadow-styles__:"./style/radio.shadow.css"*/
|
|
21
|
-
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".
|
|
22
|
-
"__SRadio": "
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"_state_normal": "
|
|
29
|
-
"_state_invalid": "
|
|
30
|
-
"__SControl": "
|
|
31
|
-
"_keyboardFocused": "
|
|
32
|
-
"_theme": "
|
|
33
|
-
"--theme": "--
|
|
26
|
+
var style = ( /*__reshadow_css_start__*/_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__*/, {
|
|
27
|
+
"__SRadio": "___SRadio_14o54_gg_",
|
|
28
|
+
"__SText": "___SText_14o54_gg_",
|
|
29
|
+
"_size_m": "_size_m_14o54_gg_",
|
|
30
|
+
"_size_l": "_size_l_14o54_gg_",
|
|
31
|
+
"__SValue": "___SValue_14o54_gg_",
|
|
32
|
+
"_disabled": "__disabled_14o54_gg_",
|
|
33
|
+
"_state_normal": "_state_normal_14o54_gg_",
|
|
34
|
+
"_state_invalid": "_state_invalid_14o54_gg_",
|
|
35
|
+
"__SControl": "___SControl_14o54_gg_",
|
|
36
|
+
"_keyboardFocused": "__keyboardFocused_14o54_gg_",
|
|
37
|
+
"_theme": "__theme_14o54_gg_",
|
|
38
|
+
"--theme": "--theme_14o54"
|
|
34
39
|
});
|
|
40
|
+
import logger from '@semcore/utils/lib/logger';
|
|
41
|
+
import { Text as TypographyText } from '@semcore/typography';
|
|
35
42
|
var RadioGroupRoot = /*#__PURE__*/function (_Component) {
|
|
36
43
|
_inherits(RadioGroupRoot, _Component);
|
|
37
44
|
var _super = _createSuper(RadioGroupRoot);
|
|
@@ -86,91 +93,116 @@ _defineProperty(RadioGroupRoot, "defaultProps", {
|
|
|
86
93
|
defaultValue: null
|
|
87
94
|
});
|
|
88
95
|
var RadioGroup = createComponent(RadioGroupRoot);
|
|
89
|
-
var
|
|
90
|
-
_inherits(
|
|
91
|
-
var _super2 = _createSuper(
|
|
92
|
-
function
|
|
96
|
+
var RadioRoot = /*#__PURE__*/function (_Component2) {
|
|
97
|
+
_inherits(RadioRoot, _Component2);
|
|
98
|
+
var _super2 = _createSuper(RadioRoot);
|
|
99
|
+
function RadioRoot() {
|
|
93
100
|
var _this;
|
|
94
|
-
_classCallCheck(this,
|
|
101
|
+
_classCallCheck(this, RadioRoot);
|
|
95
102
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
96
103
|
args[_key] = arguments[_key];
|
|
97
104
|
}
|
|
98
105
|
_this = _super2.call.apply(_super2, [this].concat(args));
|
|
99
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
107
|
+
hoistedDisabled: undefined
|
|
108
|
+
});
|
|
109
|
+
_defineProperty(_assertThisInitialized(_this), "hoistDisabled", function (disabled) {
|
|
110
|
+
logger.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']);
|
|
111
|
+
_this.setState({
|
|
112
|
+
hoistedDisabled: disabled
|
|
113
|
+
});
|
|
103
114
|
});
|
|
104
115
|
return _this;
|
|
105
116
|
}
|
|
106
|
-
_createClass(
|
|
107
|
-
key: "
|
|
108
|
-
value: function
|
|
117
|
+
_createClass(RadioRoot, [{
|
|
118
|
+
key: "getTextProps",
|
|
119
|
+
value: function getTextProps() {
|
|
109
120
|
// The default values are here, since you cannot rewrite out of context
|
|
110
|
-
var
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
disabled = _assignProps4.disabled;
|
|
118
|
-
var value = this.context.value;
|
|
119
|
-
var other = {};
|
|
120
|
-
// if used with the context
|
|
121
|
-
if (value !== undefined) {
|
|
122
|
-
other['checked'] = value === props.value;
|
|
123
|
-
other['onChange'] = this.bindHandlerChange(props.value);
|
|
124
|
-
if (this.asProps.tag !== 'label') {
|
|
125
|
-
other['onClick'] = this.bindHandlerChange(props.value);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return _objectSpread(_objectSpread({}, other), {}, {
|
|
129
|
-
state: state,
|
|
121
|
+
var _assignProps6 = assignProps(this.asProps, this.context),
|
|
122
|
+
_assignProps6$size = _assignProps6.size,
|
|
123
|
+
size = _assignProps6$size === void 0 ? 'm' : _assignProps6$size,
|
|
124
|
+
disabled = _assignProps6.disabled,
|
|
125
|
+
label = _assignProps6.label;
|
|
126
|
+
var hoistedDisabled = this.state.hoistedDisabled;
|
|
127
|
+
var textProps = {
|
|
130
128
|
size: size,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
children: label,
|
|
130
|
+
disabled: disabled !== null && disabled !== void 0 ? disabled : hoistedDisabled,
|
|
131
|
+
hoistDisabled: this.hoistDisabled,
|
|
132
|
+
rootDisabled: this.props.disabled
|
|
133
|
+
};
|
|
134
|
+
return textProps;
|
|
135
135
|
}
|
|
136
136
|
}, {
|
|
137
|
-
key: "
|
|
138
|
-
value: function
|
|
137
|
+
key: "getValueProps",
|
|
138
|
+
value: function getValueProps() {
|
|
139
|
+
var _this$props$size;
|
|
139
140
|
// The default values are here, since you cannot rewrite out of context
|
|
140
|
-
var
|
|
141
|
-
|
|
142
|
-
size =
|
|
141
|
+
var _assignProps7 = assignProps(this.context, this.asProps),
|
|
142
|
+
_assignProps7$size = _assignProps7.size,
|
|
143
|
+
size = _assignProps7$size === void 0 ? 'm' : _assignProps7$size,
|
|
144
|
+
_assignProps7$state = _assignProps7.state,
|
|
145
|
+
state = _assignProps7$state === void 0 ? 'normal' : _assignProps7$state,
|
|
146
|
+
theme = _assignProps7.theme,
|
|
147
|
+
disabled = _assignProps7.disabled,
|
|
148
|
+
name = _assignProps7.name;
|
|
149
|
+
var _this$asProps2 = this.asProps,
|
|
150
|
+
value = _this$asProps2.value,
|
|
151
|
+
checked = _this$asProps2.checked;
|
|
152
|
+
var hoistedDisabled = this.state.hoistedDisabled;
|
|
143
153
|
return {
|
|
144
|
-
size: size
|
|
154
|
+
size: (_this$props$size = this.props.size) !== null && _this$props$size !== void 0 ? _this$props$size : size,
|
|
155
|
+
disabled: disabled !== null && disabled !== void 0 ? disabled : hoistedDisabled,
|
|
156
|
+
state: state,
|
|
157
|
+
theme: theme,
|
|
158
|
+
value: value,
|
|
159
|
+
checked: checked,
|
|
160
|
+
name: name,
|
|
161
|
+
hoistDisabled: this.hoistDisabled,
|
|
162
|
+
rootDisabled: this.props.disabled
|
|
145
163
|
};
|
|
146
164
|
}
|
|
147
165
|
}, {
|
|
148
166
|
key: "render",
|
|
149
167
|
value: function render() {
|
|
150
168
|
var _ref2 = this.asProps,
|
|
151
|
-
|
|
169
|
+
_ref6;
|
|
152
170
|
var SRadio = Box;
|
|
153
|
-
var _this$
|
|
154
|
-
styles = _this$
|
|
155
|
-
Children = _this$
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
171
|
+
var _this$asProps3 = this.asProps,
|
|
172
|
+
styles = _this$asProps3.styles,
|
|
173
|
+
Children = _this$asProps3.Children,
|
|
174
|
+
hasChildren = _this$asProps3.children;
|
|
175
|
+
return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(SRadio, _ref6.cn("SRadio", _objectSpread({}, _assignProps2({
|
|
176
|
+
"tag": 'label',
|
|
177
|
+
"__excludeProps": ['onChange', 'label', 'disabled']
|
|
178
|
+
}, _ref2))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref6.cn("Children", {})) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Radio.Value, null), /*#__PURE__*/React.createElement(Radio.Text, null)));
|
|
159
179
|
}
|
|
160
180
|
}]);
|
|
161
|
-
return
|
|
181
|
+
return RadioRoot;
|
|
162
182
|
}(Component);
|
|
163
|
-
_defineProperty(
|
|
164
|
-
_defineProperty(
|
|
165
|
-
_defineProperty(
|
|
166
|
-
var
|
|
167
|
-
_inherits(
|
|
168
|
-
var _super3 = _createSuper(
|
|
169
|
-
function
|
|
170
|
-
|
|
171
|
-
|
|
183
|
+
_defineProperty(RadioRoot, "displayName", 'Radio');
|
|
184
|
+
_defineProperty(RadioRoot, "style", style);
|
|
185
|
+
_defineProperty(RadioRoot, "contextType", RadioGroup[CONTEXT_COMPONENT]);
|
|
186
|
+
var ValueRoot = /*#__PURE__*/function (_Component3) {
|
|
187
|
+
_inherits(ValueRoot, _Component3);
|
|
188
|
+
var _super3 = _createSuper(ValueRoot);
|
|
189
|
+
function ValueRoot() {
|
|
190
|
+
var _this2;
|
|
191
|
+
_classCallCheck(this, ValueRoot);
|
|
192
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
193
|
+
args[_key2] = arguments[_key2];
|
|
194
|
+
}
|
|
195
|
+
_this2 = _super3.call.apply(_super3, [this].concat(args));
|
|
196
|
+
_defineProperty(_assertThisInitialized(_this2), "bindHandlerChange", function (value) {
|
|
197
|
+
return function (e) {
|
|
198
|
+
if (typeof _this2.context.onChange === 'function') {
|
|
199
|
+
_this2.context.onChange(value, e);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
return _this2;
|
|
172
204
|
}
|
|
173
|
-
_createClass(
|
|
205
|
+
_createClass(ValueRoot, [{
|
|
174
206
|
key: "uncontrolledProps",
|
|
175
207
|
value: function uncontrolledProps() {
|
|
176
208
|
return {
|
|
@@ -179,48 +211,157 @@ var Value = /*#__PURE__*/function (_Component3) {
|
|
|
179
211
|
}
|
|
180
212
|
};
|
|
181
213
|
}
|
|
214
|
+
}, {
|
|
215
|
+
key: "getControlProps",
|
|
216
|
+
value: function getControlProps() {
|
|
217
|
+
var currentValue = this.context.value;
|
|
218
|
+
var _this$asProps4 = this.asProps,
|
|
219
|
+
forwardRef = _this$asProps4.forwardRef,
|
|
220
|
+
includeInputProps = _this$asProps4.includeInputProps,
|
|
221
|
+
state = _this$asProps4.state,
|
|
222
|
+
value = _this$asProps4.value;
|
|
223
|
+
var _getInputProps = getInputProps(this.asProps, includeInputProps),
|
|
224
|
+
_getInputProps2 = _slicedToArray(_getInputProps, 1),
|
|
225
|
+
commonControlProps = _getInputProps2[0];
|
|
226
|
+
var inputValue = value !== null && value !== void 0 ? value : '';
|
|
227
|
+
var controlProps = _objectSpread(_objectSpread({
|
|
228
|
+
ref: forwardRef,
|
|
229
|
+
state: state
|
|
230
|
+
}, commonControlProps), {}, {
|
|
231
|
+
value: inputValue
|
|
232
|
+
});
|
|
233
|
+
if (currentValue !== undefined) {
|
|
234
|
+
var _this$props = this.props,
|
|
235
|
+
onChange = _this$props.onChange,
|
|
236
|
+
onClick = _this$props.onClick;
|
|
237
|
+
controlProps.checked = currentValue === inputValue;
|
|
238
|
+
controlProps.onChange = callAllEventHandlers(onChange, this.bindHandlerChange(inputValue));
|
|
239
|
+
}
|
|
240
|
+
return controlProps;
|
|
241
|
+
}
|
|
242
|
+
}, {
|
|
243
|
+
key: "getRadioMarkProps",
|
|
244
|
+
value: function getRadioMarkProps() {
|
|
245
|
+
var currentValue = this.context.value;
|
|
246
|
+
var _this$asProps5 = this.asProps,
|
|
247
|
+
size = _this$asProps5.size,
|
|
248
|
+
state = _this$asProps5.state,
|
|
249
|
+
theme = _this$asProps5.theme,
|
|
250
|
+
keyboardFocused = _this$asProps5.keyboardFocused,
|
|
251
|
+
value = _this$asProps5.value,
|
|
252
|
+
tag = _this$asProps5.tag,
|
|
253
|
+
disabled = _this$asProps5.disabled,
|
|
254
|
+
includeInputProps = _this$asProps5.includeInputProps,
|
|
255
|
+
other = _objectWithoutProperties(_this$asProps5, _excluded);
|
|
256
|
+
var _getInputProps3 = getInputProps(other, includeInputProps),
|
|
257
|
+
_getInputProps4 = _slicedToArray(_getInputProps3, 2),
|
|
258
|
+
radioMarkProps = _getInputProps4[1];
|
|
259
|
+
var children = radioMarkProps.children,
|
|
260
|
+
Children = radioMarkProps.Children,
|
|
261
|
+
propsWithoutChildren = _objectWithoutProperties(radioMarkProps, _excluded2);
|
|
262
|
+
var inputValue = value !== null && value !== void 0 ? value : '';
|
|
263
|
+
var markProps = _objectSpread({
|
|
264
|
+
theme: theme,
|
|
265
|
+
size: size,
|
|
266
|
+
state: state,
|
|
267
|
+
keyboardFocused: keyboardFocused,
|
|
268
|
+
disabled: disabled
|
|
269
|
+
}, propsWithoutChildren);
|
|
270
|
+
if (currentValue !== undefined) {
|
|
271
|
+
var onClick = this.props.onClick;
|
|
272
|
+
if (tag !== 'label') {
|
|
273
|
+
markProps.onClick = callAllEventHandlers(onClick, this.bindHandlerChange(inputValue));
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return markProps;
|
|
277
|
+
}
|
|
278
|
+
}, {
|
|
279
|
+
key: "componentDidUpdate",
|
|
280
|
+
value: function componentDidUpdate() {
|
|
281
|
+
if (this.asProps.rootDisabled !== this.asProps.disabled) {
|
|
282
|
+
this.asProps.hoistDisabled(this.asProps.disabled);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}, {
|
|
286
|
+
key: "componentDidMount",
|
|
287
|
+
value: function componentDidMount() {
|
|
288
|
+
if (this.asProps.rootDisabled !== this.asProps.disabled) {
|
|
289
|
+
this.asProps.hoistDisabled(this.asProps.disabled);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
182
292
|
}, {
|
|
183
293
|
key: "render",
|
|
184
294
|
value: function render() {
|
|
185
|
-
var
|
|
186
|
-
var
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
controlProps = _getInputProps2[0],
|
|
196
|
-
boxProps = _getInputProps2[1];
|
|
197
|
-
return _ref5 = sstyled(styles), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SControl, _ref5.cn("SControl", _objectSpread({
|
|
198
|
-
"tag": 'input',
|
|
199
|
-
"type": 'radio'
|
|
200
|
-
}, controlProps))), /*#__PURE__*/React.createElement(SValue, _ref5.cn("SValue", _objectSpread({
|
|
201
|
-
"ref": forwardRef,
|
|
202
|
-
"use:theme": resolveColor(theme)
|
|
203
|
-
}, boxProps))));
|
|
295
|
+
var _ref8;
|
|
296
|
+
var _this$asProps6 = this.asProps,
|
|
297
|
+
styles = _this$asProps6.styles,
|
|
298
|
+
hasChildren = _this$asProps6.children,
|
|
299
|
+
Children = _this$asProps6.Children;
|
|
300
|
+
if (!hasChildren) {
|
|
301
|
+
var _ref7;
|
|
302
|
+
return _ref7 = sstyled(styles), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Radio.Value.Control, null), /*#__PURE__*/React.createElement(Radio.Value.RadioMark, null));
|
|
303
|
+
}
|
|
304
|
+
return _ref8 = sstyled(styles), /*#__PURE__*/React.createElement(Children, _ref8.cn("Children", {}));
|
|
204
305
|
}
|
|
205
306
|
}]);
|
|
206
|
-
return
|
|
307
|
+
return ValueRoot;
|
|
207
308
|
}(Component);
|
|
208
|
-
_defineProperty(
|
|
309
|
+
_defineProperty(ValueRoot, "defaultProps", {
|
|
209
310
|
includeInputProps: inputProps,
|
|
210
311
|
defaultChecked: false
|
|
211
312
|
});
|
|
212
|
-
_defineProperty(
|
|
213
|
-
_defineProperty(
|
|
214
|
-
|
|
313
|
+
_defineProperty(ValueRoot, "enhance", [keyboardFocusEnhance()]);
|
|
314
|
+
_defineProperty(ValueRoot, "displayName", 'Value');
|
|
315
|
+
_defineProperty(ValueRoot, "contextType", RadioGroup[CONTEXT_COMPONENT]);
|
|
316
|
+
_defineProperty(ValueRoot, "style", style);
|
|
317
|
+
var Control = function Control(props) {
|
|
215
318
|
var _ref3 = arguments[0],
|
|
216
|
-
|
|
217
|
-
var
|
|
319
|
+
_ref9;
|
|
320
|
+
var SControl = Box;
|
|
321
|
+
var styles = props.styles,
|
|
322
|
+
state = props.state;
|
|
323
|
+
return _ref9 = sstyled(styles), /*#__PURE__*/React.createElement(SControl, _ref9.cn("SControl", _objectSpread({}, _assignProps3({
|
|
324
|
+
"tag": 'input',
|
|
325
|
+
"type": 'radio',
|
|
326
|
+
"aria-invalid": state === 'invalid'
|
|
327
|
+
}, _ref3))));
|
|
328
|
+
};
|
|
329
|
+
Control.displayName = 'Control';
|
|
330
|
+
var RadioMark = function RadioMark(props) {
|
|
331
|
+
var _ref4 = arguments[0],
|
|
332
|
+
_ref10;
|
|
333
|
+
var SValue = Box;
|
|
334
|
+
var theme = props.theme,
|
|
335
|
+
styles = props.styles;
|
|
336
|
+
return _ref10 = sstyled(styles), /*#__PURE__*/React.createElement(SValue, _ref10.cn("SValue", _objectSpread({}, _assignProps4({
|
|
337
|
+
"tag": 'div',
|
|
338
|
+
"use:theme": resolveColor(theme)
|
|
339
|
+
}, _ref4))));
|
|
340
|
+
};
|
|
341
|
+
RadioMark.displayName = 'RadioMark';
|
|
342
|
+
var Text = function Text(props) {
|
|
343
|
+
var _ref5 = arguments[0],
|
|
344
|
+
_ref11;
|
|
345
|
+
var SText = TypographyText;
|
|
218
346
|
var styles = props.styles;
|
|
219
|
-
|
|
220
|
-
|
|
347
|
+
React.useEffect(function () {
|
|
348
|
+
if (props.rootDisabled !== props.disabled) {
|
|
349
|
+
props.hoistDisabled(props.disabled);
|
|
350
|
+
}
|
|
351
|
+
}, [props.rootDisabled, props.disabled, props.hoistDisabled]);
|
|
352
|
+
return _ref11 = sstyled(styles), /*#__PURE__*/React.createElement(SText, _ref11.cn("SText", _objectSpread({}, _assignProps5({
|
|
353
|
+
"tag": 'span'
|
|
354
|
+
}, _ref5))));
|
|
355
|
+
};
|
|
356
|
+
Text.displayName = 'Text';
|
|
221
357
|
export { inputProps, RadioGroup };
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
358
|
+
var Value = createComponent(ValueRoot, {
|
|
359
|
+
Control: Control,
|
|
360
|
+
RadioMark: RadioMark
|
|
361
|
+
});
|
|
362
|
+
var Radio = createComponent(RadioRoot, {
|
|
363
|
+
Text: Text,
|
|
364
|
+
Value: Value
|
|
225
365
|
});
|
|
366
|
+
export default Radio;
|
|
226
367
|
//# sourceMappingURL=Radio.js.map
|
package/lib/es6/Radio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","names":["React","createComponent","Component","CONTEXT_COMPONENT","sstyled","Root","Flex","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","disabled","render","_ref","Children","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","tag","_objectSpread","getTextProps","_assignProps5","_assignProps5$size","_ref2","_ref4","SRadio","_this$asProps2","styles","cn","_assignProps2","Value","_Component3","_super3","target","_ref5","SValue","SControl","_this$asProps3","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 { 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(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,IAAI,EAAEC,GAAG,QAAQ,mBAAmB;AAC7C,OAAOC,WAAW,MAAM,gCAAgC;AACxD,OAAOC,oBAAoB,MAAM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AAC;AAAAvD,eAAA,CAJGuC,KAAK,aAKQ,CAACvE,oBAAoB,EAAE,CAAC;AAAAgC,eAAA,CALrCuC,KAAK,gBAMW,CAAC,UAAU,CAAC;AAwBlC,SAASiB,IAAIA,CAACpC,KAAK,EAAE;EAAA,IAAAqC,KAAA,GAAAC,YAAA;IAAAC,KAAA;EACnB,IAAMC,KAAK,GAE2B9F,GAAG;EADzC,IAAQsE,MAAM,GAAKhB,KAAK,CAAhBgB,MAAM;EACd,OAAAuB,KAAA,GAAOhG,OAAO,CAACyE,MAAM,CAAC,eAAC7E,KAAA,CAAAuC,aAAA,CAAC8D,KAAK,EAAAD,KAAA,CAAAtB,EAAA,UAAAT,aAAA,KAAAiC,aAAA,KAAAJ,KAAA,IAAgB;AAC/C;AAEA,SAAStF,UAAU,EAAEgC,UAAU;AAC/B,eAAe3C,eAAe,CAAC4C,KAAK,EAAE;EACpCmC,KAAK,EAALA,KAAK;EACLiB,IAAI,EAAJA;AACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"Radio.js","names":["React","createComponent","Component","CONTEXT_COMPONENT","sstyled","Root","Flex","Box","assignProps","callAllEventHandlers","keyboardFocusEnhance","resolveColor","getInputProps","inputProps","style","_sstyled","insert","logger","Text","TypographyText","RadioGroupRoot","_Component","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","_createClass","key","value","uncontrolledProps","setContext","_this$asProps","asProps","theme","size","name","onChange","disabled","render","_ref","Children","createElement","_assignProps","_defineProperty","state","defaultValue","RadioGroup","RadioRoot","_Component2","_super2","_this","_len","length","args","Array","_key","call","concat","_assertThisInitialized","hoistedDisabled","undefined","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","_this$asProps3","styles","hasChildren","cn","_objectSpread","_assignProps2","Fragment","Radio","Value","ValueRoot","_Component3","_super3","_this2","_len2","_key2","e","target","getControlProps","currentValue","_this$asProps4","forwardRef","includeInputProps","_getInputProps","_getInputProps2","_slicedToArray","commonControlProps","inputValue","controlProps","ref","_this$props","onClick","bindHandlerChange","getRadioMarkProps","_this$asProps5","keyboardFocused","tag","other","_objectWithoutProperties","_excluded","_getInputProps3","_getInputProps4","radioMarkProps","propsWithoutChildren","_excluded2","markProps","componentDidUpdate","componentDidMount","_ref8","_this$asProps6","_ref7","Control","RadioMark","defaultChecked","_ref3","arguments[0]","_ref9","SControl","_assignProps3","displayName","_ref4","_ref10","SValue","_assignProps4","_ref5","_ref11","SText","useEffect","_assignProps5"],"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":";;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,eAAe,IAAIC,SAAS,EAAEC,iBAAiB,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AAC5F,SAASC,IAAI,EAAEC,GAAG,QAAQ,mBAAmB;AAC7C,OAAOC,WAAW,IAAIC,oBAAoB,QAAQ,gCAAgC;AAClF,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;AAG1E,OAAOC,MAAM,MAAM,2BAA2B;AAC9C,SAASC,IAAI,IAAIC,cAAc,QAAQ,qBAAqB;AAAC,IAEvDC,cAAc,0BAAAC,UAAA;EAAAC,SAAA,CAAAF,cAAA,EAAAC,UAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,cAAA;EAAA,SAAAA,eAAA;IAAAK,eAAA,OAAAL,cAAA;IAAA,OAAAG,MAAA,CAAAG,KAAA,OAAAC,SAAA;EAAA;EAAAC,YAAA,CAAAR,cAAA;IAAAS,GAAA;IAAAC,KAAA,EASlB,SAAAC,kBAAA,EAAoB;MAClB,OAAO;QACLD,KAAK,EAAE;MACT,CAAC;IACH;EAAC;IAAAD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CAAhBY,MAAM;EAEdtF,KAAK,CAACuJ,SAAS,CAAC,YAAM;IACpB,IAAI7E,KAAK,CAACD,YAAY,KAAKC,KAAK,CAACnC,QAAQ,EAAE;MACzCmC,KAAK,CAACF,aAAa,CAACE,KAAK,CAACnC,QAAQ,CAAC;IACrC;EACF,CAAC,EAAE,CAACmC,KAAK,CAACD,YAAY,EAAEC,KAAK,CAACnC,QAAQ,EAAEmC,KAAK,CAACF,aAAa,CAAC,CAAC;EAE7D,OAAA6E,MAAA,GAAOjJ,OAAO,CAACkF,MAAM,CAAC,eAACtF,KAAA,CAAA2C,aAAA,CAAC2G,KAAK,EAAAD,MAAA,CAAA7D,EAAA,UAAAC,aAAA,KAAA+D,aAAA;IAAA,OAA6B;EAAM,GAAAJ,KAAA,IAAG;AACrE,CAAC;AACDlI,IAAI,CAAC6H,WAAW,GAAG,MAAM;AAEzB,SAASlI,UAAU,EAAEmC,UAAU;AAE/B,IAAM6C,KAAK,GAAG5F,eAAe,CAAC6F,SAAS,EAAE;EACvCyC,OAAO,EAAPA,OAAO;EACPC,SAAS,EAATA;AACF,CAAC,CAAC;AAEF,IAAM5C,KAAK,GAAG3F,eAAe,CAACgD,SAAS,EAAE;EACvC/B,IAAI,EAAJA,IAAI;EACJ2E,KAAK,EAALA;AACF,CAAC,CAAC;AAEF,eAAeD,KAAK"}
|
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 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;
|