@wavv/ui 2.2.7 → 2.3.0-alpha.1

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.
Files changed (33) hide show
  1. package/build/components/Checkbox.d.ts +5 -2
  2. package/build/components/Checkbox.js +14 -9
  3. package/build/components/Form.d.ts +8 -4
  4. package/build/components/FormControl.d.ts +2 -0
  5. package/build/components/FormControl.js +4 -4
  6. package/build/components/Inputs/TextArea.d.ts +2 -2
  7. package/build/components/Inputs/TextArea.js +2 -2
  8. package/build/components/Inputs/helpers/InputContainerStyles.js +7 -7
  9. package/build/components/ListHelpers/ListItemStyles.js +4 -6
  10. package/build/components/Menu.js +4 -6
  11. package/build/components/Modal.d.ts +2 -5
  12. package/build/components/Modal.js +12 -26
  13. package/build/components/OptionHelpers/Item.js +4 -6
  14. package/build/components/Radio.js +1 -0
  15. package/build/components/Table/contentStyles.js +3 -6
  16. package/build/components/Toggle.d.ts +16 -6
  17. package/build/components/Toggle.js +68 -51
  18. package/build/components/helpers/getFlexPosition.d.ts +3 -0
  19. package/build/components/helpers/getFlexPosition.js +6 -0
  20. package/build/tailwind/theme.css +117 -0
  21. package/build/theme/index.d.ts +5 -2
  22. package/build/theme/index.js +23 -2
  23. package/build/theme/mono/colors.d.ts +224 -0
  24. package/build/theme/mono/colors.js +85 -0
  25. package/build/theme/mono/dark/dark.d.ts +3 -0
  26. package/build/theme/mono/dark/dark.js +562 -0
  27. package/build/theme/mono/dark/darkScale.d.ts +22 -0
  28. package/build/theme/mono/dark/darkScale.js +36 -0
  29. package/build/theme/mono/light/light.d.ts +3 -0
  30. package/build/theme/mono/light/light.js +561 -0
  31. package/build/theme/mono/light/lightScale.d.ts +22 -0
  32. package/build/theme/mono/light/lightScale.js +35 -0
  33. package/package.json +19 -19
@@ -1,5 +1,5 @@
1
1
  import { type CheckboxProps } from 'react-aria-components';
