@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,320 @@
1
- import { ComponentProps, MutableRefObject, ChangeEvent } from 'react';
2
- import { S as SwitchGroupState } from './types27.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 { S as SwitchGroupContext } from './context5.js';
5
+ import { w as warnIfNoAccessibleLabelFound } from './warnIfNoAccessibleLabelFound.js';
6
+ import styled, { css } from 'styled-components';
7
+ import { i as baseStyling } from './styles4.js';
8
+ import { u as useFocusRing } from './useFocusRing.js';
9
+ import { u as useTheme } from './useTheme.js';
6
10
 
7
11
  /**
8
- * Component props.
12
+ * Component style.
9
13
  */
10
- interface SwitchProps 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?: SwitchGroupState): 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 StyledSwitchProps = Omit<SwitchProps, 'color' | 'isColored' | 'isDisabled' | 'isInvalid' | 'isSelected' | 'isRequired' | 'size'> & {
50
- $isColored: SwitchProps['isColored'];
51
- $isDisabled: SwitchProps['isDisabled'];
52
- $isInvalid: SwitchProps['isInvalid'];
53
- $isFocusVisible: boolean;
54
- $isRequired: SwitchProps['isRequired'];
55
- $isSelected: SwitchProps['isSelected'];
56
- $theme: SwitchProps['theme'];
57
- };
14
+ const StyledSwitch = styled.label`
15
+ height: fit-content;
16
+ position: relative;
17
+ width: fit-content;
18
+ ${baseStyling}
19
+
20
+ align-items: center;
21
+ background: none;
22
+ border: none;
23
+ display: inline-flex;
24
+ margin: 4px;
25
+
26
+ input {
27
+ height: 100%;
28
+ margin: 0;
29
+ opacity: 0;
30
+ overflow: visible;
31
+ padding: 0;
32
+ position: absolute;
33
+ width: 100%;
34
+ }
35
+
36
+ span.label {
37
+ ${_ref => {
38
+ let {
39
+ $isDisabled,
40
+ $isInvalid,
41
+ $theme
42
+ } = _ref;
43
+ return $isDisabled ? css`
44
+ color: var(--redsift-color-${$theme}-components-switch-text-disabled);
45
+ ` : $isInvalid ? css`
46
+ color: var(--redsift-color-${$theme}-components-switch-text-invalid);
47
+ ` : css`
48
+ color: var(--redsift-color-${$theme}-components-switch-text-default);
49
+ `;
50
+ }}
51
+
52
+ font-family: var(--redsift-typography-body-font-family);
53
+ font-size: var(--redsift-typography-body-font-size);
54
+ font-weight: var(--redsift-typography-body-font-weight);
55
+ line-height: var(--redsift-typography-body-line-height);
56
+ padding-inline-start: 12px;
57
+ padding-inline-end: 24px;
58
+ }
59
+
60
+ .redsift-switch__slide {
61
+ height: 20px;
62
+ position: relative;
63
+ min-width: 40px;
64
+ }
65
+
66
+ .redsift-switch-slide__inner {
67
+ ${_ref2 => {
68
+ let {
69
+ $isColored,
70
+ $isDisabled,
71
+ $isInvalid,
72
+ $isSelected,
73
+ $theme
74
+ } = _ref2;
75
+ return $isDisabled ? css`
76
+ background-color: var(
77
+ --redsift-color-${$theme}-components-switch-background-disabled${$isSelected ? '-active' : ''}
78
+ );
79
+ ` : $isInvalid ? css`
80
+ background-color: var(
81
+ --redsift-color-${$theme}-components-switch-background-invalid${$isSelected ? '-active' : ''}
82
+ );
83
+ ` : css`
84
+ background-color: ${$isColored ? `var(--redsift-color-${$theme}-components-switch-background-default${$isSelected ? '-active' : ''})` : `var(--redsift-color-${$theme}-components-switch-background-uncolored${$isSelected ? '-active' : ''})`};
85
+ `;
86
+ }}
87
+ border-radius: 20px;
88
+ height: 24px;
89
+ position: absolute;
90
+ top: calc(50% - 24px / 2);
91
+ width: 46px;
92
+ z-index: 2;
93
+ }
94
+
95
+ .redsift-switch-slide__knob-wrapper {
96
+ border-radius: 50%;
97
+ height: 20px;
98
+ margin-inline-start: ${_ref3 => {
99
+ let {
100
+ $isSelected
101
+ } = _ref3;
102
+ return !$isSelected ? '2px' : '24px';
103
+ }};
104
+ position: absolute;
105
+ top: -6px;
106
+ width: 20px;
107
+ }
108
+
109
+ .redsift-switch-slide-knob-wrapper__elevation {
110
+ ${_ref4 => {
111
+ let {
112
+ $isDisabled,
113
+ $isInvalid,
114
+ $theme
115
+ } = _ref4;
116
+ return $isDisabled ? css`
117
+ background-color: var(--redsift-color-${$theme}-components-switch-dot-disabled-hover);
118
+ ` : $isInvalid ? css`
119
+ background-color: var(--redsift-color-${$theme}-components-switch-dot-invalid-hover);
120
+ ` : css`
121
+ background-color: var(--redsift-color-${$theme}-components-switch-dot-default-hover);
122
+ `;
123
+ }}
124
+
125
+ border-radius: 50%;
126
+ height: 32px;
127
+ margin-inline-start: ${_ref5 => {
128
+ let {
129
+ $isSelected
130
+ } = _ref5;
131
+ return !$isSelected ? '-6px' : '-6px';
132
+ }};
133
+ opacity: 0;
134
+ position: absolute;
135
+ width: 32px;
136
+ z-index: 3;
137
+ }
138
+
139
+ .redsift-switch-slide-knob-wrapper__knob {
140
+ ${_ref6 => {
141
+ let {
142
+ $isDisabled,
143
+ $isInvalid,
144
+ $theme
145
+ } = _ref6;
146
+ return $isDisabled ? css`
147
+ background-color: var(--redsift-color-${$theme}-components-switch-dot-disabled);
148
+ ` : $isInvalid ? css`
149
+ background-color: var(--redsift-color-${$theme}-components-switch-dot-invalid);
150
+ ` : css`
151
+ background-color: var(--redsift-color-${$theme}-components-switch-dot-default);
152
+ `;
153
+ }}
154
+ border-radius: 50%;
155
+ box-shadow: 0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px rgba(0, 0, 0, 0.14), 0px 1px 3px rgba(0, 0, 0, 0.12);
156
+ height: 20px;
157
+ position: absolute;
158
+ top: 6px;
159
+ width: 20px;
160
+ z-index: 4;
161
+ }
162
+
163
+ &:hover,
164
+ &:focus-visible {
165
+ outline: none;
166
+ cursor: pointer;
167
+
168
+ ${_ref7 => {
169
+ let {
170
+ $isDisabled
171
+ } = _ref7;
172
+ return !$isDisabled ? css`
173
+ .redsift-switch-slide-knob-wrapper__elevation {
174
+ opacity: 0.5;
175
+ }
176
+ ` : '';
177
+ }}
178
+ }
179
+
180
+ ${_ref8 => {
181
+ let {
182
+ $isDisabled,
183
+ $isFocusVisible
184
+ } = _ref8;
185
+ return $isFocusVisible && !$isDisabled ? css`
186
+ .redsift-switch-slide-knob-wrapper__elevation {
187
+ opacity: 0.5;
188
+ }
189
+ ` : '';
190
+ }}
191
+ `;
192
+
193
+ const _excluded = ["aria-label", "aria-labelledby", "autoFocus", "children", "className", "defaultSelected", "inputProps", "inputRef", "isColored", "isDisabled", "isInvalid", "isReadOnly", "isRequired", "isSelected", "name", "onChange", "theme", "value"];
194
+ const COMPONENT_NAME = 'Switch';
195
+ const CLASSNAME = 'redsift-switch';
58
196
 
