@semcore/radio 6.44.0-prerelease.0 → 6.44.0-prerelease.1
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/cjs/Radio.js +144 -129
- package/lib/cjs/Radio.js.map +1 -1
- package/lib/cjs/index.d.js +2 -0
- package/lib/cjs/index.d.js.map +1 -0
- package/lib/cjs/index.js +5 -21
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/radio.shadow.css +19 -12
- package/lib/es6/Radio.js +131 -120
- package/lib/es6/Radio.js.map +1 -1
- package/lib/es6/index.d.js +2 -0
- package/lib/es6/index.d.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 +19 -12
- package/lib/esm/Radio.mjs +105 -92
- package/lib/esm/index.mjs +2 -1
- package/lib/esm/style/radio.shadow.css +19 -12
- package/lib/types/index.d.ts +149 -2
- package/package.json +5 -5
- package/lib/cjs/Radio.type.js +0 -2
- package/lib/cjs/Radio.type.js.map +0 -1
- package/lib/es6/Radio.type.js +0 -2
- package/lib/es6/Radio.type.js.map +0 -1
- package/lib/esm/Radio.type.mjs +0 -1
- package/lib/types/Radio.d.ts +0 -9
- package/lib/types/Radio.type.d.ts +0 -98
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { PropGetterFn, UnknownProperties, Intergalactic } from '@semcore/core';\nimport { Box, BoxProps, Flex } from '@semcore/flex-box';\nimport { KeyboardFocusProps } from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport { Text } from '@semcore/typography';\n\nexport type RadioSize = 'm' | 'l';\nexport type RadioState = 'normal' | 'invalid';\nexport type RadioValue = string | number | boolean;\n\n/** @deprecated */\nexport interface IRadioProps extends RadioProps, UnknownProperties {}\nexport type RadioProps = BoxProps & {\n /** Radio item value **/\n value?: RadioValue;\n\n /** Radio item checked flag **/\n checked?: boolean;\n\n /**\n * The value displaying the state of the component\n * @default normal\n */\n state?: RadioState;\n /**\n * Radio button size\n * @default m\n **/\n size?: RadioSize;\n /** The theme of the radio button that you can send your color to */\n theme?: string;\n /** Radio item text **/\n label?: string;\n /** Blocks access and changes to the radio item **/\n disabled?: boolean;\n};\n\n/** @deprecated */\nexport interface IRadioGroupProps extends RadioGroupProps, UnknownProperties {\n /**\n * HTML tag name for the displayed item\n */\n tag?: React.ElementType | string;\n}\nexport type RadioGroupProps<T extends RadioValue = RadioValue> = {\n /** Radio group name */\n name?: string;\n /** Active default value */\n defaultValue?: T;\n /** Active value */\n value?: T;\n /** Called when the selected element is changed */\n onChange?:\n | ((value: T, e?: React.SyntheticEvent<HTMLInputElement>) => void)\n | React.Dispatch<React.SetStateAction<T>>;\n /** Radio button size */\n size?: RadioSize;\n /** The theme of the radio button that you can send your color to */\n theme?: string;\n /** Blocks access and changes to the form field */\n disabled?: boolean;\n};\n\n/** @deprecated */\nexport interface IRadioValueProps extends RadioValueProps, UnknownProperties {}\nexport type RadioValueProps = BoxProps &\n KeyboardFocusProps & {\n /** List of elements that can be put on a hidden input */\n includeInputProps?: string[];\n /**\n * @deprecated set `state` on root Radio instead\n * The value displaying the state of the component\n * @default normal\n */\n state?: RadioState;\n /**\n * @deprecated\n * The theme of the radio button that you can send your color to\n */\n theme?: string;\n /**\n * @deprecated set `size` on root RadioGroup instead\n * Radio button size\n */\n size?: RadioSize;\n /**\n * @deprecated set `value` on root Radio instead\n * The element value is required for RadioGroup\n */\n value?: RadioValue;\n /**\n * @deprecated set `defaultValue` on root RadioGroup instead\n * Default value if `value` property is not provided\n */\n defaultValue?: RadioValue;\n /**\n * @deprecated set `onChange` on root RadioGroup instead\n * Called when the value changes\n */\n onChange?: (value: boolean, e?: React.SyntheticEvent<HTMLInputElement>) => void;\n /**\n * @deprecated set `disabled` on root Radio instead\n * Blocks access and changes to the form field\n */\n disabled?: boolean;\n };\n\n/** @deprecated */\nexport interface IRadioCtx extends RadioCtx, UnknownProperties {}\nexport type RadioCtx = {\n getValueProps: PropGetterFn;\n getTextProps: PropGetterFn;\n};\n\ntype IntergalacticRadioGroupComponent<PropsExtending = {}> = (<\n Value extends RadioValue,\n Tag extends Intergalactic.Tag = typeof Flex,\n>(\n props: Intergalactic.InternalTypings.ComponentProps<Tag, typeof Flex, RadioGroupProps<Value>> &\n PropsExtending,\n) => Intergalactic.InternalTypings.ComponentRenderingResults) &\n Intergalactic.InternalTypings.ComponentAdditive<'div', typeof Flex, RadioGroupProps>;\n\nexport type RadioValueControlProps = {};\nexport type RadioValueMarkProps = {};\n\ndeclare const RadioGroup: IntergalacticRadioGroupComponent;\n\nexport { RadioGroup };\n\ndeclare const Radio: Intergalactic.Component<'label', RadioProps, RadioCtx> & {\n Value: Intergalactic.Component<'input', RadioValueProps> & {\n Control: Intergalactic.Component<'input', RadioValueControlProps>;\n RadioMark: Intergalactic.Component<typeof Box, RadioValueMarkProps>;\n };\n Text: typeof Text;\n};\n\ndeclare const wrapRadioGroup: <PropsExtending extends {}>(\n wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticRadioGroupComponent>\n > &\n PropsExtending,\n ) => React.ReactNode,\n) => IntergalacticRadioGroupComponent<PropsExtending>;\nexport { wrapRadioGroup };\n\nexport default Radio;\n"],"mappings":""}
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,41 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
var _exportNames = {
|
|
8
|
-
wrapRadioGroup: true,
|
|
9
|
-
RadioGroup: true
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "RadioGroup", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function get() {
|
|
14
|
-
return _Radio.RadioGroup;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
7
|
+
var _exportNames = {};
|
|
17
8
|
Object.defineProperty(exports, "default", {
|
|
18
9
|
enumerable: true,
|
|
19
10
|
get: function get() {
|
|
20
11
|
return _Radio["default"];
|
|
21
12
|
}
|
|
22
13
|
});
|
|
23
|
-
Object.defineProperty(exports, "wrapRadioGroup", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function get() {
|
|
26
|
-
return _Radio.wrapRadioGroup;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
14
|
var _Radio = _interopRequireWildcard(require("./Radio"));
|
|
30
|
-
|
|
31
|
-
Object.keys(_Radio2).forEach(function (key) {
|
|
15
|
+
Object.keys(_Radio).forEach(function (key) {
|
|
32
16
|
if (key === "default" || key === "__esModule") return;
|
|
33
17
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
34
|
-
if (key in exports && exports[key] ===
|
|
18
|
+
if (key in exports && exports[key] === _Radio[key]) return;
|
|
35
19
|
Object.defineProperty(exports, key, {
|
|
36
20
|
enumerable: true,
|
|
37
21
|
get: function get() {
|
|
38
|
-
return
|
|
22
|
+
return _Radio[key];
|
|
39
23
|
}
|
|
40
24
|
});
|
|
41
25
|
});
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Radio","_interopRequireWildcard","require","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Radio","_interopRequireWildcard","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["../../src/index.js"],"sourcesContent":["export { default } from './Radio';\nexport * from './Radio';\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACAC,MAAA,CAAAC,IAAA,CAAAJ,MAAA,EAAAK,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAN,MAAA,CAAAM,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAd,MAAA,CAAAM,GAAA;IAAA;EAAA;AAAA"}
|
|
@@ -17,6 +17,16 @@ 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
|
+
|
|
20
30
|
SValue {
|
|
21
31
|
position: relative;
|
|
22
32
|
flex-shrink: 0;
|
|
@@ -94,6 +104,11 @@ SControl {
|
|
|
94
104
|
clip: rect(1px, 1px, 1px, 1px);
|
|
95
105
|
}
|
|
96
106
|
|
|
107
|
+
SControl:checked~SValue::before {
|
|
108
|
+
border-color: var(--intergalactic-control-primary-info, oklch(0.23 0.01 140));
|
|
109
|
+
background-color: var(--intergalactic-control-primary-info, oklch(0.23 0.01 140));
|
|
110
|
+
}
|
|
111
|
+
|
|
97
112
|
SControl:checked~SValue[size='m']::after {
|
|
98
113
|
width: 6px;
|
|
99
114
|
height: 6px;
|
|
@@ -104,21 +119,13 @@ SControl:checked~SValue[size='l']::after {
|
|
|
104
119
|
height: 8px;
|
|
105
120
|
}
|
|
106
121
|
|
|
107
|
-
|
|
122
|
+
SValue[state='normal'][keyboardFocused]::before {
|
|
123
|
+
box-shadow: var(--intergalactic-keyboard-focus, 0px 0px 0px 3px oklch(0.376 0.247 264.2 / 0.441));
|
|
108
124
|
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));
|
|
116
125
|
}
|
|
117
126
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
@mixin focus-outline-mixin;
|
|
121
|
-
outline-color: var(--intergalactic-keyboard-focus-invalid-outline, oklch(0.628 0.257 28.9 / 0.652));
|
|
127
|
+
SValue[state='invalid'][keyboardFocused]::before {
|
|
128
|
+
box-shadow: var(--intergalactic-keyboard-focus-invalid, 0px 0px 0px 3px oklch(0.628 0.257 28.9 / 0.652));
|
|
122
129
|
}
|
|
123
130
|
|
|
124
131
|
SControl:checked~SValue[theme]::before {
|
package/lib/es6/Radio.js
CHANGED
|
@@ -1,54 +1,58 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
5
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
5
6
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
6
|
-
import _callSuper from "@babel/runtime/helpers/callSuper";
|
|
7
7
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
|
+
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
8
9
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
import { sstyled as _sstyled } from "@semcore/core";
|
|
10
|
+
import { sstyled as _sstyled } from "@semcore/utils/lib/core/index";
|
|
10
11
|
import { assignProps as _assignProps5 } from "@semcore/core";
|
|
11
12
|
import { assignProps as _assignProps4 } from "@semcore/core";
|
|
12
13
|
import { assignProps as _assignProps3 } from "@semcore/core";
|
|
13
14
|
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
14
15
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
15
|
-
var _excluded = ["size", "state", "theme", "keyboardFocused", "value", "tag", "disabled", "includeInputProps", "resolveColor",
|
|
16
|
-
|
|
17
|
-
import { createComponent, Component, sstyled, Root } from '@semcore/core';
|
|
18
|
-
import { callAllEventHandlers } from '@semcore/core/lib/utils/assignProps';
|
|
19
|
-
import resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';
|
|
20
|
-
import getInputProps, { inputProps } from '@semcore/core/lib/utils/inputProps';
|
|
21
|
-
import logger from '@semcore/core/lib/utils/logger';
|
|
22
|
-
import { useColorResolver } from '@semcore/core/lib/utils/use/useColorResolver';
|
|
23
|
-
import { Text as TypographyText } from '@semcore/typography';
|
|
16
|
+
var _excluded = ["size", "state", "theme", "keyboardFocused", "value", "tag", "disabled", "includeInputProps", "resolveColor"],
|
|
17
|
+
_excluded2 = ["children", "Children"];
|
|
24
18
|
import React from 'react';
|
|
19
|
+
import createComponent, { Component, CONTEXT_COMPONENT, sstyled, Root } from '@semcore/core';
|
|
20
|
+
import { Flex, Box, InvalidStateBox } from '@semcore/flex-box';
|
|
21
|
+
import assignProps, { callAllEventHandlers } from '@semcore/utils/lib/assignProps';
|
|
22
|
+
import keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';
|
|
23
|
+
import resolveColorEnhance from '@semcore/utils/lib/enhances/resolveColorEnhance';
|
|
24
|
+
import getInputProps, { inputProps } from '@semcore/utils/lib/inputProps';
|
|
25
|
+
import { useColorResolver } from '@semcore/utils/lib/use/useColorResolver';
|
|
25
26
|
/*!__reshadow-styles__:"./style/radio.shadow.css"*/
|
|
26
|
-
var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".
|
|
27
|
+
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SRadio_kf98w_gg_{display:inline-flex;align-items:flex-start;cursor:pointer}.___SRadio_kf98w_gg_ .___SText_kf98w_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899))}.___SRadio_kf98w_gg_ .___SText_kf98w_gg_.__color_kf98w_gg_{color:var(--color_kf98w)}.___SRadio_kf98w_gg_.__disabled_kf98w_gg_{pointer-events:none}.___SText_kf98w_gg_._size_m_kf98w_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___SText_kf98w_gg_._size_l_kf98w_gg_{font-size:var(--intergalactic-fs-300, 16px);line-height:var(--intergalactic-lh-300, 150%)}.___SValue_kf98w_gg_{position:relative;flex-shrink:0;padding:0;outline:0;z-index:0;margin-top:var(--intergalactic-spacing-05x, 2px)}.___SValue_kf98w_gg_::after,.___SValue_kf98w_gg_::before{content:\"\";position:absolute;right:0;bottom:0;border-radius:50%;background:var(--intergalactic-bg-primary-neutral, rgb(255, 255, 255))}.___SValue_kf98w_gg_::before{top:0;left:0;border:1px solid;transition:calc(var(--intergalactic-duration-control, 200)*1ms) all ease-in-out}.___SValue_kf98w_gg_::after{top:50%;left:50%;transform:translate(-50%,-50%);width:0;height:0}.___SValue_kf98w_gg_.__disabled_kf98w_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_kf98w_gg_._size_m_kf98w_gg_{width:16px;height:16px}.___SValue_kf98w_gg_._size_m_kf98w_gg_ .___SInvalidPattern_kf98w_gg_:before{width:14px;height:14px}.___SValue_kf98w_gg_._size_l_kf98w_gg_{width:20px;height:20px}.___SValue_kf98w_gg_._size_l_kf98w_gg_ .___SInvalidPattern_kf98w_gg_:before{width:18px;height:18px}.___SValue_kf98w_gg_._state_normal_kf98w_gg_::before{border-color:var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@supports (color:color(display-p3 0 0 0)){.___SValue_kf98w_gg_._state_normal_kf98w_gg_::before{border-color:var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___SValue_kf98w_gg_._state_normal_kf98w_gg_::before{border-color:var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___SValue_kf98w_gg_._state_invalid_kf98w_gg_::before{border-color:var(--intergalactic-border-critical-active, rgba(255, 0, 4, 0.56))}@supports (color:color(display-p3 0 0 0)){.___SValue_kf98w_gg_._state_invalid_kf98w_gg_::before{border-color:var(--intergalactic-border-critical-active, rgba(255, 0, 4, 0.56))}@media (color-gamut:p3){.___SValue_kf98w_gg_._state_invalid_kf98w_gg_::before{border-color:var(--intergalactic-border-critical-active, color(display-p3 0.918 0.19866 0.14259 / 0.56))}}}.___SControl_kf98w_gg_{position:absolute;clip:rect(1px,1px,1px,1px)}.___SControl_kf98w_gg_:checked~.___SValue_kf98w_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_kf98w_gg_:checked~.___SValue_kf98w_gg_._size_m_kf98w_gg_::after{width:6px;height:6px}.___SControl_kf98w_gg_:checked~.___SValue_kf98w_gg_._size_l_kf98w_gg_::after{width:8px;height:8px}.___SValue_kf98w_gg_._state_normal_kf98w_gg_.__keyboardFocused_kf98w_gg_::before{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 18, 193, 0.441));border-color:var(--intergalactic-border-info-active, rgba(0, 22, 195, 0.386))}@supports (color:color(display-p3 0 0 0)){.___SValue_kf98w_gg_._state_normal_kf98w_gg_.__keyboardFocused_kf98w_gg_::before{border-color:var(--intergalactic-border-info-active, rgba(0, 22, 195, 0.386))}@media (color-gamut:p3){.___SValue_kf98w_gg_._state_normal_kf98w_gg_.__keyboardFocused_kf98w_gg_::before{border-color:var(--intergalactic-border-info-active, color(display-p3 0.01805 0.08333 0.73488 / 0.386))}}}.___SValue_kf98w_gg_._state_invalid_kf98w_gg_.__keyboardFocused_kf98w_gg_::before{box-shadow:var(--intergalactic-keyboard-focus-invalid, 0px 0px 0px 3px rgba(255, 2, 7, 0.652))}.___SControl_kf98w_gg_:checked~.___SValue_kf98w_gg_.__theme_kf98w_gg_::before{border-color:var(--theme_kf98w);background-color:var(--theme_kf98w)}.___SValue_kf98w_gg_._state_normal_kf98w_gg_.__theme_kf98w_gg_::before{border-color:var(--theme_kf98w)}.___SInvalidPattern_kf98w_gg_{background:0 0;overflow:hidden}.___SInvalidPattern_kf98w_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_kf98w_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_kf98w_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%))}}}", /*__inner_css_end__*/"kf98w_gg_"),
|
|
27
28
|
/*__reshadow_css_end__*/
|
|
28
29
|
{
|
|
29
|
-
"__SRadio": "
|
|
30
|
-
"_disabled": "
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
30
|
+
"__SRadio": "___SRadio_kf98w_gg_",
|
|
31
|
+
"_disabled": "__disabled_kf98w_gg_",
|
|
32
|
+
"__SText": "___SText_kf98w_gg_",
|
|
33
|
+
"_size_m": "_size_m_kf98w_gg_",
|
|
34
|
+
"_size_l": "_size_l_kf98w_gg_",
|
|
35
|
+
"__SValue": "___SValue_kf98w_gg_",
|
|
36
|
+
"_state_normal": "_state_normal_kf98w_gg_",
|
|
37
|
+
"_state_invalid": "_state_invalid_kf98w_gg_",
|
|
38
|
+
"__SControl": "___SControl_kf98w_gg_",
|
|
39
|
+
"_keyboardFocused": "__keyboardFocused_kf98w_gg_",
|
|
40
|
+
"_theme": "__theme_kf98w_gg_",
|
|
41
|
+
"--theme": "--theme_kf98w",
|
|
42
|
+
"_color": "__color_kf98w_gg_",
|
|
43
|
+
"--color": "--color_kf98w",
|
|
44
|
+
"__SInvalidPattern": "___SInvalidPattern_kf98w_gg_"
|
|
43
45
|
});
|
|
44
|
-
|
|
46
|
+
import logger from '@semcore/utils/lib/logger';
|
|
47
|
+
import { Text as TypographyText } from '@semcore/typography';
|
|
45
48
|
var RadioGroupRoot = /*#__PURE__*/function (_Component) {
|
|
49
|
+
_inherits(RadioGroupRoot, _Component);
|
|
50
|
+
var _super = _createSuper(RadioGroupRoot);
|
|
46
51
|
function RadioGroupRoot() {
|
|
47
52
|
_classCallCheck(this, RadioGroupRoot);
|
|
48
|
-
return
|
|
53
|
+
return _super.apply(this, arguments);
|
|
49
54
|
}
|
|
50
|
-
|
|
51
|
-
return _createClass(RadioGroupRoot, [{
|
|
55
|
+
_createClass(RadioGroupRoot, [{
|
|
52
56
|
key: "uncontrolledProps",
|
|
53
57
|
value: function uncontrolledProps() {
|
|
54
58
|
return {
|
|
@@ -86,27 +90,27 @@ var RadioGroupRoot = /*#__PURE__*/function (_Component) {
|
|
|
86
90
|
}, _ref), /*#__PURE__*/React.createElement(Children, null));
|
|
87
91
|
}
|
|
88
92
|
}]);
|
|
93
|
+
return RadioGroupRoot;
|
|
89
94
|
}(Component);
|
|
90
95
|
_defineProperty(RadioGroupRoot, "displayName", 'RadioGroup');
|
|
91
96
|
_defineProperty(RadioGroupRoot, "defaultProps", {
|
|
92
97
|
defaultValue: null
|
|
93
98
|
});
|
|
94
|
-
var RadioGroup = createComponent(RadioGroupRoot
|
|
95
|
-
context: RadioContext
|
|
96
|
-
});
|
|
99
|
+
var RadioGroup = createComponent(RadioGroupRoot);
|
|
97
100
|
var RadioRoot = /*#__PURE__*/function (_Component2) {
|
|
101
|
+
_inherits(RadioRoot, _Component2);
|
|
102
|
+
var _super2 = _createSuper(RadioRoot);
|
|
98
103
|
function RadioRoot() {
|
|
99
104
|
var _this;
|
|
100
105
|
_classCallCheck(this, RadioRoot);
|
|
101
106
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
102
107
|
args[_key] = arguments[_key];
|
|
103
108
|
}
|
|
104
|
-
_this =
|
|
105
|
-
_defineProperty(_this, "
|
|
106
|
-
_defineProperty(_this, "state", {
|
|
109
|
+
_this = _super2.call.apply(_super2, [this].concat(args));
|
|
110
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
107
111
|
hoistedDisabled: undefined
|
|
108
112
|
});
|
|
109
|
-
_defineProperty(_this, "hoistDisabled", function (disabled) {
|
|
113
|
+
_defineProperty(_assertThisInitialized(_this), "hoistDisabled", function (disabled) {
|
|
110
114
|
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
115
|
_this.setState({
|
|
112
116
|
hoistedDisabled: disabled
|
|
@@ -114,20 +118,18 @@ var RadioRoot = /*#__PURE__*/function (_Component2) {
|
|
|
114
118
|
});
|
|
115
119
|
return _this;
|
|
116
120
|
}
|
|
117
|
-
|
|
118
|
-
return _createClass(RadioRoot, [{
|
|
121
|
+
_createClass(RadioRoot, [{
|
|
119
122
|
key: "getTextProps",
|
|
120
123
|
value: function getTextProps() {
|
|
121
|
-
|
|
122
|
-
var
|
|
123
|
-
|
|
124
|
-
size =
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
label = _this$asProps2.label;
|
|
124
|
+
// The default values are here, since you cannot rewrite out of context
|
|
125
|
+
var _assignProps6 = assignProps(this.asProps, this.context),
|
|
126
|
+
_assignProps6$size = _assignProps6.size,
|
|
127
|
+
size = _assignProps6$size === void 0 ? 'm' : _assignProps6$size,
|
|
128
|
+
disabled = _assignProps6.disabled,
|
|
129
|
+
label = _assignProps6.label;
|
|
128
130
|
var hoistedDisabled = this.state.hoistedDisabled;
|
|
129
131
|
var textProps = {
|
|
130
|
-
size: size
|
|
132
|
+
size: size,
|
|
131
133
|
children: label,
|
|
132
134
|
disabled: disabled !== null && disabled !== void 0 ? disabled : hoistedDisabled,
|
|
133
135
|
hoistDisabled: this.hoistDisabled,
|
|
@@ -138,21 +140,19 @@ var RadioRoot = /*#__PURE__*/function (_Component2) {
|
|
|
138
140
|
}, {
|
|
139
141
|
key: "getValueProps",
|
|
140
142
|
value: function getValueProps() {
|
|
141
|
-
var _this$
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
theme =
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
value = _this$asProps4.value,
|
|
155
|
-
checked = _this$asProps4.checked;
|
|
143
|
+
var _this$props$size;
|
|
144
|
+
// The default values are here, since you cannot rewrite out of context
|
|
145
|
+
var _assignProps7 = assignProps(this.asProps, this.context),
|
|
146
|
+
_assignProps7$size = _assignProps7.size,
|
|
147
|
+
size = _assignProps7$size === void 0 ? 'm' : _assignProps7$size,
|
|
148
|
+
_assignProps7$state = _assignProps7.state,
|
|
149
|
+
state = _assignProps7$state === void 0 ? 'normal' : _assignProps7$state,
|
|
150
|
+
theme = _assignProps7.theme,
|
|
151
|
+
disabled = _assignProps7.disabled,
|
|
152
|
+
name = _assignProps7.name;
|
|
153
|
+
var _this$asProps2 = this.asProps,
|
|
154
|
+
value = _this$asProps2.value,
|
|
155
|
+
checked = _this$asProps2.checked;
|
|
156
156
|
var hoistedDisabled = this.state.hoistedDisabled;
|
|
157
157
|
return {
|
|
158
158
|
size: (_this$props$size = this.props.size) !== null && _this$props$size !== void 0 ? _this$props$size : size,
|
|
@@ -172,40 +172,41 @@ var RadioRoot = /*#__PURE__*/function (_Component2) {
|
|
|
172
172
|
var _ref2 = this.asProps,
|
|
173
173
|
_ref6;
|
|
174
174
|
var SRadio = Box;
|
|
175
|
-
var _this$
|
|
176
|
-
styles = _this$
|
|
177
|
-
Children = _this$
|
|
178
|
-
hasChildren = _this$
|
|
175
|
+
var _this$asProps3 = this.asProps,
|
|
176
|
+
styles = _this$asProps3.styles,
|
|
177
|
+
Children = _this$asProps3.Children,
|
|
178
|
+
hasChildren = _this$asProps3.children;
|
|
179
179
|
return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(SRadio, _ref6.cn("SRadio", _objectSpread({}, _assignProps2({
|
|
180
180
|
"tag": 'label',
|
|
181
181
|
"__excludeProps": ['onChange', 'label', 'disabled']
|
|
182
182
|
}, _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)));
|
|
183
183
|
}
|
|
184
184
|
}]);
|
|
185
|
+
return RadioRoot;
|
|
185
186
|
}(Component);
|
|
186
187
|
_defineProperty(RadioRoot, "displayName", 'Radio');
|
|
187
188
|
_defineProperty(RadioRoot, "style", style);
|
|
188
|
-
_defineProperty(RadioRoot, "contextType",
|
|
189
|
+
_defineProperty(RadioRoot, "contextType", RadioGroup[CONTEXT_COMPONENT]);
|
|
189
190
|
var ValueRoot = /*#__PURE__*/function (_Component3) {
|
|
191
|
+
_inherits(ValueRoot, _Component3);
|
|
192
|
+
var _super3 = _createSuper(ValueRoot);
|
|
190
193
|
function ValueRoot() {
|
|
191
194
|
var _this2;
|
|
192
195
|
_classCallCheck(this, ValueRoot);
|
|
193
196
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
194
197
|
args[_key2] = arguments[_key2];
|
|
195
198
|
}
|
|
196
|
-
_this2 =
|
|
197
|
-
_defineProperty(_this2, "
|
|
198
|
-
_defineProperty(_this2, "bindHandlerChange", function (value) {
|
|
199
|
+
_this2 = _super3.call.apply(_super3, [this].concat(args));
|
|
200
|
+
_defineProperty(_assertThisInitialized(_this2), "bindHandlerChange", function (value) {
|
|
199
201
|
return function (e) {
|
|
200
|
-
if (typeof _this2.context.onChange === 'function'
|
|
202
|
+
if (typeof _this2.context.onChange === 'function') {
|
|
201
203
|
_this2.context.onChange(value, e);
|
|
202
204
|
}
|
|
203
205
|
};
|
|
204
206
|
});
|
|
205
207
|
return _this2;
|
|
206
208
|
}
|
|
207
|
-
|
|
208
|
-
return _createClass(ValueRoot, [{
|
|
209
|
+
_createClass(ValueRoot, [{
|
|
209
210
|
key: "uncontrolledProps",
|
|
210
211
|
value: function uncontrolledProps() {
|
|
211
212
|
return {
|
|
@@ -218,50 +219,54 @@ var ValueRoot = /*#__PURE__*/function (_Component3) {
|
|
|
218
219
|
key: "getControlProps",
|
|
219
220
|
value: function getControlProps() {
|
|
220
221
|
var currentValue = this.context.value;
|
|
221
|
-
var _this$
|
|
222
|
-
forwardRef = _this$
|
|
223
|
-
includeInputProps = _this$
|
|
224
|
-
state = _this$
|
|
225
|
-
value = _this$
|
|
226
|
-
var onChange = this.props.onChange;
|
|
222
|
+
var _this$asProps4 = this.asProps,
|
|
223
|
+
forwardRef = _this$asProps4.forwardRef,
|
|
224
|
+
includeInputProps = _this$asProps4.includeInputProps,
|
|
225
|
+
state = _this$asProps4.state,
|
|
226
|
+
value = _this$asProps4.value;
|
|
227
227
|
var _getInputProps = getInputProps(this.asProps, includeInputProps),
|
|
228
228
|
_getInputProps2 = _slicedToArray(_getInputProps, 1),
|
|
229
229
|
commonControlProps = _getInputProps2[0];
|
|
230
230
|
var inputValue = value !== null && value !== void 0 ? value : '';
|
|
231
|
-
|
|
231
|
+
var controlProps = _objectSpread(_objectSpread({
|
|
232
232
|
ref: forwardRef,
|
|
233
233
|
state: state
|
|
234
234
|
}, commonControlProps), {}, {
|
|
235
235
|
value: inputValue
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
236
|
+
});
|
|
237
|
+
if (currentValue !== undefined) {
|
|
238
|
+
var _this$props = this.props,
|
|
239
|
+
onChange = _this$props.onChange,
|
|
240
|
+
onClick = _this$props.onClick;
|
|
241
|
+
controlProps.checked = currentValue === inputValue;
|
|
242
|
+
controlProps.onChange = callAllEventHandlers(onChange, this.bindHandlerChange(inputValue));
|
|
243
|
+
}
|
|
244
|
+
return controlProps;
|
|
240
245
|
}
|
|
241
246
|
}, {
|
|
242
247
|
key: "getRadioMarkProps",
|
|
243
248
|
value: function getRadioMarkProps() {
|
|
244
249
|
var currentValue = this.context.value;
|
|
245
|
-
var _this$
|
|
246
|
-
size = _this$
|
|
247
|
-
state = _this$
|
|
248
|
-
theme = _this$
|
|
249
|
-
keyboardFocused = _this$
|
|
250
|
-
value = _this$
|
|
251
|
-
tag = _this$
|
|
252
|
-
disabled = _this$
|
|
253
|
-
includeInputProps = _this$
|
|
254
|
-
resolveColor = _this$
|
|
255
|
-
|
|
256
|
-
Children = _this$asProps7.Children,
|
|
257
|
-
other = _objectWithoutProperties(_this$asProps7, _excluded);
|
|
258
|
-
var onClick = this.props.onClick;
|
|
250
|
+
var _this$asProps5 = this.asProps,
|
|
251
|
+
size = _this$asProps5.size,
|
|
252
|
+
state = _this$asProps5.state,
|
|
253
|
+
theme = _this$asProps5.theme,
|
|
254
|
+
keyboardFocused = _this$asProps5.keyboardFocused,
|
|
255
|
+
value = _this$asProps5.value,
|
|
256
|
+
tag = _this$asProps5.tag,
|
|
257
|
+
disabled = _this$asProps5.disabled,
|
|
258
|
+
includeInputProps = _this$asProps5.includeInputProps,
|
|
259
|
+
resolveColor = _this$asProps5.resolveColor,
|
|
260
|
+
other = _objectWithoutProperties(_this$asProps5, _excluded);
|
|
259
261
|
var _getInputProps3 = getInputProps(other, includeInputProps),
|
|
260
262
|
_getInputProps4 = _slicedToArray(_getInputProps3, 2),
|
|
261
263
|
commonControlProps = _getInputProps4[0],
|
|
262
264
|
radioMarkProps = _getInputProps4[1];
|
|
265
|
+
var children = radioMarkProps.children,
|
|
266
|
+
Children = radioMarkProps.Children,
|
|
267
|
+
propsWithoutChildren = _objectWithoutProperties(radioMarkProps, _excluded2);
|
|
263
268
|
var inputValue = value !== null && value !== void 0 ? value : '';
|
|
264
|
-
|
|
269
|
+
var markProps = _objectSpread({
|
|
265
270
|
theme: theme,
|
|
266
271
|
size: size,
|
|
267
272
|
state: state,
|
|
@@ -269,9 +274,14 @@ var ValueRoot = /*#__PURE__*/function (_Component3) {
|
|
|
269
274
|
disabled: disabled,
|
|
270
275
|
resolveColor: resolveColor,
|
|
271
276
|
checked: commonControlProps.checked
|
|
272
|
-
},
|
|
273
|
-
|
|
274
|
-
|
|
277
|
+
}, propsWithoutChildren);
|
|
278
|
+
if (currentValue !== undefined) {
|
|
279
|
+
var onClick = this.props.onClick;
|
|
280
|
+
if (tag !== 'label') {
|
|
281
|
+
markProps.onClick = callAllEventHandlers(onClick, this.bindHandlerChange(inputValue));
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return markProps;
|
|
275
285
|
}
|
|
276
286
|
}, {
|
|
277
287
|
key: "componentDidUpdate",
|
|
@@ -291,10 +301,10 @@ var ValueRoot = /*#__PURE__*/function (_Component3) {
|
|
|
291
301
|
key: "render",
|
|
292
302
|
value: function render() {
|
|
293
303
|
var _ref8;
|
|
294
|
-
var _this$
|
|
295
|
-
styles = _this$
|
|
296
|
-
hasChildren = _this$
|
|
297
|
-
Children = _this$
|
|
304
|
+
var _this$asProps6 = this.asProps,
|
|
305
|
+
styles = _this$asProps6.styles,
|
|
306
|
+
hasChildren = _this$asProps6.children,
|
|
307
|
+
Children = _this$asProps6.Children;
|
|
298
308
|
if (!hasChildren) {
|
|
299
309
|
var _ref7;
|
|
300
310
|
return _ref7 = sstyled(styles), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Radio.Value.Control, null), /*#__PURE__*/React.createElement(Radio.Value.RadioMark, null));
|
|
@@ -302,16 +312,17 @@ var ValueRoot = /*#__PURE__*/function (_Component3) {
|
|
|
302
312
|
return _ref8 = sstyled(styles), /*#__PURE__*/React.createElement(Children, _ref8.cn("Children", {}));
|
|
303
313
|
}
|
|
304
314
|
}]);
|
|
315
|
+
return ValueRoot;
|
|
305
316
|
}(Component);
|
|
306
317
|
_defineProperty(ValueRoot, "defaultProps", {
|
|
307
318
|
includeInputProps: inputProps,
|
|
308
319
|
defaultChecked: false
|
|
309
320
|
});
|
|
310
|
-
_defineProperty(ValueRoot, "enhance", [resolveColorEnhance()]);
|
|
321
|
+
_defineProperty(ValueRoot, "enhance", [keyboardFocusEnhance(), resolveColorEnhance()]);
|
|
311
322
|
_defineProperty(ValueRoot, "displayName", 'Value');
|
|
312
|
-
_defineProperty(ValueRoot, "contextType",
|
|
323
|
+
_defineProperty(ValueRoot, "contextType", RadioGroup[CONTEXT_COMPONENT]);
|
|
313
324
|
_defineProperty(ValueRoot, "style", style);
|
|
314
|
-
function Control(props) {
|
|
325
|
+
var Control = function Control(props) {
|
|
315
326
|
var _ref3 = arguments[0],
|
|
316
327
|
_ref9;
|
|
317
328
|
var SControl = Box;
|
|
@@ -322,11 +333,11 @@ function Control(props) {
|
|
|
322
333
|
"type": 'radio',
|
|
323
334
|
"aria-invalid": state === 'invalid'
|
|
324
335
|
}, _ref3))));
|
|
325
|
-
}
|
|
336
|
+
};
|
|
326
337
|
Control.displayName = 'Control';
|
|
327
|
-
function RadioMark(props) {
|
|
338
|
+
var RadioMark = function RadioMark(props) {
|
|
328
339
|
var _ref4 = arguments[0],
|
|
329
|
-
|
|
340
|
+
_ref10;
|
|
330
341
|
var SValue = Box;
|
|
331
342
|
var SInvalidPattern = InvalidStateBox;
|
|
332
343
|
var theme = props.theme,
|
|
@@ -334,16 +345,16 @@ function RadioMark(props) {
|
|
|
334
345
|
resolveColor = props.resolveColor,
|
|
335
346
|
state = props.state,
|
|
336
347
|
checked = props.checked;
|
|
337
|
-
return
|
|
348
|
+
return _ref10 = sstyled(styles), /*#__PURE__*/React.createElement(SValue, _ref10.cn("SValue", _objectSpread({}, _assignProps4({
|
|
338
349
|
"tag": 'div',
|
|
339
350
|
"use:theme": resolveColor(theme),
|
|
340
351
|
"aria-hidden": true
|
|
341
|
-
}, _ref4))), state === 'invalid' && !checked && /*#__PURE__*/React.createElement(SInvalidPattern,
|
|
342
|
-
}
|
|
352
|
+
}, _ref4))), state === 'invalid' && !checked && /*#__PURE__*/React.createElement(SInvalidPattern, _ref10.cn("SInvalidPattern", {})));
|
|
353
|
+
};
|
|
343
354
|
RadioMark.displayName = 'RadioMark';
|
|
344
|
-
function Text(props) {
|
|
355
|
+
var Text = function Text(props) {
|
|
345
356
|
var _ref5 = arguments[0],
|
|
346
|
-
|
|
357
|
+
_ref11;
|
|
347
358
|
var SText = TypographyText;
|
|
348
359
|
var styles = props.styles,
|
|
349
360
|
color = props.color;
|
|
@@ -353,12 +364,13 @@ function Text(props) {
|
|
|
353
364
|
}
|
|
354
365
|
}, [props.rootDisabled, props.disabled, props.hoistDisabled]);
|
|
355
366
|
var resolveColor = useColorResolver();
|
|
356
|
-
return
|
|
367
|
+
return _ref11 = sstyled(styles), /*#__PURE__*/React.createElement(SText, _ref11.cn("SText", _objectSpread({}, _assignProps5({
|
|
357
368
|
"tag": 'span',
|
|
358
369
|
"use:color": resolveColor(color)
|
|
359
370
|
}, _ref5))));
|
|
360
|
-
}
|
|
371
|
+
};
|
|
361
372
|
Text.displayName = 'Text';
|
|
373
|
+
export { inputProps, RadioGroup };
|
|
362
374
|
var Value = createComponent(ValueRoot, {
|
|
363
375
|
Control: Control,
|
|
364
376
|
RadioMark: RadioMark
|
|
@@ -370,6 +382,5 @@ var Radio = createComponent(RadioRoot, {
|
|
|
370
382
|
export var wrapRadioGroup = function wrapRadioGroup(wrapper) {
|
|
371
383
|
return wrapper;
|
|
372
384
|
};
|
|
373
|
-
export { inputProps, RadioGroup };
|
|
374
385
|
export default Radio;
|
|
375
386
|
//# sourceMappingURL=Radio.js.map
|