@wireapp/react-ui-kit 9.23.8 → 9.24.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/lib/Form/Switch.d.ts
CHANGED
|
@@ -12,5 +12,5 @@ export interface SwitchProps<T = HTMLInputElement> extends InputProps<T> {
|
|
|
12
12
|
showLoading?: boolean;
|
|
13
13
|
dataUieName?: string;
|
|
14
14
|
}
|
|
15
|
-
export declare const Switch: (
|
|
15
|
+
export declare const Switch: import("react").ForwardRefExoticComponent<Omit<SwitchProps<HTMLInputElement>, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
16
16
|
//# sourceMappingURL=Switch.d.ts.map
|
package/lib/Form/Switch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../src/Form/Switch.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../src/Form/Switch.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AAMnC,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,gBAAgB,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAC;IACtE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,MAAM,yIAmDlB,CAAC"}
|
package/lib/Form/Switch.js
CHANGED
|
@@ -21,66 +21,18 @@ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
23
|
const react_1 = require("react");
|
|
24
|
+
const Switch_styles_1 = require("./Switch.styles");
|
|
24
25
|
const Identity_1 = require("../Identity");
|
|
25
26
|
const Misc_1 = require("../Misc");
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
overflow: 'hidden',
|
|
39
|
-
}, children: [(0, jsx_runtime_1.jsx)("span", { css: {
|
|
40
|
-
['&:after']: {
|
|
41
|
-
content: '" "',
|
|
42
|
-
paddingRight: '10px',
|
|
43
|
-
textAlign: 'right',
|
|
44
|
-
},
|
|
45
|
-
['&:before']: {
|
|
46
|
-
content: '" "',
|
|
47
|
-
paddingLeft: '10px',
|
|
48
|
-
},
|
|
49
|
-
['&:before, &:after']: {
|
|
50
|
-
backgroundColor: disabled || showLoading
|
|
51
|
-
? Identity_1.COLOR.tint(checked ? activatedColor : deactivatedColor, 0.4)
|
|
52
|
-
: checked
|
|
53
|
-
? activatedColor
|
|
54
|
-
: deactivatedColor,
|
|
55
|
-
boxSizing: 'border-box',
|
|
56
|
-
display: 'block',
|
|
57
|
-
float: 'left',
|
|
58
|
-
height: '25px',
|
|
59
|
-
lineHeight: '1.5625rem',
|
|
60
|
-
padding: 0,
|
|
61
|
-
width: '50%',
|
|
62
|
-
},
|
|
63
|
-
display: 'block',
|
|
64
|
-
marginLeft: checked ? 0 : '-100%',
|
|
65
|
-
transition: 'margin 0.1s ease-in 0s',
|
|
66
|
-
width: '200%',
|
|
67
|
-
} }), showLoading ? ((0, jsx_runtime_1.jsx)(Misc_1.Loading, { size: 21, color: loadingColor, style: {
|
|
68
|
-
display: 'block',
|
|
69
|
-
margin: '2px',
|
|
70
|
-
position: 'absolute',
|
|
71
|
-
} })) : ((0, jsx_runtime_1.jsx)("span", { css: {
|
|
72
|
-
background: Identity_1.COLOR.WHITE,
|
|
73
|
-
borderRadius: '100%',
|
|
74
|
-
bottom: 0,
|
|
75
|
-
boxShadow: '0px 0px 2px -1px gray',
|
|
76
|
-
display: 'block',
|
|
77
|
-
height: '23px',
|
|
78
|
-
margin: '1px',
|
|
79
|
-
opacity: disabled ? 0.7 : undefined,
|
|
80
|
-
position: 'absolute',
|
|
81
|
-
right: checked ? '0px' : '17px',
|
|
82
|
-
top: 0,
|
|
83
|
-
transition: 'all 0.15s ease-in 0s',
|
|
84
|
-
width: '23px',
|
|
85
|
-
} }))] })] }) }));
|
|
86
|
-
exports.Switch = Switch;
|
|
27
|
+
exports.Switch = (0, react_1.forwardRef)(({ id = Math.random().toString(), checked, onToggle = () => { }, showLoading, disabled, loadingColor = Identity_1.COLOR.BLUE, activatedColor = Identity_1.COLOR.BLUE, deactivatedColor = '#d2d2d2', name, dataUieName, }, ref) => ((0, jsx_runtime_1.jsxs)("div", { css: Switch_styles_1.wrapperStyles, children: [(0, jsx_runtime_1.jsx)("input", { ref: ref, id: id, checked: checked, disabled: disabled, name: name, onChange: event => onToggle(event.target.checked), onKeyDown: event => {
|
|
28
|
+
if (event.key == 'Enter') {
|
|
29
|
+
onToggle(!event.target.checked);
|
|
30
|
+
}
|
|
31
|
+
}, type: "checkbox", css: Switch_styles_1.inputStyles, "data-uie-name": dataUieName }), (0, jsx_runtime_1.jsxs)("label", { htmlFor: id, css: (0, Switch_styles_1.labelStyles)(disabled, showLoading), children: [(0, jsx_runtime_1.jsx)("span", { css: (0, Switch_styles_1.switchStyles)({
|
|
32
|
+
disabled,
|
|
33
|
+
showLoading,
|
|
34
|
+
checked,
|
|
35
|
+
activatedColor,
|
|
36
|
+
deactivatedColor,
|
|
37
|
+
}) }), showLoading ? ((0, jsx_runtime_1.jsx)(Misc_1.Loading, { size: 21, color: loadingColor, css: Switch_styles_1.loadingStyles })) : ((0, jsx_runtime_1.jsx)("span", { css: (0, Switch_styles_1.switchDotStyles)(disabled, checked) }))] })] })));
|
|
38
|
+
exports.Switch.displayName = 'Switch';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CSSObject } from '@emotion/react';
|
|
2
|
+
export declare const wrapperStyles: CSSObject;
|
|
3
|
+
export declare const inputStyles: CSSObject;
|
|
4
|
+
export declare const labelStyles: (disabled: boolean, showLoading: boolean) => CSSObject;
|
|
5
|
+
type SwitchStylesProps = {
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
showLoading: boolean;
|
|
8
|
+
checked: boolean;
|
|
9
|
+
activatedColor: string;
|
|
10
|
+
deactivatedColor: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const switchStyles: ({ disabled, showLoading, checked, activatedColor, deactivatedColor, }: SwitchStylesProps) => CSSObject;
|
|
13
|
+
export declare const loadingStyles: CSSObject;
|
|
14
|
+
export declare const switchDotStyles: (disabled: boolean, checked: boolean) => CSSObject;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=Switch.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Switch.styles.d.ts","sourceRoot":"","sources":["../../src/Form/Switch.styles.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAIzC,eAAO,MAAM,aAAa,EAAE,SAO3B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,SAOzB,CAAC;AAEF,eAAO,MAAM,WAAW,aAAc,OAAO,eAAe,OAAO,KAAG,SAMpE,CAAC;AAEH,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,YAAY,0EAMtB,iBAAiB,KAAG,SA6BrB,CAAC;AAEH,eAAO,MAAM,aAAa,EAAE,SAI3B,CAAC;AAEF,eAAO,MAAM,eAAe,aAAc,OAAO,WAAW,OAAO,KAAG,SAcpE,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Wire
|
|
4
|
+
* Copyright (C) 2022 Wire Swiss GmbH
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.switchDotStyles = exports.loadingStyles = exports.switchStyles = exports.labelStyles = exports.inputStyles = exports.wrapperStyles = void 0;
|
|
22
|
+
const Identity_1 = require("../Identity");
|
|
23
|
+
exports.wrapperStyles = {
|
|
24
|
+
display: 'grid',
|
|
25
|
+
position: 'relative',
|
|
26
|
+
textAlign: 'left',
|
|
27
|
+
userSelect: 'none',
|
|
28
|
+
verticalAlign: 'middle',
|
|
29
|
+
width: '42px',
|
|
30
|
+
};
|
|
31
|
+
exports.inputStyles = {
|
|
32
|
+
height: '0',
|
|
33
|
+
width: '0',
|
|
34
|
+
opacity: '0',
|
|
35
|
+
'&:focus + label': {
|
|
36
|
+
outline: `1px solid ${Identity_1.COLOR_V2.BLUE_LIGHT_700}`,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
const labelStyles = (disabled, showLoading) => ({
|
|
40
|
+
borderRadius: '20px',
|
|
41
|
+
cursor: disabled || showLoading ? '' : 'pointer',
|
|
42
|
+
display: 'block',
|
|
43
|
+
margin: 0,
|
|
44
|
+
overflow: 'hidden',
|
|
45
|
+
});
|
|
46
|
+
exports.labelStyles = labelStyles;
|
|
47
|
+
const switchStyles = ({ disabled, showLoading, checked, activatedColor, deactivatedColor, }) => ({
|
|
48
|
+
'&:after': {
|
|
49
|
+
content: '" "',
|
|
50
|
+
paddingRight: '10px',
|
|
51
|
+
textAlign: 'right',
|
|
52
|
+
},
|
|
53
|
+
'&:before': {
|
|
54
|
+
content: '" "',
|
|
55
|
+
paddingLeft: '10px',
|
|
56
|
+
},
|
|
57
|
+
'&:before, &:after': {
|
|
58
|
+
backgroundColor: disabled || showLoading
|
|
59
|
+
? Identity_1.COLOR.tint(checked ? activatedColor : deactivatedColor, 0.4)
|
|
60
|
+
: checked
|
|
61
|
+
? activatedColor
|
|
62
|
+
: deactivatedColor,
|
|
63
|
+
boxSizing: 'border-box',
|
|
64
|
+
display: 'block',
|
|
65
|
+
float: 'left',
|
|
66
|
+
height: '25px',
|
|
67
|
+
lineHeight: '1.5625rem',
|
|
68
|
+
padding: 0,
|
|
69
|
+
width: '50%',
|
|
70
|
+
},
|
|
71
|
+
display: 'block',
|
|
72
|
+
marginLeft: checked ? 0 : '-100%',
|
|
73
|
+
transition: 'margin 0.1s ease-in 0s',
|
|
74
|
+
width: '200%',
|
|
75
|
+
});
|
|
76
|
+
exports.switchStyles = switchStyles;
|
|
77
|
+
exports.loadingStyles = {
|
|
78
|
+
display: 'block',
|
|
79
|
+
margin: '2px',
|
|
80
|
+
position: 'absolute',
|
|
81
|
+
};
|
|
82
|
+
const switchDotStyles = (disabled, checked) => ({
|
|
83
|
+
background: Identity_1.COLOR.WHITE,
|
|
84
|
+
borderRadius: '100%',
|
|
85
|
+
bottom: 0,
|
|
86
|
+
boxShadow: '0px 0px 2px -1px gray',
|
|
87
|
+
display: 'block',
|
|
88
|
+
height: '23px',
|
|
89
|
+
margin: '1px',
|
|
90
|
+
opacity: disabled ? 0.7 : undefined,
|
|
91
|
+
position: 'absolute',
|
|
92
|
+
right: checked ? '0px' : '17px',
|
|
93
|
+
top: 0,
|
|
94
|
+
transition: 'all 0.15s ease-in 0s',
|
|
95
|
+
width: '23px',
|
|
96
|
+
});
|
|
97
|
+
exports.switchDotStyles = switchDotStyles;
|
package/package.json
CHANGED
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@babel/cli": "7.25.7",
|
|
19
|
-
"@babel/core": "7.25.
|
|
20
|
-
"@babel/preset-env": "7.25.
|
|
19
|
+
"@babel/core": "7.25.8",
|
|
20
|
+
"@babel/preset-env": "7.25.8",
|
|
21
21
|
"@babel/preset-react": "7.25.7",
|
|
22
22
|
"@babel/preset-typescript": "7.25.7",
|
|
23
23
|
"@emotion/babel-preset-css-prop": "^11.10.0",
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
"test:watch": "jest --watch",
|
|
70
70
|
"test:update": "jest --updateSnapshot"
|
|
71
71
|
},
|
|
72
|
-
"version": "9.
|
|
73
|
-
"gitHead": "
|
|
72
|
+
"version": "9.24.0",
|
|
73
|
+
"gitHead": "a2d0cafbe2a9adcc34ae62e2f94e27ccf0709cfa"
|
|
74
74
|
}
|