59
197
  /**
60
198
  * The Switch component.
61
199
  * Works both inside a SwitchGroup or as standalone.
62
200
  * Can be used as controlled or uncontrolled.
63
201
  */
64
- declare const Switch: Comp<SwitchProps, HTMLLabelElement>;
202
+ const Switch = /*#__PURE__*/forwardRef((props, ref) => {
203
+ var _isDisabled, _isReadOnly, _ref;
204
+ const groupState = useContext(SwitchGroupContext);
205
+ let {
206
+ 'aria-label': ariaLabel,
207
+ 'aria-labelledby': ariaLabelledby,
208
+ autoFocus,
209
+ children,
210
+ className,
211
+ defaultSelected,
212
+ inputProps,
213
+ inputRef,
214
+ isColored = true,
215
+ isDisabled,
216
+ isInvalid,
217
+ isReadOnly,
218
+ isRequired,
219
+ isSelected: propsIsSelected,
220
+ name,
221
+ onChange,
222
+ theme: propsTheme,
223
+ value
224
+ } = props,
225
+ forwardedProps = _objectWithoutProperties(props, _excluded);
226
+ const theme = useTheme(propsTheme);
227
+ const {
228
+ isFocusVisible,
229
+ focusProps
230
+ } = useFocusRing({
231
+ autoFocus
232
+ });
233
+ isDisabled = (_isDisabled = isDisabled) !== null && _isDisabled !== void 0 ? _isDisabled : groupState === null || groupState === void 0 ? void 0 : groupState.isDisabled;
234
+ isReadOnly = (_isReadOnly = isReadOnly) !== null && _isReadOnly !== void 0 ? _isReadOnly : groupState === null || groupState === void 0 ? void 0 : groupState.isReadOnly;
235
+ 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)));
236
+ const isControlled = propsIsSelected !== null && propsIsSelected !== undefined;
237
+ useEffect(() => {
238
+ setSelected(Boolean(propsIsSelected !== null && propsIsSelected !== void 0 ? propsIsSelected : defaultSelected));
239
+ }, [propsIsSelected, defaultSelected]);
240
+ useEffect(() => {
241
+ if (groupState) {
242
+ setSelected(groupState.value.includes(value));
243
+ }
244
+ }, [groupState === null || groupState === void 0 ? void 0 : groupState.value]);
245
+ warnIfNoAccessibleLabelFound(props, [children], 'Switch');
246
+ if (groupState) {
247
+ if (propsIsSelected != null) {
248
+ console.warn('isSelected is unsupported on individual <Switch> elements within a <SwitchGroup> unless the <Switch> is controlled. Please apply this prop to the group instead.');
249
+ }
250
+ if (defaultSelected != null) {
251
+ console.warn('defaultSelected is unsupported on individual <Switch> elements within a <SwitchGroup> unless the <Switch> is controlled. Please apply this prop to the group instead.');
252
+ }
253
+ if (props.value == null) {
254
+ console.warn('A <Switch> element within a <SwitchGroup> requires a `value` property unless the <Switch> is controlled.');
255
+ }
256
+ }
257
+ const handleChange = useCallback(event => {
258
+ if (isDisabled || isReadOnly) {
259
+ return;
260
+ }
261
+ if (groupState) {
262
+ if (!groupState.value.includes(value)) {
263
+ groupState.addValue(value);
264
+ } else {
265
+ groupState.removeValue(value);
266
+ }
267
+ }
268
+ if (isControlled) {
269
+ onChange === null || onChange === void 0 ? void 0 : onChange(!propsIsSelected, value, name, event, groupState);
270
+ } else {
271
+ setSelected(!isSelected);
272
+ onChange === null || onChange === void 0 ? void 0 : onChange(!isSelected, value, name, event, groupState);
273
+ }
274
+ }, [onChange, groupState, isSelected, propsIsSelected]);
275
+ return /*#__PURE__*/React__default.createElement(StyledSwitch, _extends({}, forwardedProps, {
276
+ $isColored: isColored,
277
+ $isDisabled: isDisabled,
278
+ $isFocusVisible: isFocusVisible,
279
+ $isInvalid: isInvalid || isRequired && !(isSelected || isControlled && propsIsSelected),
280
+ $isRequired: isRequired,
281
+ $isSelected: isSelected || isControlled && propsIsSelected,
282
+ $theme: theme,
283
+ className: classNames(Switch.className, className),
284
+ ref: ref
285
+ }), /*#__PURE__*/React__default.createElement("div", {
286
+ className: `${Switch.className}__slide`
287
+ }, /*#__PURE__*/React__default.createElement("div", {
288
+ className: `${Switch.className}-slide__inner`
289
+ }), /*#__PURE__*/React__default.createElement("div", {
290
+ className: `${Switch.className}-slide__knob-wrapper`
291
+ }, /*#__PURE__*/React__default.createElement("div", {
292
+ className: `${Switch.className}-slide-knob-wrapper__elevation`
293
+ }), /*#__PURE__*/React__default.createElement("div", {
294
+ className: `${Switch.className}-slide-knob-wrapper__knob`
295
+ }))), children ? /*#__PURE__*/React__default.createElement("span", {
296
+ className: "label"
297
+ }, children) : null, /*#__PURE__*/React__default.createElement("input", _extends({}, inputProps, focusProps, {
298
+ "aria-checked": isSelected || isControlled && propsIsSelected ? 'true' : 'false',
299
+ "aria-disabled": isDisabled,
300
+ "aria-invalid": isInvalid || isRequired && !(isSelected || isControlled && propsIsSelected),
301
+ "aria-label": ariaLabel,
302
+ "aria-labelledby": ariaLabelledby,
303
+ "aria-readonly": isReadOnly,
304
+ "aria-required": isRequired,
305
+ autoFocus: autoFocus,
306
+ checked: isSelected || isControlled && propsIsSelected ? true : false,
307
+ disabled: isDisabled,
308
+ name: name,
309
+ onChange: handleChange,
310
+ ref: inputRef,
311
+ role: "switch",
312
+ type: "checkbox",
313
+ value: value
314
+ })));
315
+ });
316
+ Switch.className = CLASSNAME;
317
+ Switch.displayName = COMPONENT_NAME;
65
318
 
