@redsift/design-system 11.6.0-muiv5-alpha.5 → 11.6.0-muiv5-alpha.7

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 (150) hide show
  1. package/_internal/Alert2.js +182 -39
  2. package/_internal/AppBar.js +240 -29
  3. package/_internal/AppContainer.js +132 -86
  4. package/_internal/AppContent.js +84 -17
  5. package/_internal/Badge2.js +137 -4
  6. package/_internal/BreadcrumbItem.js +85 -3
  7. package/_internal/Breadcrumbs2.js +86 -21
  8. package/_internal/Button2.js +81 -20
  9. package/_internal/ButtonGroup.js +165 -25
  10. package/_internal/ButtonLink.js +74 -18
  11. package/_internal/Card2.js +151 -29
  12. package/_internal/CardActions.js +38 -3
  13. package/_internal/CardBody.js +36 -3
  14. package/_internal/CardHeader.js +77 -3
  15. package/_internal/Checkbox2.js +234 -58
  16. package/_internal/CheckboxGroup.js +182 -4
  17. package/_internal/ConditionalWrapper.js +11 -12
  18. package/_internal/DetailedCard.js +6912 -48
  19. package/_internal/DetailedCardCollapsibleSectionItems.js +58 -3
  20. package/_internal/DetailedCardHeader.js +61 -3
  21. package/_internal/DetailedCardSection.js +166 -3
  22. package/_internal/DetailedCardSectionItem.js +88 -3
  23. package/_internal/Flexbox2.js +85 -22
  24. package/_internal/Grid2.js +87 -24
  25. package/_internal/GridItem.js +34 -3
  26. package/_internal/Heading2.js +107 -3
  27. package/_internal/Icon2.js +206 -5
  28. package/_internal/IconButton.js +71 -3
  29. package/_internal/IconButtonLink.js +65 -18
  30. package/_internal/Item2.js +390 -73
  31. package/_internal/Link2.js +56 -15
  32. package/_internal/LinkButton.js +56 -13
  33. package/_internal/Number2.js +103 -61
  34. package/_internal/NumberField.js +3959 -65
  35. package/_internal/Pill2.js +400 -4
  36. package/_internal/ProgressBar.js +61 -18
  37. package/_internal/Radio2.js +227 -56
  38. package/_internal/RadioGroup.js +170 -4
  39. package/_internal/Shield2.js +220 -4
  40. package/_internal/SideNavigationMenu.js +586 -4
  41. package/_internal/SideNavigationMenuItem.js +299 -4
  42. package/_internal/Skeleton2.js +36 -9
  43. package/_internal/SkeletonCircle.js +52 -3
  44. package/_internal/SkeletonText.js +71 -3
  45. package/_internal/Spinner2.js +319 -29
  46. package/_internal/Switch2.js +310 -56
  47. package/_internal/SwitchGroup.js +182 -4
  48. package/_internal/Text2.js +45 -3
  49. package/_internal/TextArea.js +430 -20
  50. package/_internal/TextField.js +463 -19
  51. package/_internal/alert.js +2 -5
  52. package/_internal/app-bar.js +2 -8
  53. package/_internal/app-container.js +3 -9
  54. package/_internal/app-content.js +2 -5
  55. package/_internal/app-side-panel.js +3 -11
  56. package/_internal/badge.js +2 -6
  57. package/_internal/breadcrumb-item.js +1 -4
  58. package/_internal/breadcrumbs.js +2 -6
  59. package/_internal/button-group.js +2 -5
  60. package/_internal/button-link.js +2 -8
  61. package/_internal/button.js +3 -8
  62. package/_internal/card-actions.js +1 -4
  63. package/_internal/card-body.js +1 -4
  64. package/_internal/card-header.js +1 -8
  65. package/_internal/card.js +2 -11
  66. package/_internal/checkbox-group.js +2 -6
  67. package/_internal/checkbox.js +2 -6
  68. package/_internal/colors.js +87 -91
  69. package/_internal/conditional-wrapper.js +2 -2
  70. package/_internal/detailed-card-collapsible-section-items.js +1 -3
  71. package/_internal/detailed-card-header.js +1 -7
  72. package/_internal/detailed-card-section-item.js +1 -10
  73. package/_internal/detailed-card-section.js +1 -6
  74. package/_internal/detailed-card.js +2 -16
  75. package/_internal/flexbox.js +2 -5
  76. package/_internal/focus-within-group.js +3 -3
  77. package/_internal/fonts.js +4 -6
  78. package/_internal/gradient-border.js +35 -16
  79. package/_internal/grid-item.js +1 -4
  80. package/_internal/grid.js +2 -6
  81. package/_internal/heading.js +2 -6
  82. package/_internal/icon-button-link.js +2 -8
  83. package/_internal/icon-button.js +2 -6
  84. package/_internal/icon.js +2 -6
  85. package/_internal/item.js +2 -8
  86. package/_internal/link-button.js +2 -8
  87. package/_internal/link.js +3 -8
  88. package/_internal/listbox.js +3 -6
  89. package/_internal/number-field.js +2 -9
  90. package/_internal/number.js +2 -7
  91. package/_internal/pill.js +2 -6
  92. package/_internal/progress-bar.js +2 -5
  93. package/_internal/radio-group.js +2 -6
  94. package/_internal/radio.js +2 -6
  95. package/_internal/shared.js +2 -5
  96. package/_internal/shield.js +2 -6
  97. package/_internal/side-navigation-menu-bar.js +3 -9
  98. package/_internal/side-navigation-menu-item.js +2 -8
  99. package/_internal/side-navigation-menu.js +2 -8
  100. package/_internal/skeleton-circle.js +1 -6
  101. package/_internal/skeleton-text.js +2 -6
  102. package/_internal/skeleton.js +1 -7
  103. package/_internal/spinner.js +2 -5
  104. package/_internal/styles.js +235 -17
  105. package/_internal/styles2.js +44 -280
  106. package/_internal/switch-group.js +2 -6
  107. package/_internal/switch.js +2 -6
  108. package/_internal/text-area.js +2 -9
  109. package/_internal/text-field.js +2 -10
  110. package/_internal/text.js +2 -6
  111. package/_internal/theme.js +1 -3
  112. package/_internal/types.js +7 -31
  113. package/_internal/types2.js +18 -29
  114. package/_internal/types3.js +15 -18
  115. package/_internal/useAppSidePanel.js +331 -6
  116. package/_internal/useFocusOnList.js +502 -44
  117. package/_internal/useListboxItem.js +120 -23
  118. package/_internal/useSideNavigationMenuBar.js +371 -7
  119. package/_internal/useTheme.js +10 -8
  120. package/index.d.ts +4667 -0
  121. package/index.js +523 -1674
  122. package/package.json +2 -2
  123. package/_internal/SideNavigationMenuBar.js +0 -9
  124. package/_internal/helpers.js +0 -23
  125. package/_internal/types10.js +0 -20
  126. package/_internal/types11.js +0 -27
  127. package/_internal/types12.js +0 -35
  128. package/_internal/types13.js +0 -143
  129. package/_internal/types14.js +0 -11
  130. package/_internal/types15.js +0 -62
  131. package/_internal/types16.js +0 -56
  132. package/_internal/types17.js +0 -57
  133. package/_internal/types18.js +0 -40
  134. package/_internal/types19.js +0 -101
  135. package/_internal/types20.js +0 -47
  136. package/_internal/types21.js +0 -68
  137. package/_internal/types22.js +0 -52
  138. package/_internal/types23.js +0 -174
  139. package/_internal/types24.js +0 -18
  140. package/_internal/types25.js +0 -12
  141. package/_internal/types26.js +0 -36
  142. package/_internal/types27.js +0 -72
  143. package/_internal/types28.js +0 -73
  144. package/_internal/types29.js +0 -99
  145. package/_internal/types4.js +0 -67
  146. package/_internal/types5.js +0 -11
  147. package/_internal/types6.js +0 -11
  148. package/_internal/types7.js +0 -28
  149. package/_internal/types8.js +0 -72
  150. package/_internal/types9.js +0 -16
