@loomhq/lens 10.63.3 → 10.63.4
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.
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
declare const SwitchInput: import("@emotion/styled-base").StyledComponent<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, SwitchInputProps, object>;
|
|
3
|
-
declare const Switch: ({ isActive, isDisabled, onChange, size, ...props }: SwitchProps & Omit<React.ComponentProps<typeof SwitchInput>, 'size'>) => JSX.Element;
|
|
3
|
+
declare const Switch: ({ isActive, isDisabled, onChange, size, ariaLabelledby, ariaLabel, ...props }: SwitchProps & Omit<React.ComponentProps<typeof SwitchInput>, 'size'>) => JSX.Element;
|
|
4
4
|
declare type SwitchProps = {
|
|
5
5
|
isActive?: boolean;
|
|
6
6
|
isDisabled?: boolean;
|
|
7
7
|
onChange?: React.ReactEventHandler;
|
|
8
8
|
size?: 'medium' | 'large';
|
|
9
|
+
ariaLabelledby?: string;
|
|
10
|
+
ariaLabel?: string;
|
|
9
11
|
};
|
|
10
12
|
declare type SwitchInputProps = {
|
|
11
13
|
switchSize?: 'medium' | 'large';
|
|
@@ -60,6 +60,14 @@ const SwitchLabel = styled.label `
|
|
|
60
60
|
const SwitchInput = styled.input `
|
|
61
61
|
position: absolute;
|
|
62
62
|
opacity: 0;
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
|
|
65
|
+
// to overlap SwitchBox and occupy the same space
|
|
66
|
+
z-index: 1;
|
|
67
|
+
margin: 0;
|
|
68
|
+
width: ${props => sizes[props.switchSize].switchWidth}px;
|
|
69
|
+
height: ${props => sizes[props.switchSize].switchHeight}px;
|
|
70
|
+
|
|
63
71
|
&:focus-visible ~ .SwitchBox {
|
|
64
72
|
${getFocusRing()};
|
|
65
73
|
}
|
|
@@ -108,9 +116,12 @@ const SwitchBox = styled.div `
|
|
|
108
116
|
}
|
|
109
117
|
`;
|
|
110
118
|
const Switch = (_a) => {
|
|
111
|
-
var { isActive, isDisabled, onChange, size = 'medium' } = _a, props = __rest(_a, ["isActive", "isDisabled", "onChange", "size"]);
|
|
119
|
+
var { isActive, isDisabled, onChange, size = 'medium', ariaLabelledby, ariaLabel } = _a, props = __rest(_a, ["isActive", "isDisabled", "onChange", "size", "ariaLabelledby", "ariaLabel"]);
|
|
120
|
+
if (ariaLabelledby && ariaLabel) {
|
|
121
|
+
throw new Error('ariaLabelledby and ariaLabel serve the same purpose and therefore cannot be used at the same time. Choose the one that best suites your needs.');
|
|
122
|
+
}
|
|
112
123
|
return (React.createElement(SwitchLabel, null,
|
|
113
|
-
React.createElement(SwitchInput, Object.assign({}, props, { checked: isActive, disabled: isDisabled, onChange: onChange, type: "checkbox", switchSize: size })),
|
|
124
|
+
React.createElement(SwitchInput, Object.assign({}, props, { checked: isActive, disabled: isDisabled, onChange: onChange, type: "checkbox", switchSize: size, "aria-labelledby": ariaLabelledby, "aria-label": ariaLabel, "aria-checked": isActive })),
|
|
114
125
|
React.createElement(SwitchBox, { className: "SwitchBox", isDisabled: isDisabled, isActive: isActive, switchSize: size })));
|
|
115
126
|
};
|
|
116
127
|
export default Switch;
|