2
- import type { Margin, ThemeProp } from './types';
2
+ import type { FlexPosition, Margin, ThemeProp } from './types';
3
3
  type Props = {
4
4
  /** Id of the input element */
5
5
  id?: string;
@@ -17,15 +17,18 @@ type Props = {
17
17
  partial?: boolean;
18
18
  /** Sets the gap between the label and the checkbox */
19
19
  gap?: number;
20
+ /** Sets the flex alignment of the checkbox container */
21
+ align?: FlexPosition;
20
22
  onChange?: CheckboxProps['onChange'];
21
23
  className?: CheckboxProps['className'];
22
24
  style?: CheckboxProps['style'];
23
25
  } & Margin & Omit<CheckboxProps, 'value' | 'isDisabled' | 'isReadOnly' | 'isSelected' | 'isIndeterminate'>;
24
- declare const Checkbox: ({ label, labelPosition, checked, partial, disabled, readOnly, onChange, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
26
+ declare const Checkbox: ({ label, labelPosition, checked, partial, disabled, readOnly, onChange, align, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
25
27
  export declare const ControlContainer: import("@emotion/styled").StyledComponent<CheckboxProps & import("react").RefAttributes<HTMLLabelElement> & {
26
28
  theme?: import("@emotion/react").Theme;
27
29
  } & {
28
30
  labelRight?: boolean;
29
31
  gap?: number;
32
+ align?: FlexPosition;
30
33
  } & Margin & ThemeProp, {}, {}>;
31
34
  export default Checkbox;
@@ -5,13 +5,15 @@ import icons_Checkbox from "../assets/icons/Checkbox.js";
5
5
  import CheckboxOff from "../assets/icons/CheckboxOff.js";
6
6
  import CheckboxPartial from "../assets/icons/CheckboxPartial.js";
7
7
  import { ControlLabel } from "./FormControl.js";
8
+ import getFlexPosition from "./helpers/getFlexPosition.js";
8
9
  import { marginProps } from "./helpers/styledProps.js";
9
10
  import Icon from "./Icon/index.js";
10
- const Checkbox_Checkbox = ({ label, labelPosition, checked, partial, disabled, readOnly, onChange, ...props })=>{
11
+ const Checkbox_Checkbox = ({ label, labelPosition, checked, partial, disabled, readOnly, onChange, align, ...props })=>{
11
12
  const labelRight = 'right' === labelPosition;
12
13
  const isControlled = 'boolean' == typeof checked;
13
14
  return /*#__PURE__*/ jsx(ControlContainer, {
14
15
  labelRight: labelRight,
16
+ align: align,
15
17
  ...isControlled ? {
16
18
  isSelected: checked
17
19
  } : {},
@@ -31,6 +33,7 @@ const Checkbox_Checkbox = ({ label, labelPosition, checked, partial, disabled, r
31
33
  return /*#__PURE__*/ jsxs(Fragment, {
32
34
  children: [
33
35
  label && /*#__PURE__*/ jsx(ControlLabel, {
36
+ disabled: disabled,
34
37
  children: label
35
38
  }),
36
39
  /*#__PURE__*/ jsx(Icon, {
@@ -42,11 +45,11 @@ const Checkbox_Checkbox = ({ label, labelPosition, checked, partial, disabled, r
42
45
  }
43
46
  });
44
47
  };
45
- const ControlContainer = styled(Checkbox)(({ theme: { accent, formControl }, labelRight, isDisabled, gap = 8 })=>({
48
+ const ControlContainer = styled(Checkbox)(({ theme: { accent, formControl }, labelRight, isDisabled, gap = 8, align })=>({
46
49
  display: 'inline-flex',
47
50
  flexDirection: labelRight ? 'row-reverse' : 'row',
48
51
  justifyContent: labelRight ? 'flex-end' : 'flex-start',
49
- alignItems: 'center',
52
+ alignItems: getFlexPosition(align) || 'center',
50
53
  gap,
51
54
  position: 'relative',
52
55
  cursor: isDisabled ? 'not-allowed' : void 0,
@@ -54,16 +57,18 @@ const ControlContainer = styled(Checkbox)(({ theme: { accent, formControl }, lab
54
57
  outline: 'none',
55
58
  outlineOffset: -1,
56
59
  '& > div': {
57
- transition: 'color 0.2s linear',
58
- color: formControl.color.default
60
+ transition: 'color 0.2s linear'
59
61
  },
60
- '&[data-hovered] > div': {
61
- color: isDisabled ? void 0 : formControl.color.hover
62
+ '&:not([data-selected]):not([data-indeterminate]):not([data-disabled]) > div': {
63
+ color: formControl.color.default
62
64
  },
63
- '&[data-selected] > div, &[data-indeterminate] > div': {
65
+ '&[data-selected]:not([data-disabled]) > div, &[data-indeterminate]:not([data-disabled]) > div': {
64
66
  color: formControl.color.active
65
67
  },
66
- '&[data-hovered][data-selected] > div': {
68
+ '&:not([data-selected]):not([data-indeterminate]):not([data-disabled])[data-hovered] > div': {
69
+ color: isDisabled ? void 0 : formControl.color.hover
70
+ },
71
+ '&[data-hovered][data-selected]:not([data-disabled]) > div': {
67
72
  color: isDisabled ? void 0 : formControl.color.activeHover
68
73
  },
69
74
  '&[data-disabled] > div': {
@@ -23,15 +23,18 @@ declare const Form: {
23
23
  className?: string;
24
24
  iconColor?: string;
25
25
  } & Margin & import("react").HTMLProps<HTMLInputElement> & import("./types").AsProp) => import("react/jsx-runtime").JSX.Element;
26
- Toggle: ({ id, label, labelPosition, checked, disabled, onChange, margin, marginTop, marginBottom, marginRight, marginLeft, ...props }: {
26
+ Toggle: ({ label, labelPosition, checked, disabled, onChange, gap, ...props }: {
27
27
  id?: string;
28
28
  label?: string;
29
29
  labelPosition?: "left" | "right";
30
30
  disabled?: boolean;
31
31
  checked?: boolean;
32
- onChange: (val: boolean) => void;
33
- } & Margin & import("./types").AsProp & import("./FormControl").CheckboxAttributes) => import("react/jsx-runtime").JSX.Element;
34
- Checkbox: ({ label, labelPosition, checked, partial, disabled, readOnly, onChange, ...props }: {
32
+ gap?: number;
33
+ onChange?: import("react-aria-components").SwitchProps["onChange"];
34
+ className?: import("react-aria-components").SwitchProps["className"];
35
+ style?: import("react-aria-components").SwitchProps["style"];
36
+ } & Margin & Omit<import("react-aria-components").SwitchProps, "isDisabled" | "isSelected">) => import("react/jsx-runtime").JSX.Element;
37
+ Checkbox: ({ label, labelPosition, checked, partial, disabled, readOnly, onChange, align, ...props }: {
35
38
  id?: string;
36
39
  label?: string;
37
40
  labelPosition?: "left" | "right";
@@ -40,6 +43,7 @@ declare const Form: {
40
43
  checked?: boolean;
41
44
  partial?: boolean;
42
45
  gap?: number;
46
+ align?: import("./types").FlexPosition;
43
47
  onChange?: import("react-aria-components").CheckboxProps["onChange"];
44
48
  className?: import("react-aria-components").CheckboxProps["className"];
45
49
  style?: import("react-aria-components").CheckboxProps["style"];
@@ -18,5 +18,7 @@ export declare const ControlInput: import("@emotion/styled").StyledComponent<{
18
18
  export declare const ControlLabel: import("@emotion/styled").StyledComponent<{
19
19
  theme?: import("@emotion/react").Theme;
20
20
  as?: React.ElementType;
21
+ } & {
22
+ disabled?: boolean;
21
23
  } & ThemeProp, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
22
24
  export type CheckboxAttributes = Attributes<HTMLInputElement>;
@@ -64,9 +64,9 @@ const ControlInput = styled.input({
64
64
  }
65
65
  }
66
66
  }));
67
- const ControlLabel = styled.span(({ theme: { font, scale10 } })=>({
68
- fontSize: font.size.md,
69
- color: scale10,
70
- cursor: 'pointer'
67
+ const ControlLabel = styled.span(({ theme, disabled })=>({
68
+ fontSize: theme.font.size.md,
69
+ color: disabled ? theme.formControl.color.disabled : theme.scale10,
70
+ cursor: disabled ? 'not-allowed' : 'pointer'
71
71
  }));
72
72
  export { ControlContainer, ControlInput, ControlLabel };
@@ -1,5 +1,5 @@
1
1
  import type { InputProps, TextAreaProps } from '../typeDefs/inputTypes';
2
2
  import type { TextFieldProps } from '../typeDefs/reactAriaTypes';
3
3
  type Props = TextAreaProps & InputProps & TextFieldProps;
4
- declare const TextAreaComponent: ({ value, label, placeholder, iconLeft, iconRight, loading, fontSize, placeholderColor, disabled, readOnly, invalid, required, description, errorMessage, accepts, asTrigger, height, maxHeight, onChange, onInput, ref, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
5
- export default TextAreaComponent;
4
+ declare const TextArea: ({ value, label, placeholder, iconLeft, iconRight, loading, fontSize, placeholderColor, disabled, readOnly, invalid, required, description, errorMessage, accepts, asTrigger, height, maxHeight, onChange, onInput, ref, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
5
+ export default TextArea;
@@ -10,7 +10,7 @@ import InputMessage from "./helpers/InputMessage.js";
10
10
  import isAcceptable from "./helpers/isAcceptable.js";
11
11
  import Label from "./helpers/Label.js";
12
12
  import TextArea from "./helpers/TextArea.js";
13
- const TextAreaComponent = ({ value, label, placeholder, iconLeft, iconRight, loading, fontSize, placeholderColor, disabled, readOnly, invalid, required, description, errorMessage, accepts, asTrigger, height, maxHeight, onChange, onInput, ref, ...props })=>{
13
+ const TextArea_TextArea = ({ value, label, placeholder, iconLeft, iconRight, loading, fontSize, placeholderColor, disabled, readOnly, invalid, required, description, errorMessage, accepts, asTrigger, height, maxHeight, onChange, onInput, ref, ...props })=>{
14
14
  const [inputValue, setInputValue] = useState('');
15
15
  const textAreaRef = useRef(null);
16
16
  useEffect(()=>{
@@ -160,5 +160,5 @@ const TextAreaContainer = styled(TextField)(InputContainerStyles, ({ asTrigger }
160
160
  };
161
161
  return baseStyles;
162
162
  });
163
- const Inputs_TextArea = TextAreaComponent;
163
+ const Inputs_TextArea = TextArea_TextArea;
164
164
  export { Inputs_TextArea as default };
@@ -19,8 +19,8 @@ const baseStyles = ({ theme: { input, accent }, backgroundColor, borderRadius, b
19
19
  outlineOffset: -1,
20
20
  transition: 'background-color 0.2s',
21
21
  '&:focus-within': {
22
- backgroundColor: backgroundColor || textOnly || isDisabled || isInvalid ? void 0 : input.background.focused,
23
- outline: `${accent} solid 1px`
22
+ backgroundColor: backgroundColor || textOnly || isDisabled ? void 0 : input.background.focused,
23
+ outline: isInvalid ? void 0 : `1px solid ${accent}`
24
24
  },
25
25
  '&:hover:not(:focus-within)': {
26
26
  backgroundColor: isDisabled || isReadOnly || textOnly || backgroundColor ? void 0 : input.background.hover,
@@ -33,16 +33,16 @@ const disabledStyles = ({ theme: { input }, isDisabled })=>({
33
33
  backgroundColor: isDisabled ? input.background.disabled : void 0,
34
34
  pointerEvents: isDisabled ? 'none' : void 0
35
35
  });
36
- const invalidStyles = ({ theme: { input }, isInvalid })=>({
37
- backgroundColor: isInvalid ? input.background.invalid : void 0,
36
+ const invalidStyles = ({ theme: { color }, isInvalid })=>({
37
+ outline: isInvalid ? `1px solid ${color.error}` : void 0,
38
38
  '&:hover:not(:focus-within)': {
39
- backgroundColor: isInvalid ? input.background.invalidHover : void 0
39
+ outline: isInvalid ? `1px solid ${color.error}` : void 0
40
40
  },
41
41
  '&[data-invalid]': {
42
- backgroundColor: input.background.invalid
42
+ outline: `1px solid ${color.error}`
43
43
  },
44
44
  '&:hover:not(:focus-within)&[data-invalid]': {
45
- backgroundColor: input.background.invalidHover
45
+ outline: `1px solid ${color.error}`
46
46
  }
47
47
  });
48
48
  const readOnlyStyles = ({ isReadOnly })=>({
@@ -1,3 +1,4 @@
1
+ import getFlexPosition from "../helpers/getFlexPosition.js";
1
2
  import isPropAllowed from "../helpers/isPropAllowed.js";
2
3
  const preventProps = {
3
4
  shouldForwardProp: (prop)=>isPropAllowed(prop, [
@@ -38,12 +39,9 @@ const baseStyles = ({ theme: { optionItem, scale4 }, color, accented, selected,
38
39
  }
39
40
  };
40
41
  };
41
- const positionStyles = ({ contentPosition })=>{
42
- const position = 'start' === contentPosition || 'end' === contentPosition ? `flex-${contentPosition}` : contentPosition;
43
- return {
44
- justifyContent: position
45
- };
46
- };
42
+ const positionStyles = ({ contentPosition })=>({
43
+ justifyContent: getFlexPosition(contentPosition)
44
+ });
47
45
  const listItemStyles = [
48
46
  baseStyles,
49
47
  positionStyles
@@ -2,6 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import styled from "@emotion/styled";
3
3
  import react, { cloneElement, useState } from "react";
4
4
  import react_keyed_flatten_children from "react-keyed-flatten-children";
5
+ import getFlexPosition from "./helpers/getFlexPosition.js";
5
6
  import { paddingProps } from "./helpers/styledProps.js";
6
7
  import Icon from "./Icon/index.js";
7
8
  const Menu = ({ vertical, backgroundColor, children, ...rest })=>{
@@ -138,12 +139,9 @@ const MenuItem = styled.button({
138
139
  outline: `${accent} solid 1px`,
139
140
  outlineOffset: -1
140
141
  }
141
- }), ({ contentPosition })=>{
142
- const position = 'start' === contentPosition || 'end' === contentPosition ? `flex-${contentPosition}` : contentPosition;
143
- return {
144
- justifyContent: position
145
- };
146
- });
142
+ }), ({ contentPosition })=>({
143
+ justifyContent: getFlexPosition(contentPosition)
144
+ }));
147
145
  const MenuGroup = styled.div(({ theme, backgroundColor })=>({
148
146
  display: 'flex',
149
147
  flexDirection: 'column',
@@ -1,4 +1,4 @@
1
- import { type CSSProperties, type ReactNode, type RefObject } from 'react';
1
+ import type { CSSProperties, ReactNode, RefObject } from 'react';
2
2
  import { type HeadingProps } from 'react-aria-components';
3
3
  import type { Attributes } from './typeDefs/elementTypes';
4
4
  import type { FlexPosition, Height, Margin, MaxWidthHeight, MinWidthHeight, Padding, PositionType, WidthHeight } from './types';
@@ -23,8 +23,6 @@ type ModalProps = {
23
23
  borderRadius?: number | string;
24
24
  /** Overrides the overflow of the modal container */
25
25
  overflow?: CSSProperties['overflow'];
26
- /** Styles the Modal as an actionable toast */
27
- small?: boolean;
28
26
  /** Removes the overlay background, and allows the modal to be positioned anywhere on the page */
29
27
  noOverlay?: boolean;
30
28
  /** Prevents the modal from being interacted with */
@@ -55,7 +53,7 @@ type ModalProps = {
55
53
  'aria-label'?: string;
56
54
  } & WidthHeight & MaxWidthHeight & MinWidthHeight & Padding & DivAttributes;
57
55
  declare const Modal: {
58
- ({ children, visible, width, height, onClose, closeIcon, preventOverlayClose, overlayBlur, overlayColor, backgroundColor, small, noOverlay, inert, drawer, drawerDirection, scopeRef, centerX, centerY, position, top, bottom, right, left, zIndex, ...props }: ModalProps): import("react/jsx-runtime").JSX.Element;
56
+ ({ children, visible, width, height, onClose, closeIcon, preventOverlayClose, overlayBlur, overlayColor, backgroundColor, noOverlay, inert, drawer, drawerDirection, scopeRef, centerX, centerY, position, top, bottom, right, left, zIndex, ...props }: ModalProps): import("react/jsx-runtime").JSX.Element;
59
57
  Header: {
60
58
  ({ children, ...props }: HeaderProps): import("react/jsx-runtime").JSX.Element;
61
59
  displayName: string;
@@ -88,7 +86,6 @@ type BodyProps = {
88
86
  type FooterProps = {
89
87
  children: ReactNode;
90
88
  justify?: FlexPosition;
91
- inline?: boolean;
92
89
  gap?: number | string;
93
90
  } & Margin & DivAttributes;
94
91
  export default Modal;
@@ -1,20 +1,12 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { keyframes } from "@emotion/react";
3
3
  import styled from "@emotion/styled";
4
- import { cloneElement } from "react";
5
4
  import { Dialog, Heading, Modal, ModalOverlay } from "react-aria-components";
6
- import react_keyed_flatten_children from "react-keyed-flatten-children";
7
5
  import { marginProps, maxWidthHeightProps, minWidthHeightProps, paddingProps } from "./helpers/styledProps.js";
8
6
  import Icon from "./Icon/index.js";
9
7
  import PortalScope from "./PortalScope.js";
10
- const Modal_Modal = ({ children, visible, width, height, onClose, closeIcon, preventOverlayClose, overlayBlur = true, overlayColor, backgroundColor, small, noOverlay, inert, drawer, drawerDirection = 'right', scopeRef, centerX, centerY, position, top, bottom, right, left, zIndex, ...props })=>{
8
+ const Modal_Modal = ({ children, visible, width, height, onClose, closeIcon, preventOverlayClose, overlayBlur = true, overlayColor, backgroundColor, noOverlay, inert, drawer, drawerDirection = 'right', scopeRef, centerX, centerY, position, top, bottom, right, left, zIndex, ...props })=>{
11
9
  const { 'aria-label': ariaLabel, ...rest } = props;
12
- const modalContent = react_keyed_flatten_children(children).map((child)=>{
13
- if (child) return /*#__PURE__*/ cloneElement(child, {
14
- inline: small
15
- });
16
- return null;
17
- });
18
10
  const handleOpenChange = (open)=>{
19
11
  if (!open) onClose();
20
12
  };
@@ -49,7 +41,6 @@ const Modal_Modal = ({ children, visible, width, height, onClose, closeIcon, pre
49
41
  width: width,
50
42
  height: height,
51
43
  backgroundColor: backgroundColor,
52
- small: small,
53
44
  noOverlay: noOverlay,
54
45
  drawer: drawer,
55
46
  drawerDirection: drawerDirection,
@@ -57,9 +48,8 @@ const Modal_Modal = ({ children, visible, width, height, onClose, closeIcon, pre
57
48
  centerY: centerY,
58
49
  ...rest,
59
50
  children: [
60
- modalContent,
51
+ children,
61
52
  closeIcon && /*#__PURE__*/ jsx(Close, {
62
- inline: small,
63
53
  children: /*#__PURE__*/ jsx(Icon, {
64
54
  name: "close",
65
55
  onClick: onClose,
@@ -108,7 +98,7 @@ const Footer = ({ children, ...props })=>/*#__PURE__*/ jsx(ModalFooter, {
108
98
  ...props,
109
99
  children: children
110
100
  });
111
- const ModalFooter = styled.div(({ justify = 'end', inline, gap })=>{
101
+ const ModalFooter = styled.div(({ justify = 'end', gap })=>{
112
102
  const justifyOptions = {
113
103
  start: 'flex-start',
114
104
  end: 'flex-end',
@@ -120,21 +110,20 @@ const ModalFooter = styled.div(({ justify = 'end', inline, gap })=>{
120
110
  display: 'flex',
121
111
  alignItems: 'center',
122
112
  justifyContent: justify ? justifyOptions[justify] : void 0,
123
- marginTop: inline ? void 0 : 8,
113
+ marginTop: 8,
124
114
  gap
125
115
  };
126
116
  }, marginProps);
127
- const ModalContainer = styled.div(({ theme, width, height, backgroundColor, small, borderRadius, overflow, drawer, drawerDirection })=>({
117
+ const ModalContainer = styled.div(({ theme, width, height, backgroundColor, borderRadius, overflow, drawer, drawerDirection })=>({
128
118
  display: 'flex',
129
- flexDirection: small ? 'row' : 'column',
130
- alignItems: small ? 'center' : void 0,
119
+ flexDirection: 'column',
131
120
  backgroundColor: backgroundColor || theme.modal.background,
132
121
  color: theme.scale10,
133
122
  boxShadow: drawer ? 'left' === drawerDirection ? '8px 0 20px rgba(0, 0, 0, 0.2)' : '-8px 0 20px rgba(0, 0, 0, 0.2)' : theme.elevation3,
134
123
  width: width || 'max-content',
135
124
  height: drawer ? height || '100%' : height || 'max-content',
136
125
  borderRadius: drawer ? 0 : borderRadius || theme.size.sm,
137
- padding: small ? theme.size.md : theme.size.lg,
126
+ padding: theme.size.lg,
138
127
  overflow: overflow || 'hidden'
139
128
  }), ({ noOverlay, drawer })=>!noOverlay && !drawer && {
140
129
  position: 'absolute',
@@ -157,14 +146,11 @@ const ModalContainer = styled.div(({ theme, width, height, backgroundColor, smal
157
146
  const Close = styled.div({
158
147
  display: 'flex',
159
148
  justifyContent: 'center',
160
- alignItems: 'center'
161
- }, ({ inline })=>inline ? {
162
- marginLeft: 16
163
- } : {
164
- position: 'absolute',
165
- top: 8,
166
- right: 8
167
- });
149
+ alignItems: 'center',
150
+ position: 'absolute',
151
+ top: 8,
152
+ right: 8
153
+ });
168
154
  const Overlay = styled(ModalOverlay)(({ color, blur, noOverlay, centerX, centerY, position, top, bottom, right, left, zIndex, width, height })=>({
169
155
  position: position || 'fixed',
170
156
  top: top || (left || bottom || right ? void 0 : 0),
@@ -1,4 +1,5 @@
1
1
  import styled from "@emotion/styled";
2
+ import getFlexPosition from "../helpers/getFlexPosition.js";
2
3
  import isPropAllowed from "../helpers/isPropAllowed.js";
3
4
  const contentPreventProps = {
4
5
  shouldForwardProp: (prop)=>isPropAllowed(prop, [
@@ -40,12 +41,9 @@ const Item = styled('div', contentPreventProps)({
40
41
  cursor: 'inherit'
41
42
  }
42
43
  };
43
- }, ({ contentPosition })=>{
44
- const position = 'start' === contentPosition || 'end' === contentPosition ? `flex-${contentPosition}` : contentPosition;
45
- return {
46
- justifyContent: position
47
- };
48
- }, ({ theme, section })=>section && {
44
+ }, ({ contentPosition })=>({
45
+ justifyContent: getFlexPosition(contentPosition)
46
+ }), ({ theme, section })=>section && {
49
47
  backgroundColor: theme.scale0,
50
48
  padding: '0 16px',
51
49
  color: theme.scale6,
@@ -21,6 +21,7 @@ const Radio = ({ id, label, labelPosition, checked, disabled, margin, marginTop,
21
21
  ...marginProps,
22
22
  children: [
23
23
  label && /*#__PURE__*/ jsx(ControlLabel, {
24
+ disabled: disabled,
24
25
  children: label
25
26
  }),
26
27
  /*#__PURE__*/ jsx(ControlInput, {
@@ -1,12 +1,9 @@
1
+ import getFlexPosition from "../helpers/getFlexPosition.js";
1
2
  import { paddingProps } from "../helpers/styledProps.js";
2
- const getPosition = (position)=>{
3
- if (!position) return;
4
- return 'start' === position || 'end' === position ? `flex-${position}` : position;
5
- };
6
3
  const baseStyles = ({ direction, justify, align = 'center', gap = 8 })=>({
7
4
  display: 'flex',
8
- justifyContent: getPosition(justify),
9
- alignItems: getPosition(align),
5
+ justifyContent: getFlexPosition(justify),
6
+ alignItems: getFlexPosition(align),
10
7
  flexDirection: direction,
11
8
  width: '100%',
12
9
  height: '100%',
@@ -1,6 +1,6 @@
1
- import { type CheckboxAttributes } from './FormControl';
2
- import type { AsProp, Margin } from './types';
3
- type ToggleProps = {
1
+ import { type SwitchProps } from 'react-aria-components';
2
+ import type { Margin, ThemeProp } from './types';
3
+ type Props = {
4
4
  /** Id of the input element */
5
5
  id?: string;
6
6
  /** Places a label element beside the toggle. The value will set the text of the label */
@@ -11,8 +11,18 @@ type ToggleProps = {
11
11
  disabled?: boolean;
12
12
  /** Controls the checked property of the toggle */
13
13
  checked?: boolean;
14
+ /** Sets the gap between the label and the toggle */
15
+ gap?: number;
14
16
  /** The function called with the toggle value after the toggle is changed */
15
- onChange: (val: boolean) => void;
16
- } & Margin & AsProp & CheckboxAttributes;
17
- declare const Toggle: ({ id, label, labelPosition, checked, disabled, onChange, margin, marginTop, marginBottom, marginRight, marginLeft, ...props }: ToggleProps) => import("react/jsx-runtime").JSX.Element;
17
+ onChange?: SwitchProps['onChange'];
18
+ className?: SwitchProps['className'];
19
+ style?: SwitchProps['style'];
20
+ } & Margin & Omit<SwitchProps, 'isDisabled' | 'isSelected'>;
21
+ declare const Toggle: ({ label, labelPosition, checked, disabled, onChange, gap, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
22
+ export declare const ControlContainer: import("@emotion/styled").StyledComponent<SwitchProps & import("react").RefAttributes<HTMLLabelElement> & {
23
+ theme?: import("@emotion/react").Theme;
24
+ } & {
25
+ labelRight?: boolean;
26
+ gap?: number;
27
+ } & Margin & ThemeProp, {}, {}>;
18
28
  export default Toggle;
@@ -1,59 +1,76 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useEffect, useState } from "react";
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import styled from "@emotion/styled";
3
+ import { Switch } from "react-aria-components";
3
4
  import ToggleOff from "../assets/icons/ToggleOff.js";
4
5
  import ToggleOn from "../assets/icons/ToggleOn.js";
5
- import { ControlContainer, ControlInput, ControlLabel } from "./FormControl.js";
6
+ import { ControlLabel } from "./FormControl.js";
7
+ import { marginProps } from "./helpers/styledProps.js";
6
8
  import Icon from "./Icon/index.js";
7
- const Toggle = ({ id, label, labelPosition, checked, disabled, onChange, margin, marginTop, marginBottom, marginRight, marginLeft, ...props })=>{
8
- const [on, setOn] = useState(checked || false);
9
+ const Toggle = ({ label, labelPosition, checked, disabled, onChange, gap, ...props })=>{
9
10
  const labelRight = 'right' === labelPosition;
10
- const marginProps = {
11
- margin,
12
- marginTop,
13
- marginBottom,
14
- marginRight,
15
- marginLeft
16
- };
17
- const handleChange = ()=>{
18
- const value = !on;
19
- setOn(value);
20
- onChange(value);
21
- };
22
- useEffect(()=>{
23
- const checkedSet = 'boolean' == typeof checked;
24
- const value = checkedSet ? checked : on;
25
- setOn(value);
26
- }, [
27
- checked,
28
- on
29
- ]);
30
- return /*#__PURE__*/ jsxs(ControlContainer, {
31
- htmlFor: id,
11
+ const isControlled = 'boolean' == typeof checked;
12
+ return /*#__PURE__*/ jsx(ControlContainer, {
32
13
  labelRight: labelRight,
33
- disabled: disabled,
34
- ...marginProps,
35
- children: [
36
- label && /*#__PURE__*/ jsx(ControlLabel, {
37
- children: label
38
- }),
39
- /*#__PURE__*/ jsx(ControlInput, {
40
- id: id,
41
- type: "checkbox",
42
- checked: on,
43
- disabled: disabled,
44
- onChange: handleChange,
45
- ...props
46
- }),
47
- /*#__PURE__*/ jsx(Icon, {
48
- svg: on ? /*#__PURE__*/ jsx(ToggleOn, {}) : /*#__PURE__*/ jsx(ToggleOff, {}),
49
- marginLeft: label && !labelRight ? 8 : 0,
50
- marginRight: label && labelRight ? 8 : 0,
51
- pointer: !disabled,
52
- width: 34,
53
- height: 17
54
- })
55
- ]
14
+ ...isControlled ? {
15
+ isSelected: checked
16
+ } : {},
17
+ isDisabled: disabled,
18
+ onChange: onChange,
19
+ gap: gap,
20
+ ...props,
21
+ children: ({ isSelected })=>{
22
+ const isOn = isSelected;
23
+ return /*#__PURE__*/ jsxs(Fragment, {
24
+ children: [
25
+ label && /*#__PURE__*/ jsx(ControlLabel, {
26
+ disabled: disabled,
27
+ children: label
28
+ }),
29
+ /*#__PURE__*/ jsx(Icon, {
30
+ svg: isOn ? /*#__PURE__*/ jsx(ToggleOn, {}) : /*#__PURE__*/ jsx(ToggleOff, {}),
31
+ marginLeft: label && !labelRight ? 0 : 0,
32
+ marginRight: label && labelRight ? 0 : 0,
33
+ pointer: !disabled,
34
+ width: 34,
35
+ height: 17
36
+ })
37
+ ]
38
+ });
39
+ }
56
40
  });
57
41
  };
42
+ const ControlContainer = styled(Switch)(({ theme: { accent, formControl }, labelRight, isDisabled, gap = 8 })=>({
43
+ display: 'inline-flex',
44
+ flexDirection: labelRight ? 'row-reverse' : 'row',
45
+ justifyContent: labelRight ? 'flex-end' : 'flex-start',
46
+ alignItems: 'center',
47
+ gap,
48
+ position: 'relative',
49
+ cursor: isDisabled ? 'not-allowed' : void 0,
50
+ borderRadius: 4,
51
+ outline: 'none',
52
+ outlineOffset: -1,
53
+ '& > div': {
54
+ transition: 'color 0.2s linear'
55
+ },
56
+ '&:not([data-selected]):not([data-disabled]) > div': {
57
+ color: formControl.color.default
58
+ },
59
+ '&[data-selected]:not([data-disabled]) > div': {
60
+ color: formControl.color.active
61
+ },
62
+ '&:not([data-selected]):not([data-disabled])[data-hovered] > div': {
63
+ color: isDisabled ? void 0 : formControl.color.hover
64
+ },
65
+ '&[data-hovered][data-selected]:not([data-disabled]) > div': {
66
+ color: isDisabled ? void 0 : formControl.color.activeHover
67
+ },
68
+ '&[data-disabled] > div': {
69
+ color: formControl.color.disabled
70
+ },
71
+ '&[data-focus-visible]': {
72
+ outline: `${accent} solid 1px`
73
+ }
74
+ }), marginProps);
58
75
  const components_Toggle = Toggle;
59
- export { components_Toggle as default };
76
+ export { ControlContainer, components_Toggle as default };
@@ -0,0 +1,3 @@
1
+ import type { FlexPosition } from '../types';
2
+ declare const getFlexPosition: (position?: FlexPosition) => string | undefined;
3
+ export default getFlexPosition;
@@ -0,0 +1,6 @@
1
+ const getFlexPosition = (position)=>{
2
+ if (!position) return;
3
+ return 'start' === position || 'end' === position ? `flex-${position}` : position;
4
+ };
5
+ const helpers_getFlexPosition = getFlexPosition;
6
+ export { helpers_getFlexPosition as default };