@ultraviolet/ui 1.8.4 → 1.9.0

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.
package/dist/index.d.ts CHANGED
@@ -1083,8 +1083,15 @@ declare const Carousel: {
1083
1083
 
1084
1084
  type CheckboxProps = {
1085
1085
  error?: string | ReactNode;
1086
+ /**
1087
+ * @deprecated Size prop is deprecated and will be removed in next major update.
1088
+ */
1086
1089
  size?: number;
1090
+ /**
1091
+ * @deprecated Progress prop is deprecated and will be removed in next major update.
1092
+ */
1087
1093
  progress?: boolean;
1094
+ helper?: ReactNode;
1088
1095
  disabled?: boolean;
1089
1096
  checked?: boolean | 'indeterminate';
1090
1097
  className?: string;
@@ -1692,7 +1699,7 @@ type ProgressBarProps = {
1692
1699
  declare const ProgressBar: ({ progress, value, sentiment, className, "data-testid": dataTestId, }: ProgressBarProps) => _emotion_react_jsx_runtime.JSX.Element;
1693
1700
 
1694
1701
  type RadioProps = {
1695
- error?: string | ReactNode;
1702
+ error?: ReactNode;
1696
1703
  checked?: boolean;
1697
1704
  value: string | number;
1698
1705
  helper?: ReactNode;
@@ -2322,6 +2329,7 @@ type ToggleProps = {
2322
2329
  size?: 'large' | 'small';
2323
2330
  labelPosition?: 'left' | 'right';
2324
2331
  label?: ReactNode;
2332
+ helper?: ReactNode;
2325
2333
  disabled?: boolean;
2326
2334
  className?: string;
2327
2335
  required?: boolean;
@@ -2362,6 +2370,21 @@ type VerificationCodeProps = {
2362
2370
  };
2363
2371
  declare const VerificationCode: ({ disabled, className, error, fields, initialValue, inputId, inputStyle, onChange, onComplete, placeholder, required, type, "data-testid": dataTestId, "aria-label": ariaLabel, }: VerificationCodeProps) => JSX.Element;
2364
2372
 
2373
+ type RadioGroupRadioProps = Omit<ComponentProps<typeof Radio>, 'onChange' | 'checked' | 'required'>;
2374
+ type RadioGroupProps = {
2375
+ legend: string;
2376
+ value: string | number;
2377
+ className?: string;
2378
+ helper?: ReactNode;
2379
+ error?: ReactNode;
2380
+ direction?: 'row' | 'column';
2381
+ children: ReactNode;
2382
+ } & Required<Pick<InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'name'>> & Pick<InputHTMLAttributes<HTMLInputElement>, 'required'>;
2383
+ declare const RadioGroup: {
2384
+ ({ legend, value, className, helper, error, direction, children, onChange, name, required, }: RadioGroupProps): _emotion_react_jsx_runtime.JSX.Element;
2385
+ Radio: ({ onFocus, onBlur, disabled, error, name, value, label, helper, className, autoFocus, onKeyDown, "data-testid": dataTestId, }: RadioGroupRadioProps) => _emotion_react_jsx_runtime.JSX.Element;
2386
+ };
2387
+
2365
2388
  declare const getUUID: (prefix?: string) => string;
2366
2389
 
2367
2390
  declare const bounce: _emotion_react.Keyframes;
@@ -2405,4 +2428,4 @@ declare const down: (size: ScreenSize, rules: string) => string;
2405
2428
 
2406
2429
  declare const normalize: () => string;
2407
2430
 
2408
- export { ActionBar, Alert, Avatar, Badge, Banner, BarChart, BarStack, Breadcrumbs, Breakpoint, Bullet, Button, Card, Carousel, Checkbox, CopyButton, DateInput, EmptyState, Expandable, LineChart, Link, List, Loader, Menu, Meter, Modal, Notice, NumberInput, Pagination, PasswordCheck, PasswordStrengthMeter, PieChart, Popover, ProgressBar, Radio, Row, SCWUITheme, SelectInput, SelectableCard, Separator, Skeleton, Snippet, Stack, Status, StepList, Stepper, SwitchButton, Table, Tabs, Tag, TagInput, TagList, Text, TextInput, TimeInput, ToastContainer, Toggle, Tooltip, VerificationCode, bounce, down, extendTheme, fadeIn, fadeOut, flash, getUUID, normalize, ping, pulse, quickScaleDown, scaleBack, scaleDown, scaleForward, scaleUp, sketchIn, sketchOut, slideDownLarge, slideFromBottom, slideFromLeft, slideFromRight, slideFromTop, slideToBottom, slideToLeft, slideToRight, slideToTop, slideUpLarge, toast, unfoldIn, unfoldOut, up, zoomIn, zoomOut };
2431
+ export { ActionBar, Alert, Avatar, Badge, Banner, BarChart, BarStack, Breadcrumbs, Breakpoint, Bullet, Button, Card, Carousel, Checkbox, CopyButton, DateInput, EmptyState, Expandable, LineChart, Link, List, Loader, Menu, Meter, Modal, Notice, NumberInput, Pagination, PasswordCheck, PasswordStrengthMeter, PieChart, Popover, ProgressBar, Radio, RadioGroup, Row, SCWUITheme, SelectInput, SelectableCard, Separator, Skeleton, Snippet, Stack, Status, StepList, Stepper, SwitchButton, Table, Tabs, Tag, TagInput, TagList, Text, TextInput, TimeInput, ToastContainer, Toggle, Tooltip, VerificationCode, bounce, down, extendTheme, fadeIn, fadeOut, flash, getUUID, normalize, ping, pulse, quickScaleDown, scaleBack, scaleDown, scaleForward, scaleUp, sketchIn, sketchOut, slideDownLarge, slideFromBottom, slideFromLeft, slideFromRight, slideFromTop, slideToBottom, slideToLeft, slideToRight, slideToTop, slideUpLarge, toast, unfoldIn, unfoldOut, up, zoomIn, zoomOut };
@@ -3,55 +3,54 @@ import { useTheme } from '@emotion/react';
3
3
  import { Icon } from '@ultraviolet/icons';
4
4
  import { forwardRef, useState, useId, useEffect, useCallback } from 'react';
5
5
  import { Loader } from '../Loader/index.js';
6
+ import { Row } from '../Row/index.js';
7
+ import { Stack } from '../Stack/index.js';
6
8
  import { Text } from '../Text/index.js';
7
- import { jsxs, Fragment, jsx } from '@emotion/react/jsx-runtime';
9
+ import { jsxs, jsx } from '@emotion/react/jsx-runtime';
8
10
 
9
11
  function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
10
- const InnerCheckbox = /*#__PURE__*/_styled("rect", {
12
+ const ErrorText = /*#__PURE__*/_styled(Text, {
11
13
  target: "eqr7bqq7"
12
- })("fill:", _ref => {
14
+ })("padding-top:", _ref => {
13
15
  let {
14
16
  theme
15
17
  } = _ref;
16
- return theme.colors.neutral.backgroundWeak;
17
- }, ";stroke:", _ref2 => {
18
+ return `${theme.space['0.5']}`;
19
+ }, ";");
20
+ const InnerCheckbox = /*#__PURE__*/_styled("rect", {
21
+ target: "eqr7bqq6"
22
+ })("fill:", _ref2 => {
18
23
  let {
19
24
  theme
20
25
  } = _ref2;
21
- return theme.colors.neutral.borderStrong;
26
+ return theme.colors.neutral.background;
27
+ }, ";stroke:", _ref3 => {
28
+ let {
29
+ theme
30
+ } = _ref3;
31
+ return theme.colors.neutral.border;
22
32
  }, ";");
23
- const CheckMark = /*#__PURE__*/_styled("rect", {
24
- target: "eqr7bqq6"
25
- })();
26
33
  const CheckMixedMark = /*#__PURE__*/_styled("rect", {
27
34
  target: "eqr7bqq5"
28
35
  })();
29
- const CheckboxIconContainer = _ref3 => {
36
+ const CheckboxIconContainer = _ref4 => {
30
37
  let {
31
38
  children
32
- } = _ref3;
39
+ } = _ref4;
33
40
  const theme = useTheme();
34
41
  return jsxs("g", {
35
42
  children: [jsx(InnerCheckbox, {
36
- x: "5",
37
- y: "5",
38
- width: "14",
39
- height: "14",
43
+ x: "2",
44
+ y: "2",
45
+ width: "20",
46
+ height: "20",
40
47
  rx: theme.radii.small,
41
48
  strokeWidth: "2"
42
49
  }), children]
43
50
  });
44
51
  };
45
- const PaddedText = /*#__PURE__*/_styled(Text, {
46
- target: "eqr7bqq4"
47
- })("padding:", _ref4 => {
48
- let {
49
- theme
50
- } = _ref4;
51
- return `0 ${theme.space['0.5']}`;
52
- }, ";");
53
52
  const StyledIcon = /*#__PURE__*/_styled('svg', {
54
- target: "eqr7bqq3"
53
+ target: "eqr7bqq4"
55
54
  })("border-radius:", _ref5 => {
56
55
  let {
57
56
  theme
@@ -77,149 +76,257 @@ const StyledIcon = /*#__PURE__*/_styled('svg', {
77
76
  size
78
77
  } = _ref9;
79
78
  return size;
80
- }, "px;");
79
+ }, "px;& path{fill:", _ref10 => {
80
+ let {
81
+ theme
82
+ } = _ref10;
83
+ return theme.colors.neutral.background;
84
+ }, ";transform:translate(2px, 2px);transform:scale(0);}");
85
+ const StyledLabel = /*#__PURE__*/_styled('label', {
86
+ target: "eqr7bqq3"
87
+ })();
81
88
  const CheckboxInput = /*#__PURE__*/_styled('input', {
82
89
  shouldForwardProp: prop => !['size'].includes(prop),
83
90
  target: "eqr7bqq2"
84
- })("position:absolute;white-space:nowrap;height:", _ref10 => {
85
- let {
86
- size
87
- } = _ref10;
88
- return size;
89
- }, "px;width:", _ref11 => {
91
+ })("position:absolute;white-space:nowrap;height:", _ref11 => {
90
92
  let {
91
93
  size
92
94
  } = _ref11;
93
95
  return size;
94
- }, "px;opacity:0;border-width:0;&:not(:disabled){cursor:pointer;}&:disabled{cursor:not-allowed;}&:not(:disabled){&:checked+", StyledIcon, ",&[aria-checked='mixed']+", StyledIcon, "{fill:", _ref12 => {
96
+ }, "px;width:", _ref12 => {
95
97
  let {
96
- theme
98
+ size
97
99
  } = _ref12;
98
- return theme.colors.primary.backgroundStrong;
99
- }, ";", InnerCheckbox, "{stroke:", _ref13 => {
100
+ return size;
101
+ }, "px;opacity:0;border-width:0;&:not(:disabled){cursor:pointer;}&:disabled{cursor:not-allowed;}&:not(:disabled){&:checked+", StyledIcon, ",&[aria-checked='mixed']+", StyledIcon, "{fill:", _ref13 => {
100
102
  let {
101
103
  theme
102
104
  } = _ref13;
103
105
  return theme.colors.primary.backgroundStrong;
104
- }, ";}}&[aria-invalid='true']+", StyledIcon, ",&[aria-invalid='mixed']+", StyledIcon, "{fill:", _ref14 => {
106
+ }, ";", InnerCheckbox, "{stroke:", _ref14 => {
105
107
  let {
106
108
  theme
107
109
  } = _ref14;
108
- return theme.colors.danger.backgroundStrong;
109
- }, ";", InnerCheckbox, "{stroke:", _ref15 => {
110
+ return theme.colors.primary.backgroundStrong;
111
+ }, ";}}&[aria-invalid='true']+", StyledIcon, ",&[aria-invalid='mixed']+", StyledIcon, "{fill:", _ref15 => {
110
112
  let {
111
113
  theme
112
114
  } = _ref15;
113
- return theme.colors.danger.backgroundStrong;
114
- }, ";}}}&:focus+", StyledIcon, "{background-color:", _ref16 => {
115
+ return theme.colors.danger.background;
116
+ }, ";", InnerCheckbox, "{stroke:", _ref16 => {
115
117
  let {
116
118
  theme
117
119
  } = _ref16;
118
- return theme.colors.primary.background;
119
- }, ";fill:", _ref17 => {
120
+ return theme.colors.danger.border;
121
+ }, ";}}}&:focus+", StyledIcon, "{background-color:", _ref17 => {
120
122
  let {
121
123
  theme
122
124
  } = _ref17;
123
- return theme.colors.primary.backgroundStrong;
124
- }, ";", InnerCheckbox, "{stroke:", _ref18 => {
125
+ return theme.colors.primary.background;
126
+ }, ";fill:", _ref18 => {
125
127
  let {
126
128
  theme
127
129
  } = _ref18;
128
- return theme.colors.primary.backgroundStrong;
129
- }, ";fill:", _ref19 => {
130
+ return theme.colors.danger.background;
131
+ }, ";outline:2px solid ", _ref19 => {
130
132
  let {
131
133
  theme
132
134
  } = _ref19;
133
- return theme.colors.primary.background;
134
- }, ";}}&[aria-invalid='true']:focus+", StyledIcon, "{background-color:", _ref20 => {
135
+ return theme.colors.primary.backgroundHover;
136
+ }, ";", InnerCheckbox, "{stroke:", _ref20 => {
135
137
  let {
136
138
  theme
137
139
  } = _ref20;
138
- return theme.colors.danger.background;
140
+ return theme.colors.primary.borderHover;
139
141
  }, ";fill:", _ref21 => {
140
142
  let {
141
143
  theme
142
144
  } = _ref21;
143
- return theme.colors.danger.backgroundStrong;
144
- }, ";", InnerCheckbox, "{stroke:", _ref22 => {
145
+ return theme.colors.primary.backgroundHover;
146
+ }, ";}}&[aria-invalid='true']:focus+", StyledIcon, "{background-color:", _ref22 => {
145
147
  let {
146
148
  theme
147
149
  } = _ref22;
148
- return theme.colors.danger.backgroundStrong;
150
+ return theme.colors.danger.background;
149
151
  }, ";fill:", _ref23 => {
150
152
  let {
151
153
  theme
152
154
  } = _ref23;
153
155
  return theme.colors.danger.background;
154
- }, ";}}");
155
- const CheckboxContainer = /*#__PURE__*/_styled("div", {
156
- target: "eqr7bqq1"
157
- })("position:relative;display:inline-flex;align-items:center;gap:", _ref24 => {
156
+ }, ";outline:2px solid ", _ref24 => {
158
157
  let {
159
158
  theme
160
159
  } = _ref24;
161
- return theme.space['1'];
162
- }, ";&[aria-disabled='false'],&[aria-disabled='false']>label{cursor:pointer;}&[aria-disabled='true']{cursor:not-allowed;color:", _ref25 => {
160
+ return theme.colors.danger.backgroundHover;
161
+ }, ";", InnerCheckbox, "{stroke:", _ref25 => {
163
162
  let {
164
163
  theme
165
164
  } = _ref25;
166
- return theme.colors.neutral.textDisabled;
167
- }, ";&>label{cursor:not-allowed;}", StyledIcon, "{fill:", _ref26 => {
165
+ return theme.colors.danger.borderHover;
166
+ }, ";fill:", _ref26 => {
168
167
  let {
169
168
  theme
170
169
  } = _ref26;
171
- return theme.colors.neutral.borderStrongDisabled;
172
- }, ";", InnerCheckbox, "{stroke:", _ref27 => {
170
+ return theme.colors.danger.backgroundHover;
171
+ }, ";}}");
172
+ const CheckboxContainer = /*#__PURE__*/_styled("div", {
173
+ target: "eqr7bqq1"
174
+ })("position:relative;display:inline-flex;align-items:start;gap:", _ref27 => {
173
175
  let {
174
176
  theme
175
177
  } = _ref27;
176
- return theme.colors.neutral.borderStrongDisabled;
177
- }, ";fill:", _ref28 => {
178
+ return theme.space['1'];
179
+ }, ";", StyledLabel, "{cursor:pointer;}&[aria-disabled='true']{cursor:not-allowed;color:", _ref28 => {
178
180
  let {
179
181
  theme
180
182
  } = _ref28;
181
- return theme.colors.neutral.backgroundDisabled;
182
- }, ";}}}", CheckMark, ",", CheckMixedMark, "{transform-origin:center;transition:200ms transform ease-in-out;transform:scale(0);}", CheckboxInput, ":checked+", StyledIcon, " ", CheckMark, "{transform:scale(1);}", CheckboxInput, "[aria-checked=\"mixed\"]+", StyledIcon, " ", CheckMixedMark, "{transform:scale(1);}&:hover[aria-disabled='false']{", CheckboxInput, "+", StyledIcon, "{background-color:", _ref29 => {
183
+ return theme.colors.neutral.textDisabled;
184
+ }, ";", StyledLabel, "{cursor:not-allowed;}", StyledIcon, "{fill:", _ref29 => {
183
185
  let {
184
186
  theme
185
187
  } = _ref29;
186
- return theme.colors.primary.background;
187
- }, ";fill:", _ref30 => {
188
+ return theme.colors.neutral.borderDisabled;
189
+ }, ";", InnerCheckbox, "{stroke:", _ref30 => {
188
190
  let {
189
191
  theme
190
192
  } = _ref30;
191
- return theme.colors.primary.backgroundStrong;
192
- }, ";", InnerCheckbox, "{stroke:", _ref31 => {
193
+ return theme.colors.neutral.borderDisabled;
194
+ }, ";fill:", _ref31 => {
193
195
  let {
194
196
  theme
195
197
  } = _ref31;
196
- return theme.colors.primary.backgroundStrong;
197
- }, ";fill:", _ref32 => {
198
+ return theme.colors.neutral.backgroundDisabled;
199
+ }, ";}}", CheckboxInput, "[aria-invalid=\"true\"]:checked+", StyledIcon, "{fill:", _ref32 => {
198
200
  let {
199
201
  theme
200
202
  } = _ref32;
201
- return theme.colors.primary.background;
202
- }, ";}}", CheckboxInput, "[aria-invalid=\"true\"]+", StyledIcon, "{background-color:", _ref33 => {
203
+ return theme.colors.danger.borderDisabled;
204
+ }, ";", InnerCheckbox, "{stroke:", _ref33 => {
203
205
  let {
204
206
  theme
205
207
  } = _ref33;
206
- return theme.colors.danger.background;
208
+ return theme.colors.danger.borderDisabled;
207
209
  }, ";fill:", _ref34 => {
208
210
  let {
209
211
  theme
210
212
  } = _ref34;
211
- return theme.colors.danger.backgroundStrong;
212
- }, ";", InnerCheckbox, "{stroke:", _ref35 => {
213
+ return theme.colors.danger.borderDisabled;
214
+ }, ";}}", CheckboxInput, "[aria-invalid=\"true\"]+", StyledIcon, "{fill:", _ref35 => {
213
215
  let {
214
216
  theme
215
217
  } = _ref35;
216
- return theme.colors.danger.backgroundStrong;
217
- }, ";fill:", _ref36 => {
218
+ return theme.colors.danger.background;
219
+ }, ";", InnerCheckbox, "{stroke:", _ref36 => {
218
220
  let {
219
221
  theme
220
222
  } = _ref36;
223
+ return theme.colors.danger.borderDisabled;
224
+ }, ";fill:", _ref37 => {
225
+ let {
226
+ theme
227
+ } = _ref37;
221
228
  return theme.colors.danger.background;
222
- }, ";}}}");
229
+ }, ";}}", CheckboxInput, ":checked+", StyledIcon, "{fill:", _ref38 => {
230
+ let {
231
+ theme
232
+ } = _ref38;
233
+ return theme.colors.primary.borderDisabled;
234
+ }, ";", InnerCheckbox, "{stroke:", _ref39 => {
235
+ let {
236
+ theme
237
+ } = _ref39;
238
+ return theme.colors.primary.borderDisabled;
239
+ }, ";fill:", _ref40 => {
240
+ let {
241
+ theme
242
+ } = _ref40;
243
+ return theme.colors.primary.borderDisabled;
244
+ }, ";}}", CheckboxInput, "[aria-checked=\"mixed\"]+", StyledIcon, "{fill:", _ref41 => {
245
+ let {
246
+ theme
247
+ } = _ref41;
248
+ return theme.colors.primary.borderDisabled;
249
+ }, ";", InnerCheckbox, "{stroke:", _ref42 => {
250
+ let {
251
+ theme
252
+ } = _ref42;
253
+ return theme.colors.primary.borderDisabled;
254
+ }, ";fill:", _ref43 => {
255
+ let {
256
+ theme
257
+ } = _ref43;
258
+ return theme.colors.primary.borderDisabled;
259
+ }, ";}}}", CheckboxInput, ":checked+", StyledIcon, " path{transform-origin:center;transition:200ms transform ease-in-out;transform:scale(1);transform:translate(2px, 2px);}", CheckboxInput, ":checked+", StyledIcon, " ", InnerCheckbox, "{fill:", _ref44 => {
260
+ let {
261
+ theme
262
+ } = _ref44;
263
+ return theme.colors.primary.border;
264
+ }, ";stroke:", _ref45 => {
265
+ let {
266
+ theme
267
+ } = _ref45;
268
+ return theme.colors.primary.border;
269
+ }, ";}", CheckboxInput, "[aria-invalid=\"true\"]:checked+", StyledIcon, " ", InnerCheckbox, "{fill:", _ref46 => {
270
+ let {
271
+ theme
272
+ } = _ref46;
273
+ return theme.colors.danger.border;
274
+ }, ";stroke:", _ref47 => {
275
+ let {
276
+ theme
277
+ } = _ref47;
278
+ return theme.colors.danger.border;
279
+ }, ";}", CheckboxInput, "[aria-checked=\"mixed\"]+", StyledIcon, "{", CheckMixedMark, "{fill:", _ref48 => {
280
+ let {
281
+ theme
282
+ } = _ref48;
283
+ return theme.colors.neutral.iconStronger;
284
+ }, ";}", InnerCheckbox, "{fill:", _ref49 => {
285
+ let {
286
+ theme
287
+ } = _ref49;
288
+ return theme.colors.primary.border;
289
+ }, ";stroke:", _ref50 => {
290
+ let {
291
+ theme
292
+ } = _ref50;
293
+ return theme.colors.primary.border;
294
+ }, ";}}&:hover[aria-disabled='false']{", CheckboxInput, "[aria-invalid='false']{&[aria-checked='false']+", StyledIcon, " ", InnerCheckbox, "{stroke:", _ref51 => {
295
+ let {
296
+ theme
297
+ } = _ref51;
298
+ return theme.colors.primary.borderHover;
299
+ }, ";fill:", _ref52 => {
300
+ let {
301
+ theme
302
+ } = _ref52;
303
+ return theme.colors.primary.backgroundHover;
304
+ }, ";}}", CheckboxInput, "[aria-invalid='true']{&[aria-checked='false']+", StyledIcon, " ", InnerCheckbox, "{stroke:", _ref53 => {
305
+ let {
306
+ theme
307
+ } = _ref53;
308
+ return theme.colors.danger.borderHover;
309
+ }, ";fill:", _ref54 => {
310
+ let {
311
+ theme
312
+ } = _ref54;
313
+ return theme.colors.danger.backgroundHover;
314
+ }, ";}}}", CheckboxInput, "[aria-invalid=\"true\"]+", StyledIcon, "{fill:", _ref55 => {
315
+ let {
316
+ theme
317
+ } = _ref55;
318
+ return theme.colors.danger.backgroundStrong;
319
+ }, ";", InnerCheckbox, "{stroke:", _ref56 => {
320
+ let {
321
+ theme
322
+ } = _ref56;
323
+ return theme.colors.danger.backgroundStrong;
324
+ }, ";fill:", _ref57 => {
325
+ let {
326
+ theme
327
+ } = _ref57;
328
+ return theme.colors.danger.background;
329
+ }, ";}}");
223
330
  const StyledActivityContainer = /*#__PURE__*/_styled("div", {
224
331
  target: "eqr7bqq0"
225
332
  })(process.env.NODE_ENV === "production" ? {
@@ -230,7 +337,7 @@ const StyledActivityContainer = /*#__PURE__*/_styled("div", {
230
337
  styles: "display:flex",
231
338
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__
232
339
  });
233
- const Checkbox = /*#__PURE__*/forwardRef((_ref37, ref) => {
340
+ const Checkbox = /*#__PURE__*/forwardRef((_ref58, ref) => {
234
341
  let {
235
342
  checked = false,
236
343
  onChange,
@@ -238,6 +345,7 @@ const Checkbox = /*#__PURE__*/forwardRef((_ref37, ref) => {
238
345
  onBlur,
239
346
  error,
240
347
  name,
348
+ helper,
241
349
  value,
242
350
  size = 24,
243
351
  children,
@@ -249,7 +357,7 @@ const Checkbox = /*#__PURE__*/forwardRef((_ref37, ref) => {
249
357
  'aria-label': ariaLabel,
250
358
  required,
251
359
  'data-testid': dataTestId
252
- } = _ref37;
360
+ } = _ref58;
253
361
  const [state, setState] = useState(checked);
254
362
  const id = useId();
255
363
  const computedName = name ?? id;
@@ -266,72 +374,84 @@ const Checkbox = /*#__PURE__*/forwardRef((_ref37, ref) => {
266
374
  setState(current => !current);
267
375
  }
268
376
  }, []);
269
- return jsxs(Fragment, {
270
- children: [jsxs(CheckboxContainer, {
271
- className: className,
272
- "aria-disabled": disabled,
273
- "data-visibility": dataVisibility,
274
- "data-checked": state,
275
- "data-error": !!error,
276
- "data-testid": dataTestId,
277
- children: [progress ? jsx(StyledActivityContainer, {
278
- children: jsx(Loader, {
279
- active: true,
280
- size: size
281
- })
282
- }) : null, jsx(CheckboxInput, {
283
- id: computedName,
284
- type: "checkbox",
285
- "aria-invalid": !!error,
286
- "aria-describedby": error ? `${computedName}-hint` : undefined,
287
- "aria-checked": state === 'indeterminate' ? 'mixed' : undefined,
288
- "aria-label": ariaLabel,
289
- checked: state === 'indeterminate' ? false : state,
290
- size: size,
291
- onChange: onLocalChange,
292
- onKeyDown: onKeyDown,
293
- onFocus: onFocus,
294
- onBlur: onBlur,
295
- disabled: disabled,
296
- value: value,
297
- name: computedName,
298
- autoFocus: autoFocus,
299
- ref: ref,
300
- required: required
301
- }), !progress ? jsx(StyledIcon, {
302
- size: size,
303
- viewBox: "0 0 24 24",
304
- children: jsxs(CheckboxIconContainer, {
305
- children: [jsx(CheckMixedMark, {
306
- x: "8",
307
- y: "11",
308
- rx: "1",
309
- width: "8",
310
- height: "2"
311
- }), jsx(CheckMark, {
312
- x: "8",
313
- y: "8",
314
- rx: "1",
315
- width: "8",
316
- height: "8"
317
- })]
318
- })
319
- }) : null, children ? jsx("label", {
320
- htmlFor: computedName,
321
- children: children
322
- }) : null, required ? jsx("sup", {
323
- children: jsx(Icon, {
324
- name: "asterisk",
325
- size: 10,
326
- color: "danger"
377
+ return jsxs(CheckboxContainer, {
378
+ className: className,
379
+ "aria-disabled": disabled,
380
+ "data-visibility": dataVisibility,
381
+ "data-checked": state,
382
+ "data-error": !!error,
383
+ "data-testid": dataTestId,
384
+ children: [progress ? jsx(StyledActivityContainer, {
385
+ children: jsx(Loader, {
386
+ active: true,
387
+ size: size
388
+ })
389
+ }) : null, jsx(CheckboxInput, {
390
+ id: computedName,
391
+ type: "checkbox",
392
+ "aria-invalid": !!error,
393
+ "aria-describedby": error ? `${computedName}-hint` : undefined,
394
+ "aria-checked": state === 'indeterminate' ? 'mixed' : state,
395
+ "aria-label": ariaLabel,
396
+ checked: state === 'indeterminate' ? false : state,
397
+ size: size,
398
+ onChange: onLocalChange,
399
+ onKeyDown: onKeyDown,
400
+ onFocus: onFocus,
401
+ onBlur: onBlur,
402
+ disabled: disabled,
403
+ value: value,
404
+ name: computedName,
405
+ autoFocus: autoFocus,
406
+ ref: ref,
407
+ required: required
408
+ }), !progress ? jsx(StyledIcon, {
409
+ size: size,
410
+ viewBox: "0 0 24 24",
411
+ children: jsx(CheckboxIconContainer, {
412
+ children: state !== 'indeterminate' ? jsx("path", {
413
+ fillRule: "evenodd",
414
+ clipRule: "evenodd",
415
+ width: 14,
416
+ height: 14,
417
+ d: "M15.6678 5.26709C16.0849 5.6463 16.113 6.28907 15.7307 6.70276L9.29172 13.6705C9.10291 13.8748 8.83818 13.9937 8.55884 13.9998C8.2795 14.0058 8.0098 13.8984 7.81223 13.7024L4.30004 10.2185C3.89999 9.82169 3.89999 9.17831 4.30004 8.78149C4.70009 8.38467 5.34869 8.38467 5.74874 8.78149L8.50441 11.5149L14.2205 5.32951C14.6028 4.91583 15.2508 4.88788 15.6678 5.26709Z",
418
+ fill: "white"
419
+ }) : jsx(CheckMixedMark, {
420
+ x: "6",
421
+ y: "11",
422
+ rx: "1",
423
+ width: "12",
424
+ height: "2"
327
425
  })
426
+ })
427
+ }) : null, jsxs(Stack, {
428
+ gap: 0.25,
429
+ children: [jsxs(Row, {
430
+ templateColumns: "11fr 1fr",
431
+ alignItems: "center",
432
+ children: [children ? jsx(StyledLabel, {
433
+ htmlFor: computedName,
434
+ children: children
435
+ }) : null, required ? jsx("sup", {
436
+ children: jsx(Icon, {
437
+ name: "asterisk",
438
+ size: 10,
439
+ color: "danger"
440
+ })
441
+ }) : null]
442
+ }), helper ? jsx(Text, {
443
+ variant: "bodySmall",
444
+ as: "p",
445
+ prominence: "weak",
446
+ color: "neutral",
447
+ children: helper
448
+ }) : null, error ? jsx(ErrorText, {
449
+ variant: "bodySmall",
450
+ as: "p",
451
+ color: "danger",
452
+ children: error
328
453
  }) : null]
329
- }), error ? jsx(PaddedText, {
330
- variant: "bodySmall",
331
- as: "p",
332
- color: "danger",
333
- children: error
334
- }) : null]
454
+ })]
335
455
  });
336
456
  });
337
457
 
@@ -0,0 +1,131 @@
1
+ import _styled from '@emotion/styled/base';
2
+ import { Icon } from '@ultraviolet/icons';
3
+ import { useMemo, createContext, useContext } from 'react';
4
+ import { Radio } from '../Radio/index.js';
5
+ import { Stack } from '../Stack/index.js';
6
+ import { Text } from '../Text/index.js';
7
+ import { jsx, jsxs } from '@emotion/react/jsx-runtime';
8
+
9
+ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
10
+ const RadioGroupContext = /*#__PURE__*/createContext(undefined);
11
+ const RadioGroupRadio = _ref => {
12
+ let {
13
+ onFocus,
14
+ onBlur,
15
+ disabled,
16
+ error,
17
+ name,
18
+ value,
19
+ label,
20
+ helper,
21
+ className,
22
+ autoFocus,
23
+ onKeyDown,
24
+ 'data-testid': dataTestId
25
+ } = _ref;
26
+ const context = useContext(RadioGroupContext);
27
+ if (!context) {
28
+ throw new Error('RadioGroup.Radio can only be used inside a RadioGroup');
29
+ }
30
+ const {
31
+ groupName,
32
+ onChange,
33
+ groupValue
34
+ } = context;
35
+ const radioName = `${groupName}-${name ?? ''}`;
36
+ return jsx(Radio, {
37
+ onChange: onChange,
38
+ checked: `${groupName}-${groupValue}` === radioName,
39
+ onFocus: onFocus,
40
+ onBlur: onBlur,
41
+ disabled: disabled,
42
+ error: error,
43
+ name: radioName,
44
+ value: value,
45
+ label: label,
46
+ helper: helper,
47
+ className: className,
48
+ autoFocus: autoFocus,
49
+ onKeyDown: onKeyDown,
50
+ "data-testid": dataTestId
51
+ });
52
+ };
53
+ const FieldSet = /*#__PURE__*/_styled("fieldset", {
54
+ target: "e15shfap1"
55
+ })(process.env.NODE_ENV === "production" ? {
56
+ name: "7o2an9",
57
+ styles: "border:none;padding:0;margin:0"
58
+ } : {
59
+ name: "7o2an9",
60
+ styles: "border:none;padding:0;margin:0",
61
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
62
+ });
63
+ const StyledRequiredIcon = /*#__PURE__*/_styled(Icon, {
64
+ target: "e15shfap0"
65
+ })(process.env.NODE_ENV === "production" ? {
66
+ name: "1nglpc5",
67
+ styles: "vertical-align:super"
68
+ } : {
69
+ name: "1nglpc5",
70
+ styles: "vertical-align:super",
71
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
72
+ });
73
+ const RadioGroup = _ref2 => {
74
+ let {
75
+ legend,
76
+ value,
77
+ className,
78
+ helper,
79
+ error,
80
+ direction = 'column',
81
+ children,
82
+ onChange,
83
+ name,
84
+ required = false
85
+ } = _ref2;
86
+ const contextValue = useMemo(() => ({
87
+ groupName: name,
88
+ groupValue: value,
89
+ onChange,
90
+ required
91
+ }), [name, value, onChange, required]);
92
+ return jsx(RadioGroupContext.Provider, {
93
+ value: contextValue,
94
+ children: jsxs(Stack, {
95
+ gap: 1,
96
+ children: [jsx(FieldSet, {
97
+ className: className,
98
+ children: jsxs(Stack, {
99
+ gap: 1.5,
100
+ children: [jsxs(Text, {
101
+ as: "legend",
102
+ variant: "bodyStrong",
103
+ children: [legend, "\xA0", required ? jsx(StyledRequiredIcon, {
104
+ name: "asterisk",
105
+ color: "danger",
106
+ size: 8
107
+ }) : null]
108
+ }), jsx(Stack, {
109
+ gap: direction === 'column' ? 1 : 2,
110
+ direction: direction,
111
+ children: children
112
+ })]
113
+ })
114
+ }), helper ? jsx(Text, {
115
+ as: "p",
116
+ variant: "bodySmall",
117
+ prominence: "weak",
118
+ children: helper
119
+ }) : null, error ? jsx(Text, {
120
+ as: "p",
121
+ variant: "bodySmall",
122
+ sentiment: "danger",
123
+ prominence: "weak",
124
+ children: error
125
+ }) : null]
126
+ })
127
+ });
128
+ };
129
+ RadioGroup.Radio = RadioGroupRadio;
130
+
131
+ export { RadioGroup };
@@ -1,8 +1,11 @@
1
1
  import _styled from '@emotion/styled/base';
2
2
  import { Icon } from '@ultraviolet/icons';
3
3
  import { forwardRef, useState, useId, useCallback, useEffect } from 'react';
4
+ import { Row } from '../Row/index.js';
5
+ import { Stack } from '../Stack/index.js';
6
+ import { Text } from '../Text/index.js';
4
7
  import { Tooltip } from '../Tooltip/index.js';
5
- import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
8
+ import { jsx, jsxs } from '@emotion/react/jsx-runtime';
6
9
 
7
10
  function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
8
11
  const SIZES = {
@@ -39,65 +42,75 @@ const StyledToggle = /*#__PURE__*/_styled("div", {
39
42
  size
40
43
  } = _ref4;
41
44
  return SIZES[size].height;
42
- }, "px;&:after{content:'';position:absolute;top:", _ref5 => {
45
+ }, "px;&:hover{background-color:", _ref5 => {
43
46
  let {
44
- size
47
+ theme
45
48
  } = _ref5;
46
- return SIZES[size].height / 2 - SIZES[size].ball / 2;
47
- }, "px;left:5px;width:", _ref6 => {
49
+ return theme.colors.neutral.backgroundStrongHover;
50
+ }, ";}&:after{content:'';position:absolute;top:", _ref6 => {
48
51
  let {
49
52
  size
50
53
  } = _ref6;
51
- return SIZES[size].ball;
52
- }, "px;height:", _ref7 => {
54
+ return SIZES[size].height / 2 - SIZES[size].ball / 2;
55
+ }, "px;left:5px;width:", _ref7 => {
53
56
  let {
54
57
  size
55
58
  } = _ref7;
56
59
  return SIZES[size].ball;
57
- }, "px;border-radius:", _ref8 => {
60
+ }, "px;height:", _ref8 => {
58
61
  let {
59
- theme
62
+ size
60
63
  } = _ref8;
61
- return theme.radii.circle;
62
- }, ";background-color:", _ref9 => {
64
+ return SIZES[size].ball;
65
+ }, "px;border-radius:", _ref9 => {
63
66
  let {
64
67
  theme
65
68
  } = _ref9;
66
- return theme.colors.neutral.background;
67
- }, ";transition:all 300ms;}&:focus-within,&:focus{box-shadow:", _ref10 => {
69
+ return theme.radii.circle;
70
+ }, ";background-color:", _ref10 => {
68
71
  let {
69
72
  theme
70
73
  } = _ref10;
71
- return theme.shadows.focusPrimary;
72
- }, ";}&[data-disabled='false']:active:after{width:", _ref11 => {
74
+ return theme.colors.neutral.background;
75
+ }, ";transition:all 300ms;}&:focus-within,&:focus{box-shadow:", _ref11 => {
73
76
  let {
74
- size
77
+ theme
75
78
  } = _ref11;
79
+ return theme.shadows.focusNeutral;
80
+ }, ";}&[data-disabled='false']:active:after{width:", _ref12 => {
81
+ let {
82
+ size
83
+ } = _ref12;
76
84
  return SIZES[size].ball * 1.3775;
77
- }, "px;}&[data-checked='true']{color:", _ref12 => {
85
+ }, "px;}&[data-checked='true']{color:", _ref13 => {
78
86
  let {
79
87
  theme
80
- } = _ref12;
88
+ } = _ref13;
81
89
  return theme.colors.neutral.textStrong;
82
- }, ";background-color:", _ref13 => {
90
+ }, ";background-color:", _ref14 => {
83
91
  let {
84
92
  theme
85
- } = _ref13;
93
+ } = _ref14;
86
94
  return theme.colors.primary.backgroundStrong;
87
- }, ";&:after{left:calc(100% - 5px);transform:translateX(-100%);}&:focus-within,&:focus{box-shadow:", _ref14 => {
95
+ }, ";&:hover{background-color:", _ref15 => {
88
96
  let {
89
97
  theme
90
- } = _ref14;
98
+ } = _ref15;
99
+ return theme.colors.primary.backgroundStrongHover;
100
+ }, ";}&:after{left:calc(100% - 5px);transform:translateX(-100%);}&:focus-within,&:focus{box-shadow:", _ref16 => {
101
+ let {
102
+ theme
103
+ } = _ref16;
91
104
  return theme.shadows.focusPrimary;
92
- }, ";}}&[data-disabled='true']{background:", _ref15 => {
105
+ }, ";}}&[data-disabled='true']{background:", _ref17 => {
93
106
  let {
94
107
  theme
95
- } = _ref15;
108
+ } = _ref17;
96
109
  return theme.colors.neutral.backgroundStrongDisabled;
97
- }, ";&[data-checked='true']{background:", _ref16 => {
110
+ }, ";&[data-checked='true']{background:", _ref18 => {
98
111
  let {
99
112
  theme
100
- } = _ref16;
113
+ } = _ref18;
101
114
  return theme.colors.primary.backgroundStrongDisabled;
102
115
  }, ";}}");
103
116
  const StyledCheckbox = /*#__PURE__*/_styled("input", {
@@ -112,20 +125,25 @@ const StyledCheckbox = /*#__PURE__*/_styled("input", {
112
125
  });
113
126
  const StyledLabel = /*#__PURE__*/_styled("label", {
114
127
  target: "e1wstm610"
115
- })("display:flex;gap:", _ref17 => {
128
+ })("display:flex;gap:", _ref19 => {
116
129
  let {
117
130
  theme
118
- } = _ref17;
131
+ } = _ref19;
119
132
  return theme.space['1'];
120
- }, ";align-items:center;width:fit-content;cursor:pointer;&:active ", StyledToggle, "[data-disabled='false']:after{width:", _ref18 => {
133
+ }, ";align-items:start;width:fit-content;cursor:pointer;flex-direction:", _ref20 => {
134
+ let {
135
+ labelPosition
136
+ } = _ref20;
137
+ return labelPosition === 'left' ? 'row' : 'row-reverse';
138
+ }, ";&:active ", StyledToggle, "[data-disabled='false']:after{width:", _ref21 => {
121
139
  let {
122
140
  size
123
- } = _ref18;
141
+ } = _ref21;
124
142
  return SIZES[size].ball * 1.3775;
125
- }, "px;}&[aria-disabled='true']{cursor:not-allowed;color:", _ref19 => {
143
+ }, "px;}&[aria-disabled='true']{cursor:not-allowed;color:", _ref22 => {
126
144
  let {
127
145
  theme
128
- } = _ref19;
146
+ } = _ref22;
129
147
  return theme.colors.neutral.textDisabled;
130
148
  }, ";}");
131
149
  const RequiredIcon = () => jsx("sup", {
@@ -135,7 +153,7 @@ const RequiredIcon = () => jsx("sup", {
135
153
  color: "danger"
136
154
  })
137
155
  });
138
- const Toggle = /*#__PURE__*/forwardRef((_ref20, ref) => {
156
+ const Toggle = /*#__PURE__*/forwardRef((_ref23, ref) => {
139
157
  let {
140
158
  checked = false,
141
159
  disabled = false,
@@ -146,10 +164,11 @@ const Toggle = /*#__PURE__*/forwardRef((_ref20, ref) => {
146
164
  tooltip,
147
165
  labelPosition = 'right',
148
166
  label,
167
+ helper,
149
168
  required,
150
169
  className,
151
170
  'data-testid': dataTestId
152
- } = _ref20;
171
+ } = _ref23;
153
172
  const [state, setState] = useState(checked);
154
173
  const uniqueId = useId();
155
174
  const onLocalChange = useCallback(event => {
@@ -166,9 +185,22 @@ const Toggle = /*#__PURE__*/forwardRef((_ref20, ref) => {
166
185
  onClick: evt => evt.stopPropagation(),
167
186
  className: className,
168
187
  "data-testid": dataTestId,
169
- children: [label && labelPosition === 'left' ? jsxs(Fragment, {
170
- children: [label, required ? jsx(RequiredIcon, {}) : null]
171
- }) : null, jsx(StyledToggle, {
188
+ labelPosition: labelPosition,
189
+ children: [jsxs(Stack, {
190
+ gap: 0.25,
191
+ alignItems: "baseline",
192
+ children: [label ? jsxs(Row, {
193
+ templateColumns: "auto 1fr",
194
+ gap: 1,
195
+ alignItems: "center",
196
+ children: [label, required ? jsx(RequiredIcon, {}) : null]
197
+ }) : null, helper ? jsx(Text, {
198
+ as: "p",
199
+ variant: "bodySmall",
200
+ prominence: "weak",
201
+ children: helper
202
+ }) : null]
203
+ }), jsx(StyledToggle, {
172
204
  size: size,
173
205
  "data-checked": state,
174
206
  "data-disabled": disabled,
@@ -182,9 +214,7 @@ const Toggle = /*#__PURE__*/forwardRef((_ref20, ref) => {
182
214
  type: "checkbox",
183
215
  ref: ref
184
216
  })
185
- }), label && labelPosition === 'right' ? jsxs(Fragment, {
186
- children: [label, required ? jsx(RequiredIcon, {}) : null]
187
- }) : null]
217
+ })]
188
218
  })
189
219
  });
190
220
  });
package/dist/src/index.js CHANGED
@@ -61,4 +61,5 @@ export { ToastContainer, toast } from './components/Toaster/index.js';
61
61
  export { Toggle } from './components/Toggle/index.js';
62
62
  export { Tooltip } from './components/Tooltip/index.js';
63
63
  export { VerificationCode } from './components/VerificationCode/index.js';
64
+ export { RadioGroup } from './components/RadioGroup/index.js';
64
65
  export { Icon } from '@ultraviolet/icons';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultraviolet/ui",
3
- "version": "1.8.4",
3
+ "version": "1.9.0",
4
4
  "description": "Ultraviolet UI",
5
5
  "homepage": "https://github.com/scaleway/ultraviolet#readme",
6
6
  "repository": {
@@ -68,6 +68,6 @@
68
68
  "react-use-clipboard": "1.0.9",
69
69
  "reakit": "1.3.11",
70
70
  "@ultraviolet/themes": "1.2.1",
71
- "@ultraviolet/icons": "1.2.3"
71
+ "@ultraviolet/icons": "1.3.0"
72
72
  }
73
73
  }