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