@@ -1,35 +1,157 @@
1
- import { C as CardActionsProps } from './types5.js';
2
- import { C as CardBodyProps } from './types6.js';
3
- import { C as CardHeaderProps } from './types7.js';
4
- import { ComponentProps } from 'react';
5
- import { h as StylingProps } from './styles2.js';
1
+ import { b as _objectWithoutProperties, c as _extends } from './_rollupPluginBabelHelpers.js';
2
+ import React__default, { forwardRef, useState, useEffect, useCallback } from 'react';
3
+ import classNames from 'classnames';
4
+ import { mdiChevronDown, mdiChevronUp } from '@redsift/icons';
5
+ import styled, { css } from 'styled-components';
6
+ import { i as baseStyling } from './styles4.js';
6
7
  import { T as Theme } from './colors.js';
7
- import { C as Comp } from './helpers.js';
8
+ import { p as partitionComponents } from './partitionComponents.js';
9
+ import { i as isComponent } from './isComponent.js';
10
+ import { C as CardHeader } from './CardHeader.js';
11
+ import { C as CardBody } from './CardBody.js';
12
+ import { C as CardActions } from './CardActions.js';
13
+ import { u as useMessageFormatter } from './useMessageFormatter.js';
14
+ import { u as useTheme, a as ThemeProvider } from './useTheme.js';
15
+ import { I as IconButton } from './IconButton.js';
8
16
 
