@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,66 +1,237 @@
1
- import { ComponentProps, MutableRefObject, ChangeEvent } from 'react';
2
- import { R as RadioGroupState } from './types21.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 { mdiRadioboxMarked, mdiRadioboxBlank } from '@redsift/icons';
5
+ import { R as RadioGroupContext } from './context4.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 RadioProps 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 component is invalid or not. */
27
- isInvalid?: boolean;
28
- /** Whether the component is read only or not. */
29
- isReadOnly?: boolean;
30
- /** Whether the component is required or not. */
31
- isRequired?: boolean;
32
- /**
33
- * Whether the component is selected or not.
34
- * Used for controlled version.
35
- */
36
- isSelected?: boolean;
37
- /** Name to pass to the input element. */
38
- name?: HTMLInputElement['name'];
39
- /** Method to handle component change. */
40
- onChange?(isChecked: boolean, value?: string, name?: string, event?: ChangeEvent<HTMLInputElement>, state?: RadioGroupState): void;
41
- /** Theme. */
42
- theme?: Theme;
43
- /**
44
- * Value to pass to the input element.
45
- * Required within a group.
46
- */
47
- value?: HTMLInputElement['value'];
48
- }
49
- type StyledRadioProps = Omit<RadioProps, 'color' | 'isColored' | 'isDisabled' | 'isInvalid' | 'isSelected' | 'isRequired' | 'size'> & {
50
- $isColored: RadioProps['isColored'];
51
- $isDisabled: RadioProps['isDisabled'];
52
- $isInvalid: RadioProps['isInvalid'];
53
- $isFocusVisible: boolean;
54
- $isRequired: RadioProps['isRequired'];
55
- $isSelected: RadioProps['isSelected'];
56
- $theme: RadioProps['theme'];
57
- };
16
+ const StyledRadio = styled.label`
17
+ height: fit-content;
18
+ position: relative;
19
+ width: fit-content;
20
+ ${baseStyling}
21
+
22
+ align-items: center;
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-radio-text-disabled);
46
+ ` : $isInvalid ? css`
47
+ color: var(--redsift-color-${$theme}-components-radio-text-invalid);
48
+ ` : css`
49
+ color: var(--redsift-color-${$theme}-components-radio-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
+
60
+ [dir='rtl'] & {
61
+ padding-left: 16px;
62
+ padding-right: 4px;
63
+ }
64
+ }
65
+
66
+ .redsift-icon {
67
+ box-sizing: content-box;
68
+ padding: 2px;
69
+ width: 24px;
70
+
71
+ ${_ref2 => {
72
+ let {
73
+ $isColored,
74
+ $isDisabled,
75
+ $isInvalid,
76
+ $isFocusVisible,
77
+ $theme
78
+ } = _ref2;
79
+ return css`
80
+ ${$isDisabled ? css`
81
+ color: var(--redsift-color-${$theme}-components-radio-fill-disabled);
82
+ ` : $isInvalid ? css`
83
+ color: var(--redsift-color-${$theme}-components-radio-fill-invalid);
84
+ ` : css`
85
+ color: ${$isColored ? `var(--redsift-color-${$theme}-components-radio-fill-default)` : `var(--redsift-color-${$theme}-components-radio-fill-uncolored)`};
86
+ `}
87
+
88
+ ${$isFocusVisible && !$isDisabled ? css`
89
+ background-color: ${$isColored ? `var(--redsift-color-${$theme}-components-radio-fill-default-hover)` : `var(--redsift-color-${$theme}-components-radio-fill-uncolored-hover)`};
90
+ border-radius: 16px;
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-radio-fill-invalid-hover);
111
+ ` : css`
112
+ background-color: ${$isColored ? `var(--redsift-color-${$theme}-components-radio-fill-default-hover)` : `var(--redsift-color-${$theme}-components-radio-fill-uncolored-hover)`};
113
+ `}
114
+ border-radius: 16px;
115
+ }
116
+ ` : '';
117
+ }}
118
+ }
119
+ `;
120
+
121
+ const _excluded = ["aria-label", "aria-labelledby", "autoFocus", "children", "className", "defaultSelected", "inputProps", "inputRef", "isColored", "isDisabled", "isInvalid", "isReadOnly", "isRequired", "isSelected", "name", "onChange", "theme", "value"];
122
+ const COMPONENT_NAME = 'Radio';
123
+ const CLASSNAME = 'redsift-radio';
58
124
 
