@semcore/radio 6.43.4-prerelease.0 → 6.44.0-prerelease.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/cjs/Radio.js +129 -144
- package/lib/cjs/Radio.js.map +1 -1
- package/lib/cjs/Radio.type.js +2 -0
- package/lib/cjs/Radio.type.js.map +1 -0
- package/lib/cjs/index.js +21 -5
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/radio.shadow.css +21 -28
- package/lib/es6/Radio.js +120 -131
- package/lib/es6/Radio.js.map +1 -1
- package/lib/es6/Radio.type.js +2 -0
- package/lib/es6/Radio.type.js.map +1 -0
- package/lib/es6/index.js +2 -2
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/radio.shadow.css +21 -28
- package/lib/esm/Radio.mjs +92 -105
- package/lib/esm/Radio.type.mjs +1 -0
- package/lib/esm/index.mjs +1 -2
- package/lib/esm/style/radio.shadow.css +21 -28
- package/lib/types/Radio.d.ts +9 -0
- package/lib/types/Radio.type.d.ts +98 -0
- package/lib/types/index.d.ts +2 -149
- package/package.json +5 -5
- package/lib/cjs/index.d.js +0 -2
- package/lib/cjs/index.d.js.map +0 -1
- package/lib/es6/index.d.js +0 -2
- package/lib/es6/index.d.js.map +0 -1
package/lib/esm/Radio.mjs
CHANGED
|
@@ -1,60 +1,56 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
5
4
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
6
5
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
6
|
+
import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
7
7
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
8
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
9
8
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
10
|
-
import { sstyled } from "@semcore/
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import { inputProps as inputProps2 } from "@semcore/utils/lib/inputProps";
|
|
19
|
-
import { useColorResolver } from "@semcore/utils/lib/use/useColorResolver";
|
|
20
|
-
import logger from "@semcore/utils/lib/logger";
|
|
9
|
+
import { sstyled, assignProps, Component, createComponent } from "@semcore/core";
|
|
10
|
+
import { Flex, Box, InvalidStateBox } from "@semcore/base-components";
|
|
11
|
+
import { callAllEventHandlers } from "@semcore/core/lib/utils/assignProps";
|
|
12
|
+
import resolveColorEnhance from "@semcore/core/lib/utils/enhances/resolveColorEnhance";
|
|
13
|
+
import getInputProps, { inputProps } from "@semcore/core/lib/utils/inputProps";
|
|
14
|
+
import { inputProps as inputProps2 } from "@semcore/core/lib/utils/inputProps";
|
|
15
|
+
import logger from "@semcore/core/lib/utils/logger";
|
|
16
|
+
import { useColorResolver } from "@semcore/core/lib/utils/use/useColorResolver";
|
|
21
17
|
import { Text as Text$1 } from "@semcore/typography";
|
|
22
|
-
|
|
18
|
+
import React from "react";
|
|
19
|
+
var _excluded = ["size", "state", "theme", "keyboardFocused", "value", "tag", "disabled", "includeInputProps", "resolveColor", "children", "Children"];
|
|
23
20
|
/*!__reshadow-styles__:"./style/radio.shadow.css"*/
|
|
24
21
|
var style = (
|
|
25
22
|
/*__reshadow_css_start__*/
|
|
26
23
|
(sstyled.insert(
|
|
27
24
|
/*__inner_css_start__*/
|
|
28
|
-
'.
|
|
25
|
+
'.___SRadio_dgqi9_gg_{display:inline-flex;align-items:flex-start;cursor:pointer}.___SRadio_dgqi9_gg_ .___SText_dgqi9_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899))}.___SRadio_dgqi9_gg_ .___SText_dgqi9_gg_.__color_dgqi9_gg_{color:var(--color_dgqi9)}.___SRadio_dgqi9_gg_.__disabled_dgqi9_gg_{pointer-events:none}.___SValue_dgqi9_gg_{position:relative;flex-shrink:0;padding:0;outline:0;z-index:0;margin-top:var(--intergalactic-spacing-05x, 2px)}.___SValue_dgqi9_gg_::after,.___SValue_dgqi9_gg_::before{content:"";position:absolute;right:0;bottom:0;border-radius:50%;background:var(--intergalactic-bg-primary-neutral, rgb(255, 255, 255))}.___SValue_dgqi9_gg_::before{top:0;left:0;border:1px solid;transition:calc(var(--intergalactic-duration-control, 200)*1ms) all ease-in-out}.___SValue_dgqi9_gg_::after{top:50%;left:50%;transform:translate(-50%,-50%);width:0;height:0}.___SValue_dgqi9_gg_.__disabled_dgqi9_gg_{opacity:var(--intergalactic-disabled-opacity, 0.4);cursor:default;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.___SValue_dgqi9_gg_._size_m_dgqi9_gg_{width:16px;height:16px}.___SValue_dgqi9_gg_._size_m_dgqi9_gg_ .___SInvalidPattern_dgqi9_gg_:before{width:14px;height:14px}.___SValue_dgqi9_gg_._size_l_dgqi9_gg_{width:20px;height:20px}.___SValue_dgqi9_gg_._size_l_dgqi9_gg_ .___SInvalidPattern_dgqi9_gg_:before{width:18px;height:18px}.___SValue_dgqi9_gg_._state_normal_dgqi9_gg_::before{border-color:var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@supports (color:color(display-p3 0 0 0%)){.___SValue_dgqi9_gg_._state_normal_dgqi9_gg_::before{border-color:var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___SValue_dgqi9_gg_._state_normal_dgqi9_gg_::before{border-color:var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___SValue_dgqi9_gg_._state_invalid_dgqi9_gg_::before{border-color:var(--intergalactic-border-critical-active, rgba(255, 0, 4, 0.56))}@supports (color:color(display-p3 0 0 0%)){.___SValue_dgqi9_gg_._state_invalid_dgqi9_gg_::before{border-color:var(--intergalactic-border-critical-active, rgba(255, 0, 4, 0.56))}@media (color-gamut:p3){.___SValue_dgqi9_gg_._state_invalid_dgqi9_gg_::before{border-color:var(--intergalactic-border-critical-active, color(display-p3 0.918 0.19866 0.14259 / 0.56))}}}.___SControl_dgqi9_gg_{position:absolute;clip:rect(1px,1px,1px,1px)}.___SControl_dgqi9_gg_:checked~.___SValue_dgqi9_gg_._size_m_dgqi9_gg_::after{width:6px;height:6px}.___SControl_dgqi9_gg_:checked~.___SValue_dgqi9_gg_._size_l_dgqi9_gg_::after{width:8px;height:8px}.___SControl_dgqi9_gg_:focus-visible+.___SValue_dgqi9_gg_._state_normal_dgqi9_gg_::before{border-color:var(--intergalactic-border-info-active, rgba(0, 22, 195, 0.386));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}@supports (color:color(display-p3 0 0 0%)){.___SControl_dgqi9_gg_:focus-visible+.___SValue_dgqi9_gg_._state_normal_dgqi9_gg_::before{border-color:var(--intergalactic-border-info-active, rgba(0, 22, 195, 0.386))}@media (color-gamut:p3){.___SControl_dgqi9_gg_:focus-visible+.___SValue_dgqi9_gg_._state_normal_dgqi9_gg_::before{border-color:var(--intergalactic-border-info-active, color(display-p3 0.01805 0.08334 0.73488 / 0.386))}}}.___SControl_dgqi9_gg_:checked:focus-visible~.___SValue_dgqi9_gg_::before,.___SControl_dgqi9_gg_:checked~.___SValue_dgqi9_gg_::before{border-color:var(--intergalactic-control-primary-info, rgb(26, 30, 26));background-color:var(--intergalactic-control-primary-info, rgb(26, 30, 26))}.___SControl_dgqi9_gg_:focus-visible+.___SValue_dgqi9_gg_._state_invalid_dgqi9_gg_::before{border-color:var(--intergalactic-border-critical-active, rgba(255, 0, 4, 0.56));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}@supports (color:color(display-p3 0 0 0%)){.___SControl_dgqi9_gg_:focus-visible+.___SValue_dgqi9_gg_._state_invalid_dgqi9_gg_::before{border-color:var(--intergalactic-border-critical-active, rgba(255, 0, 4, 0.56))}@media (color-gamut:p3){.___SControl_dgqi9_gg_:focus-visible+.___SValue_dgqi9_gg_._state_invalid_dgqi9_gg_::before{border-color:var(--intergalactic-border-critical-active, color(display-p3 0.918 0.19866 0.14259 / 0.56))}}}@supports (color:oklab(0%0 0%)){.___SControl_dgqi9_gg_:focus-visible+.___SValue_dgqi9_gg_._state_invalid_dgqi9_gg_::before{outline-color:var(--intergalactic-keyboard-focus-invalid-outline, oklch(0.628 0.257 28.9 / 0.652))}}.___SControl_dgqi9_gg_:checked~.___SValue_dgqi9_gg_.__theme_dgqi9_gg_::before{border-color:var(--theme_dgqi9);background-color:var(--theme_dgqi9)}.___SValue_dgqi9_gg_._state_normal_dgqi9_gg_.__theme_dgqi9_gg_::before{border-color:var(--theme_dgqi9)}.___SInvalidPattern_dgqi9_gg_{background:0 0;overflow:hidden}.___SInvalidPattern_dgqi9_gg_:before{content:"";position:absolute;top:1px;left:1px;border-radius:50%;background-image:var(--intergalactic-border-critical-pattern, repeating-linear-gradient(315deg, rgba(255, 0, 4, 0.56) 0, rgba(255, 0, 4, 0.56) 1px, transparent 0, transparent 50%));background-size:6px 6px;background-color:var(--intergalactic-bg-primary-neutral, rgb(255, 255, 255))}@supports (color:color(display-p3 0 0 0%)){.___SInvalidPattern_dgqi9_gg_:before{background-image:var(--intergalactic-border-critical-pattern, repeating-linear-gradient(315deg, rgba(255, 0, 4, 0.56) 0, rgba(255, 0, 4, 0.56) 1px, transparent 0, transparent 50%))}@media (color-gamut:p3){.___SInvalidPattern_dgqi9_gg_:before{background-image:var(--intergalactic-border-critical-pattern, repeating-linear-gradient(315deg, color(display-p3 0.918 0.19866 0.14259 / 0.56) 0, color(display-p3 0.918 0.19866 0.14259 / 0.56) 1px, transparent 0, transparent 50%))}}}',
|
|
29
26
|
/*__inner_css_end__*/
|
|
30
|
-
"
|
|
27
|
+
"dgqi9_gg_"
|
|
31
28
|
), /*__reshadow_css_end__*/
|
|
32
29
|
{
|
|
33
|
-
"__SRadio": "
|
|
34
|
-
"_disabled": "
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"__SInvalidPattern": "___SInvalidPattern_mgb6n_gg_"
|
|
30
|
+
"__SRadio": "___SRadio_dgqi9_gg_",
|
|
31
|
+
"_disabled": "__disabled_dgqi9_gg_",
|
|
32
|
+
"__SValue": "___SValue_dgqi9_gg_",
|
|
33
|
+
"_state_normal": "_state_normal_dgqi9_gg_",
|
|
34
|
+
"_state_invalid": "_state_invalid_dgqi9_gg_",
|
|
35
|
+
"__SControl": "___SControl_dgqi9_gg_",
|
|
36
|
+
"_size_m": "_size_m_dgqi9_gg_",
|
|
37
|
+
"_size_l": "_size_l_dgqi9_gg_",
|
|
38
|
+
"_theme": "__theme_dgqi9_gg_",
|
|
39
|
+
"--theme": "--theme_dgqi9",
|
|
40
|
+
"__SText": "___SText_dgqi9_gg_",
|
|
41
|
+
"_color": "__color_dgqi9_gg_",
|
|
42
|
+
"--color": "--color_dgqi9",
|
|
43
|
+
"__SInvalidPattern": "___SInvalidPattern_dgqi9_gg_"
|
|
48
44
|
})
|
|
49
45
|
);
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
var _super = _createSuper(RadioGroupRoot2);
|
|
46
|
+
var RadioContext = /* @__PURE__ */ React.createContext({});
|
|
47
|
+
var RadioGroupRoot = /* @__PURE__ */ (function(_Component) {
|
|
53
48
|
function RadioGroupRoot2() {
|
|
54
49
|
_classCallCheck(this, RadioGroupRoot2);
|
|
55
|
-
return
|
|
50
|
+
return _callSuper(this, RadioGroupRoot2, arguments);
|
|
56
51
|
}
|
|
57
|
-
|
|
52
|
+
_inherits(RadioGroupRoot2, _Component);
|
|
53
|
+
return _createClass(RadioGroupRoot2, [{
|
|
58
54
|
key: "uncontrolledProps",
|
|
59
55
|
value: function uncontrolledProps() {
|
|
60
56
|
return {
|
|
@@ -86,27 +82,27 @@ var RadioGroupRoot = /* @__PURE__ */ function(_Component) {
|
|
|
86
82
|
}, _ref), /* @__PURE__ */ React.createElement(Children, null));
|
|
87
83
|
}
|
|
88
84
|
}]);
|
|
89
|
-
|
|
90
|
-
}(Component);
|
|
85
|
+
})(Component);
|
|
91
86
|
_defineProperty(RadioGroupRoot, "displayName", "RadioGroup");
|
|
92
87
|
_defineProperty(RadioGroupRoot, "defaultProps", {
|
|
93
88
|
defaultValue: null
|
|
94
89
|
});
|
|
95
|
-
var RadioGroup = createComponent(RadioGroupRoot
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
90
|
+
var RadioGroup = createComponent(RadioGroupRoot, {}, {
|
|
91
|
+
context: RadioContext
|
|
92
|
+
});
|
|
93
|
+
var RadioRoot = /* @__PURE__ */ (function(_Component2) {
|
|
99
94
|
function RadioRoot2() {
|
|
100
95
|
var _this;
|
|
101
96
|
_classCallCheck(this, RadioRoot2);
|
|
102
97
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
103
98
|
args[_key] = arguments[_key];
|
|
104
99
|
}
|
|
105
|
-
_this =
|
|
106
|
-
_defineProperty(
|
|
100
|
+
_this = _callSuper(this, RadioRoot2, [].concat(args));
|
|
101
|
+
_defineProperty(_this, "context", {});
|
|
102
|
+
_defineProperty(_this, "state", {
|
|
107
103
|
hoistedDisabled: void 0
|
|
108
104
|
});
|
|
109
|
-
_defineProperty(
|
|
105
|
+
_defineProperty(_this, "hoistDisabled", function(disabled) {
|
|
110
106
|
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
107
|
_this.setState({
|
|
112
108
|
hoistedDisabled: disabled
|
|
@@ -114,13 +110,15 @@ var RadioRoot = /* @__PURE__ */ function(_Component2) {
|
|
|
114
110
|
});
|
|
115
111
|
return _this;
|
|
116
112
|
}
|
|
117
|
-
|
|
113
|
+
_inherits(RadioRoot2, _Component2);
|
|
114
|
+
return _createClass(RadioRoot2, [{
|
|
118
115
|
key: "getTextProps",
|
|
119
116
|
value: function getTextProps() {
|
|
120
|
-
var
|
|
117
|
+
var _this$context$size;
|
|
118
|
+
var _this$asProps2 = this.asProps, _this$asProps2$size = _this$asProps2.size, size = _this$asProps2$size === void 0 ? (_this$context$size = this.context.size) !== null && _this$context$size !== void 0 ? _this$context$size : "m" : _this$asProps2$size, _this$asProps2$disabl = _this$asProps2.disabled, disabled = _this$asProps2$disabl === void 0 ? this.context.disabled : _this$asProps2$disabl, label = _this$asProps2.label;
|
|
121
119
|
var hoistedDisabled = this.state.hoistedDisabled;
|
|
122
120
|
var textProps = {
|
|
123
|
-
size,
|
|
121
|
+
size: size === "m" ? 200 : 300,
|
|
124
122
|
children: label,
|
|
125
123
|
disabled: disabled !== null && disabled !== void 0 ? disabled : hoistedDisabled,
|
|
126
124
|
hoistDisabled: this.hoistDisabled,
|
|
@@ -131,9 +129,9 @@ var RadioRoot = /* @__PURE__ */ function(_Component2) {
|
|
|
131
129
|
}, {
|
|
132
130
|
key: "getValueProps",
|
|
133
131
|
value: function getValueProps() {
|
|
134
|
-
var _this$props$size;
|
|
135
|
-
var
|
|
136
|
-
var _this$
|
|
132
|
+
var _this$context$size2, _this$props$size;
|
|
133
|
+
var _this$asProps3 = this.asProps, _this$asProps3$state = _this$asProps3.state, state = _this$asProps3$state === void 0 ? "normal" : _this$asProps3$state, _this$asProps3$size = _this$asProps3.size, size = _this$asProps3$size === void 0 ? (_this$context$size2 = this.context.size) !== null && _this$context$size2 !== void 0 ? _this$context$size2 : "m" : _this$asProps3$size, _this$asProps3$theme = _this$asProps3.theme, theme = _this$asProps3$theme === void 0 ? this.context.theme : _this$asProps3$theme, _this$asProps3$disabl = _this$asProps3.disabled, disabled = _this$asProps3$disabl === void 0 ? this.context.disabled : _this$asProps3$disabl, _this$asProps3$name = _this$asProps3.name, name = _this$asProps3$name === void 0 ? this.context.name : _this$asProps3$name;
|
|
134
|
+
var _this$asProps4 = this.asProps, value = _this$asProps4.value, checked = _this$asProps4.checked;
|
|
137
135
|
var hoistedDisabled = this.state.hoistedDisabled;
|
|
138
136
|
return {
|
|
139
137
|
size: (_this$props$size = this.props.size) !== null && _this$props$size !== void 0 ? _this$props$size : size,
|
|
@@ -152,38 +150,37 @@ var RadioRoot = /* @__PURE__ */ function(_Component2) {
|
|
|
152
150
|
value: function render() {
|
|
153
151
|
var _ref2 = this.asProps, _ref6;
|
|
154
152
|
var SRadio = Box;
|
|
155
|
-
var _this$
|
|
156
|
-
return _ref6 = sstyled
|
|
153
|
+
var _this$asProps5 = this.asProps, styles = _this$asProps5.styles, Children = _this$asProps5.Children, hasChildren = _this$asProps5.children;
|
|
154
|
+
return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(SRadio, _ref6.cn("SRadio", _objectSpread({}, assignProps({
|
|
157
155
|
"tag": "label",
|
|
158
156
|
"__excludeProps": ["onChange", "label", "disabled"]
|
|
159
157
|
}, _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)));
|
|
160
158
|
}
|
|
161
159
|
}]);
|
|
162
|
-
|
|
163
|
-
}(Component);
|
|
160
|
+
})(Component);
|
|
164
161
|
_defineProperty(RadioRoot, "displayName", "Radio");
|
|
165
162
|
_defineProperty(RadioRoot, "style", style);
|
|
166
|
-
_defineProperty(RadioRoot, "contextType",
|
|
167
|
-
var ValueRoot = /* @__PURE__ */ function(_Component3) {
|
|
168
|
-
_inherits(ValueRoot2, _Component3);
|
|
169
|
-
var _super3 = _createSuper(ValueRoot2);
|
|
163
|
+
_defineProperty(RadioRoot, "contextType", RadioContext);
|
|
164
|
+
var ValueRoot = /* @__PURE__ */ (function(_Component3) {
|
|
170
165
|
function ValueRoot2() {
|
|
171
166
|
var _this2;
|
|
172
167
|
_classCallCheck(this, ValueRoot2);
|
|
173
168
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
174
169
|
args[_key2] = arguments[_key2];
|
|
175
170
|
}
|
|
176
|
-
_this2 =
|
|
177
|
-
_defineProperty(
|
|
171
|
+
_this2 = _callSuper(this, ValueRoot2, [].concat(args));
|
|
172
|
+
_defineProperty(_this2, "context", {});
|
|
173
|
+
_defineProperty(_this2, "bindHandlerChange", function(value) {
|
|
178
174
|
return function(e) {
|
|
179
|
-
if (typeof _this2.context.onChange === "function") {
|
|
175
|
+
if (typeof _this2.context.onChange === "function" && value !== void 0) {
|
|
180
176
|
_this2.context.onChange(value, e);
|
|
181
177
|
}
|
|
182
178
|
};
|
|
183
179
|
});
|
|
184
180
|
return _this2;
|
|
185
181
|
}
|
|
186
|
-
|
|
182
|
+
_inherits(ValueRoot2, _Component3);
|
|
183
|
+
return _createClass(ValueRoot2, [{
|
|
187
184
|
key: "uncontrolledProps",
|
|
188
185
|
value: function uncontrolledProps() {
|
|
189
186
|
return {
|
|
@@ -196,34 +193,29 @@ var ValueRoot = /* @__PURE__ */ function(_Component3) {
|
|
|
196
193
|
key: "getControlProps",
|
|
197
194
|
value: function getControlProps() {
|
|
198
195
|
var currentValue = this.context.value;
|
|
199
|
-
var _this$
|
|
196
|
+
var _this$asProps6 = this.asProps, forwardRef = _this$asProps6.forwardRef, includeInputProps = _this$asProps6.includeInputProps, state = _this$asProps6.state, value = _this$asProps6.value;
|
|
197
|
+
var onChange = this.props.onChange;
|
|
200
198
|
var _getInputProps = getInputProps(this.asProps, includeInputProps), _getInputProps2 = _slicedToArray(_getInputProps, 1), commonControlProps = _getInputProps2[0];
|
|
201
199
|
var inputValue = value !== null && value !== void 0 ? value : "";
|
|
202
|
-
|
|
200
|
+
return _objectSpread(_objectSpread({
|
|
203
201
|
ref: forwardRef,
|
|
204
202
|
state
|
|
205
203
|
}, commonControlProps), {}, {
|
|
206
204
|
value: inputValue
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
controlProps.checked = currentValue === inputValue;
|
|
212
|
-
controlProps.onChange = callAllEventHandlers(onChange, this.bindHandlerChange(inputValue));
|
|
213
|
-
}
|
|
214
|
-
return controlProps;
|
|
205
|
+
}, currentValue !== void 0 ? {
|
|
206
|
+
checked: currentValue === inputValue,
|
|
207
|
+
onChange: callAllEventHandlers(onChange, this.bindHandlerChange(inputValue))
|
|
208
|
+
} : {});
|
|
215
209
|
}
|
|
216
210
|
}, {
|
|
217
211
|
key: "getRadioMarkProps",
|
|
218
212
|
value: function getRadioMarkProps() {
|
|
219
213
|
var currentValue = this.context.value;
|
|
220
|
-
var _this$
|
|
214
|
+
var _this$asProps7 = this.asProps, size = _this$asProps7.size, state = _this$asProps7.state, theme = _this$asProps7.theme, keyboardFocused = _this$asProps7.keyboardFocused, value = _this$asProps7.value, tag = _this$asProps7.tag, disabled = _this$asProps7.disabled, includeInputProps = _this$asProps7.includeInputProps, resolveColor = _this$asProps7.resolveColor, children = _this$asProps7.children, Children = _this$asProps7.Children, other = _objectWithoutProperties(_this$asProps7, _excluded);
|
|
215
|
+
var onClick = this.props.onClick;
|
|
221
216
|
var _getInputProps3 = getInputProps(other, includeInputProps), _getInputProps4 = _slicedToArray(_getInputProps3, 2), commonControlProps = _getInputProps4[0], radioMarkProps = _getInputProps4[1];
|
|
222
|
-
radioMarkProps.children;
|
|
223
|
-
radioMarkProps.Children;
|
|
224
|
-
var propsWithoutChildren = _objectWithoutProperties(radioMarkProps, _excluded2);
|
|
225
217
|
var inputValue = value !== null && value !== void 0 ? value : "";
|
|
226
|
-
|
|
218
|
+
return _objectSpread(_objectSpread({
|
|
227
219
|
theme,
|
|
228
220
|
size,
|
|
229
221
|
state,
|
|
@@ -231,14 +223,9 @@ var ValueRoot = /* @__PURE__ */ function(_Component3) {
|
|
|
231
223
|
disabled,
|
|
232
224
|
resolveColor,
|
|
233
225
|
checked: commonControlProps.checked
|
|
234
|
-
},
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if (tag !== "label") {
|
|
238
|
-
markProps.onClick = callAllEventHandlers(onClick, this.bindHandlerChange(inputValue));
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
return markProps;
|
|
226
|
+
}, radioMarkProps), currentValue !== void 0 && tag !== "label" ? {
|
|
227
|
+
onClick: callAllEventHandlers(onClick, this.bindHandlerChange(inputValue))
|
|
228
|
+
} : {});
|
|
242
229
|
}
|
|
243
230
|
}, {
|
|
244
231
|
key: "componentDidUpdate",
|
|
@@ -258,48 +245,48 @@ var ValueRoot = /* @__PURE__ */ function(_Component3) {
|
|
|
258
245
|
key: "render",
|
|
259
246
|
value: function render() {
|
|
260
247
|
var _ref8;
|
|
261
|
-
var _this$
|
|
248
|
+
var _this$asProps8 = this.asProps, styles = _this$asProps8.styles, hasChildren = _this$asProps8.children, Children = _this$asProps8.Children;
|
|
262
249
|
if (!hasChildren) {
|
|
263
|
-
|
|
250
|
+
var _ref7;
|
|
251
|
+
return _ref7 = sstyled(styles), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Radio.Value.Control, null), /* @__PURE__ */ React.createElement(Radio.Value.RadioMark, null));
|
|
264
252
|
}
|
|
265
|
-
return _ref8 = sstyled
|
|
253
|
+
return _ref8 = sstyled(styles), /* @__PURE__ */ React.createElement(Children, _ref8.cn("Children", {}));
|
|
266
254
|
}
|
|
267
255
|
}]);
|
|
268
|
-
|
|
269
|
-
}(Component);
|
|
256
|
+
})(Component);
|
|
270
257
|
_defineProperty(ValueRoot, "defaultProps", {
|
|
271
258
|
includeInputProps: inputProps,
|
|
272
259
|
defaultChecked: false
|
|
273
260
|
});
|
|
274
|
-
_defineProperty(ValueRoot, "enhance", [
|
|
261
|
+
_defineProperty(ValueRoot, "enhance", [resolveColorEnhance()]);
|
|
275
262
|
_defineProperty(ValueRoot, "displayName", "Value");
|
|
276
|
-
_defineProperty(ValueRoot, "contextType",
|
|
263
|
+
_defineProperty(ValueRoot, "contextType", RadioContext);
|
|
277
264
|
_defineProperty(ValueRoot, "style", style);
|
|
278
|
-
|
|
265
|
+
function Control(props) {
|
|
279
266
|
var _ref3 = arguments[0], _ref9;
|
|
280
267
|
var SControl = Box;
|
|
281
268
|
var styles = props.styles, state = props.state;
|
|
282
|
-
return _ref9 = sstyled
|
|
269
|
+
return _ref9 = sstyled(styles), /* @__PURE__ */ React.createElement(SControl, _ref9.cn("SControl", _objectSpread({}, assignProps({
|
|
283
270
|
"tag": "input",
|
|
284
271
|
"type": "radio",
|
|
285
272
|
"aria-invalid": state === "invalid"
|
|
286
273
|
}, _ref3))));
|
|
287
|
-
}
|
|
274
|
+
}
|
|
288
275
|
Control.displayName = "Control";
|
|
289
|
-
|
|
290
|
-
var _ref4 = arguments[0],
|
|
276
|
+
function RadioMark(props) {
|
|
277
|
+
var _ref4 = arguments[0], _ref0;
|
|
291
278
|
var SValue = Box;
|
|
292
279
|
var SInvalidPattern = InvalidStateBox;
|
|
293
280
|
var theme = props.theme, styles = props.styles, resolveColor = props.resolveColor, state = props.state, checked = props.checked;
|
|
294
|
-
return
|
|
281
|
+
return _ref0 = sstyled(styles), /* @__PURE__ */ React.createElement(SValue, _ref0.cn("SValue", _objectSpread({}, assignProps({
|
|
295
282
|
"tag": "div",
|
|
296
283
|
"use:theme": resolveColor(theme),
|
|
297
284
|
"aria-hidden": true
|
|
298
|
-
}, _ref4))), state === "invalid" && !checked && /* @__PURE__ */ React.createElement(SInvalidPattern,
|
|
299
|
-
}
|
|
285
|
+
}, _ref4))), state === "invalid" && !checked && /* @__PURE__ */ React.createElement(SInvalidPattern, _ref0.cn("SInvalidPattern", {})));
|
|
286
|
+
}
|
|
300
287
|
RadioMark.displayName = "RadioMark";
|
|
301
|
-
|
|
302
|
-
var _ref5 = arguments[0],
|
|
288
|
+
function Text(props) {
|
|
289
|
+
var _ref5 = arguments[0], _ref1;
|
|
303
290
|
var SText = Text$1;
|
|
304
291
|
var styles = props.styles, color = props.color;
|
|
305
292
|
React.useEffect(function() {
|
|
@@ -308,11 +295,11 @@ var Text = function Text2(props) {
|
|
|
308
295
|
}
|
|
309
296
|
}, [props.rootDisabled, props.disabled, props.hoistDisabled]);
|
|
310
297
|
var resolveColor = useColorResolver();
|
|
311
|
-
return
|
|
298
|
+
return _ref1 = sstyled(styles), /* @__PURE__ */ React.createElement(SText, _ref1.cn("SText", _objectSpread({}, assignProps({
|
|
312
299
|
"tag": "span",
|
|
313
300
|
"use:color": resolveColor(color)
|
|
314
301
|
}, _ref5))));
|
|
315
|
-
}
|
|
302
|
+
}
|
|
316
303
|
Text.displayName = "Text";
|
|
317
304
|
var Value = createComponent(ValueRoot, {
|
|
318
305
|
Control,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/lib/esm/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ SRadio {
|
|
|
5
5
|
|
|
6
6
|
SText {
|
|
7
7
|
margin-left: var(--intergalactic-spacing-2x, 8px);
|
|
8
|
-
color: var(--intergalactic-text-primary,
|
|
8
|
+
color: var(--intergalactic-text-primary, oklch(0.1 0.03 137 / 0.899));
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
SText[color] {
|
|
@@ -17,16 +17,6 @@ SRadio[disabled] {
|
|
|
17
17
|
pointer-events: none;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
SText[size='m'] {
|
|
21
|
-
font-size: var(--intergalactic-fs-200, 14px);
|
|
22
|
-
line-height: var(--intergalactic-lh-200, 142%);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
SText[size='l'] {
|
|
26
|
-
font-size: var(--intergalactic-fs-300, 16px);
|
|
27
|
-
line-height: var(--intergalactic-lh-300, 150%);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
20
|
SValue {
|
|
31
21
|
position: relative;
|
|
32
22
|
flex-shrink: 0;
|
|
@@ -43,7 +33,7 @@ SValue {
|
|
|
43
33
|
left: 0;
|
|
44
34
|
right: 0;
|
|
45
35
|
bottom: 0;
|
|
46
|
-
background: var(--intergalactic-bg-primary-neutral,
|
|
36
|
+
background: var(--intergalactic-bg-primary-neutral, oklch(1 0 0));
|
|
47
37
|
border: 1px solid;
|
|
48
38
|
border-radius: 50%;
|
|
49
39
|
transition: calc(var(--intergalactic-duration-control, 200) * 1ms) all ease-in-out;
|
|
@@ -60,12 +50,12 @@ SValue {
|
|
|
60
50
|
width: 0;
|
|
61
51
|
height: 0;
|
|
62
52
|
border-radius: 50%;
|
|
63
|
-
background: var(--intergalactic-bg-primary-neutral,
|
|
53
|
+
background: var(--intergalactic-bg-primary-neutral, oklch(1 0 0));
|
|
64
54
|
}
|
|
65
55
|
}
|
|
66
56
|
|
|
67
57
|
SValue[disabled] {
|
|
68
|
-
opacity: var(--intergalactic-disabled-opacity, 0.
|
|
58
|
+
opacity: var(--intergalactic-disabled-opacity, 0.4);
|
|
69
59
|
cursor: default;
|
|
70
60
|
pointer-events: none;
|
|
71
61
|
user-select: none;
|
|
@@ -92,11 +82,11 @@ SValue[size='l'] {
|
|
|
92
82
|
}
|
|
93
83
|
|
|
94
84
|
SValue[state='normal']::before {
|
|
95
|
-
border-color: var(--intergalactic-border-primary,
|
|
85
|
+
border-color: var(--intergalactic-border-primary, oklch(0.137 0.026 175.7 / 0.161));
|
|
96
86
|
}
|
|
97
87
|
|
|
98
88
|
SValue[state='invalid']::before {
|
|
99
|
-
border-color: var(--intergalactic-border-critical-active,
|
|
89
|
+
border-color: var(--intergalactic-border-critical-active, oklch(0.628 0.258 29 / 0.56));
|
|
100
90
|
}
|
|
101
91
|
|
|
102
92
|
SControl {
|
|
@@ -104,11 +94,6 @@ SControl {
|
|
|
104
94
|
clip: rect(1px, 1px, 1px, 1px);
|
|
105
95
|
}
|
|
106
96
|
|
|
107
|
-
SControl:checked~SValue::before {
|
|
108
|
-
border-color: var(--intergalactic-control-primary-info, #008ff8);
|
|
109
|
-
background-color: var(--intergalactic-control-primary-info, #008ff8);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
97
|
SControl:checked~SValue[size='m']::after {
|
|
113
98
|
width: 6px;
|
|
114
99
|
height: 6px;
|
|
@@ -119,13 +104,21 @@ SControl:checked~SValue[size='l']::after {
|
|
|
119
104
|
height: 8px;
|
|
120
105
|
}
|
|
121
106
|
|
|
122
|
-
SValue[state='normal']
|
|
123
|
-
|
|
124
|
-
|
|
107
|
+
SControl:focus-visible+SValue[state='normal']::before {
|
|
108
|
+
border-color: var(--intergalactic-border-info-active, oklch(0.382 0.248 264.2 / 0.386));
|
|
109
|
+
@mixin focus-outline-mixin;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
SControl:checked~SValue::before,
|
|
113
|
+
SControl:checked:focus-visible~SValue::before {
|
|
114
|
+
border-color: var(--intergalactic-control-primary-info, oklch(0.23 0.01 140));
|
|
115
|
+
background-color: var(--intergalactic-control-primary-info, oklch(0.23 0.01 140));
|
|
125
116
|
}
|
|
126
117
|
|
|
127
|
-
SValue[state='invalid']
|
|
128
|
-
|
|
118
|
+
SControl:focus-visible+SValue[state='invalid']::before {
|
|
119
|
+
border-color: var(--intergalactic-border-critical-active, oklch(0.628 0.258 29 / 0.56));
|
|
120
|
+
@mixin focus-outline-mixin;
|
|
121
|
+
outline-color: var(--intergalactic-keyboard-focus-invalid-outline, oklch(0.628 0.257 28.9 / 0.652));
|
|
129
122
|
}
|
|
130
123
|
|
|
131
124
|
SControl:checked~SValue[theme]::before {
|
|
@@ -147,8 +140,8 @@ SInvalidPattern {
|
|
|
147
140
|
top: 1px;
|
|
148
141
|
left: 1px;
|
|
149
142
|
border-radius: 50%;
|
|
150
|
-
background-image: var(--intergalactic-border-critical-pattern, repeating-linear-gradient(315deg,
|
|
143
|
+
background-image: var(--intergalactic-border-critical-pattern, repeating-linear-gradient(315deg, oklch(0.628 0.258 29 / 0.56) 0, oklch(0.628 0.258 29 / 0.56) 1px, transparent 0, transparent 50%));
|
|
151
144
|
background-size: 6px 6px;
|
|
152
|
-
background-color: var(--intergalactic-bg-primary-neutral,
|
|
145
|
+
background-color: var(--intergalactic-bg-primary-neutral, oklch(1 0 0));
|
|
153
146
|
}
|
|
154
147
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Intergalactic } from '@semcore/core';
|
|
2
|
+
import { inputProps } from '@semcore/core/lib/utils/inputProps';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import type { NSRadio } from './Radio.type';
|
|
5
|
+
declare const RadioGroup: NSRadio.Group.Component;
|
|
6
|
+
declare const Radio: NSRadio.Component;
|
|
7
|
+
export declare const wrapRadioGroup: <PropsExtending extends {}>(wrapper: (props: Intergalactic.InternalTypings.UntypeRefAndTag<Intergalactic.InternalTypings.ComponentPropsNesting<NSRadio.Group.Component>> & PropsExtending) => React.ReactNode) => NSRadio.Group.Component<PropsExtending>;
|
|
8
|
+
export { inputProps, RadioGroup };
|
|
9
|
+
export default Radio;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { Flex, BoxProps } from '@semcore/base-components';
|
|
2
|
+
import type { Intergalactic, PropGetterFn } from '@semcore/core';
|
|
3
|
+
import type { NSText } from '@semcore/typography';
|
|
4
|
+
declare namespace NSRadio {
|
|
5
|
+
type Size = 'm' | 'l';
|
|
6
|
+
type State = 'normal' | 'invalid';
|
|
7
|
+
type Value = string | number | boolean;
|
|
8
|
+
type Props = BoxProps & {
|
|
9
|
+
/** Radio item value **/
|
|
10
|
+
value?: NSRadio.Value;
|
|
11
|
+
/** Radio item checked flag **/
|
|
12
|
+
checked?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The value displaying the state of the component
|
|
15
|
+
* @default normal
|
|
16
|
+
*/
|
|
17
|
+
state?: NSRadio.State;
|
|
18
|
+
/**
|
|
19
|
+
* Radio button size
|
|
20
|
+
* @default m
|
|
21
|
+
**/
|
|
22
|
+
size?: NSRadio.Size;
|
|
23
|
+
/** The theme of the radio button that you can send your color to */
|
|
24
|
+
theme?: string;
|
|
25
|
+
/** Radio item text **/
|
|
26
|
+
label?: string;
|
|
27
|
+
/** Blocks access and changes to the radio item **/
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
};
|
|
30
|
+
type Ctx = {
|
|
31
|
+
getValueProps: PropGetterFn;
|
|
32
|
+
getTextProps: PropGetterFn;
|
|
33
|
+
};
|
|
34
|
+
namespace Value {
|
|
35
|
+
type Props = BoxProps & {
|
|
36
|
+
/** List of elements that can be put on a hidden input */
|
|
37
|
+
includeInputProps?: string[];
|
|
38
|
+
};
|
|
39
|
+
namespace Control {
|
|
40
|
+
type Props = {};
|
|
41
|
+
type Component = Intergalactic.Component<'input', Props>;
|
|
42
|
+
}
|
|
43
|
+
namespace Mark {
|
|
44
|
+
type Props = {};
|
|
45
|
+
type Component = Intergalactic.Component<'input', Props>;
|
|
46
|
+
}
|
|
47
|
+
type Component = Intergalactic.Component<'input', Props> & {
|
|
48
|
+
Control: Control.Component;
|
|
49
|
+
RadioMark: Mark.Component;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
namespace Text {
|
|
53
|
+
type Props = NSText.Props;
|
|
54
|
+
type Component = Intergalactic.Component<'span', Props>;
|
|
55
|
+
}
|
|
56
|
+
namespace Group {
|
|
57
|
+
type Props<T extends NSRadio.Value = NSRadio.Value> = {
|
|
58
|
+
/** Radio group name */
|
|
59
|
+
name?: string;
|
|
60
|
+
/** Active default value */
|
|
61
|
+
defaultValue?: T;
|
|
62
|
+
/** Active value */
|
|
63
|
+
value?: T;
|
|
64
|
+
/** Called when the selected element is changed */
|
|
65
|
+
onChange?: ((value: T, e?: React.SyntheticEvent<HTMLInputElement>) => void) | React.Dispatch<React.SetStateAction<T>>;
|
|
66
|
+
/** Radio button size */
|
|
67
|
+
size?: NSRadio.Size;
|
|
68
|
+
/** The theme of the radio button that you can send your color to */
|
|
69
|
+
theme?: string;
|
|
70
|
+
/** Blocks access and changes to the form field */
|
|
71
|
+
disabled?: boolean;
|
|
72
|
+
};
|
|
73
|
+
type Component<PropsExtending = {}> = (<V extends Value, Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.ComponentProps<Tag, typeof Flex, Props<V>> & PropsExtending) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', typeof Flex, Props>;
|
|
74
|
+
}
|
|
75
|
+
type Component = Intergalactic.Component<'label', Props, Ctx> & {
|
|
76
|
+
Value: Value.Component;
|
|
77
|
+
Text: Text.Component;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** @deprecated It will be removed in v18. */
|
|
81
|
+
export type RadioSize = NSRadio.Size;
|
|
82
|
+
/** @deprecated It will be removed in v18. */
|
|
83
|
+
export type RadioState = NSRadio.State;
|
|
84
|
+
/** @deprecated It will be removed in v18. */
|
|
85
|
+
export type RadioValue = NSRadio.Value;
|
|
86
|
+
/** @deprecated It will be removed in v18. */
|
|
87
|
+
export type RadioProps = NSRadio.Props;
|
|
88
|
+
/** @deprecated It will be removed in v18. */
|
|
89
|
+
export type RadioGroupProps<T extends RadioValue = RadioValue> = NSRadio.Group.Props<T>;
|
|
90
|
+
/** @deprecated It will be removed in v18. */
|
|
91
|
+
export type RadioValueProps = NSRadio.Value.Props;
|
|
92
|
+
/** @deprecated It will be removed in v18. */
|
|
93
|
+
export type RadioCtx = NSRadio.Ctx;
|
|
94
|
+
/** @deprecated It will be removed in v18. */
|
|
95
|
+
export type RadioValueControlProps = NSRadio.Value.Control.Props;
|
|
96
|
+
/** @deprecated It will be removed in v18. */
|
|
97
|
+
export type RadioValueMarkProps = NSRadio.Value.Mark.Props;
|
|
98
|
+
export type { NSRadio };
|