@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/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, assignProps, Component } from "@semcore/core";
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
- var style = (
13
+ const style = (
22
14
  /*__reshadow_css_start__*/
23
15
  (sstyled.insert(
24
16
  /*__inner_css_start__*/
25
- '.___SRadio_1xn00_gg_{display:inline-flex;align-items:flex-start;cursor:pointer}.___SRadio_1xn00_gg_ .___SText_1xn00_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);color:var(--intergalactic-text-primary, #191b23)}.___SRadio_1xn00_gg_ .___SText_1xn00_gg_.__color_1xn00_gg_{color:var(--color_1xn00)}.___SRadio_1xn00_gg_.__disabled_1xn00_gg_{pointer-events:none}.___SText_1xn00_gg_._size_m_1xn00_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___SText_1xn00_gg_._size_l_1xn00_gg_{font-size:var(--intergalactic-fs-300, 16px);line-height:var(--intergalactic-lh-300, 150%)}.___SValue_1xn00_gg_{position:relative;flex-shrink:0;padding:0;outline:0;z-index:0;margin-top:var(--intergalactic-spacing-05x, 2px)}.___SValue_1xn00_gg_::after,.___SValue_1xn00_gg_::before{content:"";position:absolute;right:0;bottom:0;border-radius:50%;background:var(--intergalactic-bg-primary-neutral, #ffffff)}.___SValue_1xn00_gg_::before{top:0;left:0;border:1px solid;transition:calc(var(--intergalactic-duration-control, 200)*1ms) all ease-in-out}.___SValue_1xn00_gg_::after{top:50%;left:50%;transform:translate(-50%,-50%);width:0;height:0}.___SValue_1xn00_gg_.__disabled_1xn00_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_1xn00_gg_._size_m_1xn00_gg_{width:16px;height:16px}.___SValue_1xn00_gg_._size_m_1xn00_gg_ .___SInvalidPattern_1xn00_gg_:before{width:14px;height:14px}.___SValue_1xn00_gg_._size_l_1xn00_gg_{width:20px;height:20px}.___SValue_1xn00_gg_._size_l_1xn00_gg_ .___SInvalidPattern_1xn00_gg_:before{width:18px;height:18px}.___SValue_1xn00_gg_._state_normal_1xn00_gg_::before{border-color:var(--intergalactic-border-primary, #c4c7cf)}.___SValue_1xn00_gg_._state_invalid_1xn00_gg_::before{border-color:var(--intergalactic-border-critical-active, #d1002f)}.___SControl_1xn00_gg_{position:absolute;clip:rect(1px,1px,1px,1px)}.___SControl_1xn00_gg_:checked~.___SValue_1xn00_gg_._size_m_1xn00_gg_::after{width:6px;height:6px}.___SControl_1xn00_gg_:checked~.___SValue_1xn00_gg_._size_l_1xn00_gg_::after{width:8px;height:8px}.___SControl_1xn00_gg_:focus-visible+.___SValue_1xn00_gg_._state_normal_1xn00_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_1xn00_gg_:checked:focus-visible~.___SValue_1xn00_gg_::before,.___SControl_1xn00_gg_:checked~.___SValue_1xn00_gg_::before{border-color:var(--intergalactic-control-primary-info, #008ff8);background-color:var(--intergalactic-control-primary-info, #008ff8)}.___SControl_1xn00_gg_:focus-visible+.___SValue_1xn00_gg_._state_invalid_1xn00_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_1xn00_gg_:checked~.___SValue_1xn00_gg_.__theme_1xn00_gg_::before{border-color:var(--theme_1xn00);background-color:var(--theme_1xn00)}.___SValue_1xn00_gg_._state_normal_1xn00_gg_.__theme_1xn00_gg_::before{border-color:var(--theme_1xn00)}.___SInvalidPattern_1xn00_gg_{background:0 0;overflow:hidden}.___SInvalidPattern_1xn00_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)}',
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
- "1xn00_gg_"
19
+ "1qr3e_gg_"
28
20
  ), /*__reshadow_css_end__*/
29
21
  {
30
- "__SRadio": "___SRadio_1xn00_gg_",
31
- "_disabled": "__disabled_1xn00_gg_",
32
- "__SText": "___SText_1xn00_gg_",
33
- "_size_m": "_size_m_1xn00_gg_",
34
- "_size_l": "_size_l_1xn00_gg_",
35
- "__SValue": "___SValue_1xn00_gg_",
36
- "_state_normal": "_state_normal_1xn00_gg_",
37
- "_state_invalid": "_state_invalid_1xn00_gg_",
38
- "__SControl": "___SControl_1xn00_gg_",
39
- "_theme": "__theme_1xn00_gg_",
40
- "--theme": "--theme_1xn00",
41
- "_color": "__color_1xn00_gg_",
42
- "--color": "--color_1xn00",
43
- "__SInvalidPattern": "___SInvalidPattern_1xn00_gg_"
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
- var RadioGroupRoot = /* @__PURE__ */ (function(_Component) {
47
- function RadioGroupRoot2() {
48
- _classCallCheck(this, RadioGroupRoot2);
49
- return _callSuper(this, RadioGroupRoot2, arguments);
38
+ class RadioGroupRoot extends Component {
39
+ uncontrolledProps() {
40
+ return {
41
+ value: null
42
+ };
50
43
  }
51
- _inherits(RadioGroupRoot2, _Component);
52
- return _createClass(RadioGroupRoot2, [{
53
- key: "uncontrolledProps",
54
- value: function uncontrolledProps() {
55
- return {
56
- value: null
57
- };
58
- }
59
- }, {
60
- key: "setContext",
61
- value: function setContext() {
62
- 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;
63
- return {
64
- onChange,
65
- value,
66
- theme,
67
- size,
68
- name,
69
- disabled
70
- };
71
- }
72
- }, {
73
- key: "render",
74
- value: function render() {
75
- var _ref = this.asProps;
76
- var Children = this.asProps.Children;
77
- return /* @__PURE__ */ React.createElement(Flex, assignProps({
78
- "direction": "column",
79
- "role": "group",
80
- "__excludeProps": ["onChange"]
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
- var RadioGroup = createComponent(RadioGroupRoot);
90
- var RadioRoot = /* @__PURE__ */ (function(_Component2) {
91
- function RadioRoot2() {
92
- var _this;
93
- _classCallCheck(this, RadioRoot2);
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(_this, "hoistDisabled", function(disabled) {
102
- 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"]);
103
- _this.setState({
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
- _inherits(RadioRoot2, _Component2);
110
- return _createClass(RadioRoot2, [{
111
- key: "getTextProps",
112
- value: function getTextProps() {
113
- 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;
114
- var hoistedDisabled = this.state.hoistedDisabled;
115
- var textProps = {
116
- size,
117
- children: label,
118
- disabled: disabled !== null && disabled !== void 0 ? disabled : hoistedDisabled,
119
- hoistDisabled: this.hoistDisabled,
120
- rootDisabled: this.props.disabled
121
- };
122
- return textProps;
123
- }
124
- }, {
125
- key: "getValueProps",
126
- value: function getValueProps() {
127
- var _this$props$size;
128
- 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;
129
- var _this$asProps2 = this.asProps, value = _this$asProps2.value, checked = _this$asProps2.checked;
130
- var hoistedDisabled = this.state.hoistedDisabled;
131
- return {
132
- size: (_this$props$size = this.props.size) !== null && _this$props$size !== void 0 ? _this$props$size : size,
133
- disabled: disabled !== null && disabled !== void 0 ? disabled : hoistedDisabled,
134
- state,
135
- theme,
136
- value,
137
- checked,
138
- name,
139
- hoistDisabled: this.hoistDisabled,
140
- rootDisabled: this.props.disabled
141
- };
142
- }
143
- }, {
144
- key: "render",
145
- value: function render() {
146
- var _ref2 = this.asProps, _ref6;
147
- var SRadio = Box;
148
- var _this$asProps3 = this.asProps, styles = _this$asProps3.styles, Children = _this$asProps3.Children, hasChildren = _this$asProps3.children;
149
- return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(SRadio, _ref6.cn("SRadio", _objectSpread({}, assignProps({
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))), 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)));
153
- }
154
- }]);
155
- })(Component);
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
- var ValueRoot = /* @__PURE__ */ (function(_Component3) {
160
- function ValueRoot2() {
161
- var _this2;
162
- _classCallCheck(this, ValueRoot2);
163
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
164
- args[_key2] = arguments[_key2];
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
- _inherits(ValueRoot2, _Component3);
177
- return _createClass(ValueRoot2, [{
178
- key: "uncontrolledProps",
179
- value: function uncontrolledProps() {
180
- return {
181
- checked: function checked(e) {
182
- return e.target.checked;
183
- }
184
- };
185
- }
186
- }, {
187
- key: "getControlProps",
188
- value: function getControlProps() {
189
- var currentValue = this.context.value;
190
- var _this$asProps4 = this.asProps, forwardRef = _this$asProps4.forwardRef, includeInputProps = _this$asProps4.includeInputProps, state = _this$asProps4.state, value = _this$asProps4.value;
191
- var _getInputProps = getInputProps(this.asProps, includeInputProps), _getInputProps2 = _slicedToArray(_getInputProps, 1), commonControlProps = _getInputProps2[0];
192
- var inputValue = value !== null && value !== void 0 ? value : "";
193
- var controlProps = _objectSpread(_objectSpread({
194
- ref: forwardRef,
195
- state
196
- }, commonControlProps), {}, {
197
- value: inputValue
198
- });
199
- if (currentValue !== void 0) {
200
- var onChange = this.props.onChange;
201
- controlProps.checked = currentValue === inputValue;
202
- controlProps.onChange = callAllEventHandlers(onChange, this.bindHandlerChange(inputValue));
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
- key: "getRadioMarkProps",
208
- value: function getRadioMarkProps() {
209
- var currentValue = this.context.value;
210
- 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);
211
- var _getInputProps3 = getInputProps(other, includeInputProps), _getInputProps4 = _slicedToArray(_getInputProps3, 2), commonControlProps = _getInputProps4[0], radioMarkProps = _getInputProps4[1];
212
- radioMarkProps.children;
213
- radioMarkProps.Children;
214
- var propsWithoutChildren = _objectWithoutProperties(radioMarkProps, _excluded2);
215
- var inputValue = value !== null && value !== void 0 ? value : "";
216
- var markProps = _objectSpread({
217
- theme,
218
- size,
219
- state,
220
- keyboardFocused,
221
- disabled,
222
- resolveColor,
223
- checked: commonControlProps.checked
224
- }, propsWithoutChildren);
225
- if (currentValue !== void 0) {
226
- var onClick = this.props.onClick;
227
- if (tag !== "label") {
228
- markProps.onClick = callAllEventHandlers(onClick, this.bindHandlerChange(inputValue));
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
- key: "componentDidUpdate",
235
- value: function componentDidUpdate() {
236
- if (this.asProps.rootDisabled !== this.asProps.disabled) {
237
- this.asProps.hoistDisabled(this.asProps.disabled);
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
- key: "componentDidMount",
242
- value: function componentDidMount() {
243
- if (this.asProps.rootDisabled !== this.asProps.disabled) {
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
- key: "render",
249
- value: function render() {
250
- var _ref8;
251
- var _this$asProps6 = this.asProps, styles = _this$asProps6.styles, hasChildren = _this$asProps6.children, Children = _this$asProps6.Children;
252
- if (!hasChildren) {
253
- return sstyled(styles), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Radio.Value.Control, null), /* @__PURE__ */ React.createElement(Radio.Value.RadioMark, null));
254
- }
255
- return _ref8 = sstyled(styles), /* @__PURE__ */ React.createElement(Children, _ref8.cn("Children", {}));
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
- })(Component);
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
- var Control = function Control2(props) {
267
+ function Control(props) {
268
268
  var _ref3 = arguments[0], _ref9;
269
- var SControl = Box;
270
- var styles = props.styles, state = props.state;
271
- return _ref9 = sstyled(styles), /* @__PURE__ */ React.createElement(SControl, _ref9.cn("SControl", _objectSpread({}, assignProps({
272
- "tag": "input",
273
- "type": "radio",
274
- "aria-invalid": state === "invalid"
275
- }, _ref3))));
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
- var RadioMark = function RadioMark2(props) {
283
+ function RadioMark(props) {
279
284
  var _ref4 = arguments[0], _ref0;
280
- var SValue = Box;
281
- var SInvalidPattern = InvalidStateBox;
282
- var theme = props.theme, styles = props.styles, resolveColor = props.resolveColor, state = props.state, checked = props.checked;
283
- return _ref0 = sstyled(styles), /* @__PURE__ */ React.createElement(SValue, _ref0.cn("SValue", _objectSpread({}, assignProps({
284
- "tag": "div",
285
- "use:theme": resolveColor(theme),
286
- "aria-hidden": true
287
- }, _ref4))), state === "invalid" && !checked && /* @__PURE__ */ React.createElement(SInvalidPattern, _ref0.cn("SInvalidPattern", {})));
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
- var Text = function Text2(props) {
303
+ function Text(props) {
291
304
  var _ref5 = arguments[0], _ref1;
292
- var SText = Text$1;
293
- var styles = props.styles, color = props.color;
294
- React.useEffect(function() {
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
- var resolveColor = useColorResolver();
300
- return _ref1 = sstyled(styles), /* @__PURE__ */ React.createElement(SText, _ref1.cn("SText", _objectSpread({}, assignProps({
301
- "tag": "span",
302
- "use:color": resolveColor(color)
303
- }, _ref5))));
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
- var Value = createComponent(ValueRoot, {
324
+ const Value = createComponent(ValueRoot, {
307
325
  Control,
308
326
  RadioMark
309
327
  });
310
- var Radio = createComponent(RadioRoot, {
328
+ const Radio = createComponent(RadioRoot, {
311
329
  Text,
312
330
  Value
313
331
  });
314
- var wrapRadioGroup = function wrapRadioGroup2(wrapper) {
315
- return wrapper;
316
- };
332
+ const wrapRadioGroup = (wrapper) => wrapper;
317
333
  export {
318
334
  RadioGroup,
319
335
  Radio as default,