9
- /**
10
- * Component props.
11
- */
12
- interface CardProps extends ComponentProps<'div'>, StylingProps {
13
- /** Default collapse status. Used for uncontrolled version. */
14
- defaultCollapsed?: boolean;
15
- /** Whether the component is collapsed or not. Used for controlled version. */
16
- isCollapsed?: boolean;
17
- /** Whether the component can be collapse or not. */
18
- isCollapsible?: boolean;
19
- /** Method to handle component change. */
20
- onCollapse?(isCollapsed: boolean): void;
21
- /** Theme. */
22
- theme?: Theme;
23
- }
24
- type StyledCardProps = Omit<CardProps, 'isCollapsed'> & {
25
- $isCollapsed: CardProps['isCollapsed'];
26
- $theme: CardProps['theme'];
17
+ var collapse$1 = "Collapse";
18
+ var expand$1 = "Expand";
19
+ var enUS = {
20
+ collapse: collapse$1,
21
+ expand: expand$1
27
22
  };
28
23
 
29
- declare const Card: Comp<CardProps, HTMLDivElement> & {
30
- Header: Comp<CardHeaderProps, HTMLDivElement>;
31
- Body: Comp<CardBodyProps, HTMLDivElement>;
32
- Actions: Comp<CardActionsProps, HTMLDivElement>;
24
+ var collapse = "Réduire";
25
+ var expand = "Développer";
26
+ var frFR = {
27
+ collapse: collapse,
28
+ expand: expand
33
29
  };
34
30
 
35
- export { CardProps as C, StyledCardProps as S, Card as a };
31
+ var intlMessages = {
32
+ 'en-US': enUS,
33
+ 'fr-FR': frFR
34
+ };
35
+
36
+ /**
37
+ * Component style.
38
+ */
39
+ const StyledCard = styled.div`
40
+ ${baseStyling}
41
+
42
+ ${_ref => {
43
+ let {
44
+ $theme
45
+ } = _ref;
46
+ return css`
47
+ color: var(--redsift-color-neutral-${$theme === Theme.dark ? 'white' : 'x-dark-grey'});
48
+ `;
49
+ }}
50
+
51
+ display: flex;
52
+ flex-direction: column;
53
+
54
+ .redsift-card__header {
55
+ align-items: flex-start;
56
+ display: flex;
57
+ justify-content: space-between;
58
+ }
59
+
60
+ .redsift-card-header__icon-button {
61
+ margin-top: 8px;
62
+ margin-left: auto;
63
+ margin-right: 8px;
64
+
65
+ [dir='rtl'] & {
66
+ margin-left: 8px;
67
+ margin-right: auto;
68
+ }
69
+ }
70
+
71
+ .redsift-card__content {
72
+ visibility: ${_ref2 => {
73
+ let {
74
+ $isCollapsed
75
+ } = _ref2;
76
+ return !$isCollapsed ? 'visible' : 'hidden';
77
+ }};
78
+ overflow: ${_ref3 => {
79
+ let {
80
+ $isCollapsed
81
+ } = _ref3;
82
+ return !$isCollapsed ? 'visible' : 'hidden';
83
+ }};
84
+ height: ${_ref4 => {
85
+ let {
86
+ $isCollapsed
87
+ } = _ref4;
88
+ return !$isCollapsed ? 'auto' : '0px';
89
+ }};
90
+ }
91
+ `;
92
+
93
+ const _excluded = ["children", "className", "defaultCollapsed", "isCollapsed", "isCollapsible", "onCollapse", "theme"];
94
+ const COMPONENT_NAME = 'Card';
95
+ const CLASSNAME = 'redsift-card';
96
+
97
+ /**
98
+ * The Card component.
99
+ */
100
+ const BaseCard = /*#__PURE__*/forwardRef((props, ref) => {
101
+ const {
102
+ children,
103
+ className,
104
+ defaultCollapsed,
105
+ isCollapsed: propsIsCollapsed,
106
+ isCollapsible,
107
+ onCollapse,
108
+ theme: propsTheme
109
+ } = props,
110
+ forwardedProps = _objectWithoutProperties(props, _excluded);
111
+ const theme = useTheme(propsTheme);
112
+ const format = useMessageFormatter(intlMessages);
113
+ const [isCollapsed, setIsCollapsed] = useState(propsIsCollapsed !== null && propsIsCollapsed !== void 0 ? propsIsCollapsed : defaultCollapsed);
114
+ useEffect(() => {
115
+ setIsCollapsed(propsIsCollapsed !== null && propsIsCollapsed !== void 0 ? propsIsCollapsed : defaultCollapsed);
116
+ }, [propsIsCollapsed, defaultCollapsed]);
117
+ const handleCollapse = useCallback(collapsed => {
118
+ if (onCollapse) {
119
+ onCollapse(collapsed);
120
+ }
121
+ if (propsIsCollapsed === undefined || propsIsCollapsed === null) {
122
+ setIsCollapsed(collapsed);
123
+ }
124
+ }, [onCollapse]);
125
+ const [[header], [body], [actions]] = partitionComponents(React__default.Children.toArray(children), [isComponent('CardHeader'), isComponent('CardBody'), isComponent('CardActions')]);
126
+ return /*#__PURE__*/React__default.createElement(ThemeProvider, {
127
+ value: {
128
+ theme
129
+ }
130
+ }, /*#__PURE__*/React__default.createElement(StyledCard, _extends({}, forwardedProps, {
131
+ className: classNames(BaseCard.className, className),
132
+ ref: ref,
133
+ $isCollapsed: isCollapsed,
134
+ $theme: theme
135
+ }), header || isCollapsible ? /*#__PURE__*/React__default.createElement("div", {
136
+ className: `${BaseCard.className}__header`
137
+ }, header && isComponent('CardHeader')(header) ? header : null, isCollapsible ? /*#__PURE__*/React__default.createElement(IconButton, {
138
+ theme: theme,
139
+ "aria-label": format(isCollapsed ? 'expand' : 'collapse'),
140
+ className: `${BaseCard.className}-header__icon-button`,
141
+ color: "grey",
142
+ icon: isCollapsed ? mdiChevronDown : mdiChevronUp,
143
+ onClick: () => handleCollapse(!isCollapsed)
144
+ }) : null) : null, body || actions ? /*#__PURE__*/React__default.createElement("div", {
145
+ className: `${BaseCard.className}__content`
146
+ }, body && isComponent('CardBody')(body) ? body : null, actions && isComponent('CardActions')(actions) ? actions : null) : null));
147
+ });
148
+ BaseCard.className = CLASSNAME;
149
+ BaseCard.displayName = COMPONENT_NAME;
150
+ const Card = Object.assign(BaseCard, {
151
+ Header: CardHeader,
152
+ Body: CardBody,
153
+ Actions: CardActions
154
+ });
155
+
156
+ export { Card as C };
157
+ //# sourceMappingURL=Card2.js.map
@@ -1,9 +1,44 @@
1
- import { C as CardActionsProps } from './types5.js';
2
- import { C as Comp } from './helpers.js';
1
+ import { b as _objectWithoutProperties, c as _extends } from './_rollupPluginBabelHelpers.js';
2
+ import React__default, { forwardRef } from 'react';
3
+ import classNames from 'classnames';
4
+ import styled from 'styled-components';
5
+ import { j as baseContainer } from './styles4.js';
6
+
7
+ /**
8
+ * Component style.
9
+ */
10
+ const StyledCardActions = styled.div`
11
+ ${baseContainer}
12
+
13
+ margin-top: 8px;
14
+ margin-bottom: 8px;
15
+ `;
16
+
17
+ const _excluded = ["children", "className", "display", "flexDirection"];
18
+ const COMPONENT_NAME = 'CardActions';
19
+ const CLASSNAME = 'redsift-card-actions';
3
20
 
4
21
  /**
5
22
  * The CardActions component.
6
23
  */
7
- declare const CardActions: Comp<CardActionsProps, HTMLDivElement>;
24
+ const CardActions = /*#__PURE__*/forwardRef((props, ref) => {
25
+ const {
26
+ children,
27
+ className,
28
+ display = 'flex',
29
+ flexDirection = 'row'
30
+ } = props,
31
+ forwardedProps = _objectWithoutProperties(props, _excluded);
32
+ return /*#__PURE__*/React__default.createElement(StyledCardActions, _extends({
33
+ display: display,
34
+ flexDirection: flexDirection
35
+ }, forwardedProps, {
36
+ className: classNames(CardActions.className, className),
37
+ ref: ref
38
+ }), children);
39
+ });
40
+ CardActions.className = CLASSNAME;
41
+ CardActions.displayName = COMPONENT_NAME;
8
42
 
9
43
  export { CardActions as C };
44
+ //# sourceMappingURL=CardActions.js.map
@@ -1,9 +1,42 @@
1
- import { C as CardBodyProps } from './types6.js';
2
- import { C as Comp } from './helpers.js';
1
+ import { b as _objectWithoutProperties, c as _extends } from './_rollupPluginBabelHelpers.js';
2
+ import React__default, { forwardRef } from 'react';
3
+ import classNames from 'classnames';
4
+ import styled from 'styled-components';
5
+ import { j as baseContainer } from './styles4.js';
6
+
7
+ /**
8
+ * Component style.
9
+ */
10
+ const StyledCardBody = styled.div`
11
+ ${baseContainer}
12
+
13
+ font-family: var(--redsift-typography-body-font-family);
14
+ font-size: var(--redsift-typography-body-font-size);
15
+ font-weight: var(--redsift-typography-body-font-weight);
16
+ line-height: var(--redsift-typography-body-line-height);
17
+ padding: 16px 0px;
18
+ `;
19
+
20
+ const _excluded = ["children", "className"];
21
+ const COMPONENT_NAME = 'CardBody';
22
+ const CLASSNAME = 'redsift-card-body';
3
23
 
4
24
  /**
5
25
  * The CardBody component.
6
26
  */
7
- declare const CardBody: Comp<CardBodyProps, HTMLDivElement>;
27
+ const CardBody = /*#__PURE__*/forwardRef((props, ref) => {
28
+ const {
29
+ children,
30
+ className
31
+ } = props,
32
+ forwardedProps = _objectWithoutProperties(props, _excluded);
33
+ return /*#__PURE__*/React__default.createElement(StyledCardBody, _extends({}, forwardedProps, {
34
+ className: classNames(CardBody.className, className),
35
+ ref: ref
36
+ }), children);
37
+ });
38
+ CardBody.className = CLASSNAME;
39
+ CardBody.displayName = COMPONENT_NAME;
8
40
 
9
41
  export { CardBody as C };
42
+ //# sourceMappingURL=CardBody.js.map
@@ -1,9 +1,83 @@
1
- import { C as CardHeaderProps } from './types7.js';
2
- import { C as Comp } from './helpers.js';
1
+ import { b as _objectWithoutProperties, c as _extends } from './_rollupPluginBabelHelpers.js';
2
+ import React__default, { forwardRef } from 'react';
3
+ import classNames from 'classnames';
4
+ import styled from 'styled-components';
5
+ import { i as baseStyling, g as baseFlexbox } from './styles4.js';
6
+ import { S as Skeleton } from './Skeleton2.js';
7
+ import { H as Heading } from './Heading2.js';
8
+ import { a as Icon } from './Icon2.js';
9
+
10
+ /**
11
+ * Component style.
12
+ */
13
+ const StyledCardHeader = styled.div`
14
+ display: flex;
15
+ flex-direction: column;
16
+ width: 100%;
17
+ ${baseStyling}
18
+ ${baseFlexbox}
19
+
20
+ .redsift-card-header__header {
21
+ align-items: center;
22
+ display: flex;
23
+ gap: 8px;
24
+ padding: 10px 0px;
25
+ margin: 0px;
26
+ }
27
+
28
+ .redsift-card-header__subheader {
29
+ font-family: var(--redsift-typography-body-font-family);
30
+ font-size: var(--redsift-typography-body-font-size);
31
+ font-weight: var(--redsift-typography-body-font-weight);
32
+ line-height: var(--redsift-typography-body-line-height);
33
+ }
34
+ `;
35
+
36
+ const _excluded = ["children", "className", "header", "headingProps", "icon", "iconProps", "isLoading", "subheader"];
37
+ const COMPONENT_NAME = 'CardHeader';
38
+ const CLASSNAME = 'redsift-card-header';
3
39
 
4
40
  /**
5
41
  * The CardHeader component.
6
42
  */
7
- declare const CardHeader: Comp<CardHeaderProps, HTMLDivElement>;
43
+ const CardHeader = /*#__PURE__*/forwardRef((props, ref) => {
44
+ const {
45
+ children,
46
+ className,
47
+ header,
48
+ headingProps,
49
+ icon,
50
+ iconProps,
51
+ isLoading,
52
+ subheader
53
+ } = props,
54
+ forwardedProps = _objectWithoutProperties(props, _excluded);
55
+ return /*#__PURE__*/React__default.createElement(StyledCardHeader, _extends({}, forwardedProps, {
56
+ className: classNames(CardHeader.className, className),
57
+ ref: ref
58
+ }), subheader ? /*#__PURE__*/React__default.createElement(Skeleton.Text, {
59
+ variant: "body",
60
+ isLoaded: !isLoading
61
+ }, /*#__PURE__*/React__default.createElement("div", {
62
+ className: `${CardHeader.className}__subheader`
63
+ }, subheader)) : null, header ? /*#__PURE__*/React__default.createElement(Skeleton.Text, {
64
+ variant: (headingProps === null || headingProps === void 0 ? void 0 : headingProps.variant) || 'h2',
65
+ isLoaded: !isLoading,
66
+ marginTop: "10px",
67
+ marginBottom: "10px"
68
+ }, /*#__PURE__*/React__default.createElement(Heading, _extends({
69
+ as: "h2",
70
+ color: "black",
71
+ className: `${CardHeader.className}__header`,
72
+ variant: "h2"
73
+ }, headingProps), icon ? /*#__PURE__*/React__default.createElement(Icon, _extends({
74
+ icon: icon,
75
+ "aria-hidden": "true",
76
+ size: "large"
77
+ }, iconProps)) : null, header)) : null, children);
78
+ });
79
+ CardHeader.className = CLASSNAME;
80
+ CardHeader.displayName = COMPONENT_NAME;
8
81
 
9
82
  export { CardHeader as C };
83
+ //# sourceMappingURL=CardHeader.js.map
@@ -1,68 +1,244 @@
1
- import { ComponentProps, MutableRefObject, ChangeEvent } from 'react';
2
- import { C as CheckboxGroupState } from './types8.js';
3
- import { h as StylingProps } from './styles2.js';
4
- import { T as Theme } from './colors.js';
5
- import { C as Comp } from './helpers.js';
1
+ import { b as _objectWithoutProperties, c as _extends } from './_rollupPluginBabelHelpers.js';
2
+ import React__default, { forwardRef, useContext, useState, useEffect, useCallback } from 'react';
3
+ import classNames from 'classnames';
4
+ import { mdiCheckboxMarked, mdiMinusBox, mdiCheckboxBlankOutline } from '@redsift/icons';
5
+ import { C as CheckboxGroupContext } from './context3.js';
6
+ import { w as warnIfNoAccessibleLabelFound } from './warnIfNoAccessibleLabelFound.js';
7
+ import styled, { css } from 'styled-components';
8
+ import { i as baseStyling } from './styles4.js';
9
+ import { u as useFocusRing } from './useFocusRing.js';
10
+ import { u as useTheme } from './useTheme.js';
11
+ import { a as Icon } from './Icon2.js';
6
12
 
7
13
  /**
8
- * Component props.
14
+ * Component style.
9
15
  */
10
- interface CheckboxProps extends Omit<ComponentProps<'label'>, 'onChange'>, StylingProps {
11
- /** Whether the component can be autofocused. */
12
- autoFocus?: boolean;
13
- /**
14
- * Default select status.
15
- * Used for uncontrolled version.
16
- */
17
- defaultSelected?: boolean;
18
- /** Custom props to pass to the input element. */
19
- inputProps?: ComponentProps<'input'>;
20
- /** Custom ref object to pass to the input element. */
21
- inputRef?: MutableRefObject<HTMLInputElement>;
22
- /** Whether the component should use the product colors or shades of grey. */
23
- isColored?: boolean;
24
- /** Whether the component is disabled or not. */
25
- isDisabled?: boolean;
26
- /** Whether the checkbox status is indeterminate or not. */
27
- isIndeterminate?: boolean;
28
- /** Whether the component is invalid or not. */
29
- isInvalid?: boolean;
30
- /** Whether the component is read only or not. */
31
- isReadOnly?: boolean;
32
- /** Whether the component is required or not. */
33
- isRequired?: boolean;
34
- /**
35
- * Whether the component is selected or not.
36
- * Used for controlled version.
37
- */
38
- isSelected?: boolean;
39
- /** Name to pass to the input element. */
40
- name?: HTMLInputElement['name'];
41
- /** Method to handle component change. */
42
- onChange?(isChecked: boolean, value?: string, name?: string, event?: ChangeEvent<HTMLInputElement>, state?: CheckboxGroupState): void;
43
- /** Theme. */
44
- theme?: Theme;
45
- /**
46
- * Value to pass to the input element.
47
- * Required within a group.
48
- */
49
- value?: HTMLInputElement['value'];
50
- }
51
- type StyledCheckboxProps = Omit<CheckboxProps, 'color' | 'isColored' | 'isDisabled' | 'isInvalid' | 'isSelected' | 'isRequired'> & {
52
- $isColored: CheckboxProps['isColored'];
53
- $isDisabled: CheckboxProps['isDisabled'];
54
- $isInvalid: CheckboxProps['isInvalid'];
55
- $isFocusVisible: boolean;
56
- $isRequired: CheckboxProps['isRequired'];
57
- $isSelected: CheckboxProps['isSelected'];
58
- $theme: CheckboxProps['theme'];
59
- };
16
+ const StyledCheckbox = styled.label`
17
+ height: fit-content;
18
+ position: relative;
19
+ width: fit-content;
20
+ ${baseStyling}
21
+
22
+ align-items: flex-start;
23
+ background: none;
24
+ border: none;
25
+ display: inline-flex;
26
+
27
+ input {
28
+ height: 100%;
29
+ margin: 0;
30
+ opacity: 0;
31
+ overflow: visible;
32
+ padding: 0;
33
+ position: absolute;
34
+ width: 100%;
35
+ }
36
+
37
+ span.label {
38
+ ${_ref => {
39
+ let {
40
+ $isDisabled,
41
+ $isInvalid,
42
+ $theme
43
+ } = _ref;
44
+ return $isDisabled ? css`
45
+ color: var(--redsift-color-${$theme}-components-checkbox-text-disabled);
46
+ ` : $isInvalid ? css`
47
+ color: var(--redsift-color-${$theme}-components-checkbox-text-invalid);
48
+ ` : css`
49
+ color: var(--redsift-color-${$theme}-components-checkbox-text-default);
50
+ `;
51
+ }}
52
+
53
+ font-family: var(--redsift-typography-body-font-family);
54
+ font-size: var(--redsift-typography-body-font-size);
55
+ font-weight: var(--redsift-typography-body-font-weight);
56
+ line-height: var(--redsift-typography-body-line-height);
57
+ padding-left: 4px;
58
+ padding-right: 16px;
59
+ padding-top: 2px;
60
+
61
+ [dir='rtl'] & {
62
+ padding-left: 16px;
63
+ padding-right: 4px;
64
+ }
65
+ }
66
+
67
+ .redsift-icon {
68
+ box-sizing: content-box;
69
+ padding: 2px;
70
+ width: 24px;
71
+
72
+ ${_ref2 => {
73
+ let {
74
+ $isColored,
75
+ $isDisabled,
76
+ $isInvalid,
77
+ $isFocusVisible,
78
+ $theme
79
+ } = _ref2;
80
+ return css`
81
+ ${$isDisabled ? css`
82
+ color: var(--redsift-color-${$theme}-components-checkbox-fill-disabled);
83
+ ` : $isInvalid ? css`
84
+ color: var(--redsift-color-${$theme}-components-checkbox-fill-invalid);
85
+ ` : css`
86
+ color: ${$isColored ? `var(--redsift-color-${$theme}-components-checkbox-fill-default)` : `var(--redsift-color-${$theme}-components-checkbox-fill-uncolored)`};
87
+ `}
88
+
89
+ ${$isFocusVisible && !$isDisabled ? css`
90
+ background-color: ${$isColored ? `var(--redsift-color-${$theme}-components-checkbox-fill-default-hover)` : `var(--redsift-color-${$theme}-components-checkbox-fill-uncolored-hover)`};
91
+ ` : ''}
92
+ `;
93
+ }}
94
+ }
95
+
96
+ &:hover,
97
+ &:focus-visible {
98
+ outline: none;
99
+
100
+ ${_ref3 => {
101
+ let {
102
+ $isColored,
103
+ $isDisabled,
104
+ $isInvalid,
105
+ $theme
106
+ } = _ref3;
107
+ return !$isDisabled ? css`
108
+ .redsift-icon {
109
+ ${$isInvalid ? css`
110
+ background-color: var(--redsift-color-${$theme}-components-checkbox-fill-invalid-hover);
111
+ ` : css`
112
+ background-color: ${$isColored ? `var(--redsift-color-${$theme}-components-checkbox-fill-default-hover)` : `var(--redsift-color-${$theme}-components-checkbox-fill-uncolored-hover)`};
113
+ `}
114
+ border-radius: 4px;
115
+ }
116
+ ` : '';
117
+ }}
118
+ }
119
+ `;
120
+
121
+ const _excluded = ["aria-label", "aria-labelledby", "autoFocus", "children", "className", "defaultSelected", "inputProps", "inputRef", "isColored", "isDisabled", "isIndeterminate", "isInvalid", "isReadOnly", "isRequired", "isSelected", "name", "onChange", "theme", "value"];
122
+ const COMPONENT_NAME = 'Checkbox';
123
+ const CLASSNAME = 'redsift-checkbox';
60
124
 
61
125
  /**
62
126
  * The Checkbox component.
63
127
  * Works both inside a CheckboxGroup or as standalone.
64
128
  * Can be used as controlled or uncontrolled.
65
129
  */
66
- declare const Checkbox: Comp<CheckboxProps, HTMLLabelElement>;
130
+ const Checkbox = /*#__PURE__*/forwardRef((props, ref) => {
131
+ var _isDisabled, _isReadOnly, _ref;
132
+ const groupState = useContext(CheckboxGroupContext);
133
+ let {
134
+ 'aria-label': ariaLabel,
135
+ 'aria-labelledby': ariaLabelledby,
136
+ autoFocus,
137
+ children,
138
+ className,
139
+ defaultSelected,
140
+ inputProps,
141
+ inputRef,
142
+ isColored = true,
143
+ isDisabled,
144
+ isIndeterminate,
145
+ isInvalid,
146
+ isReadOnly,
147
+ isRequired,
148
+ isSelected: propsIsSelected,
149
+ name,
150
+ onChange,
151
+ theme: propsTheme,
152
+ value
153
+ } = props,
154
+ forwardedProps = _objectWithoutProperties(props, _excluded);
155
+ const theme = useTheme(propsTheme);
156
+ const {
157
+ isFocusVisible,
158
+ focusProps
159
+ } = useFocusRing({
160
+ autoFocus
161
+ });
162
+ isDisabled = (_isDisabled = isDisabled) !== null && _isDisabled !== void 0 ? _isDisabled : groupState === null || groupState === void 0 ? void 0 : groupState.isDisabled;
163
+ isReadOnly = (_isReadOnly = isReadOnly) !== null && _isReadOnly !== void 0 ? _isReadOnly : groupState === null || groupState === void 0 ? void 0 : groupState.isReadOnly;
164
+ const [isSelected, setSelected] = useState(Boolean((_ref = propsIsSelected !== null && propsIsSelected !== void 0 ? propsIsSelected : defaultSelected) !== null && _ref !== void 0 ? _ref : groupState === null || groupState === void 0 ? void 0 : groupState.value.includes(value)));
165
+ const isControlled = propsIsSelected !== null && propsIsSelected !== undefined;
166
+ useEffect(() => {
167
+ setSelected(Boolean(propsIsSelected !== null && propsIsSelected !== void 0 ? propsIsSelected : defaultSelected));
168
+ }, [propsIsSelected, defaultSelected]);
169
+ useEffect(() => {
170
+ if (groupState) {
171
+ setSelected(groupState.value.includes(value));
172
+ }
173
+ }, [groupState === null || groupState === void 0 ? void 0 : groupState.value]);
174
+ warnIfNoAccessibleLabelFound(props, [children], 'Checkbox');
175
+ if (groupState) {
176
+ if (propsIsSelected != null) {
177
+ console.warn('isSelected is unsupported on individual <Checkbox> elements within a <CheckboxGroup> unless the <Checkbox> is controlled. Please apply this prop to the group instead or pass isControlled to the component.');
178
+ }
179
+ if (defaultSelected != null) {
180
+ console.warn('defaultSelected is unsupported on individual <Checkbox> elements within a <CheckboxGroup> unless the <Checkbox> is controlled. Please apply this prop to the group instead or pass isControlled to the component.');
181
+ }
182
+ if (props.value == null) {
183
+ console.warn('A <Checkbox> element within a <CheckboxGroup> requires a `value` property unless the <Checkbox> is controlled.');
184
+ }
185
+ }
186
+ const handleChange = useCallback(event => {
187
+ if (isDisabled || isReadOnly) {
188
+ return;
189
+ }
190
+ if (groupState) {
191
+ if (!groupState.value.includes(value)) {
192
+ groupState.addValue(value);
193
+ } else {
194
+ groupState.removeValue(value);
195
+ }
196
+ }
197
+ if (isControlled) {
198
+ onChange === null || onChange === void 0 ? void 0 : onChange(!propsIsSelected, value, name, event, groupState);
199
+ } else {
200
+ setSelected(!isSelected);
201
+ onChange === null || onChange === void 0 ? void 0 : onChange(!isSelected, value, name, event, groupState);
202
+ }
203
+ }, [onChange, groupState, isSelected, propsIsSelected]);
204
+ return /*#__PURE__*/React__default.createElement(StyledCheckbox, _extends({}, forwardedProps, {
205
+ $isColored: isColored,
206
+ $isDisabled: isDisabled,
207
+ $isFocusVisible: isFocusVisible,
208
+ $isInvalid: isInvalid || isRequired && !(isSelected || isControlled && propsIsSelected),
209
+ $isRequired: isRequired,
210
+ $isSelected: isSelected || isControlled && propsIsSelected,
211
+ $theme: theme,
212
+ className: classNames(Checkbox.className, className),
213
+ ref: ref
214
+ }), isSelected || isControlled && propsIsSelected ? /*#__PURE__*/React__default.createElement(Icon, {
215
+ icon: mdiCheckboxMarked
216
+ }) : isIndeterminate ? /*#__PURE__*/React__default.createElement(Icon, {
217
+ icon: mdiMinusBox
218
+ }) : /*#__PURE__*/React__default.createElement(Icon, {
219
+ icon: mdiCheckboxBlankOutline
220
+ }), children ? /*#__PURE__*/React__default.createElement("span", {
221
+ className: "label"
222
+ }, children) : null, /*#__PURE__*/React__default.createElement("input", _extends({}, inputProps, focusProps, {
223
+ "aria-checked": isSelected || isControlled && propsIsSelected ? 'true' : isIndeterminate ? 'mixed' : 'false',
224
+ "aria-disabled": isDisabled,
225
+ "aria-invalid": isInvalid || isRequired && !(isSelected || isControlled && propsIsSelected),
226
+ "aria-label": ariaLabel,
227
+ "aria-labelledby": ariaLabelledby,
228
+ "aria-readonly": isReadOnly,
229
+ "aria-required": isRequired,
230
+ autoFocus: autoFocus,
231
+ checked: isSelected || isControlled && propsIsSelected ? true : false,
232
+ disabled: isDisabled,
233
+ name: name,
234
+ onChange: handleChange,
235
+ ref: inputRef,
236
+ type: "checkbox",
237
+ value: value
238
+ })));
239
+ });
240
+ Checkbox.className = CLASSNAME;
241
+ Checkbox.displayName = COMPONENT_NAME;
67
242
 
68
- export { CheckboxProps as C, StyledCheckboxProps as S, Checkbox as a };
243
+ export { Checkbox as C };
244
+ //# sourceMappingURL=Checkbox2.js.map