66
- export { SwitchProps as S, StyledSwitchProps as a, Switch as b };
319
+ export { Switch as S };
320
+ //# sourceMappingURL=Switch2.js.map
@@ -1,10 +1,188 @@
1
- import { b as SwitchGroupProps } from './types27.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 { S as SwitchGroupContext } from './context5.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 SwitchGroupOrientation = {
18
+ horizontal: 'horizontal',
19
+ vertical: 'vertical'
20
+ };
21
+
22
+ /**
23
+ * Component props.
24
+ */
25
+
26
+ /**
27
+ * Component style.
28
+ */
29
+ const StyledSwitchGroup = styled.div`
30
+ ${baseStyling}
31
+
32
+ display: flex;
33
+ flex-direction: column;
34
+
35
+ ${_ref => {
36
+ let {
37
+ $orientation
38
+ } = _ref;
39
+ return $orientation === SwitchGroupOrientation.vertical ? `
40
+ div.redsift-switch-group-switches {
41
+ display: flex;
42
+ flex-direction: column;
43
+ }
44
+ ` : `
45
+ div.redsift-switch-group-switches {
46
+ display: flex;
47
+ flex-direction: row;
48
+ flex-wrap: wrap;
49
+ }
50
+ `;
51
+ }}
52
+
53
+ span.redsift-switch-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-checkbox-text-disabled);
67
+ ` : $isInvalid ? css`
68
+ color: var(--redsift-color-${$theme}-components-checkbox-text-invalid);
69
+ ` : css`
70
+ color: var(--redsift-color-${$theme}-components-checkbox-text-default);
71
+ `;
72
+ }}
73
+ }
74
+
75
+ span.redsift-switch-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-checkbox-text-disabled);
89
+ ` : $isInvalid ? css`
90
+ color: var(--redsift-color-${$theme}-components-checkbox-text-invalid);
91
+ ` : css`
92
+ color: var(--redsift-color-${$theme}-components-checkbox-text-default);
93
+ `;
94
+ }}
95
+ }
96
+ `;
97
+
98
+ const _excluded = ["children", "className", "color", "defaultValues", "description", "isDisabled", "isInvalid", "isReadOnly", "isRequired", "label", "onChange", "orientation", "theme", "value"];
99
+ const COMPONENT_NAME = 'SwitchGroup';
100
+ const CLASSNAME = 'redsift-switch-group';
3
101
 
