@semcore/radio 16.0.0-prerelease.4 → 16.0.0-prerelease.7
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/lib/esm/Radio.mjs +252 -195
- package/lib/esm/index.mjs +6 -6
- package/package.json +4 -4
package/lib/esm/Radio.mjs
CHANGED
|
@@ -1,270 +1,327 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { sstyled
|
|
11
|
-
import
|
|
12
|
-
import { Flex
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import { inputProps as
|
|
17
|
-
import { useColorResolver
|
|
18
|
-
import
|
|
19
|
-
import { Text as
|
|
20
|
-
var
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
5
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
6
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
7
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
8
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
9
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
10
|
+
import { sstyled, createComponent, CONTEXT_COMPONENT, assignProps, Component } from "@semcore/core";
|
|
11
|
+
import React from "react";
|
|
12
|
+
import { Flex, Box, InvalidStateBox } from "@semcore/flex-box";
|
|
13
|
+
import assignProps$1, { callAllEventHandlers } from "@semcore/core/lib/utils/assignProps";
|
|
14
|
+
import resolveColorEnhance from "@semcore/core/lib/utils/enhances/resolveColorEnhance";
|
|
15
|
+
import getInputProps, { inputProps } from "@semcore/core/lib/utils/inputProps";
|
|
16
|
+
import { inputProps as inputProps2 } from "@semcore/core/lib/utils/inputProps";
|
|
17
|
+
import { useColorResolver } from "@semcore/core/lib/utils/use/useColorResolver";
|
|
18
|
+
import logger from "@semcore/core/lib/utils/logger";
|
|
19
|
+
import { Text as Text$1 } from "@semcore/typography";
|
|
20
|
+
var _excluded = ["size", "state", "theme", "keyboardFocused", "value", "tag", "disabled", "includeInputProps", "resolveColor"], _excluded2 = ["children", "Children"];
|
|
21
|
+
var style = (
|
|
21
22
|
/*__reshadow_css_start__*/
|
|
22
|
-
(
|
|
23
|
+
(sstyled.insert(
|
|
23
24
|
/*__inner_css_start__*/
|
|
24
25
|
'.___SRadio_lyu5n_gg_{display:inline-flex;align-items:flex-start;cursor:pointer}.___SRadio_lyu5n_gg_ .___SText_lyu5n_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);color:var(--intergalactic-text-primary, #191b23)}.___SRadio_lyu5n_gg_ .___SText_lyu5n_gg_.__color_lyu5n_gg_{color:var(--color_lyu5n)}.___SRadio_lyu5n_gg_.__disabled_lyu5n_gg_{pointer-events:none}.___SText_lyu5n_gg_._size_m_lyu5n_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___SText_lyu5n_gg_._size_l_lyu5n_gg_{font-size:var(--intergalactic-fs-300, 16px);line-height:var(--intergalactic-lh-300, 150%)}.___SValue_lyu5n_gg_{position:relative;flex-shrink:0;padding:0;outline:0;z-index:0;margin-top:var(--intergalactic-spacing-05x, 2px)}.___SValue_lyu5n_gg_::after,.___SValue_lyu5n_gg_::before{content:"";position:absolute;right:0;bottom:0;border-radius:50%;background:var(--intergalactic-bg-primary-neutral, #ffffff)}.___SValue_lyu5n_gg_::before{top:0;left:0;border:1px solid;transition:calc(var(--intergalactic-duration-control, 200)*1ms) all ease-in-out}.___SValue_lyu5n_gg_::after{top:50%;left:50%;transform:translate(-50%,-50%);width:0;height:0}.___SValue_lyu5n_gg_.__disabled_lyu5n_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_lyu5n_gg_._size_m_lyu5n_gg_{width:16px;height:16px}.___SValue_lyu5n_gg_._size_m_lyu5n_gg_ .___SInvalidPattern_lyu5n_gg_:before{width:14px;height:14px}.___SValue_lyu5n_gg_._size_l_lyu5n_gg_{width:20px;height:20px}.___SValue_lyu5n_gg_._size_l_lyu5n_gg_ .___SInvalidPattern_lyu5n_gg_:before{width:18px;height:18px}.___SValue_lyu5n_gg_._state_normal_lyu5n_gg_::before{border-color:var(--intergalactic-border-primary, #c4c7cf)}.___SValue_lyu5n_gg_._state_invalid_lyu5n_gg_::before{border-color:var(--intergalactic-border-critical-active, #d1002f)}.___SControl_lyu5n_gg_{position:absolute;clip:rect(1px,1px,1px,1px)}.___SControl_lyu5n_gg_:checked~.___SValue_lyu5n_gg_::before{border-color:var(--intergalactic-control-primary-info, #008ff8);background-color:var(--intergalactic-control-primary-info, #008ff8)}.___SControl_lyu5n_gg_:checked~.___SValue_lyu5n_gg_._size_m_lyu5n_gg_::after{width:6px;height:6px}.___SControl_lyu5n_gg_:checked~.___SValue_lyu5n_gg_._size_l_lyu5n_gg_::after{width:8px;height:8px}.___SControl_lyu5n_gg_:focus-visible+.___SValue_lyu5n_gg_._state_normal_lyu5n_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)}.___SControl_lyu5n_gg_:focus-visible+.___SValue_lyu5n_gg_._state_invalid_lyu5n_gg_::before{box-shadow:var(--intergalactic-keyboard-focus-invalid, 0px 0px 0px 3px rgba(255, 73, 83, 0.5))}.___SControl_lyu5n_gg_:checked~.___SValue_lyu5n_gg_.__theme_lyu5n_gg_::before{border-color:var(--theme_lyu5n);background-color:var(--theme_lyu5n)}.___SValue_lyu5n_gg_._state_normal_lyu5n_gg_.__theme_lyu5n_gg_::before{border-color:var(--theme_lyu5n)}.___SInvalidPattern_lyu5n_gg_{background:0 0;overflow:hidden}.___SInvalidPattern_lyu5n_gg_:before{content:"";position:absolute;top:1px;left:1px;border-radius:50%;background-image:var(--intergalactic-border-critical-pattern, repeating-linear-gradient(315deg, rgba(209, 0, 47, 1) 0, rgba(209, 0, 47, 1) 2px, transparent 0, transparent 50%));background-size:6px 6px;background-color:var(--intergalactic-bg-primary-neutral, #ffffff)}',
|
|
25
26
|
"lyu5n_gg_"
|
|
26
27
|
), {
|
|
27
|
-
__SRadio: "___SRadio_lyu5n_gg_",
|
|
28
|
-
_disabled: "__disabled_lyu5n_gg_",
|
|
29
|
-
__SText: "___SText_lyu5n_gg_",
|
|
30
|
-
_size_m: "_size_m_lyu5n_gg_",
|
|
31
|
-
_size_l: "_size_l_lyu5n_gg_",
|
|
32
|
-
__SValue: "___SValue_lyu5n_gg_",
|
|
33
|
-
_state_normal: "_state_normal_lyu5n_gg_",
|
|
34
|
-
_state_invalid: "_state_invalid_lyu5n_gg_",
|
|
35
|
-
__SControl: "___SControl_lyu5n_gg_",
|
|
36
|
-
_theme: "__theme_lyu5n_gg_",
|
|
28
|
+
"__SRadio": "___SRadio_lyu5n_gg_",
|
|
29
|
+
"_disabled": "__disabled_lyu5n_gg_",
|
|
30
|
+
"__SText": "___SText_lyu5n_gg_",
|
|
31
|
+
"_size_m": "_size_m_lyu5n_gg_",
|
|
32
|
+
"_size_l": "_size_l_lyu5n_gg_",
|
|
33
|
+
"__SValue": "___SValue_lyu5n_gg_",
|
|
34
|
+
"_state_normal": "_state_normal_lyu5n_gg_",
|
|
35
|
+
"_state_invalid": "_state_invalid_lyu5n_gg_",
|
|
36
|
+
"__SControl": "___SControl_lyu5n_gg_",
|
|
37
|
+
"_theme": "__theme_lyu5n_gg_",
|
|
37
38
|
"--theme": "--theme_lyu5n",
|
|
38
|
-
_color: "__color_lyu5n_gg_",
|
|
39
|
+
"_color": "__color_lyu5n_gg_",
|
|
39
40
|
"--color": "--color_lyu5n",
|
|
40
|
-
__SInvalidPattern: "___SInvalidPattern_lyu5n_gg_"
|
|
41
|
+
"__SInvalidPattern": "___SInvalidPattern_lyu5n_gg_"
|
|
41
42
|
})
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
);
|
|
44
|
+
var RadioGroupRoot = /* @__PURE__ */ function(_Component) {
|
|
45
|
+
_inherits(RadioGroupRoot2, _Component);
|
|
46
|
+
var _super = _createSuper(RadioGroupRoot2);
|
|
47
|
+
function RadioGroupRoot2() {
|
|
48
|
+
_classCallCheck(this, RadioGroupRoot2);
|
|
49
|
+
return _super.apply(this, arguments);
|
|
47
50
|
}
|
|
48
|
-
|
|
51
|
+
_createClass(RadioGroupRoot2, [{
|
|
49
52
|
key: "uncontrolledProps",
|
|
50
|
-
value: function() {
|
|
53
|
+
value: function uncontrolledProps() {
|
|
51
54
|
return {
|
|
52
55
|
value: null
|
|
53
56
|
};
|
|
54
57
|
}
|
|
55
58
|
}, {
|
|
56
59
|
key: "setContext",
|
|
57
|
-
value: function() {
|
|
58
|
-
var
|
|
60
|
+
value: function setContext() {
|
|
61
|
+
var _this$asProps = this.asProps, theme = _this$asProps.theme, size = _this$asProps.size, name = _this$asProps.name, value = _this$asProps.value, onChange = _this$asProps.onChange, disabled = _this$asProps.disabled;
|
|
59
62
|
return {
|
|
60
|
-
onChange
|
|
61
|
-
value
|
|
62
|
-
theme
|
|
63
|
-
size
|
|
64
|
-
name
|
|
65
|
-
disabled
|
|
63
|
+
onChange,
|
|
64
|
+
value,
|
|
65
|
+
theme,
|
|
66
|
+
size,
|
|
67
|
+
name,
|
|
68
|
+
disabled
|
|
66
69
|
};
|
|
67
70
|
}
|
|
68
71
|
}, {
|
|
69
72
|
key: "render",
|
|
70
|
-
value: function() {
|
|
71
|
-
var
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
value: function render() {
|
|
74
|
+
var _ref = this.asProps;
|
|
75
|
+
var Children = this.asProps.Children;
|
|
76
|
+
return /* @__PURE__ */ React.createElement(Flex, assignProps({
|
|
77
|
+
"direction": "column",
|
|
78
|
+
"role": "group",
|
|
79
|
+
"__excludeProps": ["onChange"]
|
|
80
|
+
}, _ref), /* @__PURE__ */ React.createElement(Children, null));
|
|
77
81
|
}
|
|
78
|
-
}])
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
}]);
|
|
83
|
+
return RadioGroupRoot2;
|
|
84
|
+
}(Component);
|
|
85
|
+
_defineProperty(RadioGroupRoot, "displayName", "RadioGroup");
|
|
86
|
+
_defineProperty(RadioGroupRoot, "defaultProps", {
|
|
82
87
|
defaultValue: null
|
|
83
88
|
});
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
var RadioGroup = createComponent(RadioGroupRoot);
|
|
90
|
+
var RadioRoot = /* @__PURE__ */ function(_Component2) {
|
|
91
|
+
_inherits(RadioRoot2, _Component2);
|
|
92
|
+
var _super2 = _createSuper(RadioRoot2);
|
|
93
|
+
function RadioRoot2() {
|
|
94
|
+
var _this;
|
|
95
|
+
_classCallCheck(this, RadioRoot2);
|
|
96
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
97
|
+
args[_key] = arguments[_key];
|
|
98
|
+
}
|
|
99
|
+
_this = _super2.call.apply(_super2, [this].concat(args));
|
|
100
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
93
101
|
hoistedDisabled: void 0
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
|
|
102
|
+
});
|
|
103
|
+
_defineProperty(_assertThisInitialized(_this), "hoistDisabled", function(disabled) {
|
|
104
|
+
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"]);
|
|
105
|
+
_this.setState({
|
|
106
|
+
hoistedDisabled: disabled
|
|
97
107
|
});
|
|
98
|
-
})
|
|
108
|
+
});
|
|
109
|
+
return _this;
|
|
99
110
|
}
|
|
100
|
-
|
|
111
|
+
_createClass(RadioRoot2, [{
|
|
101
112
|
key: "getTextProps",
|
|
102
|
-
value: function() {
|
|
103
|
-
var
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
113
|
+
value: function getTextProps() {
|
|
114
|
+
var _assignProps6 = assignProps$1(this.asProps, this.context), _assignProps6$size = _assignProps6.size, size = _assignProps6$size === void 0 ? "m" : _assignProps6$size, disabled = _assignProps6.disabled, label = _assignProps6.label;
|
|
115
|
+
var hoistedDisabled = this.state.hoistedDisabled;
|
|
116
|
+
var textProps = {
|
|
117
|
+
size,
|
|
118
|
+
children: label,
|
|
119
|
+
disabled: disabled !== null && disabled !== void 0 ? disabled : hoistedDisabled,
|
|
107
120
|
hoistDisabled: this.hoistDisabled,
|
|
108
121
|
rootDisabled: this.props.disabled
|
|
109
122
|
};
|
|
110
|
-
return
|
|
123
|
+
return textProps;
|
|
111
124
|
}
|
|
112
125
|
}, {
|
|
113
126
|
key: "getValueProps",
|
|
114
|
-
value: function() {
|
|
115
|
-
var
|
|
127
|
+
value: function getValueProps() {
|
|
128
|
+
var _this$props$size;
|
|
129
|
+
var _assignProps7 = assignProps$1(this.asProps, this.context), _assignProps7$size = _assignProps7.size, size = _assignProps7$size === void 0 ? "m" : _assignProps7$size, _assignProps7$state = _assignProps7.state, state = _assignProps7$state === void 0 ? "normal" : _assignProps7$state, theme = _assignProps7.theme, disabled = _assignProps7.disabled, name = _assignProps7.name;
|
|
130
|
+
var _this$asProps2 = this.asProps, value = _this$asProps2.value, checked = _this$asProps2.checked;
|
|
131
|
+
var hoistedDisabled = this.state.hoistedDisabled;
|
|
116
132
|
return {
|
|
117
|
-
size: (
|
|
118
|
-
disabled:
|
|
119
|
-
state
|
|
120
|
-
theme
|
|
121
|
-
value
|
|
122
|
-
checked
|
|
123
|
-
name
|
|
133
|
+
size: (_this$props$size = this.props.size) !== null && _this$props$size !== void 0 ? _this$props$size : size,
|
|
134
|
+
disabled: disabled !== null && disabled !== void 0 ? disabled : hoistedDisabled,
|
|
135
|
+
state,
|
|
136
|
+
theme,
|
|
137
|
+
value,
|
|
138
|
+
checked,
|
|
139
|
+
name,
|
|
124
140
|
hoistDisabled: this.hoistDisabled,
|
|
125
141
|
rootDisabled: this.props.disabled
|
|
126
142
|
};
|
|
127
143
|
}
|
|
128
144
|
}, {
|
|
129
145
|
key: "render",
|
|
130
|
-
value: function() {
|
|
131
|
-
var
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
146
|
+
value: function render() {
|
|
147
|
+
var _ref2 = this.asProps, _ref6;
|
|
148
|
+
var SRadio = Box;
|
|
149
|
+
var _this$asProps3 = this.asProps, styles = _this$asProps3.styles, Children = _this$asProps3.Children, hasChildren = _this$asProps3.children;
|
|
150
|
+
return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(SRadio, _ref6.cn("SRadio", _objectSpread({}, assignProps({
|
|
151
|
+
"tag": "label",
|
|
152
|
+
"__excludeProps": ["onChange", "label", "disabled"]
|
|
153
|
+
}, _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)));
|
|
154
|
+
}
|
|
155
|
+
}]);
|
|
156
|
+
return RadioRoot2;
|
|
157
|
+
}(Component);
|
|
158
|
+
_defineProperty(RadioRoot, "displayName", "Radio");
|
|
159
|
+
_defineProperty(RadioRoot, "style", style);
|
|
160
|
+
_defineProperty(RadioRoot, "contextType", RadioGroup[CONTEXT_COMPONENT]);
|
|
161
|
+
var ValueRoot = /* @__PURE__ */ function(_Component3) {
|
|
162
|
+
_inherits(ValueRoot2, _Component3);
|
|
163
|
+
var _super3 = _createSuper(ValueRoot2);
|
|
164
|
+
function ValueRoot2() {
|
|
165
|
+
var _this2;
|
|
166
|
+
_classCallCheck(this, ValueRoot2);
|
|
167
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
168
|
+
args[_key2] = arguments[_key2];
|
|
136
169
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
D(l, g);
|
|
144
|
-
var o = T(l);
|
|
145
|
-
function l() {
|
|
146
|
-
var r;
|
|
147
|
-
V(this, l);
|
|
148
|
-
for (var t = arguments.length, e = new Array(t), a = 0; a < t; a++)
|
|
149
|
-
e[a] = arguments[a];
|
|
150
|
-
return r = o.call.apply(o, [this].concat(e)), d(R(r), "bindHandlerChange", function(n) {
|
|
151
|
-
return function(i) {
|
|
152
|
-
typeof r.context.onChange == "function" && r.context.onChange(n, i);
|
|
170
|
+
_this2 = _super3.call.apply(_super3, [this].concat(args));
|
|
171
|
+
_defineProperty(_assertThisInitialized(_this2), "bindHandlerChange", function(value) {
|
|
172
|
+
return function(e) {
|
|
173
|
+
if (typeof _this2.context.onChange === "function") {
|
|
174
|
+
_this2.context.onChange(value, e);
|
|
175
|
+
}
|
|
153
176
|
};
|
|
154
|
-
})
|
|
177
|
+
});
|
|
178
|
+
return _this2;
|
|
155
179
|
}
|
|
156
|
-
|
|
180
|
+
_createClass(ValueRoot2, [{
|
|
157
181
|
key: "uncontrolledProps",
|
|
158
|
-
value: function() {
|
|
182
|
+
value: function uncontrolledProps() {
|
|
159
183
|
return {
|
|
160
|
-
checked: function(e) {
|
|
184
|
+
checked: function checked(e) {
|
|
161
185
|
return e.target.checked;
|
|
162
186
|
}
|
|
163
187
|
};
|
|
164
188
|
}
|
|
165
189
|
}, {
|
|
166
190
|
key: "getControlProps",
|
|
167
|
-
value: function() {
|
|
168
|
-
var
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
191
|
+
value: function getControlProps() {
|
|
192
|
+
var currentValue = this.context.value;
|
|
193
|
+
var _this$asProps4 = this.asProps, forwardRef = _this$asProps4.forwardRef, includeInputProps = _this$asProps4.includeInputProps, state = _this$asProps4.state, value = _this$asProps4.value;
|
|
194
|
+
var _getInputProps = getInputProps(this.asProps, includeInputProps), _getInputProps2 = _slicedToArray(_getInputProps, 1), commonControlProps = _getInputProps2[0];
|
|
195
|
+
var inputValue = value !== null && value !== void 0 ? value : "";
|
|
196
|
+
var controlProps = _objectSpread(_objectSpread({
|
|
197
|
+
ref: forwardRef,
|
|
198
|
+
state
|
|
199
|
+
}, commonControlProps), {}, {
|
|
200
|
+
value: inputValue
|
|
173
201
|
});
|
|
174
|
-
if (
|
|
175
|
-
var
|
|
176
|
-
|
|
202
|
+
if (currentValue !== void 0) {
|
|
203
|
+
var _this$props = this.props, onChange = _this$props.onChange;
|
|
204
|
+
_this$props.onClick;
|
|
205
|
+
controlProps.checked = currentValue === inputValue;
|
|
206
|
+
controlProps.onChange = callAllEventHandlers(onChange, this.bindHandlerChange(inputValue));
|
|
177
207
|
}
|
|
178
|
-
return
|
|
208
|
+
return controlProps;
|
|
179
209
|
}
|
|
180
210
|
}, {
|
|
181
211
|
key: "getRadioMarkProps",
|
|
182
|
-
value: function() {
|
|
183
|
-
var
|
|
184
|
-
|
|
185
|
-
var
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
212
|
+
value: function getRadioMarkProps() {
|
|
213
|
+
var currentValue = this.context.value;
|
|
214
|
+
var _this$asProps5 = this.asProps, size = _this$asProps5.size, state = _this$asProps5.state, theme = _this$asProps5.theme, keyboardFocused = _this$asProps5.keyboardFocused, value = _this$asProps5.value, tag = _this$asProps5.tag, disabled = _this$asProps5.disabled, includeInputProps = _this$asProps5.includeInputProps, resolveColor = _this$asProps5.resolveColor, other = _objectWithoutProperties(_this$asProps5, _excluded);
|
|
215
|
+
var _getInputProps3 = getInputProps(other, includeInputProps), _getInputProps4 = _slicedToArray(_getInputProps3, 2), commonControlProps = _getInputProps4[0], radioMarkProps = _getInputProps4[1];
|
|
216
|
+
radioMarkProps.children;
|
|
217
|
+
radioMarkProps.Children;
|
|
218
|
+
var propsWithoutChildren = _objectWithoutProperties(radioMarkProps, _excluded2);
|
|
219
|
+
var inputValue = value !== null && value !== void 0 ? value : "";
|
|
220
|
+
var markProps = _objectSpread({
|
|
221
|
+
theme,
|
|
222
|
+
size,
|
|
223
|
+
state,
|
|
224
|
+
keyboardFocused,
|
|
225
|
+
disabled,
|
|
226
|
+
resolveColor,
|
|
227
|
+
checked: commonControlProps.checked
|
|
228
|
+
}, propsWithoutChildren);
|
|
229
|
+
if (currentValue !== void 0) {
|
|
230
|
+
var onClick = this.props.onClick;
|
|
231
|
+
if (tag !== "label") {
|
|
232
|
+
markProps.onClick = callAllEventHandlers(onClick, this.bindHandlerChange(inputValue));
|
|
233
|
+
}
|
|
197
234
|
}
|
|
198
|
-
return
|
|
235
|
+
return markProps;
|
|
199
236
|
}
|
|
200
237
|
}, {
|
|
201
238
|
key: "componentDidUpdate",
|
|
202
|
-
value: function() {
|
|
203
|
-
this.asProps.rootDisabled !== this.asProps.disabled
|
|
239
|
+
value: function componentDidUpdate() {
|
|
240
|
+
if (this.asProps.rootDisabled !== this.asProps.disabled) {
|
|
241
|
+
this.asProps.hoistDisabled(this.asProps.disabled);
|
|
242
|
+
}
|
|
204
243
|
}
|
|
205
244
|
}, {
|
|
206
245
|
key: "componentDidMount",
|
|
207
|
-
value: function() {
|
|
208
|
-
this.asProps.rootDisabled !== this.asProps.disabled
|
|
246
|
+
value: function componentDidMount() {
|
|
247
|
+
if (this.asProps.rootDisabled !== this.asProps.disabled) {
|
|
248
|
+
this.asProps.hoistDisabled(this.asProps.disabled);
|
|
249
|
+
}
|
|
209
250
|
}
|
|
210
251
|
}, {
|
|
211
252
|
key: "render",
|
|
212
|
-
value: function() {
|
|
213
|
-
var
|
|
214
|
-
|
|
253
|
+
value: function render() {
|
|
254
|
+
var _ref8;
|
|
255
|
+
var _this$asProps6 = this.asProps, styles = _this$asProps6.styles, hasChildren = _this$asProps6.children, Children = _this$asProps6.Children;
|
|
256
|
+
if (!hasChildren) {
|
|
257
|
+
return sstyled(styles), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Radio.Value.Control, null), /* @__PURE__ */ React.createElement(Radio.Value.RadioMark, null));
|
|
258
|
+
}
|
|
259
|
+
return _ref8 = sstyled(styles), /* @__PURE__ */ React.createElement(Children, _ref8.cn("Children", {}));
|
|
215
260
|
}
|
|
216
|
-
}])
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
261
|
+
}]);
|
|
262
|
+
return ValueRoot2;
|
|
263
|
+
}(Component);
|
|
264
|
+
_defineProperty(ValueRoot, "defaultProps", {
|
|
265
|
+
includeInputProps: inputProps,
|
|
266
|
+
defaultChecked: false
|
|
221
267
|
});
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
var
|
|
227
|
-
var
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
"
|
|
232
|
-
|
|
268
|
+
_defineProperty(ValueRoot, "enhance", [resolveColorEnhance()]);
|
|
269
|
+
_defineProperty(ValueRoot, "displayName", "Value");
|
|
270
|
+
_defineProperty(ValueRoot, "contextType", RadioGroup[CONTEXT_COMPONENT]);
|
|
271
|
+
_defineProperty(ValueRoot, "style", style);
|
|
272
|
+
var Control = function Control2(props) {
|
|
273
|
+
var _ref3 = arguments[0], _ref9;
|
|
274
|
+
var SControl = Box;
|
|
275
|
+
var styles = props.styles, state = props.state;
|
|
276
|
+
return _ref9 = sstyled(styles), /* @__PURE__ */ React.createElement(SControl, _ref9.cn("SControl", _objectSpread({}, assignProps({
|
|
277
|
+
"tag": "input",
|
|
278
|
+
"type": "radio",
|
|
279
|
+
"aria-invalid": state === "invalid"
|
|
280
|
+
}, _ref3))));
|
|
233
281
|
};
|
|
234
|
-
|
|
235
|
-
var
|
|
236
|
-
var
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
282
|
+
Control.displayName = "Control";
|
|
283
|
+
var RadioMark = function RadioMark2(props) {
|
|
284
|
+
var _ref4 = arguments[0], _ref10;
|
|
285
|
+
var SValue = Box;
|
|
286
|
+
var SInvalidPattern = InvalidStateBox;
|
|
287
|
+
var theme = props.theme, styles = props.styles, resolveColor = props.resolveColor, state = props.state, checked = props.checked;
|
|
288
|
+
return _ref10 = sstyled(styles), /* @__PURE__ */ React.createElement(SValue, _ref10.cn("SValue", _objectSpread({}, assignProps({
|
|
289
|
+
"tag": "div",
|
|
290
|
+
"use:theme": resolveColor(theme),
|
|
291
|
+
"aria-hidden": true
|
|
292
|
+
}, _ref4))), state === "invalid" && !checked && /* @__PURE__ */ React.createElement(SInvalidPattern, _ref10.cn("SInvalidPattern", {})));
|
|
242
293
|
};
|
|
243
|
-
|
|
244
|
-
var
|
|
245
|
-
var
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
294
|
+
RadioMark.displayName = "RadioMark";
|
|
295
|
+
var Text = function Text2(props) {
|
|
296
|
+
var _ref5 = arguments[0], _ref11;
|
|
297
|
+
var SText = Text$1;
|
|
298
|
+
var styles = props.styles, color = props.color;
|
|
299
|
+
React.useEffect(function() {
|
|
300
|
+
if (props.rootDisabled !== props.disabled) {
|
|
301
|
+
props.hoistDisabled(props.disabled);
|
|
302
|
+
}
|
|
303
|
+
}, [props.rootDisabled, props.disabled, props.hoistDisabled]);
|
|
304
|
+
var resolveColor = useColorResolver();
|
|
305
|
+
return _ref11 = sstyled(styles), /* @__PURE__ */ React.createElement(SText, _ref11.cn("SText", _objectSpread({}, assignProps({
|
|
306
|
+
"tag": "span",
|
|
307
|
+
"use:color": resolveColor(color)
|
|
308
|
+
}, _ref5))));
|
|
254
309
|
};
|
|
255
|
-
|
|
256
|
-
var
|
|
257
|
-
Control
|
|
258
|
-
RadioMark
|
|
259
|
-
})
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
310
|
+
Text.displayName = "Text";
|
|
311
|
+
var Value = createComponent(ValueRoot, {
|
|
312
|
+
Control,
|
|
313
|
+
RadioMark
|
|
314
|
+
});
|
|
315
|
+
var Radio = createComponent(RadioRoot, {
|
|
316
|
+
Text,
|
|
317
|
+
Value
|
|
318
|
+
});
|
|
319
|
+
var wrapRadioGroup = function wrapRadioGroup2(wrapper) {
|
|
320
|
+
return wrapper;
|
|
264
321
|
};
|
|
265
322
|
export {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
323
|
+
RadioGroup,
|
|
324
|
+
Radio as default,
|
|
325
|
+
inputProps2 as inputProps,
|
|
326
|
+
wrapRadioGroup
|
|
270
327
|
};
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { RadioGroup
|
|
2
|
-
import { inputProps
|
|
1
|
+
import { RadioGroup, default as default2, wrapRadioGroup } from "./Radio.mjs";
|
|
2
|
+
import { inputProps } from "@semcore/core/lib/utils/inputProps";
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
RadioGroup,
|
|
5
|
+
default2 as default,
|
|
6
|
+
inputProps,
|
|
7
|
+
wrapRadioGroup
|
|
8
8
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/radio",
|
|
3
3
|
"description": "Semrush Radio Component",
|
|
4
|
-
"version": "16.0.0-prerelease.
|
|
4
|
+
"version": "16.0.0-prerelease.7",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
"types": "./lib/types/index.d.ts"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@semcore/flex-box": "16.0.0-prerelease.
|
|
18
|
-
"@semcore/typography": "16.0.0-prerelease.
|
|
17
|
+
"@semcore/flex-box": "16.0.0-prerelease.7",
|
|
18
|
+
"@semcore/typography": "16.0.0-prerelease.7"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@semcore/base-components": "^16.0.0-prerelease.
|
|
21
|
+
"@semcore/base-components": "^16.0.0-prerelease.7"
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|