59
125
  /**
60
126
  * The Radio component.
61
127
  * Works both inside a RadioGroup or as standalone.
62
128
  * Can be used as controlled or uncontrolled.
63
129
  */
64
- declare const Radio: Comp<RadioProps, HTMLLabelElement>;
130
+ const Radio = /*#__PURE__*/forwardRef((props, ref) => {
131
+ var _isDisabled, _isReadOnly, _ref;
132
+ const groupState = useContext(RadioGroupContext);
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
+ isInvalid,
145
+ isReadOnly,
146
+ isRequired,
147
+ isSelected: propsIsSelected,
148
+ name,
149
+ onChange,
150
+ theme: propsTheme,
151
+ value
152
+ } = props,
153
+ forwardedProps = _objectWithoutProperties(props, _excluded);
154
+ const theme = useTheme(propsTheme);
155
+ const {
156
+ isFocusVisible,
157
+ focusProps
158
+ } = useFocusRing({
159
+ autoFocus
160
+ });
161
+ isDisabled = (_isDisabled = isDisabled) !== null && _isDisabled !== void 0 ? _isDisabled : groupState === null || groupState === void 0 ? void 0 : groupState.isDisabled;
162
+ isReadOnly = (_isReadOnly = isReadOnly) !== null && _isReadOnly !== void 0 ? _isReadOnly : groupState === null || groupState === void 0 ? void 0 : groupState.isReadOnly;
163
+ const [isSelected, setSelected] = useState(Boolean((_ref = propsIsSelected !== null && propsIsSelected !== void 0 ? propsIsSelected : defaultSelected) !== null && _ref !== void 0 ? _ref : Boolean((groupState === null || groupState === void 0 ? void 0 : groupState.value) && groupState.value === value)));
164
+ const isControlled = propsIsSelected !== null && propsIsSelected !== undefined;
165
+ useEffect(() => {
166
+ setSelected(Boolean(propsIsSelected !== null && propsIsSelected !== void 0 ? propsIsSelected : defaultSelected));
167
+ }, [propsIsSelected, defaultSelected]);
168
+ useEffect(() => {
169
+ if (groupState) {
170
+ setSelected(groupState.value === value);
171
+ }
172
+ }, [groupState === null || groupState === void 0 ? void 0 : groupState.value]);
173
+ warnIfNoAccessibleLabelFound(props, [children], 'Radio');
174
+ if (groupState) {
175
+ if (propsIsSelected != null) {
176
+ console.warn('isSelected is unsupported on individual <Radio> elements within a <RadioGroup> unless the <Radio> is controlled. Please apply this prop to the group instead.');
177
+ }
178
+ if (defaultSelected != null) {
179
+ console.warn('defaultSelected is unsupported on individual <Radio> elements within a <RadioGroup> unless the <Radio> is controlled. Please apply this prop to the group instead.');
180
+ }
181
+ if (props.value == null) {
182
+ console.warn('A <Radio> element within a <RadioGroup> requires a `value` property unless the <Radio> is controlled.');
183
+ }
184
+ }
185
+ const handleChange = useCallback(event => {
186
+ if (isDisabled || isReadOnly) {
187
+ return;
188
+ }
189
+ if (groupState) {
190
+ groupState.setValue(value);
191
+ }
192
+ if (isControlled) {
193
+ onChange === null || onChange === void 0 ? void 0 : onChange(!propsIsSelected, value, name, event, groupState);
194
+ } else {
195
+ setSelected(!isSelected);
196
+ onChange === null || onChange === void 0 ? void 0 : onChange(!isSelected, value, name, event, groupState);
197
+ }
198
+ }, [onChange, groupState, isSelected, propsIsSelected]);
199
+ return /*#__PURE__*/React__default.createElement(StyledRadio, _extends({}, forwardedProps, {
200
+ $isColored: isColored,
201
+ $isDisabled: isDisabled,
202
+ $isFocusVisible: isFocusVisible,
203
+ $isInvalid: isInvalid || isRequired && !(isSelected || isControlled && propsIsSelected),
204
+ $isRequired: isRequired,
205
+ $isSelected: isSelected || isControlled && propsIsSelected,
206
+ $theme: theme,
207
+ className: classNames(Radio.className, className),
208
+ ref: ref
209
+ }), isSelected || isControlled && propsIsSelected ? /*#__PURE__*/React__default.createElement(Icon, {
210
+ icon: mdiRadioboxMarked
211
+ }) : /*#__PURE__*/React__default.createElement(Icon, {
212
+ icon: mdiRadioboxBlank
213
+ }), children ? /*#__PURE__*/React__default.createElement("span", {
214
+ className: "label"
215
+ }, children) : null, /*#__PURE__*/React__default.createElement("input", _extends({}, inputProps, focusProps, {
216
+ "aria-checked": isSelected || isControlled && propsIsSelected ? 'true' : 'false',
217
+ "aria-disabled": isDisabled,
218
+ "aria-invalid": isInvalid || isRequired && !(isSelected || isControlled && propsIsSelected),
219
+ "aria-label": ariaLabel,
220
+ "aria-labelledby": ariaLabelledby,
221
+ "aria-readonly": isReadOnly,
222
+ "aria-required": isRequired,
223
+ autoFocus: autoFocus,
224
+ checked: isSelected || isControlled && propsIsSelected ? true : false,
225
+ disabled: isDisabled,
226
+ name: name,
227
+ onChange: handleChange,
228
+ ref: inputRef,
229
+ type: "radio",
230
+ value: value
231
+ })));
232
+ });
233
+ Radio.className = CLASSNAME;
234
+ Radio.displayName = COMPONENT_NAME;
65
235
 
