@skbkontur/react-ui 6.1.7-f9746.0 → 6.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/components/Checkbox/Checkbox.d.ts +0 -5
- package/components/Checkbox/Checkbox.js +21 -42
- package/components/Checkbox/Checkbox.js.map +1 -1
- package/components/Checkbox/Checkbox.mixins.d.ts +0 -2
- package/components/Checkbox/Checkbox.mixins.js +0 -6
- package/components/Checkbox/Checkbox.mixins.js.map +1 -1
- package/components/Checkbox/Checkbox.styles.d.ts +0 -7
- package/components/Checkbox/Checkbox.styles.js +2 -23
- package/components/Checkbox/Checkbox.styles.js.map +1 -1
- package/components/Input/Input.d.ts +3 -0
- package/components/Input/Input.js +4 -1
- package/components/Input/Input.js.map +1 -1
- package/components/PasswordInput/PasswordInput.js +13 -1
- package/components/PasswordInput/PasswordInput.js.map +1 -1
- package/components/Radio/Radio.d.ts +0 -4
- package/components/Radio/Radio.js +1 -20
- package/components/Radio/Radio.js.map +1 -1
- package/components/Radio/Radio.mixins.d.ts +0 -2
- package/components/Radio/Radio.mixins.js +0 -6
- package/components/Radio/Radio.mixins.js.map +1 -1
- package/components/Radio/Radio.styles.d.ts +0 -6
- package/components/Radio/Radio.styles.js +4 -22
- package/components/Radio/Radio.styles.js.map +1 -1
- package/components/Toggle/Toggle.d.ts +0 -5
- package/components/Toggle/Toggle.js +22 -46
- package/components/Toggle/Toggle.js.map +1 -1
- package/components/Toggle/Toggle.mixins.d.ts +0 -2
- package/components/Toggle/Toggle.mixins.js +0 -6
- package/components/Toggle/Toggle.mixins.js.map +1 -1
- package/components/Toggle/Toggle.styles.d.ts +0 -9
- package/components/Toggle/Toggle.styles.js +2 -29
- package/components/Toggle/Toggle.styles.js.map +1 -1
- package/components/Tooltip/Tooltip.d.ts +2 -0
- package/components/Tooltip/Tooltip.js +25 -4
- package/components/Tooltip/Tooltip.js.map +1 -1
- package/internal/themes/BasicTheme.d.ts +0 -31
- package/internal/themes/BasicTheme.js +0 -157
- package/internal/themes/BasicTheme.js.map +1 -1
- package/internal/themes/DarkTheme6_0.js +0 -1
- package/internal/themes/DarkTheme6_0.js.map +1 -1
- package/package.json +1 -1
|
@@ -30,6 +30,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
30
30
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
31
31
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
32
32
|
};
|
|
33
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
34
|
+
var t = {};
|
|
35
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
36
|
+
t[p] = s[p];
|
|
37
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
38
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
39
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
40
|
+
t[p[i]] = s[p[i]];
|
|
41
|
+
}
|
|
42
|
+
return t;
|
|
43
|
+
};
|
|
33
44
|
import React from 'react';
|
|
34
45
|
import { CommonWrapper } from '../../internal/CommonWrapper/index.js';
|
|
35
46
|
import { RenderLayer } from '../../internal/RenderLayer/index.js';
|
|
@@ -141,9 +152,10 @@ var PasswordInput = /** @class */ (function (_super) {
|
|
|
141
152
|
_this.setState({ visible: false });
|
|
142
153
|
};
|
|
143
154
|
_this.renderMain = function (props) {
|
|
155
|
+
var detectCapsLock = props.detectCapsLock, rest = __rest(props, ["detectCapsLock"]);
|
|
144
156
|
return (React.createElement(RenderLayer, { active: _this.state.focused, onFocusOutside: _this.handleFocusOutside, onClickOutside: _this.handleFocusOutside },
|
|
145
157
|
React.createElement("div", { "data-tid": PasswordInputDataTids.root, className: _this.styles.root() },
|
|
146
|
-
React.createElement(Input, __assign({ ref: _this.refInput, type: _this.state.visible ? 'text' : 'password', onKeyDown: _this.handleKeydown, onKeyPress: _this.handleKeyPress, rightIcon: _this.renderEye(), onFocus: _this.handleFocus }
|
|
158
|
+
React.createElement(Input, __assign({ ref: _this.refInput, type: _this.state.visible ? 'text' : 'password' }, rest, { onKeyDown: _this.handleKeydown, onKeyPress: _this.handleKeyPress, rightIcon: _this.renderEye(), onFocus: _this.handleFocus })))));
|
|
147
159
|
};
|
|
148
160
|
return _this;
|
|
149
161
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordInput.js","sourceRoot":"","sources":["PasswordInput.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,kBAAkB,IAAI,KAAK,EAAE,MAAM,iDAAiD,CAAC;AAC9F,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2DAA2D,CAAC;AAElG,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MA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I,CAAC,UAAU,CACF,CACjB,CAAC;QACJ,CAAC,CACqB,CACzB,CAAC;IACJ,CAAC;IAsFO,8CAAsB,GAA9B;QACE,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;YAClB,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACjD,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAClD,KAAK,OAAO,CAAC;YACb;gBACE,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAnJa,iCAAmB,GAAG,eAAe,AAAlB,CAAmB;IACtC,yBAAW,GAAG,eAAe,AAAlB,CAAmB;IAFjC,aAAa;QAJzB,qBAAqB;QACrB,QAAQ;QACR,MAAM,CAAC,eAAe,EAAE,yBAAyB,CAAC;QAClD,QAAQ;OACI,aAAa,CA4MzB;IAAD,oBAAC;CAAA,AA5MD,CAAmC,KAAK,CAAC,aAAa,GA4MrD;SA5MY,aAAa","sourcesContent":["import type { Emotion } from '@emotion/css/create-instance';\nimport type { AriaAttributes, JSX } from 'react';\nimport React from 'react';\n\nimport type { CommonProps, CommonWrapperRestProps } from '../../internal/CommonWrapper/index.js';\nimport { CommonWrapper } from '../../internal/CommonWrapper/index.js';\nimport { RenderLayer } from '../../internal/RenderLayer/index.js';\nimport { createPropsGetter } from '../../lib/createPropsGetter.js';\nimport { isKeyCapsLock } from '../../lib/events/keyboard/identifiers.js';\nimport { KeyboardEventCodes as Codes } from '../../lib/events/keyboard/KeyboardEventCodes.js';\nimport { locale } from '../../lib/locale/decorators.js';\nimport { withRenderEnvironment } from '../../lib/renderEnvironment/RenderEnvironmentDecorator.js';\nimport type { TGetRootNode, TSetRootNode } from '../../lib/rootNode/index.js';\nimport { rootNode } from '../../lib/rootNode/index.js';\nimport { withSize } from '../../lib/size/SizeDecorator.js';\nimport type { Theme } from '../../lib/theming/Theme.js';\nimport { ThemeContext } from '../../lib/theming/ThemeContext.js';\nimport type { SizeProp } from '../../lib/types/props.js';\nimport { isNonNullable } from '../../lib/utils.js';\nimport type { Nullable } from '../../typings/utility-types.js';\nimport { Input } from '../Input/index.js';\nimport type { InputProps } from '../Input/index.js';\nimport type { PasswordInputLocale } from './locale/index.js';\nimport { PasswordInputLocaleHelper } from './locale/index.js';\nimport { getStyles } from './PasswordInput.styles.js';\nimport { PasswordInputIcon } from './PasswordInputIcon.js';\n\nexport interface PasswordInputProps\n extends Pick<AriaAttributes, 'aria-label'>, CommonProps, Omit<InputProps, 'showClearIcon'> {\n /** Визуально показывает, что активен CapsLock. */\n detectCapsLock?: boolean;\n}\n\nexport interface PasswordInputState {\n visible: boolean;\n focused: boolean;\n capsLockEnabled?: boolean | null;\n}\n\nexport const PasswordInputDataTids = {\n root: 'PasswordInput',\n capsLockDetector: 'PasswordInputCapsLockDetector',\n eyeIcon: 'PasswordInputEyeIcon',\n} as const;\n\n/**\n * Однострочное поле для ввода пароля, в котором символы заменяются на точки.\n */\n@withRenderEnvironment\n@rootNode\n@locale('PasswordInput', PasswordInputLocaleHelper)\n@withSize\nexport class PasswordInput extends React.PureComponent<PasswordInputProps, PasswordInputState> {\n public static __KONTUR_REACT_UI__ = 'PasswordInput';\n public static displayName = 'PasswordInput';\n\n public state: PasswordInputState = {\n visible: false,\n focused: false,\n capsLockEnabled: false,\n };\n private size!: SizeProp;\n\n private emotion!: Emotion;\n private cx!: Emotion['cx'];\n private styles!: ReturnType<typeof getStyles>;\n private theme!: Theme;\n\n private input: Nullable<Input>;\n public getRootNode!: TGetRootNode;\n private setRootNode!: TSetRootNode;\n private readonly locale!: PasswordInputLocale;\n\n private getProps = createPropsGetter({});\n\n public componentDidMount() {\n if (this.props.detectCapsLock) {\n this.setState({ capsLockEnabled: null });\n }\n }\n\n public static getDerivedStateFromProps(props: PasswordInputProps, state: PasswordInputState) {\n if (props.disabled) {\n return { visible: false };\n }\n\n return state;\n }\n\n public render(): JSX.Element {\n this.styles = getStyles(this.emotion);\n\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.getProps()}>\n {this.renderMain}\n </CommonWrapper>\n );\n }}\n </ThemeContext.Consumer>\n );\n }\n\n /** Программно устанавливает фокус на поле.\n * Появляется фокусная рамка, элемент получает клавиатурные события и воспринимается как текущий элемент для чтения скринридерами.\n * @public\n */\n public focus = (): void => {\n if (this.input) {\n this.input.focus();\n }\n };\n\n /** Программно снимает фокус с кнопки.\n * @public\n */\n public blur = (): void => {\n if (this.input) {\n this.input.blur();\n }\n };\n\n private handleKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\n const { onKeyPress, detectCapsLock } = this.props;\n\n if (onKeyPress) {\n onKeyPress(e);\n }\n\n if (!detectCapsLock) {\n return;\n }\n\n const capsLockEnabled = e.getModifierState(Codes.CapsLock);\n\n this.setState({ capsLockEnabled });\n };\n\n private handleKeydown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n const {\n props: { detectCapsLock, onKeyDown },\n state: { capsLockEnabled },\n } = this;\n\n if (onKeyDown) {\n onKeyDown(e);\n }\n\n if (!detectCapsLock) {\n return;\n }\n\n if (isKeyCapsLock(e) && isNonNullable(capsLockEnabled)) {\n this.setState({ capsLockEnabled: !capsLockEnabled });\n }\n };\n\n private handleToggleVisibility = () => {\n this.setState((prevState) => ({ visible: !prevState.visible }), this.focusOnInput);\n };\n\n private focusOnInput = () => {\n if (this.input) {\n this.input.focus();\n }\n };\n\n private handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n if (this.state.focused) {\n return;\n }\n\n this.setState({ focused: true });\n\n if (this.props.onFocus) {\n this.props.onFocus(event);\n }\n };\n\n private handleFocusOutside = () => {\n this.hideSymbols();\n\n if (this.state.focused) {\n this.setState({ focused: false });\n }\n };\n\n private getEyeWrapperClassname() {\n switch (this.size) {\n case 'large':\n return this.styles.eyeWrapperLarge(this.theme);\n case 'medium':\n return this.styles.eyeWrapperMedium(this.theme);\n case 'small':\n default:\n return this.styles.eyeWrapperSmall(this.theme);\n }\n }\n\n private renderEye = () => {\n const { capsLockEnabled } = this.state;\n\n return (\n <span className={this.styles.iconWrapper()}>\n {capsLockEnabled && (\n <span className={this.styles.capsLockDetector()} data-tid={PasswordInputDataTids.capsLockDetector} />\n )}\n <span className={this.cx(this.styles.toggleVisibility(this.theme), this.getEyeWrapperClassname())}>\n {!this.props.disabled && (\n <button\n type=\"button\"\n aria-label={this.state.visible ? this.locale.eyeClosedAriaLabel : this.locale.eyeOpenedAriaLabel}\n onClick={this.handleToggleVisibility}\n className={this.styles.icon()}\n data-tid={PasswordInputDataTids.eyeIcon}\n >\n <PasswordInputIcon size={this.size} visible={this.state.visible} />\n </button>\n )}\n </span>\n </span>\n );\n };\n\n private refInput = (element: Input) => {\n this.input = element;\n };\n\n private hideSymbols = () => {\n this.setState({ visible: false });\n };\n\n private renderMain = (props: CommonWrapperRestProps<PasswordInputProps>) => {\n return (\n <RenderLayer\n active={this.state.focused}\n onFocusOutside={this.handleFocusOutside}\n onClickOutside={this.handleFocusOutside}\n >\n <div data-tid={PasswordInputDataTids.root} className={this.styles.root()}>\n <Input\n ref={this.refInput}\n type={this.state.visible ? 'text' : 'password'}\n onKeyDown={this.handleKeydown}\n onKeyPress={this.handleKeyPress}\n rightIcon={this.renderEye()}\n onFocus={this.handleFocus}\n {...props}\n />\n </div>\n </RenderLayer>\n );\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PasswordInput.js","sourceRoot":"","sources":["PasswordInput.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAA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,eAAe,AAAlB,CAAmB;IACtC,yBAAW,GAAG,eAAe,AAAlB,CAAmB;IAFjC,aAAa;QAJzB,qBAAqB;QACrB,QAAQ;QACR,MAAM,CAAC,eAAe,EAAE,yBAAyB,CAAC;QAClD,QAAQ;OACI,aAAa,CA6MzB;IAAD,oBAAC;CAAA,AA7MD,CAAmC,KAAK,CAAC,aAAa,GA6MrD;SA7MY,aAAa","sourcesContent":["import type { Emotion } from '@emotion/css/create-instance';\nimport type { AriaAttributes, JSX } from 'react';\nimport React from 'react';\n\nimport type { CommonProps, CommonWrapperRestProps } from '../../internal/CommonWrapper/index.js';\nimport { CommonWrapper } from '../../internal/CommonWrapper/index.js';\nimport { RenderLayer } from '../../internal/RenderLayer/index.js';\nimport { createPropsGetter } from '../../lib/createPropsGetter.js';\nimport { isKeyCapsLock } from '../../lib/events/keyboard/identifiers.js';\nimport { KeyboardEventCodes as Codes } from '../../lib/events/keyboard/KeyboardEventCodes.js';\nimport { locale } from '../../lib/locale/decorators.js';\nimport { withRenderEnvironment } from '../../lib/renderEnvironment/RenderEnvironmentDecorator.js';\nimport type { TGetRootNode, TSetRootNode } from '../../lib/rootNode/index.js';\nimport { rootNode } from '../../lib/rootNode/index.js';\nimport { withSize } from '../../lib/size/SizeDecorator.js';\nimport type { Theme } from '../../lib/theming/Theme.js';\nimport { ThemeContext } from '../../lib/theming/ThemeContext.js';\nimport type { SizeProp } from '../../lib/types/props.js';\nimport { isNonNullable } from '../../lib/utils.js';\nimport type { Nullable } from '../../typings/utility-types.js';\nimport { Input } from '../Input/index.js';\nimport type { InputProps } from '../Input/index.js';\nimport type { PasswordInputLocale } from './locale/index.js';\nimport { PasswordInputLocaleHelper } from './locale/index.js';\nimport { getStyles } from './PasswordInput.styles.js';\nimport { PasswordInputIcon } from './PasswordInputIcon.js';\n\nexport interface PasswordInputProps\n extends Pick<AriaAttributes, 'aria-label'>, CommonProps, Omit<InputProps, 'showClearIcon'> {\n /** Визуально показывает, что активен CapsLock. */\n detectCapsLock?: boolean;\n}\n\nexport interface PasswordInputState {\n visible: boolean;\n focused: boolean;\n capsLockEnabled?: boolean | null;\n}\n\nexport const PasswordInputDataTids = {\n root: 'PasswordInput',\n capsLockDetector: 'PasswordInputCapsLockDetector',\n eyeIcon: 'PasswordInputEyeIcon',\n} as const;\n\n/**\n * Однострочное поле для ввода пароля, в котором символы заменяются на точки.\n */\n@withRenderEnvironment\n@rootNode\n@locale('PasswordInput', PasswordInputLocaleHelper)\n@withSize\nexport class PasswordInput extends React.PureComponent<PasswordInputProps, PasswordInputState> {\n public static __KONTUR_REACT_UI__ = 'PasswordInput';\n public static displayName = 'PasswordInput';\n\n public state: PasswordInputState = {\n visible: false,\n focused: false,\n capsLockEnabled: false,\n };\n private size!: SizeProp;\n\n private emotion!: Emotion;\n private cx!: Emotion['cx'];\n private styles!: ReturnType<typeof getStyles>;\n private theme!: Theme;\n\n private input: Nullable<Input>;\n public getRootNode!: TGetRootNode;\n private setRootNode!: TSetRootNode;\n private readonly locale!: PasswordInputLocale;\n\n private getProps = createPropsGetter({});\n\n public componentDidMount() {\n if (this.props.detectCapsLock) {\n this.setState({ capsLockEnabled: null });\n }\n }\n\n public static getDerivedStateFromProps(props: PasswordInputProps, state: PasswordInputState) {\n if (props.disabled) {\n return { visible: false };\n }\n\n return state;\n }\n\n public render(): JSX.Element {\n this.styles = getStyles(this.emotion);\n\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.getProps()}>\n {this.renderMain}\n </CommonWrapper>\n );\n }}\n </ThemeContext.Consumer>\n );\n }\n\n /** Программно устанавливает фокус на поле.\n * Появляется фокусная рамка, элемент получает клавиатурные события и воспринимается как текущий элемент для чтения скринридерами.\n * @public\n */\n public focus = (): void => {\n if (this.input) {\n this.input.focus();\n }\n };\n\n /** Программно снимает фокус с кнопки.\n * @public\n */\n public blur = (): void => {\n if (this.input) {\n this.input.blur();\n }\n };\n\n private handleKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\n const { onKeyPress, detectCapsLock } = this.props;\n\n if (onKeyPress) {\n onKeyPress(e);\n }\n\n if (!detectCapsLock) {\n return;\n }\n\n const capsLockEnabled = e.getModifierState(Codes.CapsLock);\n\n this.setState({ capsLockEnabled });\n };\n\n private handleKeydown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n const {\n props: { detectCapsLock, onKeyDown },\n state: { capsLockEnabled },\n } = this;\n\n if (onKeyDown) {\n onKeyDown(e);\n }\n\n if (!detectCapsLock) {\n return;\n }\n\n if (isKeyCapsLock(e) && isNonNullable(capsLockEnabled)) {\n this.setState({ capsLockEnabled: !capsLockEnabled });\n }\n };\n\n private handleToggleVisibility = () => {\n this.setState((prevState) => ({ visible: !prevState.visible }), this.focusOnInput);\n };\n\n private focusOnInput = () => {\n if (this.input) {\n this.input.focus();\n }\n };\n\n private handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n if (this.state.focused) {\n return;\n }\n\n this.setState({ focused: true });\n\n if (this.props.onFocus) {\n this.props.onFocus(event);\n }\n };\n\n private handleFocusOutside = () => {\n this.hideSymbols();\n\n if (this.state.focused) {\n this.setState({ focused: false });\n }\n };\n\n private getEyeWrapperClassname() {\n switch (this.size) {\n case 'large':\n return this.styles.eyeWrapperLarge(this.theme);\n case 'medium':\n return this.styles.eyeWrapperMedium(this.theme);\n case 'small':\n default:\n return this.styles.eyeWrapperSmall(this.theme);\n }\n }\n\n private renderEye = () => {\n const { capsLockEnabled } = this.state;\n\n return (\n <span className={this.styles.iconWrapper()}>\n {capsLockEnabled && (\n <span className={this.styles.capsLockDetector()} data-tid={PasswordInputDataTids.capsLockDetector} />\n )}\n <span className={this.cx(this.styles.toggleVisibility(this.theme), this.getEyeWrapperClassname())}>\n {!this.props.disabled && (\n <button\n type=\"button\"\n aria-label={this.state.visible ? this.locale.eyeClosedAriaLabel : this.locale.eyeOpenedAriaLabel}\n onClick={this.handleToggleVisibility}\n className={this.styles.icon()}\n data-tid={PasswordInputDataTids.eyeIcon}\n >\n <PasswordInputIcon size={this.size} visible={this.state.visible} />\n </button>\n )}\n </span>\n </span>\n );\n };\n\n private refInput = (element: Input) => {\n this.input = element;\n };\n\n private hideSymbols = () => {\n this.setState({ visible: false });\n };\n\n private renderMain = (props: CommonWrapperRestProps<PasswordInputProps>) => {\n const { detectCapsLock, ...rest } = props;\n return (\n <RenderLayer\n active={this.state.focused}\n onFocusOutside={this.handleFocusOutside}\n onClickOutside={this.handleFocusOutside}\n >\n <div data-tid={PasswordInputDataTids.root} className={this.styles.root()}>\n <Input\n ref={this.refInput}\n type={this.state.visible ? 'text' : 'password'}\n {...rest}\n onKeyDown={this.handleKeydown}\n onKeyPress={this.handleKeyPress}\n rightIcon={this.renderEye()}\n onFocus={this.handleFocus}\n />\n </div>\n </RenderLayer>\n );\n };\n}\n"]}
|
|
@@ -27,8 +27,6 @@ export interface RadioProps<T> extends Pick<AriaAttributes, 'aria-label'>, Commo
|
|
|
27
27
|
onMouseOver?: React.MouseEventHandler<HTMLLabelElement>;
|
|
28
28
|
/** Значение. */
|
|
29
29
|
value: T;
|
|
30
|
-
/** Задаёт второстепенный пояснительный текст под основным текстом радиокнопки. */
|
|
31
|
-
comment?: React.ReactNode;
|
|
32
30
|
}> {
|
|
33
31
|
}
|
|
34
32
|
export interface RadioState {
|
|
@@ -78,8 +76,6 @@ export declare class Radio<T> extends React.Component<RadioProps<T>, RadioState>
|
|
|
78
76
|
renderMain: (props: CommonWrapperRestProps<RadioProps<T>>) => React.JSX.Element;
|
|
79
77
|
private _isInRadioGroup;
|
|
80
78
|
private renderCaption;
|
|
81
|
-
private getSubcaptionSizeClassName;
|
|
82
|
-
private renderComment;
|
|
83
79
|
private handleChange;
|
|
84
80
|
private handleMouseOver;
|
|
85
81
|
private handleMouseEnter;
|
|
@@ -120,9 +120,7 @@ var Radio = /** @class */ (function (_super) {
|
|
|
120
120
|
React.createElement("input", __assign({}, inputProps))),
|
|
121
121
|
React.createElement("span", __assign({}, radioProps),
|
|
122
122
|
React.createElement("span", { className: _this.styles.placeholder() })),
|
|
123
|
-
_this.props.children &&
|
|
124
|
-
_this.renderCaption(),
|
|
125
|
-
_this.props.comment && _this.renderComment()))));
|
|
123
|
+
_this.props.children && _this.renderCaption()));
|
|
126
124
|
};
|
|
127
125
|
_this._isInRadioGroup = function () { return Boolean(_this.context.name); };
|
|
128
126
|
_this.handleChange = function (e) {
|
|
@@ -236,23 +234,6 @@ var Radio = /** @class */ (function (_super) {
|
|
|
236
234
|
_a));
|
|
237
235
|
return React.createElement("div", { className: captionClassNames }, this.props.children);
|
|
238
236
|
};
|
|
239
|
-
Radio.prototype.getSubcaptionSizeClassName = function () {
|
|
240
|
-
switch (this.size) {
|
|
241
|
-
case 'large':
|
|
242
|
-
return this.styles.subcaptionLarge(this.theme);
|
|
243
|
-
case 'medium':
|
|
244
|
-
return this.styles.subcaptionMedium(this.theme);
|
|
245
|
-
case 'small':
|
|
246
|
-
default:
|
|
247
|
-
return this.styles.subcaptionSmall(this.theme);
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
Radio.prototype.renderComment = function () {
|
|
251
|
-
var _a;
|
|
252
|
-
return (React.createElement("div", { className: this.cx(this.styles.subcaption(this.theme), this.getSubcaptionSizeClassName(), (_a = {},
|
|
253
|
-
_a[this.styles.subcaptionDisabled(this.theme)] = !!(this.props.disabled || this.context.disabled),
|
|
254
|
-
_a)) }, this.props.comment));
|
|
255
|
-
};
|
|
256
237
|
var Radio_1;
|
|
257
238
|
Radio.__KONTUR_REACT_UI__ = 'Radio';
|
|
258
239
|
Radio.displayName = 'Radio';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","sourceRoot":"","sources":["Radio.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,aAAa,EAAE,MAAM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ACf,AAFyB,CAExB;IAIY,iBAAW,GAAG,iBAAiB,AAApB,CAAqB;IAdnC,KAAK;QAHjB,qBAAqB;QACrB,QAAQ;QACR,QAAQ;OACI,KAAK,CA6QjB;IAAD,YAAC;CAAA,AA7QD,CAA8B,KAAK,CAAC,SAAS,GA6Q5C;SA7QY,KAAK","sourcesContent":["import type { Emotion } from '@emotion/css/create-instance';\nimport type { AriaAttributes } from 'react';\nimport React from 'react';\n\nimport type { CommonProps, CommonWrapperRestProps } from '../../internal/CommonWrapper/index.js';\nimport { CommonWrapper } from '../../internal/CommonWrapper/index.js';\nimport { FocusControlWrapper } from '../../internal/FocusControlWrapper/index.js';\nimport { createPropsGetter } from '../../lib/createPropsGetter.js';\nimport { fixFirefoxModifiedClickOnLabel } from '../../lib/events/fixFirefoxModifiedClickOnLabel.js';\nimport { KeyListener } from '../../lib/events/keyListener.js';\nimport type { GlobalObject } from '../../lib/globalObject.js';\nimport { withRenderEnvironment } from '../../lib/renderEnvironment/index.js';\nimport type { TGetRootNode, TSetRootNode } from '../../lib/rootNode/index.js';\nimport { rootNode } from '../../lib/rootNode/index.js';\nimport { withSize } from '../../lib/size/SizeDecorator.js';\nimport type { Theme } from '../../lib/theming/Theme.js';\nimport { ThemeContext } from '../../lib/theming/ThemeContext.js';\nimport type { SizeProp } from '../../lib/types/props.js';\nimport type { Override } from '../../typings/utility-types.js';\nimport { RadioGroupContext } from '../RadioGroup/RadioGroupContext.js';\nimport type { RadioGroupContextType } from '../RadioGroup/RadioGroupContext.js';\nimport { getStyles, globalClasses } from './Radio.styles.js';\n\nexport interface RadioProps<T>\n extends\n Pick<AriaAttributes, 'aria-label'>,\n CommonProps,\n Override<\n React.InputHTMLAttributes<HTMLInputElement>,\n {\n /** Переводит контрол в состояние ошибки. */\n error?: boolean;\n\n /** Переводит контрол в состояние предупреждения. */\n warning?: boolean;\n\n /** Размер радиокнопки. */\n size?: SizeProp;\n\n /** Задаёт состояние фокуса. */\n focused?: boolean;\n\n /** Событие изменения `value`. */\n onValueChange?: (value: T) => void;\n\n /** HTML-событие `onmouseenter`.\n * @ignore */\n onMouseEnter?: React.MouseEventHandler<HTMLLabelElement>;\n\n /** HTML-событие `onmouseleave`.\n * @ignore */\n onMouseLeave?: React.MouseEventHandler<HTMLLabelElement>;\n\n /** HTML-событие `onmouseover`.\n * @ignore */\n onMouseOver?: React.MouseEventHandler<HTMLLabelElement>;\n\n /** Значение. */\n value: T;\n\n /** Задаёт второстепенный пояснительный текст под основным текстом радиокнопки. */\n comment?: React.ReactNode;\n }\n > {}\n\nexport interface RadioState {\n focusedByKeyboard: boolean;\n}\n\nexport const RadioDataTids = {\n root: 'Radio__root',\n} as const;\n\ntype DefaultProps = Required<Pick<RadioProps<any>, 'focused'>>;\n\n/** Радиокнопка позволяет выбрать одно значение из нескольких. Подходит при небольшом количестве вариантов — 2–5.\n *\n * Для создания группы радиокнопок используйте специальный контейнер — компонент [RadioGroup](https://tech.skbkontur.ru/kontur-ui/?path=/docs/react-ui_input-data-radiogroup--docs).\n */\n@withRenderEnvironment\n@rootNode\n@withSize\nexport class Radio<T> extends React.Component<RadioProps<T>, RadioState> {\n public static __KONTUR_REACT_UI__ = 'Radio';\n public static displayName = 'Radio';\n\n public state = {\n focusedByKeyboard: false,\n };\n\n public static defaultProps: DefaultProps = {\n focused: false,\n };\n\n private getProps = createPropsGetter(Radio.defaultProps);\n\n public static contextType = RadioGroupContext;\n public context: RadioGroupContextType<T> = this.context;\n private size!: SizeProp;\n\n private inputEl = React.createRef<HTMLInputElement>();\n public getRootNode!: TGetRootNode;\n private setRootNode!: TSetRootNode;\n private globalObject!: GlobalObject;\n private emotion!: Emotion;\n private cx!: Emotion['cx'];\n private styles!: ReturnType<typeof getStyles>;\n private theme!: Theme;\n private keyListener!: KeyListener;\n\n private getRootSizeClassName() {\n switch (this.size) {\n case 'large':\n return this.styles.rootLarge(this.theme);\n case 'medium':\n return this.styles.rootMedium(this.theme);\n case 'small':\n default:\n return this.styles.rootSmall(this.theme);\n }\n }\n\n private getCircleSizeClassName() {\n switch (this.size) {\n case 'large':\n return this.styles.circleLarge(this.theme);\n case 'medium':\n return this.styles.circleMedium(this.theme);\n case 'small':\n default:\n return this.styles.circleSmall(this.theme);\n }\n }\n\n private getCheckedSizeClassName() {\n switch (this.size) {\n case 'large':\n return this.styles.checkedLarge(this.theme);\n case 'medium':\n return this.styles.checkedMedium(this.theme);\n case 'small':\n default:\n return this.styles.checkedSmall(this.theme);\n }\n }\n\n public componentDidMount() {\n this.keyListener = new KeyListener(this.globalObject);\n }\n\n public render(): React.JSX.Element {\n this.styles = getStyles(this.emotion);\n\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.getProps()}>\n {this.renderMain}\n </CommonWrapper>\n );\n }}\n </ThemeContext.Consumer>\n );\n }\n\n /** Программно устанавливает фокус на радиокнопку. Появляется фокусная обводка, элемент получает клавиатурные события и воспринимается как текущий элемент для чтения скринридерами.\n * @public\n */\n public focus(): void {\n this.keyListener.isTabPressed = true;\n this.inputEl.current?.focus();\n }\n\n /** Программно снимает фокус с радиокнопки.\n * @public\n */\n public blur(): void {\n this.inputEl.current?.blur();\n }\n\n public renderMain = (props: CommonWrapperRestProps<RadioProps<T>>): React.JSX.Element => {\n const {\n disabled = this.context.disabled,\n warning = this.context.warning,\n error = this.context.error,\n size,\n focused,\n onMouseOver,\n onMouseEnter,\n onMouseLeave,\n onValueChange,\n ...rest\n } = props;\n\n const radioProps = {\n className: this.cx({\n [this.styles.circle(this.theme)]: true,\n [this.getCircleSizeClassName()]: true,\n [this.styles.checked(this.theme)]: this.props.checked,\n [this.getCheckedSizeClassName()]: this.props.checked,\n [this.styles.focus(this.theme)]: this.getProps().focused || this.state.focusedByKeyboard,\n [this.styles.error(this.theme)]: error,\n [this.styles.warning(this.theme)]: warning,\n [this.styles.disabled(this.theme)]: disabled,\n [this.styles.checkedDisabled(this.theme)]: this.props.checked && disabled,\n [globalClasses.circle]: true,\n }),\n };\n\n let value: string | number | undefined;\n if (typeof this.props.value === 'string' || typeof this.props.value === 'number') {\n value = this.props.value;\n }\n\n const inputProps = {\n ...rest,\n type: 'radio',\n className: this.styles.input(),\n disabled,\n tabIndex: this.props.tabIndex,\n value,\n ref: this.inputEl,\n onChange: this.handleChange,\n onFocus: this.handleFocus,\n onBlur: this.handleBlur,\n };\n\n const labelProps = {\n className: this.cx(this.styles.root(this.theme), this.getRootSizeClassName(), {\n [this.styles.rootChecked(this.theme)]: this.props.checked,\n }),\n onMouseOver: this.handleMouseOver,\n onMouseEnter: this.handleMouseEnter,\n onMouseLeave: this.handleMouseLeave,\n onClick: fixFirefoxModifiedClickOnLabel(this.inputEl),\n };\n\n if (this._isInRadioGroup()) {\n const checked = this.props.value === this.context.activeItem;\n inputProps.checked = checked;\n inputProps.name = this.context.name;\n inputProps.suppressHydrationWarning = true;\n labelProps.className = this.cx(this.styles.root(this.theme), this.getRootSizeClassName(), {\n [this.styles.rootChecked(this.theme)]: checked,\n });\n radioProps.className = this.cx(radioProps.className, {\n [this.styles.checked(this.theme)]: checked,\n [this.getCheckedSizeClassName()]: checked,\n [this.styles.checkedDisabled(this.theme)]: checked && disabled,\n });\n }\n\n return (\n <label data-tid={RadioDataTids.root} {...labelProps}>\n <FocusControlWrapper onBlurWhenDisabled={this.resetFocus}>\n <input {...inputProps} />\n </FocusControlWrapper>\n <span {...radioProps}>\n <span className={this.styles.placeholder()} />\n </span>\n {this.props.children && (\n <div className={this.styles.captionWrapper(this.theme)}>\n {this.renderCaption()}\n {this.props.comment && this.renderComment()}\n </div>\n )}\n </label>\n );\n };\n\n private _isInRadioGroup = () => Boolean(this.context.name);\n\n private renderCaption() {\n const captionClassNames = this.cx({\n [this.styles.caption(this.theme)]: true,\n [this.styles.captionDisabled(this.theme)]: !!(this.props.disabled || this.context.disabled),\n });\n\n return <div className={captionClassNames}>{this.props.children}</div>;\n }\n\n private getSubcaptionSizeClassName() {\n switch (this.size) {\n case 'large':\n return this.styles.subcaptionLarge(this.theme);\n case 'medium':\n return this.styles.subcaptionMedium(this.theme);\n case 'small':\n default:\n return this.styles.subcaptionSmall(this.theme);\n }\n }\n\n private renderComment() {\n return (\n <div\n className={this.cx(this.styles.subcaption(this.theme), this.getSubcaptionSizeClassName(), {\n [this.styles.subcaptionDisabled(this.theme)]: !!(this.props.disabled || this.context.disabled),\n })}\n >\n {this.props.comment}\n </div>\n );\n }\n\n private handleChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {\n this.props.onValueChange?.(this.props.value);\n\n if (this._isInRadioGroup()) {\n this.context.onSelect(this.props.value);\n }\n\n this.props.onChange?.(e);\n };\n\n private handleMouseOver: React.MouseEventHandler<HTMLLabelElement> = (e) => {\n this.props.onMouseOver?.(e);\n };\n\n private handleMouseEnter: React.MouseEventHandler<HTMLLabelElement> = (e) => {\n this.props.onMouseEnter?.(e);\n };\n\n private handleMouseLeave: React.MouseEventHandler<HTMLLabelElement> = (e) => {\n this.props.onMouseLeave?.(e);\n };\n\n private handleFocus = (e: React.FocusEvent<any>) => {\n if (!this.context.disabled) {\n // focus event fires before keyDown eventlistener\n // so we should check tabPressed in async way\n this.globalObject.requestAnimationFrame?.(() => {\n if (this.keyListener.isArrowPressed || this.keyListener.isTabPressed) {\n this.setState({ focusedByKeyboard: true });\n }\n });\n\n if (this.props.onFocus) {\n this.props.onFocus(e);\n }\n }\n };\n\n private resetFocus = () => this.setState({ focusedByKeyboard: false });\n\n private handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n this.resetFocus();\n this.props.onBlur?.(e);\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Radio.js","sourceRoot":"","sources":["Radio.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,m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AAO,6BAAK,SAAS,EAAE,iBAAiB,IAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAO,CAAC;IACxE,CAAC;;IAjMa,yBAAmB,GAAG,OAAO,AAAV,CAAW;IAC9B,iBAAW,GAAG,OAAO,AAAV,CAAW;IAMtB,kBAAY,GAAiB;QACzC,OAAO,EAAE,KAAK;KACf,AAFyB,CAExB;IAIY,iBAAW,GAAG,iBAAiB,AAApB,CAAqB;IAdnC,KAAK;QAHjB,qBAAqB;QACrB,QAAQ;QACR,QAAQ;OACI,KAAK,CAgPjB;IAAD,YAAC;CAAA,AAhPD,CAA8B,KAAK,CAAC,SAAS,GAgP5C;SAhPY,KAAK","sourcesContent":["import type { Emotion } from '@emotion/css/create-instance';\nimport type { AriaAttributes } from 'react';\nimport React from 'react';\n\nimport type { CommonProps, CommonWrapperRestProps } from '../../internal/CommonWrapper/index.js';\nimport { CommonWrapper } from '../../internal/CommonWrapper/index.js';\nimport { FocusControlWrapper } from '../../internal/FocusControlWrapper/index.js';\nimport { createPropsGetter } from '../../lib/createPropsGetter.js';\nimport { fixFirefoxModifiedClickOnLabel } from '../../lib/events/fixFirefoxModifiedClickOnLabel.js';\nimport { KeyListener } from '../../lib/events/keyListener.js';\nimport type { GlobalObject } from '../../lib/globalObject.js';\nimport { withRenderEnvironment } from '../../lib/renderEnvironment/index.js';\nimport type { TGetRootNode, TSetRootNode } from '../../lib/rootNode/index.js';\nimport { rootNode } from '../../lib/rootNode/index.js';\nimport { withSize } from '../../lib/size/SizeDecorator.js';\nimport type { Theme } from '../../lib/theming/Theme.js';\nimport { ThemeContext } from '../../lib/theming/ThemeContext.js';\nimport type { SizeProp } from '../../lib/types/props.js';\nimport type { Override } from '../../typings/utility-types.js';\nimport { RadioGroupContext } from '../RadioGroup/RadioGroupContext.js';\nimport type { RadioGroupContextType } from '../RadioGroup/RadioGroupContext.js';\nimport { getStyles, globalClasses } from './Radio.styles.js';\n\nexport interface RadioProps<T>\n extends\n Pick<AriaAttributes, 'aria-label'>,\n CommonProps,\n Override<\n React.InputHTMLAttributes<HTMLInputElement>,\n {\n /** Переводит контрол в состояние ошибки. */\n error?: boolean;\n\n /** Переводит контрол в состояние предупреждения. */\n warning?: boolean;\n\n /** Размер радиокнопки. */\n size?: SizeProp;\n\n /** Задаёт состояние фокуса. */\n focused?: boolean;\n\n /** Событие изменения `value`. */\n onValueChange?: (value: T) => void;\n\n /** HTML-событие `onmouseenter`.\n * @ignore */\n onMouseEnter?: React.MouseEventHandler<HTMLLabelElement>;\n\n /** HTML-событие `onmouseleave`.\n * @ignore */\n onMouseLeave?: React.MouseEventHandler<HTMLLabelElement>;\n\n /** HTML-событие `onmouseover`.\n * @ignore */\n onMouseOver?: React.MouseEventHandler<HTMLLabelElement>;\n\n /** Значение. */\n value: T;\n }\n > {}\n\nexport interface RadioState {\n focusedByKeyboard: boolean;\n}\n\nexport const RadioDataTids = {\n root: 'Radio__root',\n} as const;\n\ntype DefaultProps = Required<Pick<RadioProps<any>, 'focused'>>;\n\n/** Радиокнопка позволяет выбрать одно значение из нескольких. Подходит при небольшом количестве вариантов — 2–5.\n *\n * Для создания группы радиокнопок используйте специальный контейнер — компонент [RadioGroup](https://tech.skbkontur.ru/kontur-ui/?path=/docs/react-ui_input-data-radiogroup--docs).\n */\n@withRenderEnvironment\n@rootNode\n@withSize\nexport class Radio<T> extends React.Component<RadioProps<T>, RadioState> {\n public static __KONTUR_REACT_UI__ = 'Radio';\n public static displayName = 'Radio';\n\n public state = {\n focusedByKeyboard: false,\n };\n\n public static defaultProps: DefaultProps = {\n focused: false,\n };\n\n private getProps = createPropsGetter(Radio.defaultProps);\n\n public static contextType = RadioGroupContext;\n public context: RadioGroupContextType<T> = this.context;\n private size!: SizeProp;\n\n private inputEl = React.createRef<HTMLInputElement>();\n public getRootNode!: TGetRootNode;\n private setRootNode!: TSetRootNode;\n private globalObject!: GlobalObject;\n private emotion!: Emotion;\n private cx!: Emotion['cx'];\n private styles!: ReturnType<typeof getStyles>;\n private theme!: Theme;\n private keyListener!: KeyListener;\n\n private getRootSizeClassName() {\n switch (this.size) {\n case 'large':\n return this.styles.rootLarge(this.theme);\n case 'medium':\n return this.styles.rootMedium(this.theme);\n case 'small':\n default:\n return this.styles.rootSmall(this.theme);\n }\n }\n\n private getCircleSizeClassName() {\n switch (this.size) {\n case 'large':\n return this.styles.circleLarge(this.theme);\n case 'medium':\n return this.styles.circleMedium(this.theme);\n case 'small':\n default:\n return this.styles.circleSmall(this.theme);\n }\n }\n\n private getCheckedSizeClassName() {\n switch (this.size) {\n case 'large':\n return this.styles.checkedLarge(this.theme);\n case 'medium':\n return this.styles.checkedMedium(this.theme);\n case 'small':\n default:\n return this.styles.checkedSmall(this.theme);\n }\n }\n\n public componentDidMount() {\n this.keyListener = new KeyListener(this.globalObject);\n }\n\n public render(): React.JSX.Element {\n this.styles = getStyles(this.emotion);\n\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.getProps()}>\n {this.renderMain}\n </CommonWrapper>\n );\n }}\n </ThemeContext.Consumer>\n );\n }\n\n /** Программно устанавливает фокус на радиокнопку. Появляется фокусная обводка, элемент получает клавиатурные события и воспринимается как текущий элемент для чтения скринридерами.\n * @public\n */\n public focus(): void {\n this.keyListener.isTabPressed = true;\n this.inputEl.current?.focus();\n }\n\n /** Программно снимает фокус с радиокнопки.\n * @public\n */\n public blur(): void {\n this.inputEl.current?.blur();\n }\n\n public renderMain = (props: CommonWrapperRestProps<RadioProps<T>>): React.JSX.Element => {\n const {\n disabled = this.context.disabled,\n warning = this.context.warning,\n error = this.context.error,\n size,\n focused,\n onMouseOver,\n onMouseEnter,\n onMouseLeave,\n onValueChange,\n ...rest\n } = props;\n\n const radioProps = {\n className: this.cx({\n [this.styles.circle(this.theme)]: true,\n [this.getCircleSizeClassName()]: true,\n [this.styles.checked(this.theme)]: this.props.checked,\n [this.getCheckedSizeClassName()]: this.props.checked,\n [this.styles.focus(this.theme)]: this.getProps().focused || this.state.focusedByKeyboard,\n [this.styles.error(this.theme)]: error,\n [this.styles.warning(this.theme)]: warning,\n [this.styles.disabled(this.theme)]: disabled,\n [this.styles.checkedDisabled(this.theme)]: this.props.checked && disabled,\n [globalClasses.circle]: true,\n }),\n };\n\n let value: string | number | undefined;\n if (typeof this.props.value === 'string' || typeof this.props.value === 'number') {\n value = this.props.value;\n }\n\n const inputProps = {\n ...rest,\n type: 'radio',\n className: this.styles.input(),\n disabled,\n tabIndex: this.props.tabIndex,\n value,\n ref: this.inputEl,\n onChange: this.handleChange,\n onFocus: this.handleFocus,\n onBlur: this.handleBlur,\n };\n\n const labelProps = {\n className: this.cx(this.styles.root(this.theme), this.getRootSizeClassName(), {\n [this.styles.rootChecked(this.theme)]: this.props.checked,\n }),\n onMouseOver: this.handleMouseOver,\n onMouseEnter: this.handleMouseEnter,\n onMouseLeave: this.handleMouseLeave,\n onClick: fixFirefoxModifiedClickOnLabel(this.inputEl),\n };\n\n if (this._isInRadioGroup()) {\n const checked = this.props.value === this.context.activeItem;\n inputProps.checked = checked;\n inputProps.name = this.context.name;\n inputProps.suppressHydrationWarning = true;\n labelProps.className = this.cx(this.styles.root(this.theme), this.getRootSizeClassName(), {\n [this.styles.rootChecked(this.theme)]: checked,\n });\n radioProps.className = this.cx(radioProps.className, {\n [this.styles.checked(this.theme)]: checked,\n [this.getCheckedSizeClassName()]: checked,\n [this.styles.checkedDisabled(this.theme)]: checked && disabled,\n });\n }\n\n return (\n <label data-tid={RadioDataTids.root} {...labelProps}>\n <FocusControlWrapper onBlurWhenDisabled={this.resetFocus}>\n <input {...inputProps} />\n </FocusControlWrapper>\n <span {...radioProps}>\n <span className={this.styles.placeholder()} />\n </span>\n {this.props.children && this.renderCaption()}\n </label>\n );\n };\n\n private _isInRadioGroup = () => Boolean(this.context.name);\n\n private renderCaption() {\n const captionClassNames = this.cx({\n [this.styles.caption(this.theme)]: true,\n [this.styles.captionDisabled(this.theme)]: !!(this.props.disabled || this.context.disabled),\n });\n\n return <div className={captionClassNames}>{this.props.children}</div>;\n }\n\n private handleChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {\n this.props.onValueChange?.(this.props.value);\n\n if (this._isInRadioGroup()) {\n this.context.onSelect(this.props.value);\n }\n\n this.props.onChange?.(e);\n };\n\n private handleMouseOver: React.MouseEventHandler<HTMLLabelElement> = (e) => {\n this.props.onMouseOver?.(e);\n };\n\n private handleMouseEnter: React.MouseEventHandler<HTMLLabelElement> = (e) => {\n this.props.onMouseEnter?.(e);\n };\n\n private handleMouseLeave: React.MouseEventHandler<HTMLLabelElement> = (e) => {\n this.props.onMouseLeave?.(e);\n };\n\n private handleFocus = (e: React.FocusEvent<any>) => {\n if (!this.context.disabled) {\n // focus event fires before keyDown eventlistener\n // so we should check tabPressed in async way\n this.globalObject.requestAnimationFrame?.(() => {\n if (this.keyListener.isArrowPressed || this.keyListener.isTabPressed) {\n this.setState({ focusedByKeyboard: true });\n }\n });\n\n if (this.props.onFocus) {\n this.props.onFocus(e);\n }\n }\n };\n\n private resetFocus = () => this.setState({ focusedByKeyboard: false });\n\n private handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n this.resetFocus();\n this.props.onBlur?.(e);\n };\n}\n"]}
|
|
@@ -3,5 +3,3 @@ export declare const circleSizeMixin: (labGrotesqueBaselineCompensation: string,
|
|
|
3
3
|
export declare const radioCheckedMixin: (bulletSize: string) => string;
|
|
4
4
|
export declare const afterOutlineMixin: (radioOutlineWidth: string) => string;
|
|
5
5
|
export declare const outlineColorMixin: (shadow: string, borderColor: string) => string;
|
|
6
|
-
export declare const subcaptionMixin: (fontSize: string, lineHeight: string) => string;
|
|
7
|
-
export declare const disabledTextColorMixin: (textColor: string) => string;
|
|
@@ -21,10 +21,4 @@ export var afterOutlineMixin = function (radioOutlineWidth) {
|
|
|
21
21
|
export var outlineColorMixin = function (shadow, borderColor) {
|
|
22
22
|
return "\n box-shadow: ".concat(shadow, ";\n border-color: ").concat(borderColor, ";\n ");
|
|
23
23
|
};
|
|
24
|
-
export var subcaptionMixin = function (fontSize, lineHeight) {
|
|
25
|
-
return "\n font-size: ".concat(fontSize, ";\n line-height: ").concat(lineHeight, ";\n ");
|
|
26
|
-
};
|
|
27
|
-
export var disabledTextColorMixin = function (textColor) {
|
|
28
|
-
return "\n color: ".concat(textColor, ";\n ");
|
|
29
|
-
};
|
|
30
24
|
//# sourceMappingURL=Radio.mixins.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.mixins.js","sourceRoot":"","sources":["Radio.mixins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,mCAAmC,EAAE,MAAM,yDAAyD,CAAC;AAE9G,MAAM,CAAC,IAAM,cAAc,GAAG,UAAC,QAAgB,EAAE,UAAkB,EAAE,QAAgB,EAAE,SAAiB;IACtG,OAAO,2BACQ,QAAQ,iCACN,UAAU,6BACd,QAAQ,gDAER,SAAS,iBAErB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,eAAe,GAAG,UAC7B,gCAAwC,EACxC,QAAgB,EAChB,SAAiB,EACjB,4BAAoC,EACpC,kBAA0B;IAE1B,IAAM,yBAAyB,GAAG,QAAQ,CAAC,gCAAgC,CAAC,CAAC;IAC7E,IAAM,aAAa,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAEzC,IAAM,oBAAoB,GAAG,mCAAmC,CAC9D,aAAa,EACb,yBAAyB,EACzB,QAAQ,EACR,SAAS,CACV,CAAC;IACF,IAAM,UAAU,GAAG,eAAQ,SAAS,oBAAU,4BAA4B,MAAG,CAAC;IAC9E,IAAM,aAAa,GAAG,eAAQ,kBAAkB,gBAAM,4BAA4B,gBAAM,oBAAoB,QAAK,CAAC;IAClH,IAAM,aAAa,GAAG,4BAA4B,CAAC;IACnD,OAAO,wBACK,UAAU,2BACX,UAAU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4BAA4B,MAAG,CAAC;IAC9E,IAAM,aAAa,GAAG,eAAQ,kBAAkB,gBAAM,4BAA4B,gBAAM,oBAAoB,QAAK,CAAC;IAClH,IAAM,aAAa,GAAG,4BAA4B,CAAC;IACnD,OAAO,wBACK,UAAU,2BACX,UAAU,4BACT,aAAa,cAAI,aAAa,YACzC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,iBAAiB,GAAG,UAAC,UAAkB;IAClD,OAAO,2CAEO,UAAU,6BACX,UAAU,iBAEtB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,iBAAiB,GAAG,UAAC,iBAAyB;IACzD,OAAO,kEAGG,iBAAiB,6BACd,iBAAiB,2BACnB,iBAAiB,4BAChB,iBAAiB,kCACX,iBAAiB,0FAIlC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,iBAAiB,GAAG,UAAC,MAAc,EAAE,WAAmB;IACnE,OAAO,4BACS,MAAM,kCACJ,WAAW,UAC5B,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { isChrome, isFirefox } from '../../lib/client.js';\nimport { getLabGrotesqueBaselineCompensation } from '../../lib/styles/getLabGrotesqueBaselineCompensation.js';\n\nexport const radioSizeMixin = (fontSize: string, lineHeight: string, paddingY: string, radioSize: string): string => {\n return `\n font-size: ${fontSize};\n line-height: ${lineHeight};\n padding: ${paddingY} 0;\n &::before {\n width: ${radioSize};\n }\n `;\n};\n\nexport const circleSizeMixin = (\n labGrotesqueBaselineCompensation: string,\n fontSize: string,\n radioSize: string,\n radioBorderWidthCompensation: string,\n radioCircleOffsetY: string,\n): string => {\n const labGrotesqueCompenstation = parseInt(labGrotesqueBaselineCompensation);\n const radioFontSize = parseInt(fontSize);\n\n const baselineCompensation = getLabGrotesqueBaselineCompensation(\n radioFontSize,\n labGrotesqueCompenstation,\n isChrome,\n isFirefox,\n );\n const circleSize = `calc(${radioSize} - 2 * ${radioBorderWidthCompensation})`;\n const circleOffsetY = `calc(${radioCircleOffsetY} + ${radioBorderWidthCompensation} + ${baselineCompensation}px)`;\n const circleMarginX = radioBorderWidthCompensation;\n return `\n height: ${circleSize};\n width: ${circleSize};\n margin: ${circleOffsetY} ${circleMarginX} 0;\n `;\n};\n\nexport const radioCheckedMixin = (bulletSize: string): string => {\n return `\n &::before {\n height: ${bulletSize};\n width: ${bulletSize};\n }\n `;\n};\n\nexport const afterOutlineMixin = (radioOutlineWidth: string): string => {\n return `\n content: ' ';\n position: absolute;\n top: -${radioOutlineWidth};\n bottom: -${radioOutlineWidth};\n left: -${radioOutlineWidth};\n right: -${radioOutlineWidth};\n border-width: ${radioOutlineWidth};\n border-style: solid;\n border-radius: 50%;\n box-sizing: border-box;\n `;\n};\n\nexport const outlineColorMixin = (shadow: string, borderColor: string): string => {\n return `\n box-shadow: ${shadow};\n border-color: ${borderColor};\n `;\n};\n"]}
|
|
@@ -25,10 +25,4 @@ export declare const getStyles: import("../../lib/theming/Emotion.js").StylesGet
|
|
|
25
25
|
caption(t: Theme): string;
|
|
26
26
|
captionDisabled(t: Theme): string;
|
|
27
27
|
placeholder(): string;
|
|
28
|
-
captionWrapper(t: Theme): string;
|
|
29
|
-
subcaption(t: Theme): string;
|
|
30
|
-
subcaptionDisabled(t: Theme): string;
|
|
31
|
-
subcaptionSmall(t: Theme): string;
|
|
32
|
-
subcaptionMedium(t: Theme): string;
|
|
33
|
-
subcaptionLarge(t: Theme): string;
|
|
34
28
|
}>;
|
|
@@ -3,7 +3,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
3
3
|
return cooked;
|
|
4
4
|
};
|
|
5
5
|
import { memoizeGetStyles, prefix } from '../../lib/theming/Emotion.js';
|
|
6
|
-
import { afterOutlineMixin, circleSizeMixin,
|
|
6
|
+
import { afterOutlineMixin, circleSizeMixin, outlineColorMixin, radioCheckedMixin, radioSizeMixin, } from './Radio.mixins.js';
|
|
7
7
|
export var globalClasses = prefix('radio')({
|
|
8
8
|
circle: 'circle',
|
|
9
9
|
});
|
|
@@ -68,33 +68,15 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
68
68
|
return css(templateObject_19 || (templateObject_19 = __makeTemplateObject(["\n background: ", " !important; // override root hover/active styles\n border-color: transparent !important; // override root hover/active styles\n box-shadow: ", " !important; // override root hover/active styles\n "], ["\n background: ", " !important; // override root hover/active styles\n border-color: transparent !important; // override root hover/active styles\n box-shadow: ", " !important; // override root hover/active styles\n "])), t.radioDisabledBg, t.radioDisabledShadow);
|
|
69
69
|
},
|
|
70
70
|
caption: function (t) {
|
|
71
|
-
return css(templateObject_20 || (templateObject_20 = __makeTemplateObject(["\n display: ", ";\n white-space: normal;\n color: ", ";\n "], ["\n display: ", ";\n white-space: normal;\n color: ", ";\n "])), t.radioCaptionDisplay, t.radioTextColor);
|
|
71
|
+
return css(templateObject_20 || (templateObject_20 = __makeTemplateObject(["\n display: ", ";\n padding-left: ", ";\n white-space: normal;\n color: ", ";\n "], ["\n display: ", ";\n padding-left: ", ";\n white-space: normal;\n color: ", ";\n "])), t.radioCaptionDisplay, t.radioCaptionGap, t.radioTextColor);
|
|
72
72
|
},
|
|
73
73
|
captionDisabled: function (t) {
|
|
74
|
-
return css(templateObject_21 || (templateObject_21 = __makeTemplateObject(["\n ", ";\n "], ["\n ", ";\n "])),
|
|
74
|
+
return css(templateObject_21 || (templateObject_21 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), t.textColorDisabled);
|
|
75
75
|
},
|
|
76
76
|
placeholder: function () {
|
|
77
77
|
return css(templateObject_22 || (templateObject_22 = __makeTemplateObject(["\n display: inline-block;\n "], ["\n display: inline-block;\n "])));
|
|
78
78
|
},
|
|
79
|
-
captionWrapper: function (t) {
|
|
80
|
-
return css(templateObject_23 || (templateObject_23 = __makeTemplateObject(["\n display: inline-block;\n padding-left: ", ";\n "], ["\n display: inline-block;\n padding-left: ", ";\n "])), t.radioCaptionGap);
|
|
81
|
-
},
|
|
82
|
-
subcaption: function (t) {
|
|
83
|
-
return css(templateObject_24 || (templateObject_24 = __makeTemplateObject(["\n margin-top: 2px;\n color: ", ";\n "], ["\n margin-top: 2px;\n color: ", ";\n "])), t.radioCommentTextColor);
|
|
84
|
-
},
|
|
85
|
-
subcaptionDisabled: function (t) {
|
|
86
|
-
return css(templateObject_25 || (templateObject_25 = __makeTemplateObject(["\n ", ";\n "], ["\n ", ";\n "])), disabledTextColorMixin(t.textColorDisabled));
|
|
87
|
-
},
|
|
88
|
-
subcaptionSmall: function (t) {
|
|
89
|
-
return css(templateObject_26 || (templateObject_26 = __makeTemplateObject(["\n ", ";\n "], ["\n ", ";\n "])), subcaptionMixin(t.radioCommentFontSizeSmall, t.radioCommentLineHeightSmall));
|
|
90
|
-
},
|
|
91
|
-
subcaptionMedium: function (t) {
|
|
92
|
-
return css(templateObject_27 || (templateObject_27 = __makeTemplateObject(["\n ", ";\n "], ["\n ", ";\n "])), subcaptionMixin(t.radioCommentFontSizeMedium, t.radioCommentLineHeightMedium));
|
|
93
|
-
},
|
|
94
|
-
subcaptionLarge: function (t) {
|
|
95
|
-
return css(templateObject_28 || (templateObject_28 = __makeTemplateObject(["\n ", ";\n "], ["\n ", ";\n "])), subcaptionMixin(t.radioCommentFontSizeLarge, t.radioCommentLineHeightLarge));
|
|
96
|
-
},
|
|
97
79
|
});
|
|
98
80
|
});
|
|
99
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20, templateObject_21, templateObject_22
|
|
81
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20, templateObject_21, templateObject_22;
|
|
100
82
|
//# sourceMappingURL=Radio.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.styles.js","sourceRoot":"","sources":["Radio.styles.ts"],"names":[],"mappings":";;;;AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAExE,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,IAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,EAAE,QAAQ;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,IAAM,SAAS,GAAG,gBAAgB,CAAC,UAAC,EAAgB;QAAd,GAAG,SAAA;IAAgB,OAAA,CAAC;QAC/D,IAAI,YAAC,CAAQ;YACX,OAAO,GAAG,ouBAAA,uJAOL,EAAoB,qCACI,EAAoB,GAAI,EAA0B,+BAGlE,EAAoB,0BACf,EAAc,yBACd,EAAkB,8BAEtB,EAAoB,0BAChB,EAAe,yBACf,EAAmB,+SAWpC,KArBI,aAAa,CAAC,MAAM,EACI,CAAC,CAAC,kBAAkB,EAAI,CAAC,CAAC,wBAAwB,EAGlE,aAAa,CAAC,MAAM,EACf,CAAC,CAAC,YAAY,EACd,CAAC,CAAC,gBAAgB,EAEtB,aAAa,CAAC,MAAM,EAChB,CAAC,CAAC,aAAa,EACf,CAAC,CAAC,iBAAiB,EAWnC;QACJ,CAAC;QACD,SAAS,YAAC,CAAQ;YAChB,OAAO,GAAG,wFAAA,UACN,EAAoG,SACvG,KADG,cAAc,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,oBAAoB,EAAE,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,cAAc,CAAC,EACtG;QACJ,CAAC;QACD,UAAU,YAAC,CAAQ;YACjB,OAA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KADG,sBAAsB,CAAC,CAAC,CAAC,iBAAiB,CAAC,EAC7C;QACJ,CAAC;QAED,eAAe,YAAC,CAAQ;YACtB,OAAO,GAAG,0FAAA,UACN,EAA2E,SAC9E,KADG,eAAe,CAAC,CAAC,CAAC,yBAAyB,EAAE,CAAC,CAAC,2BAA2B,CAAC,EAC7E;QACJ,CAAC;QACD,gBAAgB,YAAC,CAAQ;YACvB,OAAO,GAAG,0FAAA,UACN,EAA6E,SAChF,KADG,eAAe,CAAC,CAAC,CAAC,0BAA0B,EAAE,CAAC,CAAC,4BAA4B,CAAC,EAC/E;QACJ,CAAC;QACD,eAAe,YAAC,CAAQ;YACtB,OAAO,GAAG,0FAAA,UACN,EAA2E,SAC9E,KADG,eAAe,CAAC,CAAC,CAAC,yBAAyB,EAAE,CAAC,CAAC,2BAA2B,CAAC,EAC7E;QACJ,CAAC;KACF,CAAC;AAtP8D,CAsP9D,CAAC,CAAC","sourcesContent":["import type { Emotion } from '@emotion/css/create-instance';\n\nimport { memoizeGetStyles, prefix } from '../../lib/theming/Emotion.js';\nimport type { Theme } from '../../lib/theming/Theme.js';\nimport {\n afterOutlineMixin,\n circleSizeMixin,\n disabledTextColorMixin,\n outlineColorMixin,\n radioCheckedMixin,\n radioSizeMixin,\n subcaptionMixin,\n} from './Radio.mixins.js';\n\nexport const globalClasses = prefix('radio')({\n circle: 'circle',\n});\n\nexport const getStyles = memoizeGetStyles(({ css }: Emotion) => ({\n root(t: Theme) {\n return css`\n cursor: pointer;\n position: relative;\n white-space: nowrap;\n display: inline-flex;\n align-items: baseline;\n\n .${globalClasses.circle} {\n transition: background ${t.transitionDuration} ${t.transitionTimingFunction};\n }\n\n &:hover .${globalClasses.circle} {\n background: ${t.radioHoverBg};\n box-shadow: ${t.radioHoverShadow};\n }\n &:active .${globalClasses.circle} {\n background: ${t.radioActiveBg};\n box-shadow: ${t.radioActiveShadow};\n }\n\n &::before {\n // non-breaking space.\n // makes a correct space for absolutely positioned circle,\n // and also height and baseline for radio without caption.\n content: '\\\\00A0';\n display: inline-block;\n flex: 0 0 auto;\n }\n `;\n },\n rootSmall(t: Theme) {\n return css`\n ${radioSizeMixin(t.radioFontSizeSmall, t.radioLineHeightSmall, t.radioPaddingYSmall, t.radioSizeSmall)};\n `;\n },\n rootMedium(t: Theme) {\n return css`\n ${radioSizeMixin(t.radioFontSizeMedium, t.radioLineHeightMedium, t.radioPaddingYMedium, t.radioSizeMedium)};\n `;\n },\n rootLarge(t: Theme) {\n return css`\n ${radioSizeMixin(t.radioFontSizeLarge, t.radioLineHeightLarge, t.radioPaddingYLarge, t.radioSizeLarge)};\n `;\n },\n\n rootChecked(t: Theme) {\n return css`\n &:hover .${globalClasses.circle} {\n background: ${t.radioCheckedHoverBgColor};\n }\n `;\n },\n\n circle(t: Theme) {\n return css`\n background-image: ${t.radioBgImage};\n border-radius: 50%;\n border: ${t.radioBorder};\n box-shadow: ${t.radioBoxShadow};\n box-sizing: border-box;\n display: inline-block;\n position: absolute;\n left: 0;\n background-color: ${t.radioBgColor};\n `;\n },\n circleSmall(t: Theme) {\n return css`\n ${circleSizeMixin(\n t.labGrotesqueBaselineCompensation,\n t.radioFontSizeSmall,\n t.radioSizeSmall,\n t.radioBorderWidthCompensation,\n t.radioCircleOffsetY,\n )};\n `;\n },\n circleMedium(t: Theme) {\n return css`\n ${circleSizeMixin(\n t.labGrotesqueBaselineCompensation,\n t.radioFontSizeMedium,\n t.radioSizeMedium,\n t.radioBorderWidthCompensation,\n t.radioCircleOffsetY,\n )};\n `;\n },\n circleLarge(t: Theme) {\n return css`\n ${circleSizeMixin(\n t.labGrotesqueBaselineCompensation,\n t.radioFontSizeLarge,\n t.radioSizeLarge,\n t.radioBorderWidthCompensation,\n t.radioCircleOffsetY,\n )};\n `;\n },\n\n focus(t: Theme) {\n return css`\n &::after {\n ${afterOutlineMixin(t.radioOutlineWidth)};\n ${outlineColorMixin(t.radioFocusShadow, t.radioBorderColorFocus)};\n }\n `;\n },\n\n warning(t: Theme) {\n return css`\n &::after {\n ${afterOutlineMixin(t.radioOutlineWidth)};\n ${outlineColorMixin(t.radioFocusShadow, t.radioBorderColorWarning)};\n }\n `;\n },\n\n error(t: Theme) {\n return css`\n &::after {\n ${afterOutlineMixin(t.radioOutlineWidth)};\n ${outlineColorMixin(t.radioFocusShadow, t.radioBorderColorError)};\n }\n `;\n },\n\n checked(t: Theme) {\n return css`\n background-color: ${t.radioCheckedBgColor};\n border-color: ${t.radioCheckedBorderColor};\n\n &::before {\n content: ' ';\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n margin: auto;\n border-radius: 50%;\n background: ${t.radioCheckedBulletColor};\n }\n `;\n },\n checkedSmall(t: Theme) {\n return css`\n ${radioCheckedMixin(t.radioBulletSizeSmall)};\n `;\n },\n checkedMedium(t: Theme) {\n return css`\n ${radioCheckedMixin(t.radioBulletSizeMedium)};\n `;\n },\n checkedLarge(t: Theme) {\n return css`\n ${radioCheckedMixin(t.radioBulletSizeLarge)};\n `;\n },\n\n checkedDisabled(t: Theme) {\n return css`\n &::before {\n background: ${t.radioCheckedDisabledBulletBg};\n }\n `;\n },\n\n input() {\n return css`\n display: inline-block;\n height: 0;\n opacity: 0;\n position: absolute;\n width: 0;\n z-index: -1;\n `;\n },\n\n disabled(t: Theme) {\n return css`\n background: ${t.radioDisabledBg} !important; // override root hover/active styles\n border-color: transparent !important; // override root hover/active styles\n box-shadow: ${t.radioDisabledShadow} !important; // override root hover/active styles\n `;\n },\n\n caption(t: Theme) {\n return css`\n display: ${t.radioCaptionDisplay};\n white-space: normal;\n color: ${t.radioTextColor};\n `;\n },\n\n captionDisabled(t: Theme) {\n return css`\n ${disabledTextColorMixin(t.textColorDisabled)};\n `;\n },\n\n placeholder() {\n return css`\n display: inline-block;\n `;\n },\n\n captionWrapper(t: Theme) {\n return css`\n display: inline-block;\n padding-left: ${t.radioCaptionGap};\n `;\n },\n\n subcaption(t: Theme) {\n return css`\n margin-top: 2px;\n color: ${t.radioCommentTextColor};\n `;\n },\n\n subcaptionDisabled(t: Theme) {\n return css`\n ${disabledTextColorMixin(t.textColorDisabled)};\n `;\n },\n\n subcaptionSmall(t: Theme) {\n return css`\n ${subcaptionMixin(t.radioCommentFontSizeSmall, t.radioCommentLineHeightSmall)};\n `;\n },\n subcaptionMedium(t: Theme) {\n return css`\n ${subcaptionMixin(t.radioCommentFontSizeMedium, t.radioCommentLineHeightMedium)};\n `;\n },\n subcaptionLarge(t: Theme) {\n return css`\n ${subcaptionMixin(t.radioCommentFontSizeLarge, t.radioCommentLineHeightLarge)};\n `;\n },\n}));\n"]}
|
|
1
|
+
{"version":3,"file":"Radio.styles.js","sourceRoot":"","sources":["Radio.styles.ts"],"names":[],"mappings":";;;;AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAExE,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,IAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,EAAE,QAAQ;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,IAAM,SAAS,GAAG,gBAAgB,CAAC,UAAC,EAAgB;QAAd,GAAG,SAAA;IAAgB,OAAA,CAAC;QAC/D,IAAI,YAAC,CAAQ;YACX,OAAO,GAAG,ouBAAA,uJAOL,EAAoB,qCACI,EAAoB,GAAI,EAA0B,+BAGlE,EAAoB,0BACf,EAAc,yBACd,EAAkB,8BAEtB,EAAoB,0BAChB,EAAe,yBACf,EAAmB,+SAWpC,KArBI,aAAa,CAAC,MAAM,EACI,CAAC,CAAC,kBAAkB,EAAI,CAAC,CAAC,wBAAwB,EAGlE,aAAa,CAAC,MAAM,EACf,CAAC,CAAC,YAAY,EACd,CAAC,CAAC,gBAAgB,EAEtB,aAAa,CAAC,MAAM,EAChB,CAAC,CAAC,aAAa,EACf,CAAC,CAAC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AnN8D,CAmN9D,CAAC,CAAC","sourcesContent":["import type { Emotion } from '@emotion/css/create-instance';\n\nimport { memoizeGetStyles, prefix } from '../../lib/theming/Emotion.js';\nimport type { Theme } from '../../lib/theming/Theme.js';\nimport {\n afterOutlineMixin,\n circleSizeMixin,\n outlineColorMixin,\n radioCheckedMixin,\n radioSizeMixin,\n} from './Radio.mixins.js';\n\nexport const globalClasses = prefix('radio')({\n circle: 'circle',\n});\n\nexport const getStyles = memoizeGetStyles(({ css }: Emotion) => ({\n root(t: Theme) {\n return css`\n cursor: pointer;\n position: relative;\n white-space: nowrap;\n display: inline-flex;\n align-items: baseline;\n\n .${globalClasses.circle} {\n transition: background ${t.transitionDuration} ${t.transitionTimingFunction};\n }\n\n &:hover .${globalClasses.circle} {\n background: ${t.radioHoverBg};\n box-shadow: ${t.radioHoverShadow};\n }\n &:active .${globalClasses.circle} {\n background: ${t.radioActiveBg};\n box-shadow: ${t.radioActiveShadow};\n }\n\n &::before {\n // non-breaking space.\n // makes a correct space for absolutely positioned circle,\n // and also height and baseline for radio without caption.\n content: '\\\\00A0';\n display: inline-block;\n flex: 0 0 auto;\n }\n `;\n },\n rootSmall(t: Theme) {\n return css`\n ${radioSizeMixin(t.radioFontSizeSmall, t.radioLineHeightSmall, t.radioPaddingYSmall, t.radioSizeSmall)};\n `;\n },\n rootMedium(t: Theme) {\n return css`\n ${radioSizeMixin(t.radioFontSizeMedium, t.radioLineHeightMedium, t.radioPaddingYMedium, t.radioSizeMedium)};\n `;\n },\n rootLarge(t: Theme) {\n return css`\n ${radioSizeMixin(t.radioFontSizeLarge, t.radioLineHeightLarge, t.radioPaddingYLarge, t.radioSizeLarge)};\n `;\n },\n\n rootChecked(t: Theme) {\n return css`\n &:hover .${globalClasses.circle} {\n background: ${t.radioCheckedHoverBgColor};\n }\n `;\n },\n\n circle(t: Theme) {\n return css`\n background-image: ${t.radioBgImage};\n border-radius: 50%;\n border: ${t.radioBorder};\n box-shadow: ${t.radioBoxShadow};\n box-sizing: border-box;\n display: inline-block;\n position: absolute;\n left: 0;\n background-color: ${t.radioBgColor};\n `;\n },\n circleSmall(t: Theme) {\n return css`\n ${circleSizeMixin(\n t.labGrotesqueBaselineCompensation,\n t.radioFontSizeSmall,\n t.radioSizeSmall,\n t.radioBorderWidthCompensation,\n t.radioCircleOffsetY,\n )};\n `;\n },\n circleMedium(t: Theme) {\n return css`\n ${circleSizeMixin(\n t.labGrotesqueBaselineCompensation,\n t.radioFontSizeMedium,\n t.radioSizeMedium,\n t.radioBorderWidthCompensation,\n t.radioCircleOffsetY,\n )};\n `;\n },\n circleLarge(t: Theme) {\n return css`\n ${circleSizeMixin(\n t.labGrotesqueBaselineCompensation,\n t.radioFontSizeLarge,\n t.radioSizeLarge,\n t.radioBorderWidthCompensation,\n t.radioCircleOffsetY,\n )};\n `;\n },\n\n focus(t: Theme) {\n return css`\n &::after {\n ${afterOutlineMixin(t.radioOutlineWidth)};\n ${outlineColorMixin(t.radioFocusShadow, t.radioBorderColorFocus)};\n }\n `;\n },\n\n warning(t: Theme) {\n return css`\n &::after {\n ${afterOutlineMixin(t.radioOutlineWidth)};\n ${outlineColorMixin(t.radioFocusShadow, t.radioBorderColorWarning)};\n }\n `;\n },\n\n error(t: Theme) {\n return css`\n &::after {\n ${afterOutlineMixin(t.radioOutlineWidth)};\n ${outlineColorMixin(t.radioFocusShadow, t.radioBorderColorError)};\n }\n `;\n },\n\n checked(t: Theme) {\n return css`\n background-color: ${t.radioCheckedBgColor};\n border-color: ${t.radioCheckedBorderColor};\n\n &::before {\n content: ' ';\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n margin: auto;\n border-radius: 50%;\n background: ${t.radioCheckedBulletColor};\n }\n `;\n },\n checkedSmall(t: Theme) {\n return css`\n ${radioCheckedMixin(t.radioBulletSizeSmall)};\n `;\n },\n checkedMedium(t: Theme) {\n return css`\n ${radioCheckedMixin(t.radioBulletSizeMedium)};\n `;\n },\n checkedLarge(t: Theme) {\n return css`\n ${radioCheckedMixin(t.radioBulletSizeLarge)};\n `;\n },\n\n checkedDisabled(t: Theme) {\n return css`\n &::before {\n background: ${t.radioCheckedDisabledBulletBg};\n }\n `;\n },\n\n input() {\n return css`\n display: inline-block;\n height: 0;\n opacity: 0;\n position: absolute;\n width: 0;\n z-index: -1;\n `;\n },\n\n disabled(t: Theme) {\n return css`\n background: ${t.radioDisabledBg} !important; // override root hover/active styles\n border-color: transparent !important; // override root hover/active styles\n box-shadow: ${t.radioDisabledShadow} !important; // override root hover/active styles\n `;\n },\n\n caption(t: Theme) {\n return css`\n display: ${t.radioCaptionDisplay};\n padding-left: ${t.radioCaptionGap};\n white-space: normal;\n color: ${t.radioTextColor};\n `;\n },\n\n captionDisabled(t: Theme) {\n return css`\n color: ${t.textColorDisabled};\n `;\n },\n\n placeholder() {\n return css`\n display: inline-block;\n `;\n },\n}));\n"]}
|
|
@@ -39,8 +39,6 @@ export interface ToggleProps extends Pick<AriaAttributes, 'aria-label' | 'aria-d
|
|
|
39
39
|
onBlur?: React.FocusEventHandler<HTMLInputElement>;
|
|
40
40
|
/** Отключает анимацию. */
|
|
41
41
|
disableAnimations?: boolean;
|
|
42
|
-
/** Задаёт второстепенный пояснительный текст под основным текстом тогла. */
|
|
43
|
-
comment?: React.ReactNode;
|
|
44
42
|
}
|
|
45
43
|
export interface ToggleState {
|
|
46
44
|
checked?: boolean;
|
|
@@ -82,10 +80,7 @@ export declare class Toggle extends React.Component<ToggleProps, ToggleState> {
|
|
|
82
80
|
private getRootSizeClassName;
|
|
83
81
|
private getInputSizeClassName;
|
|
84
82
|
private getCaptionSizeClassName;
|
|
85
|
-
private getSubcaptionSizeClassName;
|
|
86
83
|
private renderMain;
|
|
87
|
-
private renderCaption;
|
|
88
|
-
private renderComment;
|
|
89
84
|
private inputRef;
|
|
90
85
|
private handleChange;
|
|
91
86
|
private handleFocus;
|
|
@@ -181,20 +181,9 @@ var Toggle = /** @class */ (function (_super) {
|
|
|
181
181
|
return this.styles.captionSmall(this.theme);
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
|
-
Toggle.prototype.getSubcaptionSizeClassName = function () {
|
|
185
|
-
switch (this.size) {
|
|
186
|
-
case 'large':
|
|
187
|
-
return this.styles.subcaptionLarge(this.theme);
|
|
188
|
-
case 'medium':
|
|
189
|
-
return this.styles.subcaptionMedium(this.theme);
|
|
190
|
-
case 'small':
|
|
191
|
-
default:
|
|
192
|
-
return this.styles.subcaptionSmall(this.theme);
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
184
|
Toggle.prototype.renderMain = function () {
|
|
196
185
|
var _a, _b, _c, _d, _e;
|
|
197
|
-
var _f = this.props, children = _f.children, warning = _f.warning, error = _f.error, id = _f.id, name = _f.name,
|
|
186
|
+
var _f = this.props, children = _f.children, warning = _f.warning, error = _f.error, id = _f.id, name = _f.name, ariaDescribedby = _f["aria-describedby"], ariaLabel = _f["aria-label"];
|
|
198
187
|
var _g = this.getProps(), loading = _g.loading, captionPosition = _g.captionPosition, disableAnimations = _g.disableAnimations;
|
|
199
188
|
var disabled = this.getProps().disabled || loading;
|
|
200
189
|
var checked = this.isUncontrolled() ? this.state.checked : this.props.checked;
|
|
@@ -212,45 +201,32 @@ var Toggle = /** @class */ (function (_super) {
|
|
|
212
201
|
_b[globalClasses.disabled] = !!disabled,
|
|
213
202
|
_b[this.styles.disableAnimation()] = disableAnimations,
|
|
214
203
|
_b));
|
|
204
|
+
var caption = null;
|
|
205
|
+
if (children) {
|
|
206
|
+
var captionClass = this.cx(this.getCaptionSizeClassName(), (_c = {},
|
|
207
|
+
_c[this.styles.caption(this.theme)] = true,
|
|
208
|
+
_c[this.styles.captionLeft(this.theme)] = captionPosition === 'left',
|
|
209
|
+
_c[this.styles.disabledCaption(this.theme)] = !!disabled,
|
|
210
|
+
_c));
|
|
211
|
+
caption = React.createElement("span", { className: captionClass }, children);
|
|
212
|
+
}
|
|
215
213
|
return (React.createElement(CommonWrapper, __assign({ rootNodeRef: this.setRootNode }, this.props),
|
|
216
214
|
React.createElement("label", { "data-tid": ToggleDataTids.root, className: labelClassNames },
|
|
217
|
-
React.createElement("div", { className: this.cx(this.getButtonSizeClassName(), (
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
215
|
+
React.createElement("div", { className: this.cx(this.getButtonSizeClassName(), (_d = {},
|
|
216
|
+
_d[this.styles.button(this.theme)] = true,
|
|
217
|
+
_d[this.styles.buttonRight()] = captionPosition === 'left',
|
|
218
|
+
_d[this.styles.isWarning(this.theme)] = !!warning,
|
|
219
|
+
_d[this.styles.isError(this.theme)] = !!error,
|
|
220
|
+
_d[this.styles.focused(this.theme)] = !disabled && !!this.state.focusByTab,
|
|
221
|
+
_d)) },
|
|
224
222
|
React.createElement(FocusControlWrapper, { onBlurWhenDisabled: this.resetFocus },
|
|
225
223
|
React.createElement("input", { type: "checkbox", checked: checked, onChange: this.handleChange, className: this.cx(this.getInputSizeClassName(), this.styles.input(this.theme)), onFocus: this.handleFocus, onBlur: this.handleBlur, ref: this.inputRef, disabled: disabled, id: id, name: name, role: "switch", "aria-label": ariaLabel, "aria-describedby": ariaDescribedby })),
|
|
226
224
|
React.createElement("div", { className: containerClassNames }),
|
|
227
|
-
React.createElement("div", { className: this.cx(this.getHandleSizeClassName(), globalClasses.handle, (
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
(comment ? (React.createElement("div", { className: this.cx(this.styles.captionWrapper(), (_e = {},
|
|
233
|
-
_e[this.styles.captionWrapperGap(this.theme)] = captionPosition !== 'left',
|
|
234
|
-
_e[this.styles.captionWrapperGapLeft(this.theme)] = captionPosition === 'left',
|
|
235
|
-
_e)) },
|
|
236
|
-
this.renderCaption(disabled, captionPosition, true),
|
|
237
|
-
this.renderComment(disabled))) : (this.renderCaption(disabled, captionPosition, false))))));
|
|
238
|
-
};
|
|
239
|
-
Toggle.prototype.renderCaption = function (disabled, captionPosition, noGap) {
|
|
240
|
-
var _a;
|
|
241
|
-
var captionClass = this.cx(this.getCaptionSizeClassName(), (_a = {},
|
|
242
|
-
_a[this.styles.caption(this.theme)] = true,
|
|
243
|
-
_a[this.styles.captionLeft(this.theme)] = captionPosition === 'left',
|
|
244
|
-
_a[this.styles.disabledCaption(this.theme)] = !!disabled,
|
|
245
|
-
_a[this.styles.captionNoGap()] = noGap,
|
|
246
|
-
_a));
|
|
247
|
-
return React.createElement("div", { className: captionClass }, this.props.children);
|
|
248
|
-
};
|
|
249
|
-
Toggle.prototype.renderComment = function (disabled) {
|
|
250
|
-
var _a;
|
|
251
|
-
return (React.createElement("div", { className: this.cx(this.styles.subcaption(this.theme), this.getSubcaptionSizeClassName(), (_a = {},
|
|
252
|
-
_a[this.styles.subcaptionDisabled(this.theme)] = !!disabled,
|
|
253
|
-
_a)) }, this.props.comment));
|
|
225
|
+
React.createElement("div", { className: this.cx(this.getHandleSizeClassName(), globalClasses.handle, (_e = {},
|
|
226
|
+
_e[this.styles.handle(this.theme)] = true,
|
|
227
|
+
_e[this.styles.handleDisabled(this.theme)] = disabled,
|
|
228
|
+
_e)) })),
|
|
229
|
+
caption)));
|
|
254
230
|
};
|
|
255
231
|
Toggle.prototype.isUncontrolled = function () {
|
|
256
232
|
return this.props.checked === undefined;
|