4
102
  /**
5
103
  * The SwitchGroup component.
6
104
  * Can be used as controlled or uncontrolled.
7
105
  */
8
- declare const SwitchGroup: Comp<SwitchGroupProps, HTMLDivElement>;
106
+ const SwitchGroup = /*#__PURE__*/forwardRef((props, ref) => {
107
+ const {
108
+ children,
109
+ className,
110
+ color = ColorPalette.primary,
111
+ defaultValues,
112
+ description,
113
+ isDisabled,
114
+ isInvalid,
115
+ isReadOnly,
116
+ isRequired,
117
+ label,
118
+ onChange,
119
+ orientation = SwitchGroupOrientation.vertical,
120
+ theme: propsTheme,
121
+ value
122
+ } = props,
123
+ forwardedProps = _objectWithoutProperties(props, _excluded);
124
+ const theme = useTheme(propsTheme);
125
+ const [selectedValues, setValue] = useState(value || defaultValues || []);
126
+ useEffect(() => {
127
+ if (value) {
128
+ state.setValue(value);
129
+ }
130
+ }, [value]);
131
+ const state = {
132
+ value: selectedValues,
133
+ isDisabled: isDisabled || false,
134
+ isReadOnly: isReadOnly || false,
135
+ setValue(values) {
136
+ if (isReadOnly || isDisabled) {
137
+ return;
138
+ }
139
+ setValue(values);
140
+ },
141
+ addValue(value) {
142
+ if (!selectedValues.includes(value)) {
143
+ setValue(selectedValues.concat(value));
144
+ if (onChange) {
145
+ onChange(selectedValues.concat(value));
146
+ }
147
+ }
148
+ },
149
+ removeValue(value) {
150
+ if (selectedValues.includes(value)) {
151
+ setValue(selectedValues.filter(existingValue => existingValue !== value));
152
+ if (onChange) {
153
+ onChange(selectedValues.filter(existingValue => existingValue !== value));
154
+ }
155
+ }
156
+ }
157
+ };
158
+ return /*#__PURE__*/React__default.createElement(ThemeProvider, {
159
+ value: {
160
+ theme
161
+ }
162
+ }, /*#__PURE__*/React__default.createElement(StyledSwitchGroup, _extends({
163
+ color: color
164
+ }, forwardedProps, {
165
+ $isDisabled: isDisabled,
166
+ $isInvalid: isInvalid || isRequired && selectedValues.length === 0,
167
+ $isReadOnly: isReadOnly,
168
+ $orientation: orientation,
169
+ $theme: theme,
170
+ "aria-disabled": isDisabled,
171
+ className: classNames(SwitchGroup.className, className),
172
+ ref: ref,
173
+ role: "group"
174
+ }), /*#__PURE__*/React__default.createElement("span", {
175
+ className: `${SwitchGroup.className}-label`
176
+ }, label, isRequired ? ' *' : null), /*#__PURE__*/React__default.createElement("div", {
177
+ className: `${SwitchGroup.className}-switches`
178
+ }, /*#__PURE__*/React__default.createElement(SwitchGroupContext.Provider, {
179
+ value: state
180
+ }, children)), /*#__PURE__*/React__default.createElement("span", {
181
+ className: `${SwitchGroup.className}-description`
182
+ }, description)));
183
+ });
184
+ SwitchGroup.className = CLASSNAME;
185
+ SwitchGroup.displayName = COMPONENT_NAME;
9
186
 