66
- export { RadioProps as R, StyledRadioProps as S, Radio as a };
236
+ export { Radio as R };
237
+ //# sourceMappingURL=Radio2.js.map
@@ -1,10 +1,176 @@
1
- import { b as RadioGroupProps } from './types21.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, useState, useEffect } from 'react';
3
+ import classNames from 'classnames';
4
+ import { R as RadioGroupContext } from './context4.js';
5
+ import styled, { css } from 'styled-components';
6
+ import { i as baseStyling } from './styles4.js';
7
+ import { C as ColorPalette } from './colors.js';
8
+ import { u as useTheme, a as ThemeProvider } from './useTheme.js';
9
+
10
+ /**
11
+ * Context props.
12
+ */
13
+
14
+ /**
15
+ * Component orientation.
16
+ */
17
+ const RadioGroupOrientation = {
18
+ horizontal: 'horizontal',
19
+ vertical: 'vertical'
20
+ };
21
+
22
+ /**
23
+ * Component props.
24
+ */
25
+
26
+ /**
27
+ * Component style.
28
+ */
29
+ const StyledRadioGroup = styled.div`
30
+ ${baseStyling}
31
+
32
+ display: flex;
33
+ flex-direction: column;
34
+
35
+ ${_ref => {
36
+ let {
37
+ $orientation
38
+ } = _ref;
39
+ return $orientation === RadioGroupOrientation.vertical ? `
40
+ div.redsift-radio-group-boxes {
41
+ display: flex;
42
+ flex-direction: column;
43
+ }
44
+ ` : `
45
+ div.redsift-radio-group-boxes {
46
+ display: flex;
47
+ flex-direction: row;
48
+ flex-wrap: wrap;
49
+ }
50
+ `;
51
+ }}
52
+
53
+ span.redsift-radio-group-label {
54
+ font-family: var(--redsift-typography-body-font-family);
55
+ font-weight: var(--redsift-typography-body-font-weight);
56
+ font-size: var(--redsift-typography-body-font-size);
57
+ line-height: var(--redsift-typography-body-line-height);
58
+
59
+ ${_ref2 => {
60
+ let {
61
+ $isDisabled,
62
+ $isInvalid,
63
+ $theme
64
+ } = _ref2;
65
+ return $isDisabled ? css`
66
+ color: var(--redsift-color-${$theme}-components-radio-text-disabled);
67
+ ` : $isInvalid ? css`
68
+ color: var(--redsift-color-${$theme}-components-radio-text-invalid);
69
+ ` : css`
70
+ color: var(--redsift-color-${$theme}-components-radio-text-default);
71
+ `;
72
+ }}
73
+ }
74
+
75
+ span.redsift-radio-group-description {
76
+ font-family: var(--redsift-typography-helper-font-family);
77
+ font-weight: var(--redsift-typography-helper-font-weight);
78
+ font-size: var(--redsift-typography-helper-font-size);
79
+ line-height: var(--redsift-typography-helper-line-height);
80
+
81
+ ${_ref3 => {
82
+ let {
83
+ $isDisabled,
84
+ $isInvalid,
85
+ $theme
86
+ } = _ref3;
87
+ return $isDisabled ? css`
88
+ color: var(--redsift-color-${$theme}-components-radio-text-disabled);
89
+ ` : $isInvalid ? css`
90
+ color: var(--redsift-color-${$theme}-components-radio-text-invalid);
91
+ ` : css`
92
+ color: var(--redsift-color-${$theme}-components-radio-text-default);
93
+ `;
94
+ }}
95
+ }
96
+ `;
97
+
98
+ const _excluded = ["children", "className", "color", "defaultValue", "description", "isDisabled", "isInvalid", "isReadOnly", "isRequired", "label", "onChange", "orientation", "theme", "value"];
99
+ const COMPONENT_NAME = 'RadioGroup';
100
+ const CLASSNAME = 'redsift-radio-group';
3
101
 
