@charcoal-ui/react 3.6.0 → 3.7.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/_lib/compat.d.ts +1 -0
- package/dist/_lib/compat.d.ts.map +1 -1
- package/dist/components/Button/StyledButton.d.ts +12 -0
- package/dist/components/Button/StyledButton.d.ts.map +1 -0
- package/dist/components/Button/index.d.ts +2 -2
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/lib/variantToBackground.d.ts +3 -0
- package/dist/components/Button/lib/variantToBackground.d.ts.map +1 -0
- package/dist/components/Button/lib/variantToFont.d.ts +3 -0
- package/dist/components/Button/lib/variantToFont.d.ts.map +1 -0
- package/dist/components/Checkbox/index.story.d.ts +6 -16
- package/dist/components/Checkbox/index.story.d.ts.map +1 -1
- package/dist/components/Clickable/index.story.d.ts +4 -6
- package/dist/components/Clickable/index.story.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.story.d.ts +1 -0
- package/dist/components/DropdownSelector/index.story.d.ts.map +1 -1
- package/dist/components/Icon/index.story.d.ts +1 -1
- package/dist/components/SegmentedControl/RadioGroupContext.d.ts +1 -1
- package/dist/components/SegmentedControl/RadioGroupContext.d.ts.map +1 -1
- package/dist/index.cjs.js +341 -123
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +310 -92
- package/dist/index.esm.js.map +1 -1
- package/package.json +17 -20
- package/src/_lib/compat.ts +8 -0
- package/src/components/Button/StyledButton.tsx +66 -0
- package/src/components/Button/index.tsx +12 -104
- package/src/components/Button/lib/variantToBackground.tsx +19 -0
- package/src/components/Button/lib/variantToFont.tsx +19 -0
- package/src/components/Checkbox/index.story.tsx +82 -88
- package/src/components/Clickable/index.story.tsx +12 -9
- package/src/components/DropdownSelector/DropdownMenuItem.tsx +1 -14
- package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +173 -109
- package/src/components/DropdownSelector/index.story.tsx +33 -0
- package/src/components/DropdownSelector/index.tsx +8 -15
- package/src/components/Modal/__snapshots__/index.story.storyshot +19 -23
- package/src/components/SegmentedControl/RadioGroupContext.tsx +1 -1
- package/src/components/SegmentedControl/__snapshots__/index.story.storyshot +9 -9
- package/src/components/SegmentedControl/index.tsx +1 -1
- package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +17 -15
- package/src/components/TextField/__snapshots__/TextField.story.storyshot +21 -20
- package/dist/components/Checkbox/performance.test.d.ts +0 -4
- package/dist/components/Checkbox/performance.test.d.ts.map +0 -1
- package/dist/components/Checkbox/snapshot.test.d.ts +0 -2
- package/dist/components/Checkbox/snapshot.test.d.ts.map +0 -1
- package/src/components/Checkbox/__snapshots__/snapshot.test.tsx.snap +0 -1093
- package/src/components/Checkbox/performance.test.tsx +0 -30
- package/src/components/Checkbox/snapshot.test.tsx +0 -66
package/dist/index.esm.js
CHANGED
|
@@ -50,7 +50,6 @@ function CharcoalProvider({
|
|
|
50
50
|
|
|
51
51
|
// src/components/Button/index.tsx
|
|
52
52
|
import { forwardRef as forwardRef3 } from "react";
|
|
53
|
-
import styled2, { css } from "styled-components";
|
|
54
53
|
|
|
55
54
|
// src/_lib/index.ts
|
|
56
55
|
function unreachable(value) {
|
|
@@ -74,6 +73,45 @@ function countCodePointsInString(string) {
|
|
|
74
73
|
return Array.from(string).length;
|
|
75
74
|
}
|
|
76
75
|
|
|
76
|
+
// src/components/Button/lib/variantToFont.tsx
|
|
77
|
+
function variantToFont(variant) {
|
|
78
|
+
switch (variant) {
|
|
79
|
+
case "Overlay":
|
|
80
|
+
return "text5";
|
|
81
|
+
case "Default":
|
|
82
|
+
return "text2";
|
|
83
|
+
case "Primary":
|
|
84
|
+
return "text5";
|
|
85
|
+
case "Navigation":
|
|
86
|
+
return "text5";
|
|
87
|
+
case "Danger":
|
|
88
|
+
return "text5";
|
|
89
|
+
default:
|
|
90
|
+
return unreachable(variant);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/components/Button/lib/variantToBackground.tsx
|
|
95
|
+
function variantToBackground(variant) {
|
|
96
|
+
switch (variant) {
|
|
97
|
+
case "Overlay":
|
|
98
|
+
return "surface4";
|
|
99
|
+
case "Default":
|
|
100
|
+
return "surface3";
|
|
101
|
+
case "Primary":
|
|
102
|
+
return "brand";
|
|
103
|
+
case "Navigation":
|
|
104
|
+
return "surface6";
|
|
105
|
+
case "Danger":
|
|
106
|
+
return "assertive";
|
|
107
|
+
default:
|
|
108
|
+
return unreachable(variant);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/components/Button/StyledButton.tsx
|
|
113
|
+
import styled2, { css } from "styled-components";
|
|
114
|
+
|
|
77
115
|
// src/components/Clickable/index.tsx
|
|
78
116
|
import * as React2 from "react";
|
|
79
117
|
import styled from "styled-components";
|
|
@@ -144,31 +182,7 @@ var StyledClickableDiv = styled.div`
|
|
|
144
182
|
}
|
|
145
183
|
`;
|
|
146
184
|
|
|
147
|
-
// src/components/Button/
|
|
148
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
149
|
-
var Button = forwardRef3(function Button2({
|
|
150
|
-
children,
|
|
151
|
-
variant = "Default",
|
|
152
|
-
size = "M",
|
|
153
|
-
fullWidth: fixed = false,
|
|
154
|
-
disabled = false,
|
|
155
|
-
...rest
|
|
156
|
-
}, ref) {
|
|
157
|
-
return /* @__PURE__ */ jsx4(
|
|
158
|
-
StyledButton,
|
|
159
|
-
{
|
|
160
|
-
...rest,
|
|
161
|
-
disabled,
|
|
162
|
-
$background: variantToBackground(variant),
|
|
163
|
-
$color: variantToFont(variant),
|
|
164
|
-
$size: size,
|
|
165
|
-
$fullWidth: fixed,
|
|
166
|
-
ref,
|
|
167
|
-
children
|
|
168
|
-
}
|
|
169
|
-
);
|
|
170
|
-
});
|
|
171
|
-
var Button_default = Button;
|
|
185
|
+
// src/components/Button/StyledButton.tsx
|
|
172
186
|
var horizontalPaddingSmall = css`
|
|
173
187
|
padding-right: 16px;
|
|
174
188
|
padding-left: 16px;
|
|
@@ -191,7 +205,6 @@ var StyledButton = styled2(Clickable_default)`
|
|
|
191
205
|
font-weight: bold;
|
|
192
206
|
|
|
193
207
|
${(p) => p.$size === "M" ? horizontalPaddingMedium : horizontalPaddingSmall}
|
|
194
|
-
|
|
195
208
|
color: var(--charcoal-${(p) => p.$color});
|
|
196
209
|
background-color: var(--charcoal-${(p) => p.$background});
|
|
197
210
|
transition: 0.2s color, 0.2s background-color, 0.2s box-shadow;
|
|
@@ -219,42 +232,34 @@ var StyledButton = styled2(Clickable_default)`
|
|
|
219
232
|
&[aria-disabled]:not([aria-disabled='false']) {
|
|
220
233
|
opacity: 0.32;
|
|
221
234
|
}
|
|
222
|
-
|
|
223
|
-
/* よく考えたらheight=32って定義が存在しないな... */
|
|
224
235
|
height: ${(p) => p.$size === "M" ? 40 : 32}px;
|
|
225
236
|
`;
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
case "Danger":
|
|
253
|
-
return "text5";
|
|
254
|
-
default:
|
|
255
|
-
return unreachable(variant);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
237
|
+
|
|
238
|
+
// src/components/Button/index.tsx
|
|
239
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
240
|
+
var Button = forwardRef3(function Button2({
|
|
241
|
+
children,
|
|
242
|
+
variant = "Default",
|
|
243
|
+
size = "M",
|
|
244
|
+
fullWidth: fixed = false,
|
|
245
|
+
disabled = false,
|
|
246
|
+
...rest
|
|
247
|
+
}, ref) {
|
|
248
|
+
return /* @__PURE__ */ jsx4(
|
|
249
|
+
StyledButton,
|
|
250
|
+
{
|
|
251
|
+
...rest,
|
|
252
|
+
disabled,
|
|
253
|
+
$background: variantToBackground(variant),
|
|
254
|
+
$color: variantToFont(variant),
|
|
255
|
+
$size: size,
|
|
256
|
+
$fullWidth: fixed,
|
|
257
|
+
ref,
|
|
258
|
+
children
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
});
|
|
262
|
+
var Button_default = Button;
|
|
258
263
|
|
|
259
264
|
// src/components/IconButton/index.tsx
|
|
260
265
|
import { forwardRef as forwardRef4 } from "react";
|
|
@@ -2179,6 +2184,7 @@ var DropdownButton = styled16.button`
|
|
|
2179
2184
|
box-sizing: border-box;
|
|
2180
2185
|
border: none;
|
|
2181
2186
|
cursor: pointer;
|
|
2187
|
+
gap: 4px;
|
|
2182
2188
|
|
|
2183
2189
|
${disabledSelector2} {
|
|
2184
2190
|
cursor: default;
|
|
@@ -2189,7 +2195,7 @@ var DropdownButton = styled16.button`
|
|
|
2189
2195
|
background-color: var(--charcoal-surface3);
|
|
2190
2196
|
border-radius: 4px;
|
|
2191
2197
|
|
|
2192
|
-
transition: 0.2s box-shadow;
|
|
2198
|
+
transition: 0.2s box-shadow, 0.2s background-color;
|
|
2193
2199
|
|
|
2194
2200
|
&:not(:disabled):not([aria-disabled]),
|
|
2195
2201
|
&[aria-disabled='false'] {
|
|
@@ -2199,6 +2205,9 @@ var DropdownButton = styled16.button`
|
|
|
2199
2205
|
outline: none;
|
|
2200
2206
|
box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
|
|
2201
2207
|
}
|
|
2208
|
+
&:hover {
|
|
2209
|
+
background-color: var(--charcoal-surface3-hover);
|
|
2210
|
+
}
|
|
2202
2211
|
}
|
|
2203
2212
|
|
|
2204
2213
|
${({ invalid }) => invalid === true && css9`
|
|
@@ -2214,20 +2223,9 @@ var DropdownButtonText = styled16.span`
|
|
|
2214
2223
|
line-height: 22px;
|
|
2215
2224
|
display: flow-root;
|
|
2216
2225
|
color: var(--charcoal-text2);
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
height: 0;
|
|
2221
|
-
content: '';
|
|
2222
|
-
margin-top: -4px;
|
|
2223
|
-
}
|
|
2224
|
-
&::after {
|
|
2225
|
-
display: block;
|
|
2226
|
-
width: 0;
|
|
2227
|
-
height: 0;
|
|
2228
|
-
content: '';
|
|
2229
|
-
margin-bottom: -4px;
|
|
2230
|
-
}
|
|
2226
|
+
overflow: hidden;
|
|
2227
|
+
text-overflow: ellipsis;
|
|
2228
|
+
white-space: nowrap;
|
|
2231
2229
|
`;
|
|
2232
2230
|
var DropdownButtonIcon = styled16(Icon_default)`
|
|
2233
2231
|
color: var(--charcoal-text2);
|
|
@@ -2395,20 +2393,7 @@ var StyledSpan = styled18.span`
|
|
|
2395
2393
|
font-size: 14px;
|
|
2396
2394
|
line-height: 22px;
|
|
2397
2395
|
color: var(--charcoal-text2);
|
|
2398
|
-
|
|
2399
|
-
display: block;
|
|
2400
|
-
width: 0;
|
|
2401
|
-
height: 0;
|
|
2402
|
-
content: '';
|
|
2403
|
-
margin-top: -4px;
|
|
2404
|
-
}
|
|
2405
|
-
&::after {
|
|
2406
|
-
display: block;
|
|
2407
|
-
width: 0;
|
|
2408
|
-
height: 0;
|
|
2409
|
-
content: '';
|
|
2410
|
-
margin-bottom: -4px;
|
|
2411
|
-
}
|
|
2396
|
+
padding: 9px 0;
|
|
2412
2397
|
|
|
2413
2398
|
display: flex;
|
|
2414
2399
|
align-items: center;
|
|
@@ -2449,7 +2434,240 @@ var StyledLi2 = styled19.li`
|
|
|
2449
2434
|
|
|
2450
2435
|
// src/components/SegmentedControl/index.tsx
|
|
2451
2436
|
import { forwardRef as forwardRef15, memo as memo6, useMemo as useMemo2, useRef as useRef10 } from "react";
|
|
2452
|
-
|
|
2437
|
+
|
|
2438
|
+
// ../../node_modules/@react-stately/form/dist/import.mjs
|
|
2439
|
+
import { createContext as $jcIOw$createContext, useMemo as $jcIOw$useMemo, useContext as $jcIOw$useContext, useState as $jcIOw$useState, useRef as $jcIOw$useRef, useEffect as $jcIOw$useEffect } from "react";
|
|
2440
|
+
var $e5be200c675c3b3a$export$aca958c65c314e6c = {
|
|
2441
|
+
badInput: false,
|
|
2442
|
+
customError: false,
|
|
2443
|
+
patternMismatch: false,
|
|
2444
|
+
rangeOverflow: false,
|
|
2445
|
+
rangeUnderflow: false,
|
|
2446
|
+
stepMismatch: false,
|
|
2447
|
+
tooLong: false,
|
|
2448
|
+
tooShort: false,
|
|
2449
|
+
typeMismatch: false,
|
|
2450
|
+
valueMissing: false,
|
|
2451
|
+
valid: true
|
|
2452
|
+
};
|
|
2453
|
+
var $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE = {
|
|
2454
|
+
...$e5be200c675c3b3a$export$aca958c65c314e6c,
|
|
2455
|
+
customError: true,
|
|
2456
|
+
valid: false
|
|
2457
|
+
};
|
|
2458
|
+
var $e5be200c675c3b3a$export$dad6ae84456c676a = {
|
|
2459
|
+
isInvalid: false,
|
|
2460
|
+
validationDetails: $e5be200c675c3b3a$export$aca958c65c314e6c,
|
|
2461
|
+
validationErrors: []
|
|
2462
|
+
};
|
|
2463
|
+
var $e5be200c675c3b3a$export$571b5131b7e65c11 = (0, $jcIOw$createContext)({});
|
|
2464
|
+
var $e5be200c675c3b3a$export$a763b9476acd3eb = "__formValidationState" + Date.now();
|
|
2465
|
+
function $e5be200c675c3b3a$export$fc1a364ae1f3ff10(props) {
|
|
2466
|
+
if (props[$e5be200c675c3b3a$export$a763b9476acd3eb]) {
|
|
2467
|
+
let { realtimeValidation, displayValidation, updateValidation, resetValidation, commitValidation } = props[$e5be200c675c3b3a$export$a763b9476acd3eb];
|
|
2468
|
+
return {
|
|
2469
|
+
realtimeValidation,
|
|
2470
|
+
displayValidation,
|
|
2471
|
+
updateValidation,
|
|
2472
|
+
resetValidation,
|
|
2473
|
+
commitValidation
|
|
2474
|
+
};
|
|
2475
|
+
}
|
|
2476
|
+
return $e5be200c675c3b3a$var$useFormValidationStateImpl(props);
|
|
2477
|
+
}
|
|
2478
|
+
function $e5be200c675c3b3a$var$useFormValidationStateImpl(props) {
|
|
2479
|
+
let { isInvalid, validationState, name, value, builtinValidation, validate, validationBehavior = "aria" } = props;
|
|
2480
|
+
if (validationState)
|
|
2481
|
+
isInvalid || (isInvalid = validationState === "invalid");
|
|
2482
|
+
let controlledError = isInvalid ? {
|
|
2483
|
+
isInvalid: true,
|
|
2484
|
+
validationErrors: [],
|
|
2485
|
+
validationDetails: $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE
|
|
2486
|
+
} : null;
|
|
2487
|
+
let clientError = (0, $jcIOw$useMemo)(() => $e5be200c675c3b3a$var$getValidationResult($e5be200c675c3b3a$var$runValidate(validate, value)), [
|
|
2488
|
+
validate,
|
|
2489
|
+
value
|
|
2490
|
+
]);
|
|
2491
|
+
if (builtinValidation === null || builtinValidation === void 0 ? void 0 : builtinValidation.validationDetails.valid)
|
|
2492
|
+
builtinValidation = null;
|
|
2493
|
+
let serverErrors = (0, $jcIOw$useContext)($e5be200c675c3b3a$export$571b5131b7e65c11);
|
|
2494
|
+
let serverErrorMessages = (0, $jcIOw$useMemo)(() => {
|
|
2495
|
+
if (name)
|
|
2496
|
+
return Array.isArray(name) ? name.flatMap((name2) => $e5be200c675c3b3a$var$asArray(serverErrors[name2])) : $e5be200c675c3b3a$var$asArray(serverErrors[name]);
|
|
2497
|
+
return [];
|
|
2498
|
+
}, [
|
|
2499
|
+
serverErrors,
|
|
2500
|
+
name
|
|
2501
|
+
]);
|
|
2502
|
+
let [lastServerErrors, setLastServerErrors] = (0, $jcIOw$useState)(serverErrors);
|
|
2503
|
+
let [isServerErrorCleared, setServerErrorCleared] = (0, $jcIOw$useState)(false);
|
|
2504
|
+
if (serverErrors !== lastServerErrors) {
|
|
2505
|
+
setLastServerErrors(serverErrors);
|
|
2506
|
+
setServerErrorCleared(false);
|
|
2507
|
+
}
|
|
2508
|
+
let serverError = (0, $jcIOw$useMemo)(() => $e5be200c675c3b3a$var$getValidationResult(isServerErrorCleared ? [] : serverErrorMessages), [
|
|
2509
|
+
isServerErrorCleared,
|
|
2510
|
+
serverErrorMessages
|
|
2511
|
+
]);
|
|
2512
|
+
let nextValidation = (0, $jcIOw$useRef)($e5be200c675c3b3a$export$dad6ae84456c676a);
|
|
2513
|
+
let [currentValidity, setCurrentValidity] = (0, $jcIOw$useState)($e5be200c675c3b3a$export$dad6ae84456c676a);
|
|
2514
|
+
let lastError = (0, $jcIOw$useRef)($e5be200c675c3b3a$export$dad6ae84456c676a);
|
|
2515
|
+
let commitValidation = () => {
|
|
2516
|
+
if (!commitQueued)
|
|
2517
|
+
return;
|
|
2518
|
+
setCommitQueued(false);
|
|
2519
|
+
let error = clientError || builtinValidation || nextValidation.current;
|
|
2520
|
+
if (!$e5be200c675c3b3a$var$isEqualValidation(error, lastError.current)) {
|
|
2521
|
+
lastError.current = error;
|
|
2522
|
+
setCurrentValidity(error);
|
|
2523
|
+
}
|
|
2524
|
+
};
|
|
2525
|
+
let [commitQueued, setCommitQueued] = (0, $jcIOw$useState)(false);
|
|
2526
|
+
(0, $jcIOw$useEffect)(commitValidation);
|
|
2527
|
+
let realtimeValidation = controlledError || serverError || clientError || builtinValidation || $e5be200c675c3b3a$export$dad6ae84456c676a;
|
|
2528
|
+
let displayValidation = validationBehavior === "native" ? controlledError || serverError || currentValidity : controlledError || serverError || clientError || builtinValidation || currentValidity;
|
|
2529
|
+
return {
|
|
2530
|
+
realtimeValidation,
|
|
2531
|
+
displayValidation,
|
|
2532
|
+
updateValidation(value2) {
|
|
2533
|
+
if (validationBehavior === "aria" && !$e5be200c675c3b3a$var$isEqualValidation(currentValidity, value2))
|
|
2534
|
+
setCurrentValidity(value2);
|
|
2535
|
+
else
|
|
2536
|
+
nextValidation.current = value2;
|
|
2537
|
+
},
|
|
2538
|
+
resetValidation() {
|
|
2539
|
+
let error = $e5be200c675c3b3a$export$dad6ae84456c676a;
|
|
2540
|
+
if (!$e5be200c675c3b3a$var$isEqualValidation(error, lastError.current)) {
|
|
2541
|
+
lastError.current = error;
|
|
2542
|
+
setCurrentValidity(error);
|
|
2543
|
+
}
|
|
2544
|
+
if (validationBehavior === "native")
|
|
2545
|
+
setCommitQueued(false);
|
|
2546
|
+
setServerErrorCleared(true);
|
|
2547
|
+
},
|
|
2548
|
+
commitValidation() {
|
|
2549
|
+
if (validationBehavior === "native")
|
|
2550
|
+
setCommitQueued(true);
|
|
2551
|
+
setServerErrorCleared(true);
|
|
2552
|
+
}
|
|
2553
|
+
};
|
|
2554
|
+
}
|
|
2555
|
+
function $e5be200c675c3b3a$var$asArray(v) {
|
|
2556
|
+
if (!v)
|
|
2557
|
+
return [];
|
|
2558
|
+
return Array.isArray(v) ? v : [
|
|
2559
|
+
v
|
|
2560
|
+
];
|
|
2561
|
+
}
|
|
2562
|
+
function $e5be200c675c3b3a$var$runValidate(validate, value) {
|
|
2563
|
+
if (typeof validate === "function") {
|
|
2564
|
+
let e = validate(value);
|
|
2565
|
+
if (e && typeof e !== "boolean")
|
|
2566
|
+
return $e5be200c675c3b3a$var$asArray(e);
|
|
2567
|
+
}
|
|
2568
|
+
return [];
|
|
2569
|
+
}
|
|
2570
|
+
function $e5be200c675c3b3a$var$getValidationResult(errors) {
|
|
2571
|
+
return errors.length ? {
|
|
2572
|
+
isInvalid: true,
|
|
2573
|
+
validationErrors: errors,
|
|
2574
|
+
validationDetails: $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE
|
|
2575
|
+
} : null;
|
|
2576
|
+
}
|
|
2577
|
+
function $e5be200c675c3b3a$var$isEqualValidation(a, b) {
|
|
2578
|
+
if (a === b)
|
|
2579
|
+
return true;
|
|
2580
|
+
return a && b && a.isInvalid === b.isInvalid && a.validationErrors.length === b.validationErrors.length && a.validationErrors.every((a2, i) => a2 === b.validationErrors[i]) && Object.entries(a.validationDetails).every(([k, v]) => b.validationDetails[k] === v);
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2583
|
+
// ../../node_modules/@react-stately/utils/dist/import.mjs
|
|
2584
|
+
import { useState as $6imuh$useState, useRef as $6imuh$useRef, useEffect as $6imuh$useEffect, useCallback as $6imuh$useCallback } from "react";
|
|
2585
|
+
function $458b0a5536c1a7cf$export$40bfa8c7b0832715(value, defaultValue, onChange) {
|
|
2586
|
+
let [stateValue, setStateValue] = (0, $6imuh$useState)(value || defaultValue);
|
|
2587
|
+
let isControlledRef = (0, $6imuh$useRef)(value !== void 0);
|
|
2588
|
+
let isControlled = value !== void 0;
|
|
2589
|
+
(0, $6imuh$useEffect)(() => {
|
|
2590
|
+
let wasControlled = isControlledRef.current;
|
|
2591
|
+
if (wasControlled !== isControlled)
|
|
2592
|
+
console.warn(`WARN: A component changed from ${wasControlled ? "controlled" : "uncontrolled"} to ${isControlled ? "controlled" : "uncontrolled"}.`);
|
|
2593
|
+
isControlledRef.current = isControlled;
|
|
2594
|
+
}, [
|
|
2595
|
+
isControlled
|
|
2596
|
+
]);
|
|
2597
|
+
let currentValue = isControlled ? value : stateValue;
|
|
2598
|
+
let setValue = (0, $6imuh$useCallback)((value2, ...args) => {
|
|
2599
|
+
let onChangeCaller = (value3, ...onChangeArgs) => {
|
|
2600
|
+
if (onChange) {
|
|
2601
|
+
if (!Object.is(currentValue, value3))
|
|
2602
|
+
onChange(value3, ...onChangeArgs);
|
|
2603
|
+
}
|
|
2604
|
+
if (!isControlled)
|
|
2605
|
+
currentValue = value3;
|
|
2606
|
+
};
|
|
2607
|
+
if (typeof value2 === "function") {
|
|
2608
|
+
console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320");
|
|
2609
|
+
let updateFunction = (oldValue, ...functionArgs) => {
|
|
2610
|
+
let interceptedValue = value2(isControlled ? currentValue : oldValue, ...functionArgs);
|
|
2611
|
+
onChangeCaller(interceptedValue, ...args);
|
|
2612
|
+
if (!isControlled)
|
|
2613
|
+
return interceptedValue;
|
|
2614
|
+
return oldValue;
|
|
2615
|
+
};
|
|
2616
|
+
setStateValue(updateFunction);
|
|
2617
|
+
} else {
|
|
2618
|
+
if (!isControlled)
|
|
2619
|
+
setStateValue(value2);
|
|
2620
|
+
onChangeCaller(value2, ...args);
|
|
2621
|
+
}
|
|
2622
|
+
}, [
|
|
2623
|
+
isControlled,
|
|
2624
|
+
currentValue,
|
|
2625
|
+
onChange
|
|
2626
|
+
]);
|
|
2627
|
+
return [
|
|
2628
|
+
currentValue,
|
|
2629
|
+
setValue
|
|
2630
|
+
];
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
// ../../node_modules/@react-stately/radio/dist/import.mjs
|
|
2634
|
+
import { useMemo as $fQ2SF$useMemo, useState as $fQ2SF$useState } from "react";
|
|
2635
|
+
var $a54cdc5c1942b639$var$instance = Math.round(Math.random() * 1e10);
|
|
2636
|
+
var $a54cdc5c1942b639$var$i = 0;
|
|
2637
|
+
function $a54cdc5c1942b639$export$bca9d026f8e704eb(props) {
|
|
2638
|
+
let name = (0, $fQ2SF$useMemo)(() => props.name || `radio-group-${$a54cdc5c1942b639$var$instance}-${++$a54cdc5c1942b639$var$i}`, [
|
|
2639
|
+
props.name
|
|
2640
|
+
]);
|
|
2641
|
+
var _props_defaultValue;
|
|
2642
|
+
let [selectedValue, setSelected] = (0, $458b0a5536c1a7cf$export$40bfa8c7b0832715)(props.value, (_props_defaultValue = props.defaultValue) !== null && _props_defaultValue !== void 0 ? _props_defaultValue : null, props.onChange);
|
|
2643
|
+
let [lastFocusedValue, setLastFocusedValue] = (0, $fQ2SF$useState)(null);
|
|
2644
|
+
let validation = (0, $e5be200c675c3b3a$export$fc1a364ae1f3ff10)({
|
|
2645
|
+
...props,
|
|
2646
|
+
value: selectedValue
|
|
2647
|
+
});
|
|
2648
|
+
let setSelectedValue = (value) => {
|
|
2649
|
+
if (!props.isReadOnly && !props.isDisabled) {
|
|
2650
|
+
setSelected(value);
|
|
2651
|
+
validation.commitValidation();
|
|
2652
|
+
}
|
|
2653
|
+
};
|
|
2654
|
+
let isInvalid = validation.displayValidation.isInvalid;
|
|
2655
|
+
return {
|
|
2656
|
+
...validation,
|
|
2657
|
+
name,
|
|
2658
|
+
selectedValue,
|
|
2659
|
+
setSelectedValue,
|
|
2660
|
+
lastFocusedValue,
|
|
2661
|
+
setLastFocusedValue,
|
|
2662
|
+
isDisabled: props.isDisabled || false,
|
|
2663
|
+
isReadOnly: props.isReadOnly || false,
|
|
2664
|
+
isRequired: props.isRequired || false,
|
|
2665
|
+
validationState: props.validationState || (isInvalid ? "invalid" : null),
|
|
2666
|
+
isInvalid
|
|
2667
|
+
};
|
|
2668
|
+
}
|
|
2669
|
+
|
|
2670
|
+
// src/components/SegmentedControl/index.tsx
|
|
2453
2671
|
import {
|
|
2454
2672
|
useRadio,
|
|
2455
2673
|
useRadioGroup
|
|
@@ -2487,7 +2705,7 @@ var SegmentedControl = forwardRef15(
|
|
|
2487
2705
|
}),
|
|
2488
2706
|
[props]
|
|
2489
2707
|
);
|
|
2490
|
-
const state =
|
|
2708
|
+
const state = $a54cdc5c1942b639$export$bca9d026f8e704eb(ariaRadioGroupProps);
|
|
2491
2709
|
const { radioGroupProps } = useRadioGroup(ariaRadioGroupProps, state);
|
|
2492
2710
|
const segmentedControlItems = useMemo2(() => {
|
|
2493
2711
|
return props.data.map(
|