10
- export { SwitchGroup as S };
187
+ export { SwitchGroupOrientation as S, SwitchGroup as a };
188
+ //# sourceMappingURL=SwitchGroup.js.map
@@ -1,9 +1,51 @@
1
- import { b as TextProps } from './types28.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 { S as StyledText } from './styles5.js';
5
+ import { F as FontFamily } from './fonts.js';
6
+ import { u as useTheme } from './useTheme.js';
7
+
8
+ const _excluded = ["as", "children", "className", "color", "fontFamily", "fontSize", "fontWeight", "lineHeight", "noWrap", "theme", "variant"];
9
+ const COMPONENT_NAME = 'Text';
10
+ const CLASSNAME = 'redsift-text';
3
11
 
4
12
  /**
5
13
  * The Text component.
6
14
  */
7
- declare const Text: Comp<TextProps, HTMLDivElement>;
15
+ const Text = /*#__PURE__*/forwardRef((props, ref) => {
16
+ const {
17
+ as,
18
+ children,
19
+ className,
20
+ color,
21
+ fontFamily = FontFamily.poppins,
22
+ fontSize,
23
+ fontWeight,
24
+ lineHeight,
25
+ noWrap,
26
+ theme: propsTheme,
27
+ variant
28
+ } = props,
29
+ forwardedProps = _objectWithoutProperties(props, _excluded);
30
+ const theme = useTheme(propsTheme);
31
+ return /*#__PURE__*/React__default.createElement(StyledText, _extends({
32
+ as: as
33
+ }, forwardedProps, {
34
+ className: classNames(Text.className, className),
35
+ ref: ref,
36
+ $as: as,
37
+ $color: color,
38
+ $fontFamily: fontFamily,
39
+ $fontSize: fontSize,
40
+ $fontWeight: fontWeight,
41
+ $lineHeight: lineHeight,
42
+ $noWrap: noWrap,
43
+ $theme: theme,
44
+ $variant: variant
45
+ }), children);
46
+ });
47
+ Text.className = CLASSNAME;
48
+ Text.displayName = COMPONENT_NAME;
8
49
 
9
50
  export { Text as T };
51
+ //# sourceMappingURL=Text2.js.map