@panneau/ui 5.0.0-alpha.41 → 5.0.0-alpha.43
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/date-picker/DatePicker.css +6 -0
- package/dist/date-picker/DatePicker.d.ts +13 -1
- package/dist/date-picker/DatePicker.d.ts.map +1 -1
- package/dist/date-picker/DatePicker.js +206 -126
- package/dist/date-picker/DatePicker.js.map +1 -1
- package/dist/date-picker/DatePicker.module.js +4 -2
- package/dist/date-picker/DatePicker.module.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/radio-group/RadioGroup.css +115 -0
- package/dist/radio-group/RadioGroup.d.ts +15 -5
- package/dist/radio-group/RadioGroup.d.ts.map +1 -1
- package/dist/radio-group/RadioGroup.js +172 -128
- package/dist/radio-group/RadioGroup.js.map +1 -1
- package/dist/radio-group/RadioGroup.module.js +12 -2
- package/dist/radio-group/RadioGroup.module.js.map +1 -1
- package/dist/radio-group/tokens.d.ts +1 -1
- package/dist/radio-group/tokens.d.ts.map +1 -1
- package/dist/radio-group/tokens.js +8 -0
- package/dist/radio-group/tokens.js.map +1 -1
- package/dist/theme/components.d.ts +1 -1
- package/package.json +3 -3
|
@@ -172,3 +172,118 @@
|
|
|
172
172
|
.panneau-radio-group-card[data-focus-visible] .panneau-radio-group-circle {
|
|
173
173
|
outline: none;
|
|
174
174
|
}
|
|
175
|
+
|
|
176
|
+
/*
|
|
177
|
+
* Scale: the options as joined buttons of the same width in one row, the selected one filled, and
|
|
178
|
+
* what the two ends mean under them. It keeps the width of its options, at most that of the field.
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
.panneau-radio-group-scale-body {
|
|
182
|
+
display: inline-flex;
|
|
183
|
+
flex-direction: column;
|
|
184
|
+
align-self: flex-start;
|
|
185
|
+
gap: var(--panneau-space-1);
|
|
186
|
+
max-width: 100%;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.panneau-radio-group-scale .panneau-radio-group-options {
|
|
190
|
+
display: flex;
|
|
191
|
+
flex-flow: row nowrap;
|
|
192
|
+
gap: 0;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.panneau-radio-group-step {
|
|
196
|
+
display: inline-flex;
|
|
197
|
+
flex: 1 1 0;
|
|
198
|
+
align-items: center;
|
|
199
|
+
justify-content: center;
|
|
200
|
+
min-width: calc(var(--panneau-control-height) * 1.25);
|
|
201
|
+
min-height: var(--panneau-control-height);
|
|
202
|
+
padding: 0 var(--panneau-space-2);
|
|
203
|
+
font-size: var(--panneau-font-size-control);
|
|
204
|
+
font-weight: var(--panneau-font-weight-medium);
|
|
205
|
+
font-variant-numeric: var(--panneau-font-numeric);
|
|
206
|
+
color: var(--panneau-color-text);
|
|
207
|
+
cursor: pointer;
|
|
208
|
+
background-color: var(--panneau-radio-scale-bg, var(--panneau-color-surface));
|
|
209
|
+
border: var(--panneau-border-width) solid
|
|
210
|
+
var(--panneau-radio-scale-border-color, var(--panneau-color-border-control));
|
|
211
|
+
transition:
|
|
212
|
+
background-color var(--panneau-duration),
|
|
213
|
+
color var(--panneau-duration);
|
|
214
|
+
-webkit-tap-highlight-color: transparent;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.panneau-radio-group-step + .panneau-radio-group-step {
|
|
218
|
+
margin-inline-start: calc(-1 * var(--panneau-border-width));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.panneau-radio-group-step:first-child {
|
|
222
|
+
border-start-start-radius: var(--panneau-radius-md);
|
|
223
|
+
border-end-start-radius: var(--panneau-radius-md);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.panneau-radio-group-step:last-child {
|
|
227
|
+
border-start-end-radius: var(--panneau-radius-md);
|
|
228
|
+
border-end-end-radius: var(--panneau-radius-md);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.panneau-radio-group-step[data-hovered] {
|
|
232
|
+
background-color: var(--panneau-color-hover);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.panneau-radio-group-step[data-selected] {
|
|
236
|
+
position: relative;
|
|
237
|
+
color: var(
|
|
238
|
+
--panneau-radio-scale-selected-text,
|
|
239
|
+
var(--panneau-selected-text, var(--panneau-color-accent-text))
|
|
240
|
+
);
|
|
241
|
+
background-color: var(
|
|
242
|
+
--panneau-radio-scale-selected-bg,
|
|
243
|
+
var(--panneau-selected-bg, var(--panneau-color-accent))
|
|
244
|
+
);
|
|
245
|
+
border-color: var(
|
|
246
|
+
--panneau-radio-scale-selected-bg,
|
|
247
|
+
var(--panneau-selected-bg, var(--panneau-color-accent))
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.panneau-radio-group-step[data-invalid] {
|
|
252
|
+
border-color: var(--panneau-color-danger);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.panneau-radio-group-step[data-disabled] {
|
|
256
|
+
cursor: not-allowed;
|
|
257
|
+
opacity: 0.55;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.panneau-radio-group-step[data-readonly] {
|
|
261
|
+
cursor: default;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.panneau-radio-group-step[data-focus-visible] {
|
|
265
|
+
position: relative;
|
|
266
|
+
z-index: 1;
|
|
267
|
+
outline: var(--panneau-focus-width) solid var(--panneau-color-focus);
|
|
268
|
+
outline-offset: 2px;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.panneau-radio-group-ends {
|
|
272
|
+
display: flex;
|
|
273
|
+
justify-content: space-between;
|
|
274
|
+
gap: var(--panneau-space-3);
|
|
275
|
+
font-size: var(--panneau-font-size-sm);
|
|
276
|
+
color: var(--panneau-color-text-muted);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.panneau-radio-group-visually-hidden {
|
|
280
|
+
position: absolute;
|
|
281
|
+
width: 1px;
|
|
282
|
+
height: 1px;
|
|
283
|
+
padding: 0;
|
|
284
|
+
margin: -1px;
|
|
285
|
+
overflow: hidden;
|
|
286
|
+
clip-path: inset(50%);
|
|
287
|
+
white-space: nowrap;
|
|
288
|
+
border: 0;
|
|
289
|
+
}
|
|
@@ -7,8 +7,11 @@ export interface RadioGroupOption extends SelectOption {
|
|
|
7
7
|
/** Leading media, such as an avatar or an image, between the radio and the label. */
|
|
8
8
|
media?: ReactNode;
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* How a `RadioGroup` shows its options: a list of radios, bordered cards in a grid, or a scale of
|
|
12
|
+
* joined buttons in one row (a rating from 1 to 5).
|
|
13
|
+
*/
|
|
14
|
+
export type RadioGroupAppearance = 'list' | 'cards' | 'scale';
|
|
12
15
|
export interface RadioGroupProps extends Omit<AriaRadioGroupProps, 'className' | 'style' | 'children' | 'isInvalid' | 'validate' | 'value' | 'defaultValue' | 'onChange'>, FieldChromeProps {
|
|
13
16
|
options: readonly RadioGroupOption[];
|
|
14
17
|
value?: OptionValue | null;
|
|
@@ -21,11 +24,18 @@ export interface RadioGroupProps extends Omit<AriaRadioGroupProps, 'className' |
|
|
|
21
24
|
appearance?: RadioGroupAppearance;
|
|
22
25
|
/** Columns of cards, with `appearance="cards"`. Defaults to 2. */
|
|
23
26
|
columns?: number;
|
|
27
|
+
/**
|
|
28
|
+
* What the first and the last options mean, under them, with `appearance="scale"`: "Not at
|
|
29
|
+
* all" and "Completely". They are read with these options too.
|
|
30
|
+
*/
|
|
31
|
+
startLabel?: ReactNode;
|
|
32
|
+
endLabel?: ReactNode;
|
|
24
33
|
radioClassName?: string;
|
|
25
34
|
}
|
|
26
35
|
/**
|
|
27
|
-
* A set of options where one can be picked, all visible at once, as a list of radios
|
|
28
|
-
* (`appearance="cards"`). Arrow keys move between options in
|
|
36
|
+
* A set of options where one can be picked, all visible at once, as a list of radios, as cards
|
|
37
|
+
* (`appearance="cards"`) or as a scale (`appearance="scale"`). Arrow keys move between options in
|
|
38
|
+
* every appearance.
|
|
29
39
|
*/
|
|
30
|
-
export declare function RadioGroup({ options, value, onChange, label, description, errors, orientation, appearance, columns, isRequired, className, labelClassName, descriptionClassName, errorsClassName, radioClassName, ...props }: RadioGroupProps): import("react").JSX.Element;
|
|
40
|
+
export declare function RadioGroup({ options, value, onChange, label, description, errors, orientation, appearance, columns, startLabel, endLabel, isRequired, className, labelClassName, descriptionClassName, errorsClassName, radioClassName, ...props }: RadioGroupProps): import("react").JSX.Element;
|
|
31
41
|
//# sourceMappingURL=RadioGroup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../src/radio-group/RadioGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAEH,KAAK,eAAe,IAAI,mBAAmB,EAE9C,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,KAAK,gBAAgB,EAKxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIlE,qFAAqF;AACrF,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IAClD,qFAAqF;IACrF,KAAK,CAAC,EAAE,SAAS,CAAC;CACrB;AAED
|
|
1
|
+
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../src/radio-group/RadioGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAEH,KAAK,eAAe,IAAI,mBAAmB,EAE9C,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,KAAK,gBAAgB,EAKxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIlE,qFAAqF;AACrF,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IAClD,qFAAqF;IACrF,KAAK,CAAC,EAAE,SAAS,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAE9D,MAAM,WAAW,eACb,SACI,IAAI,CACA,mBAAmB,EACjB,WAAW,GACX,OAAO,GACP,UAAU,GACV,WAAW,GACX,UAAU,GACV,OAAO,GACP,cAAc,GACd,UAAU,CACf,EACD,gBAAgB;IACpB,OAAO,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACrC,KAAK,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACxC;;;;OAIG;IACH,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EACvB,OAAO,EACP,KAAK,EACL,QAAQ,EACR,KAAK,EACL,WAAW,EACX,MAAW,EACX,WAAwB,EACxB,UAAmB,EACnB,OAAW,EACX,UAAU,EACV,QAAQ,EACR,UAAU,EACV,SAAS,EACT,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,GAAG,KAAK,EACX,EAAE,eAAe,+BA4GjB"}
|
|
@@ -7,14 +7,16 @@ import { Radio, RadioGroup } from "react-aria-components";
|
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
//#region src/radio-group/RadioGroup.tsx
|
|
9
9
|
/**
|
|
10
|
-
* A set of options where one can be picked, all visible at once, as a list of radios
|
|
11
|
-
* (`appearance="cards"`). Arrow keys move between options in
|
|
10
|
+
* A set of options where one can be picked, all visible at once, as a list of radios, as cards
|
|
11
|
+
* (`appearance="cards"`) or as a scale (`appearance="scale"`). Arrow keys move between options in
|
|
12
|
+
* every appearance.
|
|
12
13
|
*/
|
|
13
14
|
function RadioGroup$1(t0) {
|
|
14
|
-
const $ = c(
|
|
15
|
+
const $ = c(75);
|
|
15
16
|
let className;
|
|
16
17
|
let description;
|
|
17
18
|
let descriptionClassName;
|
|
19
|
+
let endLabel;
|
|
18
20
|
let errorsClassName;
|
|
19
21
|
let isRequired;
|
|
20
22
|
let label;
|
|
@@ -23,64 +25,88 @@ function RadioGroup$1(t0) {
|
|
|
23
25
|
let options;
|
|
24
26
|
let props;
|
|
25
27
|
let radioClassName;
|
|
28
|
+
let startLabel;
|
|
26
29
|
let t1;
|
|
27
30
|
let t2;
|
|
28
31
|
let t3;
|
|
29
32
|
let t4;
|
|
30
33
|
let value;
|
|
31
34
|
if ($[0] !== t0) {
|
|
32
|
-
({options, value, onChange, label, description, errors: t1, orientation: t2, appearance: t3, columns: t4, isRequired, className, labelClassName, descriptionClassName, errorsClassName, radioClassName, ...props} = t0);
|
|
35
|
+
({options, value, onChange, label, description, errors: t1, orientation: t2, appearance: t3, columns: t4, startLabel, endLabel, isRequired, className, labelClassName, descriptionClassName, errorsClassName, radioClassName, ...props} = t0);
|
|
33
36
|
$[0] = t0;
|
|
34
37
|
$[1] = className;
|
|
35
38
|
$[2] = description;
|
|
36
39
|
$[3] = descriptionClassName;
|
|
37
|
-
$[4] =
|
|
38
|
-
$[5] =
|
|
39
|
-
$[6] =
|
|
40
|
-
$[7] =
|
|
41
|
-
$[8] =
|
|
42
|
-
$[9] =
|
|
43
|
-
$[10] =
|
|
44
|
-
$[11] =
|
|
45
|
-
$[12] =
|
|
46
|
-
$[13] =
|
|
47
|
-
$[14] =
|
|
48
|
-
$[15] =
|
|
49
|
-
$[16] =
|
|
40
|
+
$[4] = endLabel;
|
|
41
|
+
$[5] = errorsClassName;
|
|
42
|
+
$[6] = isRequired;
|
|
43
|
+
$[7] = label;
|
|
44
|
+
$[8] = labelClassName;
|
|
45
|
+
$[9] = onChange;
|
|
46
|
+
$[10] = options;
|
|
47
|
+
$[11] = props;
|
|
48
|
+
$[12] = radioClassName;
|
|
49
|
+
$[13] = startLabel;
|
|
50
|
+
$[14] = t1;
|
|
51
|
+
$[15] = t2;
|
|
52
|
+
$[16] = t3;
|
|
53
|
+
$[17] = t4;
|
|
54
|
+
$[18] = value;
|
|
50
55
|
} else {
|
|
51
56
|
className = $[1];
|
|
52
57
|
description = $[2];
|
|
53
58
|
descriptionClassName = $[3];
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
endLabel = $[4];
|
|
60
|
+
errorsClassName = $[5];
|
|
61
|
+
isRequired = $[6];
|
|
62
|
+
label = $[7];
|
|
63
|
+
labelClassName = $[8];
|
|
64
|
+
onChange = $[9];
|
|
65
|
+
options = $[10];
|
|
66
|
+
props = $[11];
|
|
67
|
+
radioClassName = $[12];
|
|
68
|
+
startLabel = $[13];
|
|
69
|
+
t1 = $[14];
|
|
70
|
+
t2 = $[15];
|
|
71
|
+
t3 = $[16];
|
|
72
|
+
t4 = $[17];
|
|
73
|
+
value = $[18];
|
|
67
74
|
}
|
|
68
75
|
let t5;
|
|
69
|
-
if ($[
|
|
76
|
+
if ($[19] !== t1) {
|
|
70
77
|
t5 = t1 === void 0 ? [] : t1;
|
|
71
|
-
$[
|
|
72
|
-
$[
|
|
73
|
-
} else t5 = $[
|
|
78
|
+
$[19] = t1;
|
|
79
|
+
$[20] = t5;
|
|
80
|
+
} else t5 = $[20];
|
|
74
81
|
const errors = t5;
|
|
75
82
|
const orientation = t2 === void 0 ? "vertical" : t2;
|
|
76
83
|
const appearance = t3 === void 0 ? "list" : t3;
|
|
77
84
|
const columns = t4 === void 0 ? 2 : t4;
|
|
85
|
+
const isScale = appearance === "scale";
|
|
86
|
+
const hasEnds = isScale && (startLabel !== void 0 && startLabel !== null || endLabel !== void 0 && endLabel !== null);
|
|
78
87
|
let t6;
|
|
79
|
-
if ($[
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
if ($[21] !== endLabel || $[22] !== options.length || $[23] !== startLabel) {
|
|
89
|
+
t6 = (position) => position === 0 ? startLabel : position === options.length - 1 ? endLabel : null;
|
|
90
|
+
$[21] = endLabel;
|
|
91
|
+
$[22] = options.length;
|
|
92
|
+
$[23] = startLabel;
|
|
93
|
+
$[24] = t6;
|
|
94
|
+
} else t6 = $[24];
|
|
95
|
+
const endOf = t6;
|
|
96
|
+
let t7;
|
|
97
|
+
if ($[25] !== appearance || $[26] !== endOf || $[27] !== isScale || $[28] !== options || $[29] !== radioClassName) {
|
|
98
|
+
let t8;
|
|
99
|
+
if ($[31] !== appearance || $[32] !== endOf || $[33] !== isScale || $[34] !== radioClassName) {
|
|
100
|
+
t8 = (option, position_0) => isScale ? /* @__PURE__ */ jsxs(Radio, {
|
|
101
|
+
value: String(position_0),
|
|
102
|
+
isDisabled: option.disabled,
|
|
103
|
+
className: cx("panneau-radio", RadioGroup_module_default.step, radioClassName),
|
|
104
|
+
children: [option.label, endOf(position_0) !== void 0 && endOf(position_0) !== null ? /* @__PURE__ */ jsxs("span", {
|
|
105
|
+
className: RadioGroup_module_default.visuallyHidden,
|
|
106
|
+
children: [", ", endOf(position_0)]
|
|
107
|
+
}) : null]
|
|
108
|
+
}, position_0) : /* @__PURE__ */ jsxs(Radio, {
|
|
109
|
+
value: String(position_0),
|
|
84
110
|
isDisabled: option.disabled,
|
|
85
111
|
className: cx("panneau-radio", RadioGroup_module_default.radio, appearance === "cards" && RadioGroup_module_default.card, radioClassName),
|
|
86
112
|
children: [
|
|
@@ -103,128 +129,146 @@ function RadioGroup$1(t0) {
|
|
|
103
129
|
}) : null]
|
|
104
130
|
})
|
|
105
131
|
]
|
|
106
|
-
},
|
|
107
|
-
$[
|
|
108
|
-
$[
|
|
109
|
-
$[
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
$[
|
|
113
|
-
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
132
|
+
}, position_0);
|
|
133
|
+
$[31] = appearance;
|
|
134
|
+
$[32] = endOf;
|
|
135
|
+
$[33] = isScale;
|
|
136
|
+
$[34] = radioClassName;
|
|
137
|
+
$[35] = t8;
|
|
138
|
+
} else t8 = $[35];
|
|
139
|
+
t7 = options.map(t8);
|
|
140
|
+
$[25] = appearance;
|
|
141
|
+
$[26] = endOf;
|
|
142
|
+
$[27] = isScale;
|
|
143
|
+
$[28] = options;
|
|
144
|
+
$[29] = radioClassName;
|
|
145
|
+
$[30] = t7;
|
|
146
|
+
} else t7 = $[30];
|
|
147
|
+
const radios = t7;
|
|
148
|
+
let t8;
|
|
149
|
+
if ($[36] !== options || $[37] !== value) {
|
|
150
|
+
t8 = value === void 0 ? void 0 : options.findIndex((o) => o.value === value);
|
|
151
|
+
$[36] = options;
|
|
152
|
+
$[37] = value;
|
|
153
|
+
$[38] = t8;
|
|
154
|
+
} else t8 = $[38];
|
|
155
|
+
const index = t8;
|
|
156
|
+
const t9 = index === void 0 ? void 0 : index === -1 ? null : String(index);
|
|
157
|
+
let t10;
|
|
158
|
+
if ($[39] !== onChange || $[40] !== options) {
|
|
159
|
+
t10 = (key) => {
|
|
130
160
|
const option_0 = options[Number(key)];
|
|
131
161
|
if (option_0 !== void 0) onChange?.(option_0.value);
|
|
132
162
|
};
|
|
133
|
-
$[
|
|
134
|
-
$[
|
|
135
|
-
$[
|
|
136
|
-
} else
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
let t12;
|
|
140
|
-
if ($[32] !== className || $[33] !== t11) {
|
|
141
|
-
t12 = cx("panneau-radio-group", Field_module_default.field, t11, className);
|
|
142
|
-
$[32] = className;
|
|
143
|
-
$[33] = t11;
|
|
144
|
-
$[34] = t12;
|
|
145
|
-
} else t12 = $[34];
|
|
163
|
+
$[39] = onChange;
|
|
164
|
+
$[40] = options;
|
|
165
|
+
$[41] = t10;
|
|
166
|
+
} else t10 = $[41];
|
|
167
|
+
const t11 = errors.length > 0;
|
|
168
|
+
const t12 = appearance === "cards" ? RadioGroup_module_default.cards : isScale ? RadioGroup_module_default.scale : orientation === "horizontal" && RadioGroup_module_default.horizontal;
|
|
146
169
|
let t13;
|
|
147
|
-
if ($[
|
|
148
|
-
t13 =
|
|
170
|
+
if ($[42] !== className || $[43] !== t12) {
|
|
171
|
+
t13 = cx("panneau-radio-group", Field_module_default.field, t12, className);
|
|
172
|
+
$[42] = className;
|
|
173
|
+
$[43] = t12;
|
|
174
|
+
$[44] = t13;
|
|
175
|
+
} else t13 = $[44];
|
|
176
|
+
let t14;
|
|
177
|
+
if ($[45] !== isRequired || $[46] !== label || $[47] !== labelClassName) {
|
|
178
|
+
t14 = /* @__PURE__ */ jsx(FieldLabel, {
|
|
149
179
|
isRequired,
|
|
150
180
|
className: labelClassName,
|
|
151
181
|
children: label
|
|
152
182
|
});
|
|
153
|
-
$[
|
|
154
|
-
$[
|
|
155
|
-
$[
|
|
156
|
-
$[
|
|
157
|
-
} else
|
|
158
|
-
let
|
|
159
|
-
if ($[
|
|
160
|
-
|
|
183
|
+
$[45] = isRequired;
|
|
184
|
+
$[46] = label;
|
|
185
|
+
$[47] = labelClassName;
|
|
186
|
+
$[48] = t14;
|
|
187
|
+
} else t14 = $[48];
|
|
188
|
+
let t15;
|
|
189
|
+
if ($[49] !== appearance || $[50] !== columns || $[51] !== endLabel || $[52] !== hasEnds || $[53] !== isScale || $[54] !== radios || $[55] !== startLabel) {
|
|
190
|
+
t15 = appearance === "cards" ? /* @__PURE__ */ jsx("div", {
|
|
161
191
|
className: RadioGroup_module_default.grid,
|
|
162
192
|
children: /* @__PURE__ */ jsx("div", {
|
|
163
193
|
className: RadioGroup_module_default.options,
|
|
164
194
|
style: { "--_panneau-radio-group-columns": String(Math.max(1, Math.floor(columns))) },
|
|
165
195
|
children: radios
|
|
166
196
|
})
|
|
197
|
+
}) : isScale ? /* @__PURE__ */ jsxs("div", {
|
|
198
|
+
className: RadioGroup_module_default.scaleBody,
|
|
199
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
200
|
+
className: RadioGroup_module_default.options,
|
|
201
|
+
children: radios
|
|
202
|
+
}), hasEnds ? /* @__PURE__ */ jsxs("div", {
|
|
203
|
+
className: RadioGroup_module_default.ends,
|
|
204
|
+
"aria-hidden": "true",
|
|
205
|
+
children: [/* @__PURE__ */ jsx("span", { children: startLabel }), /* @__PURE__ */ jsx("span", { children: endLabel })]
|
|
206
|
+
}) : null]
|
|
167
207
|
}) : /* @__PURE__ */ jsx("div", {
|
|
168
208
|
className: RadioGroup_module_default.options,
|
|
169
209
|
children: radios
|
|
170
210
|
});
|
|
171
|
-
$[
|
|
172
|
-
$[
|
|
173
|
-
$[
|
|
174
|
-
$[
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
211
|
+
$[49] = appearance;
|
|
212
|
+
$[50] = columns;
|
|
213
|
+
$[51] = endLabel;
|
|
214
|
+
$[52] = hasEnds;
|
|
215
|
+
$[53] = isScale;
|
|
216
|
+
$[54] = radios;
|
|
217
|
+
$[55] = startLabel;
|
|
218
|
+
$[56] = t15;
|
|
219
|
+
} else t15 = $[56];
|
|
220
|
+
let t16;
|
|
221
|
+
if ($[57] !== description || $[58] !== descriptionClassName) {
|
|
222
|
+
t16 = /* @__PURE__ */ jsx(FieldDescription, {
|
|
179
223
|
className: descriptionClassName,
|
|
180
224
|
children: description
|
|
181
225
|
});
|
|
182
|
-
$[
|
|
183
|
-
$[
|
|
184
|
-
$[
|
|
185
|
-
} else
|
|
186
|
-
let
|
|
187
|
-
if ($[
|
|
188
|
-
|
|
226
|
+
$[57] = description;
|
|
227
|
+
$[58] = descriptionClassName;
|
|
228
|
+
$[59] = t16;
|
|
229
|
+
} else t16 = $[59];
|
|
230
|
+
let t17;
|
|
231
|
+
if ($[60] !== errors || $[61] !== errorsClassName) {
|
|
232
|
+
t17 = /* @__PURE__ */ jsx(FieldErrors, {
|
|
189
233
|
errors,
|
|
190
234
|
className: errorsClassName
|
|
191
235
|
});
|
|
192
|
-
$[
|
|
193
|
-
$[
|
|
194
|
-
$[
|
|
195
|
-
} else
|
|
196
|
-
let
|
|
197
|
-
if ($[
|
|
198
|
-
|
|
236
|
+
$[60] = errors;
|
|
237
|
+
$[61] = errorsClassName;
|
|
238
|
+
$[62] = t17;
|
|
239
|
+
} else t17 = $[62];
|
|
240
|
+
let t18;
|
|
241
|
+
if ($[63] !== isRequired || $[64] !== orientation || $[65] !== props || $[66] !== t10 || $[67] !== t11 || $[68] !== t13 || $[69] !== t14 || $[70] !== t15 || $[71] !== t16 || $[72] !== t17 || $[73] !== t9) {
|
|
242
|
+
t18 = /* @__PURE__ */ jsxs(RadioGroup, {
|
|
199
243
|
...props,
|
|
200
244
|
orientation,
|
|
201
245
|
isRequired,
|
|
202
|
-
value:
|
|
203
|
-
onChange:
|
|
204
|
-
isInvalid:
|
|
246
|
+
value: t9,
|
|
247
|
+
onChange: t10,
|
|
248
|
+
isInvalid: t11,
|
|
205
249
|
validationBehavior: "aria",
|
|
206
|
-
className:
|
|
250
|
+
className: t13,
|
|
207
251
|
children: [
|
|
208
|
-
t13,
|
|
209
252
|
t14,
|
|
210
253
|
t15,
|
|
211
|
-
t16
|
|
254
|
+
t16,
|
|
255
|
+
t17
|
|
212
256
|
]
|
|
213
257
|
});
|
|
214
|
-
$[
|
|
215
|
-
$[
|
|
216
|
-
$[
|
|
217
|
-
$[
|
|
218
|
-
$[
|
|
219
|
-
$[
|
|
220
|
-
$[
|
|
221
|
-
$[
|
|
222
|
-
$[
|
|
223
|
-
$[
|
|
224
|
-
$[
|
|
225
|
-
$[
|
|
226
|
-
} else
|
|
227
|
-
return
|
|
258
|
+
$[63] = isRequired;
|
|
259
|
+
$[64] = orientation;
|
|
260
|
+
$[65] = props;
|
|
261
|
+
$[66] = t10;
|
|
262
|
+
$[67] = t11;
|
|
263
|
+
$[68] = t13;
|
|
264
|
+
$[69] = t14;
|
|
265
|
+
$[70] = t15;
|
|
266
|
+
$[71] = t16;
|
|
267
|
+
$[72] = t17;
|
|
268
|
+
$[73] = t9;
|
|
269
|
+
$[74] = t18;
|
|
270
|
+
} else t18 = $[74];
|
|
271
|
+
return t18;
|
|
228
272
|
}
|
|
229
273
|
//#endregion
|
|
230
274
|
export { RadioGroup$1 as RadioGroup };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","names":["CSSProperties","ReactNode","RadioGroup","AriaRadioGroup","RadioGroupProps","AriaRadioGroupProps","Radio","FieldChromeProps","FieldDescription","FieldErrors","FieldLabel","fieldStyles","OptionValue","SelectOption","cx","styles","RadioGroupOption","media","RadioGroupAppearance","Omit","options","value","onChange","appearance","columns","radioClassName","t0","$","_c","className","description","descriptionClassName","errorsClassName","isRequired","label","labelClassName","props","t1","t2","t3","t4","errors","orientation","t5","undefined","t6","t7","option","position","String","disabled","radio","card","circle","text","optionLabel","map","radios","findIndex","o","index","t8","t9","key","option_0","Number","t10","length","t11","cards","horizontal","t12","field","t13","t14","grid","Math","max","floor","t15","t16","t17","RadioGroup","_c","styles","fieldStyles","AriaRadioGroup"],"sources":["../../src/radio-group/RadioGroup.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from 'react';\nimport {\n RadioGroup as AriaRadioGroup,\n type RadioGroupProps as AriaRadioGroupProps,\n Radio,\n} from 'react-aria-components';\n\nimport {\n type FieldChromeProps,\n FieldDescription,\n FieldErrors,\n FieldLabel,\n fieldStyles,\n} from '../field/FieldParts';\nimport type { OptionValue, SelectOption } from '../select/Select';\nimport { cx } from '../utils/cx';\nimport styles from './RadioGroup.module.css';\n\n/** An option of a `RadioGroup`: a `SelectOption`, with an optional leading media. */\nexport interface RadioGroupOption extends SelectOption {\n /** Leading media, such as an avatar or an image, between the radio and the label. */\n media?: ReactNode;\n}\n\n/** How a `RadioGroup` shows its options: a list of radios, or bordered cards in a grid. */\nexport type RadioGroupAppearance = 'list' | 'cards';\n\nexport interface RadioGroupProps\n extends\n Omit<\n AriaRadioGroupProps,\n | 'className'\n | 'style'\n | 'children'\n | 'isInvalid'\n | 'validate'\n | 'value'\n | 'defaultValue'\n | 'onChange'\n >,\n FieldChromeProps {\n options: readonly RadioGroupOption[];\n value?: OptionValue | null;\n onChange?: (value: OptionValue) => void;\n /**\n * `list` (default) shows the options as radios, one under the other or side by side with\n * `orientation=\"horizontal\"`. `cards` shows them as bordered cards in a grid of `columns`, which\n * becomes a single column in a narrow container. The selected card has a stronger border.\n */\n appearance?: RadioGroupAppearance;\n /** Columns of cards, with `appearance=\"cards\"`. Defaults to 2. */\n columns?: number;\n radioClassName?: string;\n}\n\n/**\n * A set of options where one can be picked, all visible at once, as a list of radios or as cards\n * (`appearance=\"cards\"`). Arrow keys move between options in both appearances.\n */\nexport function RadioGroup({\n options,\n value,\n onChange,\n label,\n description,\n errors = [],\n orientation = 'vertical',\n appearance = 'list',\n columns = 2,\n isRequired,\n className,\n labelClassName,\n descriptionClassName,\n errorsClassName,\n radioClassName,\n ...props\n}: RadioGroupProps) {\n const radios = options.map((option, position) => (\n <Radio\n key={position}\n value={String(position)}\n isDisabled={option.disabled}\n className={cx(\n 'panneau-radio',\n styles.radio,\n appearance === 'cards' && styles.card,\n radioClassName,\n )}\n >\n <span className={styles.circle} aria-hidden=\"true\" />\n {option.media !== undefined && option.media !== null ? (\n <span className={styles.media}>{option.media}</span>\n ) : null}\n <span className={styles.text}>\n <span className={styles.optionLabel}>{option.label}</span>\n {option.description !== undefined ? (\n <span className={styles.description}>{option.description}</span>\n ) : null}\n </span>\n </Radio>\n ));\n const index = value === undefined ? undefined : options.findIndex((o) => o.value === value);\n return (\n <AriaRadioGroup\n {...props}\n orientation={orientation}\n isRequired={isRequired}\n value={index === undefined ? undefined : index === -1 ? null : String(index)}\n onChange={(key) => {\n const option = options[Number(key)];\n if (option !== undefined) {\n onChange?.(option.value);\n }\n }}\n isInvalid={errors.length > 0}\n validationBehavior=\"aria\"\n className={cx(\n 'panneau-radio-group',\n fieldStyles.field,\n appearance === 'cards'\n ? styles.cards\n : orientation === 'horizontal' && styles.horizontal,\n className,\n )}\n >\n <FieldLabel isRequired={isRequired} className={labelClassName}>\n {label}\n </FieldLabel>\n {appearance === 'cards' ? (\n <div className={styles.grid}>\n <div\n className={styles.options}\n style={\n {\n '--_panneau-radio-group-columns': String(\n Math.max(1, Math.floor(columns)),\n ),\n } as CSSProperties\n }\n >\n {radios}\n </div>\n </div>\n ) : (\n <div className={styles.options}>{radios}</div>\n )}\n <FieldDescription className={descriptionClassName}>{description}</FieldDescription>\n <FieldErrors errors={errors} className={errorsClassName} />\n </AriaRadioGroup>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA2DA,SAAOE,aAAAwB,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAb;CAAA,IAAAF;CAAA,IAAAgB;CAAA,IAAAX;CAAA,IAAAY;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAnB;CAAA,IAAAM,EAAA,OAAAD,IAAA;EAAoB,CAAA,CAAAN,SAAAC,OAAAC,UAAAY,OAAAJ,aAAAW,QAAAJ,IAAAK,aAAAJ,IAAAf,YAAAgB,IAAAf,SAAAgB,IAAAP,YAAAJ,WAAAM,gBAAAJ,sBAAAC,iBAAAP,gBAAA,GAAAW,SAAAV;EAiBTC,EAAA,KAAAD;EAAAC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,EAAA,MAAA8C;EAAA9C,EAAA,MAAA+C;EAAA/C,EAAA,MAAAoD;EAAApD,EAAA,MAAAqD;EAAArD,EAAA,MAAAkC;EAAAlC,EAAA,MAAAmC;EAAAnC,EAAA,MAAAsD;CAAA,OAAAA,MAAAtD,EAAA;CAAA,OA7CjBsD;AA6CiB"}
|
|
1
|
+
{"version":3,"file":"RadioGroup.js","names":["CSSProperties","ReactNode","RadioGroup","AriaRadioGroup","RadioGroupProps","AriaRadioGroupProps","Radio","FieldChromeProps","FieldDescription","FieldErrors","FieldLabel","fieldStyles","OptionValue","SelectOption","cx","styles","RadioGroupOption","media","RadioGroupAppearance","Omit","options","value","onChange","appearance","columns","startLabel","endLabel","radioClassName","t0","$","_c","className","description","descriptionClassName","errorsClassName","isRequired","label","labelClassName","props","t1","t2","t3","t4","errors","orientation","t5","undefined","isScale","hasEnds","t6","length","position","endOf","t7","t8","option","position_0","String","disabled","step","visuallyHidden","radio","card","circle","text","optionLabel","map","radios","findIndex","o","index","t9","t10","key","option_0","Number","t11","t12","cards","scale","horizontal","t13","field","t14","t15","grid","Math","max","floor","scaleBody","ends","t16","t17","t18","RadioGroup","_c","styles","fieldStyles","AriaRadioGroup"],"sources":["../../src/radio-group/RadioGroup.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from 'react';\nimport {\n RadioGroup as AriaRadioGroup,\n type RadioGroupProps as AriaRadioGroupProps,\n Radio,\n} from 'react-aria-components';\n\nimport {\n type FieldChromeProps,\n FieldDescription,\n FieldErrors,\n FieldLabel,\n fieldStyles,\n} from '../field/FieldParts';\nimport type { OptionValue, SelectOption } from '../select/Select';\nimport { cx } from '../utils/cx';\nimport styles from './RadioGroup.module.css';\n\n/** An option of a `RadioGroup`: a `SelectOption`, with an optional leading media. */\nexport interface RadioGroupOption extends SelectOption {\n /** Leading media, such as an avatar or an image, between the radio and the label. */\n media?: ReactNode;\n}\n\n/**\n * How a `RadioGroup` shows its options: a list of radios, bordered cards in a grid, or a scale of\n * joined buttons in one row (a rating from 1 to 5).\n */\nexport type RadioGroupAppearance = 'list' | 'cards' | 'scale';\n\nexport interface RadioGroupProps\n extends\n Omit<\n AriaRadioGroupProps,\n | 'className'\n | 'style'\n | 'children'\n | 'isInvalid'\n | 'validate'\n | 'value'\n | 'defaultValue'\n | 'onChange'\n >,\n FieldChromeProps {\n options: readonly RadioGroupOption[];\n value?: OptionValue | null;\n onChange?: (value: OptionValue) => void;\n /**\n * `list` (default) shows the options as radios, one under the other or side by side with\n * `orientation=\"horizontal\"`. `cards` shows them as bordered cards in a grid of `columns`, which\n * becomes a single column in a narrow container. The selected card has a stronger border.\n */\n appearance?: RadioGroupAppearance;\n /** Columns of cards, with `appearance=\"cards\"`. Defaults to 2. */\n columns?: number;\n /**\n * What the first and the last options mean, under them, with `appearance=\"scale\"`: \"Not at\n * all\" and \"Completely\". They are read with these options too.\n */\n startLabel?: ReactNode;\n endLabel?: ReactNode;\n radioClassName?: string;\n}\n\n/**\n * A set of options where one can be picked, all visible at once, as a list of radios, as cards\n * (`appearance=\"cards\"`) or as a scale (`appearance=\"scale\"`). Arrow keys move between options in\n * every appearance.\n */\nexport function RadioGroup({\n options,\n value,\n onChange,\n label,\n description,\n errors = [],\n orientation = 'vertical',\n appearance = 'list',\n columns = 2,\n startLabel,\n endLabel,\n isRequired,\n className,\n labelClassName,\n descriptionClassName,\n errorsClassName,\n radioClassName,\n ...props\n}: RadioGroupProps) {\n const isScale = appearance === 'scale';\n const hasEnds =\n isScale &&\n ((startLabel !== undefined && startLabel !== null) ||\n (endLabel !== undefined && endLabel !== null));\n const endOf = (position: number): ReactNode =>\n position === 0 ? startLabel : position === options.length - 1 ? endLabel : null;\n const radios = options.map((option, position) =>\n isScale ? (\n <Radio\n key={position}\n value={String(position)}\n isDisabled={option.disabled}\n className={cx('panneau-radio', styles.step, radioClassName)}\n >\n {option.label}\n {endOf(position) !== undefined && endOf(position) !== null ? (\n <span className={styles.visuallyHidden}>, {endOf(position)}</span>\n ) : null}\n </Radio>\n ) : (\n <Radio\n key={position}\n value={String(position)}\n isDisabled={option.disabled}\n className={cx(\n 'panneau-radio',\n styles.radio,\n appearance === 'cards' && styles.card,\n radioClassName,\n )}\n >\n <span className={styles.circle} aria-hidden=\"true\" />\n {option.media !== undefined && option.media !== null ? (\n <span className={styles.media}>{option.media}</span>\n ) : null}\n <span className={styles.text}>\n <span className={styles.optionLabel}>{option.label}</span>\n {option.description !== undefined ? (\n <span className={styles.description}>{option.description}</span>\n ) : null}\n </span>\n </Radio>\n ),\n );\n const index = value === undefined ? undefined : options.findIndex((o) => o.value === value);\n return (\n <AriaRadioGroup\n {...props}\n orientation={orientation}\n isRequired={isRequired}\n value={index === undefined ? undefined : index === -1 ? null : String(index)}\n onChange={(key) => {\n const option = options[Number(key)];\n if (option !== undefined) {\n onChange?.(option.value);\n }\n }}\n isInvalid={errors.length > 0}\n validationBehavior=\"aria\"\n className={cx(\n 'panneau-radio-group',\n fieldStyles.field,\n appearance === 'cards'\n ? styles.cards\n : isScale\n ? styles.scale\n : orientation === 'horizontal' && styles.horizontal,\n className,\n )}\n >\n <FieldLabel isRequired={isRequired} className={labelClassName}>\n {label}\n </FieldLabel>\n {appearance === 'cards' ? (\n <div className={styles.grid}>\n <div\n className={styles.options}\n style={\n {\n '--_panneau-radio-group-columns': String(\n Math.max(1, Math.floor(columns)),\n ),\n } as CSSProperties\n }\n >\n {radios}\n </div>\n </div>\n ) : isScale ? (\n <div className={styles.scaleBody}>\n <div className={styles.options}>{radios}</div>\n {hasEnds ? (\n // Read with the first and the last options\n <div className={styles.ends} aria-hidden=\"true\">\n <span>{startLabel}</span>\n <span>{endLabel}</span>\n </div>\n ) : null}\n </div>\n ) : (\n <div className={styles.options}>{radios}</div>\n )}\n <FieldDescription className={descriptionClassName}>{description}</FieldDescription>\n <FieldErrors errors={errors} className={errorsClassName} />\n </AriaRadioGroup>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAqEA,SAAOE,aAAA0B,IAAA;CAAA,M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|
13
13
|
var card = "panneau-radio-group-card";
|
|
14
|
+
var scaleBody = "panneau-radio-group-scale-body";
|
|
15
|
+
var scale = "panneau-radio-group-scale";
|
|
16
|
+
var step = "panneau-radio-group-step";
|
|
17
|
+
var ends = "panneau-radio-group-ends";
|
|
18
|
+
var visuallyHidden = "panneau-radio-group-visually-hidden";
|
|
14
19
|
var RadioGroup_module_default = {
|
|
15
20
|
options,
|
|
16
21
|
horizontal,
|
|
@@ -22,9 +27,14 @@ var RadioGroup_module_default = {
|
|
|
22
27
|
media,
|
|
23
28
|
grid,
|
|
24
29
|
cards,
|
|
25
|
-
card
|
|
30
|
+
card,
|
|
31
|
+
scaleBody,
|
|
32
|
+
scale,
|
|
33
|
+
step,
|
|
34
|
+
ends,
|
|
35
|
+
visuallyHidden
|
|
26
36
|
};
|
|
27
37
|
//#endregion
|
|
28
|
-
export { card, cards, circle, RadioGroup_module_default as default, description, grid, horizontal, media, optionLabel, options, radio, text };
|
|
38
|
+
export { card, cards, circle, RadioGroup_module_default as default, description, ends, grid, horizontal, media, optionLabel, options, radio, scale, scaleBody, step, text, visuallyHidden };
|
|
29
39
|
|
|
30
40
|
//# sourceMappingURL=RadioGroup.module.js.map
|