@via-profit/ui-kit 0.1.0-rc.76 → 0.1.0-rc.78
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/Accordion/AccordionActions.d.ts +8 -0
- package/Accordion/AccordionActions.js +31 -0
- package/Accordion/AccordionContainer.d.ts +8 -0
- package/Accordion/AccordionContainer.js +61 -0
- package/Accordion/AccordionContent.d.ts +10 -0
- package/Accordion/AccordionContent.js +35 -0
- package/Accordion/AccordionHeader.d.ts +10 -0
- package/Accordion/AccordionHeader.js +53 -0
- package/Accordion/Chevron.d.ts +4 -0
- package/Accordion/Chevron.js +13 -0
- package/Accordion/index.d.ts +86 -0
- package/Accordion/index.js +65 -0
- package/Button/ButtonIconWrapper.d.ts +1 -1
- package/Calendar/CalendarBottomBar.d.ts +4 -0
- package/Calendar/CalendarBottomBar.js +28 -0
- package/Calendar/CalendarMonthControl.d.ts +6 -0
- package/Calendar/CalendarMonthControl.js +41 -0
- package/Calendar/IconChevronLeft.d.ts +3 -0
- package/Calendar/IconChevronLeft.js +9 -0
- package/CountryFlags/Uknown.d.ts +3 -0
- package/CountryFlags/Uknown.js +34 -0
- package/Selectbox/IconShow.d.ts +3 -0
- package/Selectbox/IconShow.js +9 -0
- package/Switch/SwitchAsterisk.d.ts +13 -0
- package/Switch/SwitchAsterisk.js +53 -0
- package/Switch/SwitchContainer.d.ts +26 -0
- package/Switch/SwitchContainer.js +52 -0
- package/Switch/SwitchDot.d.ts +17 -0
- package/Switch/SwitchDot.js +145 -0
- package/Switch/SwitchErrorText.d.ts +6 -0
- package/Switch/SwitchErrorText.js +76 -0
- package/Switch/SwitchTextWrapper.d.ts +4 -0
- package/Switch/SwitchTextWrapper.js +30 -0
- package/Switch/SwitchToggleWrapper.d.ts +4 -0
- package/Switch/SwitchToggleWrapper.js +57 -0
- package/Switch/SwitchTrack.d.ts +17 -0
- package/Switch/SwitchTrack.js +80 -0
- package/Switch/SwitchWrapper.d.ts +4 -0
- package/Switch/SwitchWrapper.js +31 -0
- package/Switch/index.d.ts +138 -0
- package/Switch/index.js +56 -0
- package/TextArea/TextAreaIconWrapper.d.ts +1 -1
- package/TextField/TextFieldIconWrapper.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type SwitchContainerProps = React.LabelHTMLAttributes<HTMLLabelElement> & {
|
|
3
|
+
/**
|
|
4
|
+
* This property changes position of switch and its label.
|
|
5
|
+
* Default: `end`
|
|
6
|
+
*/
|
|
7
|
+
readonly labelPosition?: 'start' | 'end' | 'top' | 'bottom';
|
|
8
|
+
/**
|
|
9
|
+
* if `true` switch state can not be changed
|
|
10
|
+
* Default: false;
|
|
11
|
+
*/
|
|
12
|
+
readonly disabled?: boolean;
|
|
13
|
+
};
|
|
14
|
+
declare const _default: React.ForwardRefExoticComponent<React.LabelHTMLAttributes<HTMLLabelElement> & {
|
|
15
|
+
/**
|
|
16
|
+
* This property changes position of switch and its label.
|
|
17
|
+
* Default: `end`
|
|
18
|
+
*/
|
|
19
|
+
readonly labelPosition?: "bottom" | "top" | "start" | "end" | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* if `true` switch state can not be changed
|
|
22
|
+
* Default: false;
|
|
23
|
+
*/
|
|
24
|
+
readonly disabled?: boolean | undefined;
|
|
25
|
+
} & React.RefAttributes<HTMLLabelElement>>;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const react_1 = __importDefault(require("react"));
|
|
18
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
19
|
+
const react_2 = require("@emotion/react");
|
|
20
|
+
const StyledContainer = styled_1.default.label `
|
|
21
|
+
cursor: ${({ disabled }) => (disabled ? 'default' : 'pointer')};
|
|
22
|
+
font-size: 1em;
|
|
23
|
+
padding-right: 1em;
|
|
24
|
+
display: inline-flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
opacity: ${({ disabled }) => (disabled ? 0.6 : 1)};
|
|
27
|
+
${({ labelPosition }) => {
|
|
28
|
+
let direction = 'row';
|
|
29
|
+
switch (labelPosition) {
|
|
30
|
+
case 'bottom':
|
|
31
|
+
direction = 'column';
|
|
32
|
+
break;
|
|
33
|
+
case 'start':
|
|
34
|
+
direction = 'row-reverse';
|
|
35
|
+
break;
|
|
36
|
+
case 'top':
|
|
37
|
+
direction = 'column-reverse';
|
|
38
|
+
break;
|
|
39
|
+
default:
|
|
40
|
+
//do nothing
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
return (0, react_2.css) `
|
|
44
|
+
flex-direction: ${direction};
|
|
45
|
+
`;
|
|
46
|
+
}}
|
|
47
|
+
`;
|
|
48
|
+
const SwitchContainer = (props, ref) => {
|
|
49
|
+
const { children, labelPosition, disabled } = props, nativeProps = __rest(props, ["children", "labelPosition", "disabled"]);
|
|
50
|
+
return (react_1.default.createElement(StyledContainer, Object.assign({}, nativeProps, { labelPosition: labelPosition, disabled: disabled, ref: ref }), children));
|
|
51
|
+
};
|
|
52
|
+
exports.default = react_1.default.forwardRef(SwitchContainer);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SwitchProps } from './index';
|
|
3
|
+
export type SwitchDotProps = React.HTMLAttributes<HTMLSpanElement> & {
|
|
4
|
+
/**
|
|
5
|
+
* This prop allows you to provide switch state and control it. This property overrides internal component state
|
|
6
|
+
*/
|
|
7
|
+
readonly checked: boolean;
|
|
8
|
+
readonly color?: SwitchProps['color'];
|
|
9
|
+
};
|
|
10
|
+
declare const _default: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
|
|
11
|
+
/**
|
|
12
|
+
* This prop allows you to provide switch state and control it. This property overrides internal component state
|
|
13
|
+
*/
|
|
14
|
+
readonly checked: boolean;
|
|
15
|
+
readonly color?: string | undefined;
|
|
16
|
+
} & React.RefAttributes<HTMLSpanElement>>;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const react_1 = __importDefault(require("react"));
|
|
18
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
19
|
+
const react_2 = require("@emotion/react");
|
|
20
|
+
const Color_1 = __importDefault(require("../Color"));
|
|
21
|
+
const ToggleContainer = styled_1.default.span `
|
|
22
|
+
display: inline-flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
background-color: transparent;
|
|
27
|
+
vertical-align: middle;
|
|
28
|
+
text-decoration: none;
|
|
29
|
+
padding: 0.8rem;
|
|
30
|
+
border-radius: 50%;
|
|
31
|
+
position: absolute;
|
|
32
|
+
top: 0px;
|
|
33
|
+
left: 0px;
|
|
34
|
+
z-index: 1;
|
|
35
|
+
color: rgb(255, 255, 255);
|
|
36
|
+
transition:
|
|
37
|
+
left 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
|
|
38
|
+
transform 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
39
|
+
transform: ${({ checked }) => (checked ? 'translateX(1.5rem)' : 'translateX(0)')};
|
|
40
|
+
`;
|
|
41
|
+
const Dot = styled_1.default.span `
|
|
42
|
+
width: 1.4rem;
|
|
43
|
+
height: 1.4rem;
|
|
44
|
+
border-radius: 50%;
|
|
45
|
+
box-shadow:
|
|
46
|
+
rgba(0, 0, 0, 0.2) 0px 2px 1px -1px,
|
|
47
|
+
rgba(0, 0, 0, 0.14) 0px 1px 1px 0px,
|
|
48
|
+
rgba(0, 0, 0, 0.12) 0px 1px 3px 0px;
|
|
49
|
+
background-color: ${({ $color, checked, theme }) => {
|
|
50
|
+
switch (true) {
|
|
51
|
+
case checked:
|
|
52
|
+
return $color ? $color.toString() : theme.color.accentPrimary.toString();
|
|
53
|
+
default:
|
|
54
|
+
return theme.isDark ? theme.color.textPrimary.toString() : theme.color.surface.toString();
|
|
55
|
+
}
|
|
56
|
+
}};
|
|
57
|
+
&:before {
|
|
58
|
+
content: '';
|
|
59
|
+
position: absolute;
|
|
60
|
+
width: 1.4rem;
|
|
61
|
+
height: 1.4rem;
|
|
62
|
+
border-radius: 50%;
|
|
63
|
+
transition: all 0.3s ease-out;
|
|
64
|
+
top: 50%;
|
|
65
|
+
left: 50%;
|
|
66
|
+
transform: translate(-50%, -50%) scale(0);
|
|
67
|
+
background-color: ${({ $color, checked, theme }) => {
|
|
68
|
+
switch (true) {
|
|
69
|
+
case checked:
|
|
70
|
+
return $color
|
|
71
|
+
? $color.alpha(0.2).toString()
|
|
72
|
+
: theme.color.accentPrimary.alpha(0.2).toString();
|
|
73
|
+
default:
|
|
74
|
+
return theme.isDark
|
|
75
|
+
? theme.color.textPrimary.alpha(0.2).toString()
|
|
76
|
+
: theme.color.surface.alpha(0.2).toString();
|
|
77
|
+
}
|
|
78
|
+
}};
|
|
79
|
+
}
|
|
80
|
+
&:after {
|
|
81
|
+
content: '';
|
|
82
|
+
position: absolute;
|
|
83
|
+
width: 1.4rem;
|
|
84
|
+
height: 1.4rem;
|
|
85
|
+
border-radius: 50%;
|
|
86
|
+
transition: all 0.3s ease-out;
|
|
87
|
+
top: 50%;
|
|
88
|
+
left: 50%;
|
|
89
|
+
transform: translate(-50%, -50%) scale(0);
|
|
90
|
+
background-color: ${({ $color, checked, theme }) => {
|
|
91
|
+
switch (true) {
|
|
92
|
+
case checked:
|
|
93
|
+
return $color
|
|
94
|
+
? $color.alpha(0.1).toString()
|
|
95
|
+
: theme.color.accentPrimary.alpha(0.1).toString();
|
|
96
|
+
default:
|
|
97
|
+
return theme.isDark
|
|
98
|
+
? theme.color.textPrimary.alpha(0.1).toString()
|
|
99
|
+
: theme.color.surface.alpha(0.1).toString();
|
|
100
|
+
}
|
|
101
|
+
}};
|
|
102
|
+
}
|
|
103
|
+
`;
|
|
104
|
+
const SwitchDot = (props, ref) => {
|
|
105
|
+
const { children, color, checked } = props, nativeProps = __rest(props, ["children", "color", "checked"]);
|
|
106
|
+
const theme = (0, react_2.useTheme)();
|
|
107
|
+
const { $color } = react_1.default.useMemo(() => {
|
|
108
|
+
switch (true) {
|
|
109
|
+
case color === 'primary':
|
|
110
|
+
return {
|
|
111
|
+
$color: theme.color.accentPrimary,
|
|
112
|
+
};
|
|
113
|
+
case color === 'secondary':
|
|
114
|
+
return {
|
|
115
|
+
$color: theme.color.accentSecondary,
|
|
116
|
+
};
|
|
117
|
+
case typeof color === 'undefined':
|
|
118
|
+
case color === 'default':
|
|
119
|
+
return {
|
|
120
|
+
$color: theme.color.accentPrimary,
|
|
121
|
+
};
|
|
122
|
+
case typeof color === 'string': {
|
|
123
|
+
let $color = theme.color.surface;
|
|
124
|
+
try {
|
|
125
|
+
if (color) {
|
|
126
|
+
$color = new Color_1.default(color);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
console.error(`invalid color value «${color}»`);
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
$color,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
default:
|
|
137
|
+
return {
|
|
138
|
+
$color: theme.color.surface,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}, [color, theme.color]);
|
|
142
|
+
return (react_1.default.createElement(ToggleContainer, Object.assign({}, nativeProps, { ref: ref, "$color": $color, checked: checked }),
|
|
143
|
+
react_1.default.createElement(Dot, { "$color": $color, checked: checked }, children)));
|
|
144
|
+
};
|
|
145
|
+
exports.default = react_1.default.forwardRef(SwitchDot);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface SwitchErrorTextProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
3
|
+
readonly error?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare const _default: React.ForwardRefExoticComponent<SwitchErrorTextProps & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
const React = __importStar(require("react"));
|
|
41
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
42
|
+
const NoSSR_1 = __importDefault(require("../NoSSR"));
|
|
43
|
+
const ErrorTextContainer = styled_1.default.div `
|
|
44
|
+
margin-left: 0.5em;
|
|
45
|
+
max-height: 0;
|
|
46
|
+
max-height: ${({ $maxHeight }) => typeof $maxHeight === 'number' ? `${$maxHeight}px` : $maxHeight};
|
|
47
|
+
transition: max-height 240ms cubic-bezier(0.22, 0.61, 0.36, 1);
|
|
48
|
+
overflow: hidden;
|
|
49
|
+
`;
|
|
50
|
+
const ErrorTextInner = styled_1.default.div `
|
|
51
|
+
color: ${({ theme }) => theme.color.error.toString()};
|
|
52
|
+
font-size: 0.8em;
|
|
53
|
+
transform: translateY(${({ $error }) => ($error ? 0 : '0.2em')});
|
|
54
|
+
opacity: ${({ $error }) => ($error ? 1 : 0)};
|
|
55
|
+
transition: all 240ms 240ms ease-out;
|
|
56
|
+
`;
|
|
57
|
+
const SwitchErrorText = (props, ref) => {
|
|
58
|
+
const { children, error } = props, nativeProps = __rest(props, ["children", "error"]);
|
|
59
|
+
const innerRef = React.useRef(null);
|
|
60
|
+
const [maxHeight, setMaxHeight] = React.useState('initial');
|
|
61
|
+
React.useEffect(() => {
|
|
62
|
+
const updateMaxHeight = () => {
|
|
63
|
+
if (innerRef.current && innerRef.current.getBoundingClientRect().height > 0) {
|
|
64
|
+
setMaxHeight(innerRef.current.getBoundingClientRect().height);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
updateMaxHeight();
|
|
68
|
+
window.addEventListener('resize', updateMaxHeight);
|
|
69
|
+
return () => {
|
|
70
|
+
window.removeEventListener('resize', updateMaxHeight);
|
|
71
|
+
};
|
|
72
|
+
}, [children]);
|
|
73
|
+
return (React.createElement(ErrorTextContainer, Object.assign({}, nativeProps, { "$maxHeight": error ? maxHeight : 0, ref: ref }),
|
|
74
|
+
React.createElement(ErrorTextInner, { ref: innerRef, "$error": Boolean(error) }, children ? React.createElement(NoSSR_1.default, null, children) : React.createElement(React.Fragment, null, "\u00A0"))));
|
|
75
|
+
};
|
|
76
|
+
exports.default = React.forwardRef(SwitchErrorText);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const react_1 = __importDefault(require("react"));
|
|
18
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
19
|
+
// type StyleProps = {};
|
|
20
|
+
const TextWrapper = styled_1.default.span `
|
|
21
|
+
font-size: 0.86em;
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
user-select: none;
|
|
25
|
+
`;
|
|
26
|
+
const SwitchTextWrapper = (props, ref) => {
|
|
27
|
+
const { children } = props, nativeProps = __rest(props, ["children"]);
|
|
28
|
+
return (react_1.default.createElement(TextWrapper, Object.assign({}, nativeProps, { ref: ref }), children));
|
|
29
|
+
};
|
|
30
|
+
exports.default = react_1.default.forwardRef(SwitchTextWrapper);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const react_1 = __importDefault(require("react"));
|
|
18
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
19
|
+
const ToggleWrapper = styled_1.default.span `
|
|
20
|
+
font-size: 0.86em;
|
|
21
|
+
display: inline-flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
user-select: none;
|
|
24
|
+
position: relative;
|
|
25
|
+
height: 3rem;
|
|
26
|
+
width: 4.5rem;
|
|
27
|
+
padding: 1.1rem;
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
box-sizing: border-box;
|
|
30
|
+
&:hover span[class*='ToggleContainer'] > span[class*='Dot']:after {
|
|
31
|
+
transform: translate(-50%, -50%) scale(1.7);
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
const StyledInput = styled_1.default.input `
|
|
35
|
+
cursor: inherit;
|
|
36
|
+
position: absolute;
|
|
37
|
+
width: 100%;
|
|
38
|
+
opacity: 0;
|
|
39
|
+
height: 100%;
|
|
40
|
+
top: 0px;
|
|
41
|
+
left: 0px;
|
|
42
|
+
margin: 0px;
|
|
43
|
+
padding: 0px;
|
|
44
|
+
z-index: 1;
|
|
45
|
+
&:focus-visible ~ span[class*='ToggleContainer'] > span[class*='Dot']:before {
|
|
46
|
+
transform: translate(-50%, -50%) scale(1.7);
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
const SwitchToggleWrapper = (props, ref) => {
|
|
50
|
+
const { children, disabled } = props, nativeProps = __rest(props, ["children", "disabled"]);
|
|
51
|
+
return (react_1.default.createElement(ToggleWrapper, { ref: ref },
|
|
52
|
+
react_1.default.createElement(StyledInput, Object.assign({}, nativeProps, { disabled: disabled, onChange: e => {
|
|
53
|
+
(nativeProps === null || nativeProps === void 0 ? void 0 : nativeProps.onChange) && nativeProps.onChange(e);
|
|
54
|
+
}, type: "checkbox" })),
|
|
55
|
+
children));
|
|
56
|
+
};
|
|
57
|
+
exports.default = react_1.default.forwardRef(SwitchToggleWrapper);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SwitchProps } from './index';
|
|
3
|
+
export type SwitchTrackProps = React.HTMLAttributes<HTMLSpanElement> & {
|
|
4
|
+
/**
|
|
5
|
+
* This prop allows you to provide switch state and control it. This property overrides internal component state
|
|
6
|
+
*/
|
|
7
|
+
readonly checked: boolean;
|
|
8
|
+
readonly color?: SwitchProps['color'];
|
|
9
|
+
};
|
|
10
|
+
declare const _default: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
|
|
11
|
+
/**
|
|
12
|
+
* This prop allows you to provide switch state and control it. This property overrides internal component state
|
|
13
|
+
*/
|
|
14
|
+
readonly checked: boolean;
|
|
15
|
+
readonly color?: string | undefined;
|
|
16
|
+
} & React.RefAttributes<HTMLSpanElement>>;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const react_1 = __importDefault(require("react"));
|
|
18
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
19
|
+
const react_2 = require("@emotion/react");
|
|
20
|
+
const Color_1 = __importDefault(require("../Color"));
|
|
21
|
+
const Track = styled_1.default.span `
|
|
22
|
+
height: 100%;
|
|
23
|
+
width: 100%;
|
|
24
|
+
border-radius: 7px;
|
|
25
|
+
transition:
|
|
26
|
+
opacity 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
|
|
27
|
+
background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
28
|
+
background-color: ${({ $color, checked, theme }) => {
|
|
29
|
+
switch (true) {
|
|
30
|
+
case checked:
|
|
31
|
+
return $color ? $color.toString() : theme.color.accentPrimary.toString();
|
|
32
|
+
default:
|
|
33
|
+
return theme.isDark
|
|
34
|
+
? theme.color.textPrimary.darken(10).toString()
|
|
35
|
+
: theme.color.surface.darken(200).toString();
|
|
36
|
+
}
|
|
37
|
+
}};
|
|
38
|
+
opacity: 0.5;
|
|
39
|
+
`;
|
|
40
|
+
const SwitchTrack = (props, ref) => {
|
|
41
|
+
const { color, checked, children } = props, nativeProps = __rest(props, ["color", "checked", "children"]);
|
|
42
|
+
const theme = (0, react_2.useTheme)();
|
|
43
|
+
const { $color } = react_1.default.useMemo(() => {
|
|
44
|
+
switch (true) {
|
|
45
|
+
case color === 'primary':
|
|
46
|
+
return {
|
|
47
|
+
$color: theme.color.accentPrimary,
|
|
48
|
+
};
|
|
49
|
+
case color === 'secondary':
|
|
50
|
+
return {
|
|
51
|
+
$color: theme.color.accentSecondary,
|
|
52
|
+
};
|
|
53
|
+
case typeof color === 'undefined':
|
|
54
|
+
case color === 'default':
|
|
55
|
+
return {
|
|
56
|
+
$color: theme.color.accentPrimary,
|
|
57
|
+
};
|
|
58
|
+
case typeof color === 'string': {
|
|
59
|
+
let $color = theme.color.surface;
|
|
60
|
+
try {
|
|
61
|
+
if (color) {
|
|
62
|
+
$color = new Color_1.default(color);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
console.error(`invalid color value «${color}»`);
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
$color,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
default:
|
|
73
|
+
return {
|
|
74
|
+
$color: theme.color.surface,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}, [color, theme.color]);
|
|
78
|
+
return (react_1.default.createElement(Track, Object.assign({}, nativeProps, { ref: ref, "$color": $color, checked: checked }), children));
|
|
79
|
+
};
|
|
80
|
+
exports.default = react_1.default.forwardRef(SwitchTrack);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const react_1 = __importDefault(require("react"));
|
|
18
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
19
|
+
const StyledWrapper = styled_1.default.span `
|
|
20
|
+
font-size: 1em;
|
|
21
|
+
padding-right: 1em;
|
|
22
|
+
display: inline-flex;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
align-items: center;
|
|
26
|
+
`;
|
|
27
|
+
const SwitchWrapper = (props, ref) => {
|
|
28
|
+
const { children } = props, nativeProps = __rest(props, ["children"]);
|
|
29
|
+
return (react_1.default.createElement(StyledWrapper, Object.assign({}, nativeProps, { ref: ref }), children));
|
|
30
|
+
};
|
|
31
|
+
exports.default = react_1.default.forwardRef(SwitchWrapper);
|