@wireapp/react-ui-kit 8.15.0 → 8.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/Form/Checkbox.d.ts +3 -0
- package/src/Form/Checkbox.js +35 -12
- package/src/Form/Checkbox.js.map +1 -1
package/package.json
CHANGED
|
@@ -73,6 +73,6 @@
|
|
|
73
73
|
"test:update": "yarn test --updateSnapshot",
|
|
74
74
|
"test:project": "yarn dist && yarn test"
|
|
75
75
|
},
|
|
76
|
-
"version": "8.
|
|
77
|
-
"gitHead": "
|
|
76
|
+
"version": "8.17.0",
|
|
77
|
+
"gitHead": "1eac5c07396bb1fb1df9eb2b02d5035ff7dc4f7d"
|
|
78
78
|
}
|
package/src/Form/Checkbox.d.ts
CHANGED
|
@@ -7,10 +7,13 @@ export interface StyledLabelProps<T = HTMLLabelElement> extends React.HTMLProps<
|
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
markInvalid?: boolean;
|
|
9
9
|
aligncenter?: boolean;
|
|
10
|
+
labelBeforeCheckbox?: boolean;
|
|
10
11
|
}
|
|
11
12
|
interface CheckboxProps<T = HTMLInputElement> extends InputProps<T> {
|
|
12
13
|
id?: string;
|
|
13
14
|
aligncenter?: boolean;
|
|
15
|
+
labelBeforeCheckbox?: boolean;
|
|
16
|
+
outlineOffset?: string;
|
|
14
17
|
}
|
|
15
18
|
export declare const Checkbox: React.FC<CheckboxProps<HTMLInputElement>>;
|
|
16
19
|
export declare type CheckboxLabelProps<T = HTMLSpanElement> = TextProps<T>;
|
package/src/Form/Checkbox.js
CHANGED
|
@@ -23,8 +23,8 @@ var _Text = require("../Text");
|
|
|
23
23
|
|
|
24
24
|
var _Input = require("./Input");
|
|
25
25
|
|
|
26
|
-
var _excluded = ["disabled", "markInvalid", "aligncenter", "children"],
|
|
27
|
-
_excluded2 = ["id", "children", "style", "disabled", "wrapperCSS", "markInvalid", "aligncenter"];
|
|
26
|
+
var _excluded = ["disabled", "markInvalid", "aligncenter", "labelBeforeCheckbox", "children"],
|
|
27
|
+
_excluded2 = ["id", "children", "style", "disabled", "wrapperCSS", "markInvalid", "aligncenter", "labelBeforeCheckbox", "outlineOffset"];
|
|
28
28
|
|
|
29
29
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
30
30
|
|
|
@@ -39,25 +39,31 @@ var StyledLabel = function StyledLabel(_ref) {
|
|
|
39
39
|
markInvalid = _ref.markInvalid,
|
|
40
40
|
_ref$aligncenter = _ref.aligncenter,
|
|
41
41
|
aligncenter = _ref$aligncenter === void 0 ? false : _ref$aligncenter,
|
|
42
|
+
_ref$labelBeforeCheck = _ref.labelBeforeCheckbox,
|
|
43
|
+
labelBeforeCheckbox = _ref$labelBeforeCheck === void 0 ? false : _ref$labelBeforeCheck,
|
|
42
44
|
children = _ref.children,
|
|
43
45
|
props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
44
46
|
return (0, _react.jsx)("label", (0, _extends2["default"])({
|
|
45
47
|
css: function css(theme) {
|
|
46
|
-
var _objectSpread2
|
|
48
|
+
var _objectSpread2;
|
|
47
49
|
|
|
48
|
-
return _objectSpread(_objectSpread((_objectSpread2 = {}, (0, _defineProperty2["default"])(_objectSpread2, ".".concat(_Input.INPUT_CLASSNAME, ":checked + &::before"), {
|
|
50
|
+
return _objectSpread(_objectSpread(_objectSpread((_objectSpread2 = {}, (0, _defineProperty2["default"])(_objectSpread2, ".".concat(_Input.INPUT_CLASSNAME, ":checked + &::before"), {
|
|
49
51
|
background: "".concat(disabled ? theme.Checkbox.disablecheckedBgColor : theme.general.primaryColor),
|
|
50
52
|
borderColor: theme.general.primaryColor
|
|
51
53
|
}), (0, _defineProperty2["default"])(_objectSpread2, ".".concat(_Input.INPUT_CLASSNAME, ":checked + & > svg"), {
|
|
52
54
|
fill: theme.general.backgroundColor
|
|
53
|
-
}), (0, _defineProperty2["default"])(_objectSpread2, ".".concat(_Input.INPUT_CLASSNAME, " + & > svg"), {
|
|
55
|
+
}), (0, _defineProperty2["default"])(_objectSpread2, ".".concat(_Input.INPUT_CLASSNAME, " + & > svg"), _objectSpread({
|
|
54
56
|
fill: 'none',
|
|
55
57
|
position: 'absolute',
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
58
|
+
top: '50%',
|
|
59
|
+
transform: 'translateY(-50%)'
|
|
60
|
+
}, labelBeforeCheckbox ? {
|
|
61
|
+
right: '0.75rem'
|
|
62
|
+
} : {
|
|
63
|
+
left: '0.25rem'
|
|
64
|
+
})), _objectSpread2), !disabled && (0, _defineProperty2["default"])({}, ".".concat(_Input.INPUT_CLASSNAME, ":hover + &::before"), {
|
|
59
65
|
borderColor: theme.general.primaryColor
|
|
60
|
-
})), {}, (
|
|
66
|
+
})), {}, (0, _defineProperty2["default"])({}, ".".concat(_Input.INPUT_CLASSNAME, " + &::before"), _objectSpread(_objectSpread({
|
|
61
67
|
background: disabled ? theme.Checkbox.disableBgColor : theme.Checkbox.background
|
|
62
68
|
}, !disabled ? {
|
|
63
69
|
border: markInvalid ? "2px solid ".concat(theme.Checkbox.invalidBorderColor) : "2px solid ".concat(theme.Checkbox.border)
|
|
@@ -73,7 +79,20 @@ var StyledLabel = function StyledLabel(_ref) {
|
|
|
73
79
|
lineHeight: 1.4,
|
|
74
80
|
margin: '0 8px 0 0px',
|
|
75
81
|
color: theme.general.color
|
|
76
|
-
})),
|
|
82
|
+
})), labelBeforeCheckbox && {
|
|
83
|
+
flexDirection: 'row-reverse',
|
|
84
|
+
justifyContent: 'space-between'
|
|
85
|
+
}), {}, {
|
|
86
|
+
alignItems: 'center',
|
|
87
|
+
position: 'relative',
|
|
88
|
+
margin: '0 0 0 -16px',
|
|
89
|
+
width: aligncenter ? 'auto' : '100%',
|
|
90
|
+
lineHeight: 1.4,
|
|
91
|
+
display: 'flex',
|
|
92
|
+
opacity: disabled ? 0.56 : 1,
|
|
93
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
94
|
+
borderRadius: '4px'
|
|
95
|
+
});
|
|
77
96
|
}
|
|
78
97
|
}, props), children, (0, _react.jsx)("svg", {
|
|
79
98
|
width: "15",
|
|
@@ -95,6 +114,9 @@ var Checkbox = /*#__PURE__*/_react2["default"].forwardRef(function (_ref3, ref)
|
|
|
95
114
|
wrapperCSS = _ref3$wrapperCSS === void 0 ? {} : _ref3$wrapperCSS,
|
|
96
115
|
markInvalid = _ref3.markInvalid,
|
|
97
116
|
aligncenter = _ref3.aligncenter,
|
|
117
|
+
labelBeforeCheckbox = _ref3.labelBeforeCheckbox,
|
|
118
|
+
_ref3$outlineOffset = _ref3.outlineOffset,
|
|
119
|
+
outlineOffset = _ref3$outlineOffset === void 0 ? '0.4rem' : _ref3$outlineOffset,
|
|
98
120
|
props = (0, _objectWithoutProperties2["default"])(_ref3, _excluded2);
|
|
99
121
|
return (0, _react.jsx)("div", {
|
|
100
122
|
css: function css(theme) {
|
|
@@ -106,7 +128,7 @@ var Checkbox = /*#__PURE__*/_react2["default"].forwardRef(function (_ref3, ref)
|
|
|
106
128
|
left: '-0.3rem'
|
|
107
129
|
}, ".".concat(_Input.INPUT_CLASSNAME, ":focus-visible + label"), {
|
|
108
130
|
outline: "1px solid ".concat(theme.general.primaryColor),
|
|
109
|
-
outlineOffset:
|
|
131
|
+
outlineOffset: outlineOffset
|
|
110
132
|
}), wrapperCSS);
|
|
111
133
|
},
|
|
112
134
|
style: style
|
|
@@ -127,7 +149,8 @@ var Checkbox = /*#__PURE__*/_react2["default"].forwardRef(function (_ref3, ref)
|
|
|
127
149
|
htmlFor: id,
|
|
128
150
|
disabled: disabled,
|
|
129
151
|
markInvalid: markInvalid,
|
|
130
|
-
aligncenter: aligncenter
|
|
152
|
+
aligncenter: aligncenter,
|
|
153
|
+
labelBeforeCheckbox: labelBeforeCheckbox
|
|
131
154
|
}, children));
|
|
132
155
|
});
|
|
133
156
|
|
package/src/Form/Checkbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Checkbox.tsx"],"names":["StyledLabel","disabled","markInvalid","aligncenter","children","props","theme","INPUT_CLASSNAME","background","Checkbox","disablecheckedBgColor","general","primaryColor","borderColor","fill","backgroundColor","position","left","top","disableBgColor","border","invalidBorderColor","disableBorderColor","borderRadius","boxSizing","content","display","width","height","lineHeight","margin","color","React","forwardRef","ref","id","style","wrapperCSS","alignItems","justifyContent","outline","outlineOffset","marginBottom","opacity","cursor","CheckboxLabel"],"mappings":";;;;;;;;;;;;;;;;;AAoBA;;AACA;;AAGA;;AACA;;;;;;;;;;;;;AAQA,IAAMA,WAAW,GAAG,SAAdA,WAAc,OAAwF;AAAA,MAAtFC,QAAsF,QAAtFA,QAAsF;AAAA,MAA5EC,WAA4E,QAA5EA,WAA4E;AAAA,8BAA/DC,WAA+D;AAAA,MAA/DA,WAA+D,iCAAjD,KAAiD;AAAA,MAA1CC,QAA0C,QAA1CA,QAA0C;AAAA,MAA7BC,KAA6B;AAC1G,SACE;AACE,IAAA,GAAG,EAAE,aAACC,KAAD;AAAA;;AAAA,2HACEC,sBADF,2BAC0C;AAC3CC,QAAAA,UAAU,YAAKP,QAAQ,GAAGK,KAAK,CAACG,QAAN,CAAeC,qBAAlB,GAA0CJ,KAAK,CAACK,OAAN,CAAcC,YAArE,CADiC;AAE3CC,QAAAA,WAAW,EAAEP,KAAK,CAACK,OAAN,CAAcC;AAFgB,OAD1C,+DAKEL,sBALF,yBAKwC;AACzCO,QAAAA,IAAI,EAAER,KAAK,CAACK,OAAN,CAAcI;AADqB,OALxC,+DAQER,sBARF,iBAQgC;AACjCO,QAAAA,IAAI,EAAE,MAD2B;AAEjCE,QAAAA,QAAQ,EAAE,UAFuB;AAGjCC,QAAAA,IAAI,EAAE,SAH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AAYE,IAAA,SAAS,EAAE3B;AAZb,KAaMF,KAbN,EAfF,EA+BE,gBAAC,WAAD;AAAa,IAAA,OAAO,EAAE8B,EAAtB;AAA0B,IAAA,QAAQ,EAAElC,QAApC;AAA8C,IAAA,WAAW,EAAEC,WAA3D;AAAwE,IAAA,WAAW,EAAEC;AAArF,KACGC,QADH,CA/BF,CADA;AAAA,CAHiE,CAA5D;;;;AA2CA,IAAMyC,aAAa,GAAG,SAAhBA,aAAgB;AAAA,MAAKxC,KAAL;AAAA,SAC3B,gBAAC,UAAD;AACE,IAAA,GAAG,EAAE,aAACC,KAAD;AAAA,+BACA,qBAAUA,KAAV,oBACED,KADF,EADA;AAAA;AADP,KAMMA,KANN,EAD2B;AAAA,CAAtB","sourcesContent":["/*\n * Wire\n * Copyright (C) 2018 Wire Swiss GmbH\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see http://www.gnu.org/licenses/.\n *\n */\n\n/** @jsx jsx */\nimport {jsx} from '@emotion/react';\nimport React, {useId} from 'react';\n\nimport {Theme} from '../Layout';\nimport {Text, TextProps, textStyle} from '../Text';\nimport {INPUT_CLASSNAME, InputProps} from './Input';\n\nexport interface StyledLabelProps<T = HTMLLabelElement> extends React.HTMLProps<T> {\n disabled?: boolean;\n markInvalid?: boolean;\n aligncenter?: boolean;\n}\n\nconst StyledLabel = ({disabled, markInvalid, aligncenter = false, children, ...props}: StyledLabelProps) => {\n return (\n <label\n css={(theme: Theme) => ({\n [`.${INPUT_CLASSNAME}:checked + &::before`]: {\n background: `${disabled ? theme.Checkbox.disablecheckedBgColor : theme.general.primaryColor}`,\n borderColor: theme.general.primaryColor,\n },\n [`.${INPUT_CLASSNAME}:checked + & > svg`]: {\n fill: theme.general.backgroundColor,\n },\n [`.${INPUT_CLASSNAME} + & > svg`]: {\n fill: 'none',\n position: 'absolute',\n left: '0.25rem',\n top: '0.25rem',\n },\n ...(!disabled && {\n [`.${INPUT_CLASSNAME}:hover + &::before`]: {\n borderColor: theme.general.primaryColor,\n },\n }),\n [`.${INPUT_CLASSNAME} + &::before`]: {\n background: disabled ? theme.Checkbox.disableBgColor : theme.Checkbox.background,\n ...(!disabled\n ? {\n border: markInvalid\n ? `2px solid ${theme.Checkbox.invalidBorderColor}`\n : `2px solid ${theme.Checkbox.border}`,\n }\n : {\n border: `2px solid ${theme.Checkbox.disableBorderColor}`,\n }),\n borderRadius: '3px',\n boxSizing: 'border-box',\n content: '\"\"',\n display: 'inline-block',\n width: '22px',\n height: '22px',\n lineHeight: 1.4,\n margin: '0 8px 0 0px',\n color: theme.general.color,\n },\n position: 'relative',\n margin: '0 0 0 -16px',\n width: aligncenter ? 'auto' : '100%',\n lineHeight: 1.4,\n display: 'flex',\n opacity: disabled ? 0.56 : 1,\n cursor: disabled ? 'not-allowed' : 'pointer',\n borderRadius: '4px',\n })}\n {...props}\n >\n {children}\n <svg width=\"15\" height=\"13\" viewBox=\"0 0 16 13\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M5.65685 12.0711L15.9842 1.62738L14.57 0.213167L5.65685 9.24264L1.41421 5L0 6.41421L5.65685 12.0711Z\" />\n </svg>\n </label>\n );\n};\n\ninterface CheckboxProps<T = HTMLInputElement> extends InputProps<T> {\n id?: string;\n aligncenter?: boolean;\n}\n\nexport const Checkbox: React.FC<CheckboxProps<HTMLInputElement>> = React.forwardRef<\n HTMLInputElement,\n CheckboxProps<HTMLInputElement>\n>(({id = useId(), children, style, disabled, wrapperCSS = {}, markInvalid, aligncenter, ...props}, ref) => (\n <div\n css={(theme: Theme) => ({\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'flex-start',\n position: 'relative',\n left: '-0.3rem',\n [`.${INPUT_CLASSNAME}:focus-visible + label`]: {\n outline: `1px solid ${theme.general.primaryColor}`,\n outlineOffset: '0.4rem',\n },\n ...wrapperCSS,\n })}\n style={style}\n >\n <input\n type=\"checkbox\"\n id={id}\n style={{\n height: '22px',\n marginBottom: '0',\n opacity: 0,\n width: '22px',\n cursor: disabled ? 'not-allowed' : 'pointer',\n }}\n disabled={disabled}\n ref={ref}\n className={INPUT_CLASSNAME}\n {...props}\n />\n\n <StyledLabel htmlFor={id} disabled={disabled} markInvalid={markInvalid} aligncenter={aligncenter}>\n {children}\n </StyledLabel>\n </div>\n));\n\nexport type CheckboxLabelProps<T = HTMLSpanElement> = TextProps<T>;\n\nexport const CheckboxLabel = ({...props}: CheckboxLabelProps) => (\n <Text\n css={(theme: Theme) => ({\n ...textStyle(theme, {\n ...props,\n }),\n })}\n {...props}\n />\n);\n"],"file":"Checkbox.js"}
|
|
1
|
+
{"version":3,"sources":["Checkbox.tsx"],"names":["StyledLabel","disabled","markInvalid","aligncenter","labelBeforeCheckbox","children","props","theme","INPUT_CLASSNAME","background","Checkbox","disablecheckedBgColor","general","primaryColor","borderColor","fill","backgroundColor","position","top","transform","right","left","disableBgColor","border","invalidBorderColor","disableBorderColor","borderRadius","boxSizing","content","display","width","height","lineHeight","margin","color","flexDirection","justifyContent","alignItems","opacity","cursor","React","forwardRef","ref","id","style","wrapperCSS","outlineOffset","outline","marginBottom","CheckboxLabel"],"mappings":";;;;;;;;;;;;;;;;;AAoBA;;AACA;;AAGA;;AACA;;;;;;;;;;;;;AASA,IAAMA,WAAW,GAAG,SAAdA,WAAc,OAOI;AAAA,MANtBC,QAMsB,QANtBA,QAMsB;AAAA,MALtBC,WAKsB,QALtBA,WAKsB;AAAA,8BAJtBC,WAIsB;AAAA,MAJtBA,WAIsB,iCAJR,KAIQ;AAAA,mCAHtBC,mBAGsB;AAAA,MAHtBA,mBAGsB,sCAHA,KAGA;AAAA,MAFtBC,QAEsB,QA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;;;;AAiEA,IAAM4C,aAAa,GAAG,SAAhBA,aAAgB;AAAA,MAAK3C,KAAL;AAAA,SAC3B,gBAAC,UAAD;AACE,IAAA,GAAG,EAAE,aAACC,KAAD;AAAA,+BACA,qBAAUA,KAAV,oBACED,KADF,EADA;AAAA;AADP,KAMMA,KANN,EAD2B;AAAA,CAAtB","sourcesContent":["/*\n * Wire\n * Copyright (C) 2018 Wire Swiss GmbH\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see http://www.gnu.org/licenses/.\n *\n */\n\n/** @jsx jsx */\nimport {jsx} from '@emotion/react';\nimport React, {useId} from 'react';\n\nimport {Theme} from '../Layout';\nimport {Text, TextProps, textStyle} from '../Text';\nimport {INPUT_CLASSNAME, InputProps} from './Input';\n\nexport interface StyledLabelProps<T = HTMLLabelElement> extends React.HTMLProps<T> {\n disabled?: boolean;\n markInvalid?: boolean;\n aligncenter?: boolean;\n labelBeforeCheckbox?: boolean;\n}\n\nconst StyledLabel = ({\n disabled,\n markInvalid,\n aligncenter = false,\n labelBeforeCheckbox = false,\n children,\n ...props\n}: StyledLabelProps) => {\n return (\n <label\n css={(theme: Theme) => ({\n [`.${INPUT_CLASSNAME}:checked + &::before`]: {\n background: `${disabled ? theme.Checkbox.disablecheckedBgColor : theme.general.primaryColor}`,\n borderColor: theme.general.primaryColor,\n },\n [`.${INPUT_CLASSNAME}:checked + & > svg`]: {\n fill: theme.general.backgroundColor,\n },\n [`.${INPUT_CLASSNAME} + & > svg`]: {\n fill: 'none',\n position: 'absolute',\n top: '50%',\n transform: 'translateY(-50%)',\n ...(labelBeforeCheckbox\n ? {\n right: '0.75rem',\n }\n : {\n left: '0.25rem',\n }),\n },\n ...(!disabled && {\n [`.${INPUT_CLASSNAME}:hover + &::before`]: {\n borderColor: theme.general.primaryColor,\n },\n }),\n [`.${INPUT_CLASSNAME} + &::before`]: {\n background: disabled ? theme.Checkbox.disableBgColor : theme.Checkbox.background,\n ...(!disabled\n ? {\n border: markInvalid\n ? `2px solid ${theme.Checkbox.invalidBorderColor}`\n : `2px solid ${theme.Checkbox.border}`,\n }\n : {\n border: `2px solid ${theme.Checkbox.disableBorderColor}`,\n }),\n borderRadius: '3px',\n boxSizing: 'border-box',\n content: '\"\"',\n display: 'inline-block',\n width: '22px',\n height: '22px',\n lineHeight: 1.4,\n margin: '0 8px 0 0px',\n color: theme.general.color,\n },\n ...(labelBeforeCheckbox && {\n flexDirection: 'row-reverse',\n justifyContent: 'space-between',\n }),\n alignItems: 'center',\n position: 'relative',\n margin: '0 0 0 -16px',\n width: aligncenter ? 'auto' : '100%',\n lineHeight: 1.4,\n display: 'flex',\n opacity: disabled ? 0.56 : 1,\n cursor: disabled ? 'not-allowed' : 'pointer',\n borderRadius: '4px',\n })}\n {...props}\n >\n {children}\n <svg width=\"15\" height=\"13\" viewBox=\"0 0 16 13\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M5.65685 12.0711L15.9842 1.62738L14.57 0.213167L5.65685 9.24264L1.41421 5L0 6.41421L5.65685 12.0711Z\" />\n </svg>\n </label>\n );\n};\n\ninterface CheckboxProps<T = HTMLInputElement> extends InputProps<T> {\n id?: string;\n aligncenter?: boolean;\n labelBeforeCheckbox?: boolean;\n outlineOffset?: string;\n}\n\nexport const Checkbox: React.FC<CheckboxProps<HTMLInputElement>> = React.forwardRef<\n HTMLInputElement,\n CheckboxProps<HTMLInputElement>\n>(\n (\n {\n id = useId(),\n children,\n style,\n disabled,\n wrapperCSS = {},\n markInvalid,\n aligncenter,\n labelBeforeCheckbox,\n outlineOffset = '0.4rem',\n ...props\n },\n ref,\n ) => (\n <div\n css={(theme: Theme) => ({\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'flex-start',\n position: 'relative',\n left: '-0.3rem',\n [`.${INPUT_CLASSNAME}:focus-visible + label`]: {\n outline: `1px solid ${theme.general.primaryColor}`,\n outlineOffset: outlineOffset,\n },\n ...wrapperCSS,\n })}\n style={style}\n >\n <input\n type=\"checkbox\"\n id={id}\n style={{\n height: '22px',\n marginBottom: '0',\n opacity: 0,\n width: '22px',\n cursor: disabled ? 'not-allowed' : 'pointer',\n }}\n disabled={disabled}\n ref={ref}\n className={INPUT_CLASSNAME}\n {...props}\n />\n\n <StyledLabel\n htmlFor={id}\n disabled={disabled}\n markInvalid={markInvalid}\n aligncenter={aligncenter}\n labelBeforeCheckbox={labelBeforeCheckbox}\n >\n {children}\n </StyledLabel>\n </div>\n ),\n);\n\nexport type CheckboxLabelProps<T = HTMLSpanElement> = TextProps<T>;\n\nexport const CheckboxLabel = ({...props}: CheckboxLabelProps) => (\n <Text\n css={(theme: Theme) => ({\n ...textStyle(theme, {\n ...props,\n }),\n })}\n {...props}\n />\n);\n"],"file":"Checkbox.js"}
|