4
102
  /**
5
103
  * The RadioGroup component.
6
104
  * Can be used as controlled or uncontrolled.
7
105
  */
8
- declare const RadioGroup: Comp<RadioGroupProps, HTMLDivElement>;
106
+ const RadioGroup = /*#__PURE__*/forwardRef((props, ref) => {
107
+ const {
108
+ children,
109
+ className,
110
+ color = ColorPalette.primary,
111
+ defaultValue,
112
+ description,
113
+ isDisabled,
114
+ isInvalid,
115
+ isReadOnly,
116
+ isRequired,
117
+ label,
118
+ onChange,
119
+ orientation = RadioGroupOrientation.vertical,
120
+ theme: propsTheme,
121
+ value
122
+ } = props,
123
+ forwardedProps = _objectWithoutProperties(props, _excluded);
124
+ const theme = useTheme(propsTheme);
125
+ const [selectedValue, setValue] = useState(value || defaultValue || '');
126
+ useEffect(() => {
127
+ if (value) {
128
+ state.setValue(value);
129
+ }
130
+ }, [value]);
131
+ const state = {
132
+ value: selectedValue,
133
+ isDisabled: isDisabled || false,
134
+ isReadOnly: isReadOnly || false,
135
+ setValue(value) {
136
+ if (isReadOnly || isDisabled) {
137
+ return;
138
+ }
139
+ const previousValue = selectedValue;
140
+ setValue(value);
141
+ if (value !== previousValue && onChange) {
142
+ onChange(value);
143
+ }
144
+ }
145
+ };
146
+ return /*#__PURE__*/React__default.createElement(ThemeProvider, {
147
+ value: {
148
+ theme
149
+ }
150
+ }, /*#__PURE__*/React__default.createElement(StyledRadioGroup, _extends({
151
+ color: color
152
+ }, forwardedProps, {
153
+ $isDisabled: isDisabled,
154
+ $isInvalid: isInvalid || isRequired && selectedValue.length === 0,
155
+ $isReadOnly: isReadOnly,
156
+ $orientation: orientation,
157
+ $theme: theme,
158
+ "aria-disabled": isDisabled,
159
+ className: classNames(RadioGroup.className, className),
160
+ ref: ref,
161
+ role: "radiogroup"
162
+ }), /*#__PURE__*/React__default.createElement("span", {
163
+ className: `${RadioGroup.className}-label`
164
+ }, label, isRequired ? ' *' : null), /*#__PURE__*/React__default.createElement("div", {
165
+ className: `${RadioGroup.className}-boxes`
166
+ }, /*#__PURE__*/React__default.createElement(RadioGroupContext.Provider, {
167
+ value: state
168
+ }, children)), /*#__PURE__*/React__default.createElement("span", {
169
+ className: `${RadioGroup.className}-description`
170
+ }, description)));
171
+ });
172
+ RadioGroup.className = CLASSNAME;
173
+ RadioGroup.displayName = COMPONENT_NAME;
9
174
 
10
- export { RadioGroup as R };
175
+ export { RadioGroupOrientation as R, RadioGroup as a };
176
+ //# sourceMappingURL=RadioGroup.js.map