@panneau/ui 5.0.0-alpha.6 → 5.0.0-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.
- package/README.md +24 -1
- package/dist/alert/Alert.js +108 -40
- package/dist/alert/Alert.js.map +1 -1
- package/dist/alert/tokens.js.map +1 -1
- package/dist/badge/Badge.js +34 -6
- package/dist/badge/Badge.js.map +1 -1
- package/dist/badge/tokens.js.map +1 -1
- package/dist/button/Button.js +111 -17
- package/dist/button/Button.js.map +1 -1
- package/dist/button/tokens.js.map +1 -1
- package/dist/card/Card.js +76 -23
- package/dist/card/Card.js.map +1 -1
- package/dist/card/tokens.js.map +1 -1
- package/dist/checkbox/Checkbox.js +86 -25
- package/dist/checkbox/Checkbox.js.map +1 -1
- package/dist/checkbox/ChoiceChrome.js +82 -21
- package/dist/checkbox/ChoiceChrome.js.map +1 -1
- package/dist/checkbox/tokens.js.map +1 -1
- package/dist/combo-box/ComboBox.js +291 -79
- package/dist/combo-box/ComboBox.js.map +1 -1
- package/dist/command-palette/CommandPalette.js +463 -160
- package/dist/command-palette/CommandPalette.js.map +1 -1
- package/dist/command-palette/match.js.map +1 -1
- package/dist/command-palette/tokens.js.map +1 -1
- package/dist/command-palette/useCommandShortcut.js +31 -12
- package/dist/command-palette/useCommandShortcut.js.map +1 -1
- package/dist/container/Container.js +48 -5
- package/dist/container/Container.js.map +1 -1
- package/dist/container/tokens.js.map +1 -1
- package/dist/date-picker/DatePicker.js +234 -73
- package/dist/date-picker/DatePicker.js.map +1 -1
- package/dist/date-picker/calendarTokens.js.map +1 -1
- package/dist/dialog/Dialog.js +161 -45
- package/dist/dialog/Dialog.js.map +1 -1
- package/dist/dialog/tokens.js.map +1 -1
- package/dist/disclosure/Disclosure.js +132 -28
- package/dist/disclosure/Disclosure.js.map +1 -1
- package/dist/disclosure/tokens.js.map +1 -1
- package/dist/divider/Divider.js +55 -11
- package/dist/divider/Divider.js.map +1 -1
- package/dist/divider/tokens.js.map +1 -1
- package/dist/field/FieldParts.js +69 -15
- package/dist/field/FieldParts.js.map +1 -1
- package/dist/field/Fieldset.js +99 -32
- package/dist/field/Fieldset.js.map +1 -1
- package/dist/field/inputTokens.js.map +1 -1
- package/dist/field/tokens.js.map +1 -1
- package/dist/grid/Grid.js +123 -14
- package/dist/grid/Grid.js.map +1 -1
- package/dist/grid/tokens.js.map +1 -1
- package/dist/heading/Heading.js +41 -6
- package/dist/heading/Heading.js.map +1 -1
- package/dist/heading/tokens.js.map +1 -1
- package/dist/icon/Icon.js +36 -11
- package/dist/icon/Icon.js.map +1 -1
- package/dist/icon/lucideIconLoader.js.map +1 -1
- package/dist/icon/namedIcons.js +87 -26
- package/dist/icon/namedIcons.js.map +1 -1
- package/dist/icon-button/IconButton.js +70 -13
- package/dist/icon-button/IconButton.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/inline/Inline.js +65 -7
- package/dist/inline/Inline.js.map +1 -1
- package/dist/inline/tokens.js.map +1 -1
- package/dist/intl/usePanneauIntl.js.map +1 -1
- package/dist/layout/responsive.js.map +1 -1
- package/dist/locales/index.js.map +1 -1
- package/dist/menu/Menu.js +170 -44
- package/dist/menu/Menu.js.map +1 -1
- package/dist/menu/tokens.js.map +1 -1
- package/dist/number-input/NumberInput.js +232 -60
- package/dist/number-input/NumberInput.js.map +1 -1
- package/dist/number-input/tokens.js.map +1 -1
- package/dist/pill-trigger/PillTrigger.js +76 -20
- package/dist/pill-trigger/PillTrigger.js.map +1 -1
- package/dist/pill-trigger/tokens.js.map +1 -1
- package/dist/popover/Popover.js +109 -18
- package/dist/popover/Popover.js.map +1 -1
- package/dist/popover/tokens.js.map +1 -1
- package/dist/prose/Prose.js +36 -5
- package/dist/prose/Prose.js.map +1 -1
- package/dist/prose/tokens.js.map +1 -1
- package/dist/radio-group/RadioGroup.js +211 -61
- package/dist/radio-group/RadioGroup.js.map +1 -1
- package/dist/radio-group/tokens.js.map +1 -1
- package/dist/root/PanneauRoot.js +197 -49
- package/dist/root/PanneauRoot.js.map +1 -1
- package/dist/root/ThemeScope.js +107 -26
- package/dist/root/ThemeScope.js.map +1 -1
- package/dist/segmented-control/SegmentedControl.js +120 -22
- package/dist/segmented-control/SegmentedControl.js.map +1 -1
- package/dist/segmented-control/tokens.js.map +1 -1
- package/dist/select/Select.js +298 -92
- package/dist/select/Select.js.map +1 -1
- package/dist/select/listBoxTokens.js.map +1 -1
- package/dist/skeleton/LoadingRegion.d.ts +16 -0
- package/dist/skeleton/LoadingRegion.d.ts.map +1 -0
- package/dist/skeleton/LoadingRegion.js +65 -0
- package/dist/skeleton/LoadingRegion.js.map +1 -0
- package/dist/skeleton/Skeleton.css +62 -0
- package/dist/skeleton/Skeleton.d.ts +25 -0
- package/dist/skeleton/Skeleton.d.ts.map +1 -0
- package/dist/skeleton/Skeleton.js +106 -0
- package/dist/skeleton/Skeleton.js.map +1 -0
- package/dist/skeleton/Skeleton.module.js +22 -0
- package/dist/skeleton/Skeleton.module.js.map +1 -0
- package/dist/skeleton/tokens.d.ts +3 -0
- package/dist/skeleton/tokens.d.ts.map +1 -0
- package/dist/skeleton/tokens.js +15 -0
- package/dist/skeleton/tokens.js.map +1 -0
- package/dist/slider/Slider.js +222 -44
- package/dist/slider/Slider.js.map +1 -1
- package/dist/spinner/Spinner.js +49 -9
- package/dist/spinner/Spinner.js.map +1 -1
- package/dist/spinner/tokens.js.map +1 -1
- package/dist/stack/Stack.js +60 -7
- package/dist/stack/Stack.js.map +1 -1
- package/dist/stack/tokens.js.map +1 -1
- package/dist/switch/Switch.js +68 -11
- package/dist/switch/Switch.js.map +1 -1
- package/dist/switch/tokens.js.map +1 -1
- package/dist/tabs/Tabs.js +1 -1
- package/dist/tabs/Tabs.js.map +1 -1
- package/dist/tabs/tokens.js.map +1 -1
- package/dist/tags-input/TagsInput.js +277 -121
- package/dist/tags-input/TagsInput.js.map +1 -1
- package/dist/text/Text.js +70 -5
- package/dist/text/Text.js.map +1 -1
- package/dist/text/tokens.js.map +1 -1
- package/dist/text-area/TextArea.js +135 -28
- package/dist/text-area/TextArea.js.map +1 -1
- package/dist/text-input/TextInput.js +164 -49
- package/dist/text-input/TextInput.js.map +1 -1
- package/dist/theme/bootstrap.js.map +1 -1
- package/dist/theme/chartColors.js.map +1 -1
- package/dist/theme/checkTheme.js.map +1 -1
- package/dist/theme/cli.js.map +1 -1
- package/dist/theme/color.js.map +1 -1
- package/dist/theme/colorVision.js.map +1 -1
- package/dist/theme/componentTokens.js.map +1 -1
- package/dist/theme/components.d.ts +1 -0
- package/dist/theme/components.d.ts.map +1 -1
- package/dist/theme/components.js +2 -0
- package/dist/theme/components.js.map +1 -1
- package/dist/theme/defineTheme.js.map +1 -1
- package/dist/theme/fonts.js.map +1 -1
- package/dist/theme/semanticTokens.js.map +1 -1
- package/dist/theme/theme.js.map +1 -1
- package/dist/theme/toneClass.js.map +1 -1
- package/dist/theme/tones.js.map +1 -1
- package/dist/time-input/TimeInput.js +138 -31
- package/dist/time-input/TimeInput.js.map +1 -1
- package/dist/toast/Toast.js +1 -1
- package/dist/toast/Toast.js.map +1 -1
- package/dist/toast/tokens.js.map +1 -1
- package/dist/tooltip/Tooltip.js +38 -8
- package/dist/tooltip/Tooltip.js.map +1 -1
- package/dist/tooltip/tokens.js.map +1 -1
- package/dist/utils/cx.js.map +1 -1
- package/package.json +3 -3
|
@@ -2,6 +2,7 @@ import { cx } from "../utils/cx.js";
|
|
|
2
2
|
import Field_module_default from "../field/Field.module.js";
|
|
3
3
|
import { FieldDescription, FieldErrors, FieldLabel } from "../field/FieldParts.js";
|
|
4
4
|
import RadioGroup_module_default from "./RadioGroup.module.js";
|
|
5
|
+
import { c } from "react/compiler-runtime";
|
|
5
6
|
import { Radio, RadioGroup } from "react-aria-components";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
//#region src/radio-group/RadioGroup.tsx
|
|
@@ -9,72 +10,221 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
9
10
|
* A set of options where one can be picked, all visible at once, as a list of radios or as cards
|
|
10
11
|
* (`appearance="cards"`). Arrow keys move between options in both appearances.
|
|
11
12
|
*/
|
|
12
|
-
function RadioGroup$1(
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
]
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
13
|
+
function RadioGroup$1(t0) {
|
|
14
|
+
const $ = c(61);
|
|
15
|
+
let className;
|
|
16
|
+
let description;
|
|
17
|
+
let descriptionClassName;
|
|
18
|
+
let errorsClassName;
|
|
19
|
+
let isRequired;
|
|
20
|
+
let label;
|
|
21
|
+
let labelClassName;
|
|
22
|
+
let onChange;
|
|
23
|
+
let options;
|
|
24
|
+
let props;
|
|
25
|
+
let radioClassName;
|
|
26
|
+
let t1;
|
|
27
|
+
let t2;
|
|
28
|
+
let t3;
|
|
29
|
+
let t4;
|
|
30
|
+
let value;
|
|
31
|
+
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);
|
|
33
|
+
$[0] = t0;
|
|
34
|
+
$[1] = className;
|
|
35
|
+
$[2] = description;
|
|
36
|
+
$[3] = descriptionClassName;
|
|
37
|
+
$[4] = errorsClassName;
|
|
38
|
+
$[5] = isRequired;
|
|
39
|
+
$[6] = label;
|
|
40
|
+
$[7] = labelClassName;
|
|
41
|
+
$[8] = onChange;
|
|
42
|
+
$[9] = options;
|
|
43
|
+
$[10] = props;
|
|
44
|
+
$[11] = radioClassName;
|
|
45
|
+
$[12] = t1;
|
|
46
|
+
$[13] = t2;
|
|
47
|
+
$[14] = t3;
|
|
48
|
+
$[15] = t4;
|
|
49
|
+
$[16] = value;
|
|
50
|
+
} else {
|
|
51
|
+
className = $[1];
|
|
52
|
+
description = $[2];
|
|
53
|
+
descriptionClassName = $[3];
|
|
54
|
+
errorsClassName = $[4];
|
|
55
|
+
isRequired = $[5];
|
|
56
|
+
label = $[6];
|
|
57
|
+
labelClassName = $[7];
|
|
58
|
+
onChange = $[8];
|
|
59
|
+
options = $[9];
|
|
60
|
+
props = $[10];
|
|
61
|
+
radioClassName = $[11];
|
|
62
|
+
t1 = $[12];
|
|
63
|
+
t2 = $[13];
|
|
64
|
+
t3 = $[14];
|
|
65
|
+
t4 = $[15];
|
|
66
|
+
value = $[16];
|
|
67
|
+
}
|
|
68
|
+
let t5;
|
|
69
|
+
if ($[17] !== t1) {
|
|
70
|
+
t5 = t1 === void 0 ? [] : t1;
|
|
71
|
+
$[17] = t1;
|
|
72
|
+
$[18] = t5;
|
|
73
|
+
} else t5 = $[18];
|
|
74
|
+
const errors = t5;
|
|
75
|
+
const orientation = t2 === void 0 ? "vertical" : t2;
|
|
76
|
+
const appearance = t3 === void 0 ? "list" : t3;
|
|
77
|
+
const columns = t4 === void 0 ? 2 : t4;
|
|
78
|
+
let t6;
|
|
79
|
+
if ($[19] !== appearance || $[20] !== options || $[21] !== radioClassName) {
|
|
80
|
+
let t7;
|
|
81
|
+
if ($[23] !== appearance || $[24] !== radioClassName) {
|
|
82
|
+
t7 = (option, position) => /* @__PURE__ */ jsxs(Radio, {
|
|
83
|
+
value: String(position),
|
|
84
|
+
isDisabled: option.disabled,
|
|
85
|
+
className: cx("panneau-radio", RadioGroup_module_default.radio, appearance === "cards" && RadioGroup_module_default.card, radioClassName),
|
|
86
|
+
children: [
|
|
87
|
+
/* @__PURE__ */ jsx("span", {
|
|
88
|
+
className: RadioGroup_module_default.circle,
|
|
89
|
+
"aria-hidden": "true"
|
|
90
|
+
}),
|
|
91
|
+
option.media !== void 0 && option.media !== null ? /* @__PURE__ */ jsx("span", {
|
|
92
|
+
className: RadioGroup_module_default.media,
|
|
93
|
+
children: option.media
|
|
94
|
+
}) : null,
|
|
95
|
+
/* @__PURE__ */ jsxs("span", {
|
|
96
|
+
className: RadioGroup_module_default.text,
|
|
97
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
98
|
+
className: RadioGroup_module_default.optionLabel,
|
|
99
|
+
children: option.label
|
|
100
|
+
}), option.description !== void 0 ? /* @__PURE__ */ jsx("span", {
|
|
101
|
+
className: RadioGroup_module_default.description,
|
|
102
|
+
children: option.description
|
|
103
|
+
}) : null]
|
|
104
|
+
})
|
|
105
|
+
]
|
|
106
|
+
}, position);
|
|
107
|
+
$[23] = appearance;
|
|
108
|
+
$[24] = radioClassName;
|
|
109
|
+
$[25] = t7;
|
|
110
|
+
} else t7 = $[25];
|
|
111
|
+
t6 = options.map(t7);
|
|
112
|
+
$[19] = appearance;
|
|
113
|
+
$[20] = options;
|
|
114
|
+
$[21] = radioClassName;
|
|
115
|
+
$[22] = t6;
|
|
116
|
+
} else t6 = $[22];
|
|
117
|
+
const radios = t6;
|
|
118
|
+
let t7;
|
|
119
|
+
if ($[26] !== options || $[27] !== value) {
|
|
120
|
+
t7 = value === void 0 ? void 0 : options.findIndex((o) => o.value === value);
|
|
121
|
+
$[26] = options;
|
|
122
|
+
$[27] = value;
|
|
123
|
+
$[28] = t7;
|
|
124
|
+
} else t7 = $[28];
|
|
125
|
+
const index = t7;
|
|
126
|
+
const t8 = index === void 0 ? void 0 : index === -1 ? null : String(index);
|
|
127
|
+
let t9;
|
|
128
|
+
if ($[29] !== onChange || $[30] !== options) {
|
|
129
|
+
t9 = (key) => {
|
|
45
130
|
const option_0 = options[Number(key)];
|
|
46
131
|
if (option_0 !== void 0) onChange?.(option_0.value);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
132
|
+
};
|
|
133
|
+
$[29] = onChange;
|
|
134
|
+
$[30] = options;
|
|
135
|
+
$[31] = t9;
|
|
136
|
+
} else t9 = $[31];
|
|
137
|
+
const t10 = errors.length > 0;
|
|
138
|
+
const t11 = appearance === "cards" ? RadioGroup_module_default.cards : orientation === "horizontal" && RadioGroup_module_default.horizontal;
|
|
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];
|
|
146
|
+
let t13;
|
|
147
|
+
if ($[35] !== isRequired || $[36] !== label || $[37] !== labelClassName) {
|
|
148
|
+
t13 = /* @__PURE__ */ jsx(FieldLabel, {
|
|
149
|
+
isRequired,
|
|
150
|
+
className: labelClassName,
|
|
151
|
+
children: label
|
|
152
|
+
});
|
|
153
|
+
$[35] = isRequired;
|
|
154
|
+
$[36] = label;
|
|
155
|
+
$[37] = labelClassName;
|
|
156
|
+
$[38] = t13;
|
|
157
|
+
} else t13 = $[38];
|
|
158
|
+
let t14;
|
|
159
|
+
if ($[39] !== appearance || $[40] !== columns || $[41] !== radios) {
|
|
160
|
+
t14 = appearance === "cards" ? /* @__PURE__ */ jsx("div", {
|
|
161
|
+
className: RadioGroup_module_default.grid,
|
|
162
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
65
163
|
className: RadioGroup_module_default.options,
|
|
164
|
+
style: { "--_panneau-radio-group-columns": String(Math.max(1, Math.floor(columns))) },
|
|
66
165
|
children: radios
|
|
67
|
-
}),
|
|
68
|
-
/* @__PURE__ */ jsx(FieldDescription, {
|
|
69
|
-
className: descriptionClassName,
|
|
70
|
-
children: description
|
|
71
|
-
}),
|
|
72
|
-
/* @__PURE__ */ jsx(FieldErrors, {
|
|
73
|
-
errors,
|
|
74
|
-
className: errorsClassName
|
|
75
166
|
})
|
|
76
|
-
|
|
77
|
-
|
|
167
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
168
|
+
className: RadioGroup_module_default.options,
|
|
169
|
+
children: radios
|
|
170
|
+
});
|
|
171
|
+
$[39] = appearance;
|
|
172
|
+
$[40] = columns;
|
|
173
|
+
$[41] = radios;
|
|
174
|
+
$[42] = t14;
|
|
175
|
+
} else t14 = $[42];
|
|
176
|
+
let t15;
|
|
177
|
+
if ($[43] !== description || $[44] !== descriptionClassName) {
|
|
178
|
+
t15 = /* @__PURE__ */ jsx(FieldDescription, {
|
|
179
|
+
className: descriptionClassName,
|
|
180
|
+
children: description
|
|
181
|
+
});
|
|
182
|
+
$[43] = description;
|
|
183
|
+
$[44] = descriptionClassName;
|
|
184
|
+
$[45] = t15;
|
|
185
|
+
} else t15 = $[45];
|
|
186
|
+
let t16;
|
|
187
|
+
if ($[46] !== errors || $[47] !== errorsClassName) {
|
|
188
|
+
t16 = /* @__PURE__ */ jsx(FieldErrors, {
|
|
189
|
+
errors,
|
|
190
|
+
className: errorsClassName
|
|
191
|
+
});
|
|
192
|
+
$[46] = errors;
|
|
193
|
+
$[47] = errorsClassName;
|
|
194
|
+
$[48] = t16;
|
|
195
|
+
} else t16 = $[48];
|
|
196
|
+
let t17;
|
|
197
|
+
if ($[49] !== isRequired || $[50] !== orientation || $[51] !== props || $[52] !== t10 || $[53] !== t12 || $[54] !== t13 || $[55] !== t14 || $[56] !== t15 || $[57] !== t16 || $[58] !== t8 || $[59] !== t9) {
|
|
198
|
+
t17 = /* @__PURE__ */ jsxs(RadioGroup, {
|
|
199
|
+
...props,
|
|
200
|
+
orientation,
|
|
201
|
+
isRequired,
|
|
202
|
+
value: t8,
|
|
203
|
+
onChange: t9,
|
|
204
|
+
isInvalid: t10,
|
|
205
|
+
validationBehavior: "aria",
|
|
206
|
+
className: t12,
|
|
207
|
+
children: [
|
|
208
|
+
t13,
|
|
209
|
+
t14,
|
|
210
|
+
t15,
|
|
211
|
+
t16
|
|
212
|
+
]
|
|
213
|
+
});
|
|
214
|
+
$[49] = isRequired;
|
|
215
|
+
$[50] = orientation;
|
|
216
|
+
$[51] = props;
|
|
217
|
+
$[52] = t10;
|
|
218
|
+
$[53] = t12;
|
|
219
|
+
$[54] = t13;
|
|
220
|
+
$[55] = t14;
|
|
221
|
+
$[56] = t15;
|
|
222
|
+
$[57] = t16;
|
|
223
|
+
$[58] = t8;
|
|
224
|
+
$[59] = t9;
|
|
225
|
+
$[60] = t17;
|
|
226
|
+
} else t17 = $[60];
|
|
227
|
+
return t17;
|
|
78
228
|
}
|
|
79
229
|
//#endregion
|
|
80
230
|
export { RadioGroup$1 as RadioGroup };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","names":["option","RadioGroup","styles","AriaRadioGroup","fieldStyles"],"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,SAAgBC,aAAW,EACvB,SACA,OACA,UACA,OACA,aACA,SAAS,CAAA,GACT,cAAc,YACd,aAAa,QACb,UAAU,GACV,YACA,WACA,gBACA,sBACA,iBACA,gBACA,GAAG,SACa;CAChB,MAAM,SAAS,QAAQ,KAAK,QAAQ,aAChC,qBAAC,OAAD;EAEI,OAAO,OAAO,QAAQ;EACtB,YAAY,OAAO;EACnB,WAAW,GACP,iBACAC,0BAAO,OACP,eAAe,WAAWA,0BAAO,MACjC,cACJ;EATJ,UAAA;GAWI,oBAAC,QAAD;IAAM,WAAWA,0BAAO;IAAQ,eAAY;GAAM,CAAA;GACjD,OAAO,UAAU,KAAA,KAAa,OAAO,UAAU,OAC5C,oBAAC,QAAD;IAAM,WAAWA,0BAAO;IAAQ,UAAA,OAAO;GAAY,CAAA,IACnD;GACJ,qBAAC,QAAD;IAAM,WAAWA,0BAAO;IAAxB,UAAA,CACI,oBAAC,QAAD;KAAM,WAAWA,0BAAO;KAAc,UAAA,OAAO;IAAY,CAAA,GACxD,OAAO,gBAAgB,KAAA,IACpB,oBAAC,QAAD;KAAM,WAAWA,0BAAO;KAAc,UAAA,OAAO;IAAkB,CAAA,IAC/D,IACF;;EACH;CApBE,GAAA,QAoBF,CACV;CACD,MAAM,QAAQ,UAAU,KAAA,IAAY,KAAA,IAAY,QAAQ,WAAW,MAAM,EAAE,UAAU,KAAK;CAC1F,OACI,qBAACC,YAAD;EACI,GAAI;EACS;EACD;EACZ,OAAO,UAAU,KAAA,IAAY,KAAA,IAAY,UAAU,KAAK,OAAO,OAAO,KAAK;EAC3E,WAAW,QAAQ;GACf,MAAMH,WAAS,QAAQ,OAAO,GAAG;GACjC,IAAIA,aAAW,KAAA,GACX,WAAWA,SAAO,KAAK;EAE/B;EACA,WAAW,OAAO,SAAS;EAC3B,oBAAmB;EACnB,WAAW,GACP,uBACAI,qBAAY,OACZ,eAAe,UACTF,0BAAO,QACP,gBAAgB,gBAAgBA,0BAAO,YAC7C,SACJ;EApBJ,UAAA;GAsBI,oBAAC,YAAD;IAAwB;IAAY,WAAW;IAC1C,UAAA;GACO,CAAA;GACX,eAAe,UACZ,oBAAC,OAAD;IAAK,WAAWA,0BAAO;IACnB,UAAA,oBAAC,OAAD;KACI,WAAWA,0BAAO;KAClB,OACI,EACI,kCAAkC,OAC9B,KAAK,IAAI,GAAG,KAAK,MAAM,OAAO,CAAC,CACnC,EACJ;KAGH,UAAA;IACA,CAAA;GACJ,CAAA,IAEL,oBAAC,OAAD;IAAK,WAAWA,0BAAO;IAAU,UAAA;GAAY,CAAA;GAEjD,oBAAC,kBAAD;IAAkB,WAAW;IAAuB,UAAA;GAA8B,CAAA;GAClF,oBAAC,aAAD;IAAqB;IAAQ,WAAW;GAAgB,CAAA;EAC5C;;AAExB"}
|
|
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;CAA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AAAuC,OAAAvC,EAAA,QAAA4C,OAAA5C,EAAA,QAAA8C,OAAA9C,EAAA,QAAA+C,OAAA/C,EAAA,QAAAoD,OAAApD,EAAA,QAAAqD,OAAArD,EAAA,QAAAkC,MAAAlC,EAAA,QAAAmC,IAAA;EA5C/DmB,MAAA,qBAACK,YAAD;GAAe,GACPlD;GACSM;GACDT;GACL,OAAA4B;GACG,UAAAC;GAMC,WAAAI;GACQ,oBAAA;GACR,WAAAK;GAbf,UAAA;IAsBIE;IAGCC;IAkBDK;IACAC;GA5CW;;EA6CErD,EAAA,MAAAM;EAAAN,EAAA,MAAAe;EAAAf,EAAA,MAAAS;EAAAT,EAAA,MAAAuC;EAAAvC,EAAA,MAAA4C;EAAA5C,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","names":[],"sources":["../../src/radio-group/tokens.ts"],"sourcesContent":["import { defineComponentTokens } from '../theme/componentTokens';\n\n/** Tokens of RadioGroup: its radios, the media of its options, and its cards. */\nexport const radioTokens = defineComponentTokens('radio', {\n /** Size of the circle. */\n size: '1.125rem',\n /** Background of the circle. */\n bg: 'var(--panneau-color-surface)',\n /** Border color of the circle. */\n 'border-color': 'var(--panneau-color-border-control)',\n /** Color of a selected circle. */\n 'checked-color': 'var(--panneau-color-accent)',\n /** Border width of a selected circle, which draws the dot. */\n 'checked-border-width': '0.3125rem',\n /** Size of the leading media of an option. */\n 'media-size': '2rem',\n /** Corner radius of the leading media of an option: its content is clipped to it. */\n 'media-radius': 'var(--panneau-radius-full)',\n /** Space between the cards, with `appearance=\"cards\"`. */\n 'card-gap': 'var(--panneau-space-2)',\n /** Padding of a card. */\n 'card-padding': 'var(--panneau-space-3)',\n /** Background of a card. */\n 'card-bg': 'var(--panneau-color-surface)',\n /** Border color of a card. */\n 'card-border-color': 'var(--panneau-color-border)',\n /** Border color of a hovered card. */\n 'card-border-color-hover': 'var(--panneau-color-border-control)',\n /** Border color of the selected card, which is twice as wide. */\n 'card-border-color-selected': 'var(--panneau-color-accent)',\n /** Corner radius of a card. */\n 'card-radius': 'var(--panneau-radius-md)',\n /** Font weight of the label of a card. */\n 'card-label-font-weight': 'var(--panneau-font-weight-medium)',\n});\n"],"mappings":";;;AAGA,
|
|
1
|
+
{"version":3,"file":"tokens.js","names":["defineComponentTokens","radioTokens","size","bg"],"sources":["../../src/radio-group/tokens.ts"],"sourcesContent":["import { defineComponentTokens } from '../theme/componentTokens';\n\n/** Tokens of RadioGroup: its radios, the media of its options, and its cards. */\nexport const radioTokens = defineComponentTokens('radio', {\n /** Size of the circle. */\n size: '1.125rem',\n /** Background of the circle. */\n bg: 'var(--panneau-color-surface)',\n /** Border color of the circle. */\n 'border-color': 'var(--panneau-color-border-control)',\n /** Color of a selected circle. */\n 'checked-color': 'var(--panneau-color-accent)',\n /** Border width of a selected circle, which draws the dot. */\n 'checked-border-width': '0.3125rem',\n /** Size of the leading media of an option. */\n 'media-size': '2rem',\n /** Corner radius of the leading media of an option: its content is clipped to it. */\n 'media-radius': 'var(--panneau-radius-full)',\n /** Space between the cards, with `appearance=\"cards\"`. */\n 'card-gap': 'var(--panneau-space-2)',\n /** Padding of a card. */\n 'card-padding': 'var(--panneau-space-3)',\n /** Background of a card. */\n 'card-bg': 'var(--panneau-color-surface)',\n /** Border color of a card. */\n 'card-border-color': 'var(--panneau-color-border)',\n /** Border color of a hovered card. */\n 'card-border-color-hover': 'var(--panneau-color-border-control)',\n /** Border color of the selected card, which is twice as wide. */\n 'card-border-color-selected': 'var(--panneau-color-accent)',\n /** Corner radius of a card. */\n 'card-radius': 'var(--panneau-radius-md)',\n /** Font weight of the label of a card. */\n 'card-label-font-weight': 'var(--panneau-font-weight-medium)',\n});\n"],"mappings":";;;AAGA,IAAaC,cAAcD,sBAAsB,SAAS;;CAEtDE,MAAM;;CAENC,IAAI;;CAEJ,gBAAgB;;CAEhB,iBAAiB;;CAEjB,wBAAwB;;CAExB,cAAc;;CAEd,gBAAgB;;CAEhB,YAAY;;CAEZ,gBAAgB;;CAEhB,WAAW;;CAEX,qBAAqB;;CAErB,2BAA2B;;CAE3B,8BAA8B;;CAE9B,eAAe;;CAEf,0BAA0B;AAC9B,CAAC"}
|
package/dist/root/PanneauRoot.js
CHANGED
|
@@ -4,12 +4,12 @@ import { getFontFaceCss, getFontStylesheets } from "../theme/fonts.js";
|
|
|
4
4
|
import { getThemeCss, hashString } from "../theme/theme.js";
|
|
5
5
|
import { ToastProvider } from "../toast/Toast.js";
|
|
6
6
|
import PanneauRoot_module_default from "./PanneauRoot.module.js";
|
|
7
|
+
import { c } from "react/compiler-runtime";
|
|
7
8
|
import { I18nProvider } from "react-aria-components";
|
|
8
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
import { getPanneauMessages } from "@panneau/intl";
|
|
10
11
|
import { createContext, use, useState } from "react";
|
|
11
12
|
import { IntlContext, IntlProvider } from "react-intl";
|
|
12
|
-
import { c } from "react/compiler-runtime";
|
|
13
13
|
//#region src/root/PanneauRoot.tsx
|
|
14
14
|
/** `undefined` outside of a root, `null` while the root's container isn't mounted yet. */
|
|
15
15
|
var PortalContext = createContext(void 0);
|
|
@@ -104,15 +104,46 @@ function usePortalContainer() {
|
|
|
104
104
|
* Panneau doesn't translate gets English, so that react-intl doesn't report every message as
|
|
105
105
|
* missing.
|
|
106
106
|
*/
|
|
107
|
-
function PanneauIntlProvider(
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
107
|
+
function PanneauIntlProvider(t0) {
|
|
108
|
+
const $ = c(11);
|
|
109
|
+
const { locale: t1, children } = t0;
|
|
110
|
+
const locale = t1 === void 0 ? "en" : t1;
|
|
111
|
+
let t2;
|
|
112
|
+
if ($[0] !== locale) {
|
|
113
|
+
t2 = getPanneauMessages(locale);
|
|
114
|
+
$[0] = locale;
|
|
115
|
+
$[1] = t2;
|
|
116
|
+
} else t2 = $[1];
|
|
117
|
+
const messages = t2;
|
|
118
|
+
let t3;
|
|
119
|
+
if ($[2] !== messages) {
|
|
120
|
+
t3 = Object.keys(messages);
|
|
121
|
+
$[2] = messages;
|
|
122
|
+
$[3] = t3;
|
|
123
|
+
} else t3 = $[3];
|
|
124
|
+
const translated = t3.length > 0;
|
|
125
|
+
const t4 = translated ? locale : "en";
|
|
126
|
+
let t5;
|
|
127
|
+
if ($[4] !== messages || $[5] !== translated) {
|
|
128
|
+
t5 = translated ? messages : getPanneauMessages("en");
|
|
129
|
+
$[4] = messages;
|
|
130
|
+
$[5] = translated;
|
|
131
|
+
$[6] = t5;
|
|
132
|
+
} else t5 = $[6];
|
|
133
|
+
let t6;
|
|
134
|
+
if ($[7] !== children || $[8] !== t4 || $[9] !== t5) {
|
|
135
|
+
t6 = /* @__PURE__ */ jsx(IntlProvider, {
|
|
136
|
+
locale: t4,
|
|
137
|
+
defaultLocale: "en",
|
|
138
|
+
messages: t5,
|
|
139
|
+
children
|
|
140
|
+
});
|
|
141
|
+
$[7] = children;
|
|
142
|
+
$[8] = t4;
|
|
143
|
+
$[9] = t5;
|
|
144
|
+
$[10] = t6;
|
|
145
|
+
} else t6 = $[10];
|
|
146
|
+
return t6;
|
|
116
147
|
}
|
|
117
148
|
/**
|
|
118
149
|
* The root of every Panneau interface. It scopes the base stylesheet and the design tokens to its
|
|
@@ -121,48 +152,165 @@ function PanneauIntlProvider({ locale = "en", children }) {
|
|
|
121
152
|
* any token with its own class on the root. Without an `IntlProvider` above it, it provides one
|
|
122
153
|
* with Panneau's messages in its `locale`.
|
|
123
154
|
*/
|
|
124
|
-
function PanneauRoot(
|
|
155
|
+
function PanneauRoot(t0) {
|
|
156
|
+
const $ = c(45);
|
|
157
|
+
let children;
|
|
158
|
+
let className;
|
|
159
|
+
let locale;
|
|
160
|
+
let props;
|
|
161
|
+
let t1;
|
|
162
|
+
let t2;
|
|
163
|
+
let t3;
|
|
164
|
+
let t4;
|
|
165
|
+
if ($[0] !== t0) {
|
|
166
|
+
({theme: t1, colorScheme: t2, density: t3, iconLoader: t4, locale, className, children, ...props} = t0);
|
|
167
|
+
$[0] = t0;
|
|
168
|
+
$[1] = children;
|
|
169
|
+
$[2] = className;
|
|
170
|
+
$[3] = locale;
|
|
171
|
+
$[4] = props;
|
|
172
|
+
$[5] = t1;
|
|
173
|
+
$[6] = t2;
|
|
174
|
+
$[7] = t3;
|
|
175
|
+
$[8] = t4;
|
|
176
|
+
} else {
|
|
177
|
+
children = $[1];
|
|
178
|
+
className = $[2];
|
|
179
|
+
locale = $[3];
|
|
180
|
+
props = $[4];
|
|
181
|
+
t1 = $[5];
|
|
182
|
+
t2 = $[6];
|
|
183
|
+
t3 = $[7];
|
|
184
|
+
t4 = $[8];
|
|
185
|
+
}
|
|
186
|
+
const theme = t1 === void 0 ? null : t1;
|
|
187
|
+
const colorScheme = t2 === void 0 ? "light" : t2;
|
|
188
|
+
const density = t3 === void 0 ? "auto" : t3;
|
|
189
|
+
const iconLoader = t4 === void 0 ? null : t4;
|
|
125
190
|
const intl = use(IntlContext);
|
|
126
191
|
const [container, setContainer] = useState(null);
|
|
127
192
|
const { scope, styles: themeStyles } = useThemeStyles(theme);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
children
|
|
165
|
-
|
|
193
|
+
let t5;
|
|
194
|
+
if ($[9] !== className) {
|
|
195
|
+
t5 = cx("panneau-root", PanneauRoot_module_default.root, PanneauRoot_module_default.container, className);
|
|
196
|
+
$[9] = className;
|
|
197
|
+
$[10] = t5;
|
|
198
|
+
} else t5 = $[10];
|
|
199
|
+
const t6 = locale ?? intl?.locale;
|
|
200
|
+
let t7;
|
|
201
|
+
if ($[11] !== colorScheme || $[12] !== density) {
|
|
202
|
+
t7 = {
|
|
203
|
+
colorScheme,
|
|
204
|
+
density
|
|
205
|
+
};
|
|
206
|
+
$[11] = colorScheme;
|
|
207
|
+
$[12] = density;
|
|
208
|
+
$[13] = t7;
|
|
209
|
+
} else t7 = $[13];
|
|
210
|
+
let t8;
|
|
211
|
+
if ($[14] !== colorScheme || $[15] !== density || $[16] !== scope) {
|
|
212
|
+
t8 = {
|
|
213
|
+
"data-color-scheme": colorScheme,
|
|
214
|
+
"data-density": density,
|
|
215
|
+
"data-panneau-theme": scope
|
|
216
|
+
};
|
|
217
|
+
$[14] = colorScheme;
|
|
218
|
+
$[15] = density;
|
|
219
|
+
$[16] = scope;
|
|
220
|
+
$[17] = t8;
|
|
221
|
+
} else t8 = $[17];
|
|
222
|
+
let t9;
|
|
223
|
+
if ($[18] !== children || $[19] !== t8) {
|
|
224
|
+
t9 = /* @__PURE__ */ jsx(ToastProvider, {
|
|
225
|
+
regionClassName: PanneauRoot_module_default.root,
|
|
226
|
+
regionProps: t8,
|
|
227
|
+
children
|
|
228
|
+
});
|
|
229
|
+
$[18] = children;
|
|
230
|
+
$[19] = t8;
|
|
231
|
+
$[20] = t9;
|
|
232
|
+
} else t9 = $[20];
|
|
233
|
+
let t10;
|
|
234
|
+
if ($[21] !== container || $[22] !== t9) {
|
|
235
|
+
t10 = /* @__PURE__ */ jsx(PortalContext, {
|
|
236
|
+
value: container,
|
|
237
|
+
children: t9
|
|
238
|
+
});
|
|
239
|
+
$[21] = container;
|
|
240
|
+
$[22] = t9;
|
|
241
|
+
$[23] = t10;
|
|
242
|
+
} else t10 = $[23];
|
|
243
|
+
let t11;
|
|
244
|
+
if ($[24] !== t10 || $[25] !== t7) {
|
|
245
|
+
t11 = /* @__PURE__ */ jsx(ScopeContext, {
|
|
246
|
+
value: t7,
|
|
247
|
+
children: t10
|
|
248
|
+
});
|
|
249
|
+
$[24] = t10;
|
|
250
|
+
$[25] = t7;
|
|
251
|
+
$[26] = t11;
|
|
252
|
+
} else t11 = $[26];
|
|
253
|
+
let t12;
|
|
254
|
+
if ($[27] !== iconLoader || $[28] !== t11) {
|
|
255
|
+
t12 = /* @__PURE__ */ jsx(NamedIconLoaderContext, {
|
|
256
|
+
value: iconLoader,
|
|
257
|
+
children: t11
|
|
258
|
+
});
|
|
259
|
+
$[27] = iconLoader;
|
|
260
|
+
$[28] = t11;
|
|
261
|
+
$[29] = t12;
|
|
262
|
+
} else t12 = $[29];
|
|
263
|
+
let t13;
|
|
264
|
+
if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
|
|
265
|
+
t13 = /* @__PURE__ */ jsx("div", {
|
|
266
|
+
ref: setContainer,
|
|
267
|
+
className: PanneauRoot_module_default.portal
|
|
268
|
+
});
|
|
269
|
+
$[30] = t13;
|
|
270
|
+
} else t13 = $[30];
|
|
271
|
+
let t14;
|
|
272
|
+
if ($[31] !== t12 || $[32] !== t6) {
|
|
273
|
+
t14 = /* @__PURE__ */ jsxs(I18nProvider, {
|
|
274
|
+
locale: t6,
|
|
275
|
+
children: [t12, t13]
|
|
276
|
+
});
|
|
277
|
+
$[31] = t12;
|
|
278
|
+
$[32] = t6;
|
|
279
|
+
$[33] = t14;
|
|
280
|
+
} else t14 = $[33];
|
|
281
|
+
let t15;
|
|
282
|
+
if ($[34] !== colorScheme || $[35] !== density || $[36] !== props || $[37] !== scope || $[38] !== t14 || $[39] !== t5 || $[40] !== themeStyles) {
|
|
283
|
+
t15 = /* @__PURE__ */ jsxs("div", {
|
|
284
|
+
...props,
|
|
285
|
+
className: t5,
|
|
286
|
+
"data-color-scheme": colorScheme,
|
|
287
|
+
"data-density": density,
|
|
288
|
+
"data-panneau-theme": scope,
|
|
289
|
+
children: [themeStyles, t14]
|
|
290
|
+
});
|
|
291
|
+
$[34] = colorScheme;
|
|
292
|
+
$[35] = density;
|
|
293
|
+
$[36] = props;
|
|
294
|
+
$[37] = scope;
|
|
295
|
+
$[38] = t14;
|
|
296
|
+
$[39] = t5;
|
|
297
|
+
$[40] = themeStyles;
|
|
298
|
+
$[41] = t15;
|
|
299
|
+
} else t15 = $[41];
|
|
300
|
+
const root = t15;
|
|
301
|
+
if (intl === null || intl === void 0) {
|
|
302
|
+
let t16;
|
|
303
|
+
if ($[42] !== locale || $[43] !== root) {
|
|
304
|
+
t16 = /* @__PURE__ */ jsx(PanneauIntlProvider, {
|
|
305
|
+
locale,
|
|
306
|
+
children: root
|
|
307
|
+
});
|
|
308
|
+
$[42] = locale;
|
|
309
|
+
$[43] = root;
|
|
310
|
+
$[44] = t16;
|
|
311
|
+
} else t16 = $[44];
|
|
312
|
+
return t16;
|
|
313
|
+
}
|
|
166
314
|
return root;
|
|
167
315
|
}
|
|
168
316
|
//#endregion
|