@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.cjs.js
CHANGED
|
@@ -110,7 +110,6 @@ function CharcoalProvider({
|
|
|
110
110
|
|
|
111
111
|
// src/components/Button/index.tsx
|
|
112
112
|
var import_react2 = require("react");
|
|
113
|
-
var import_styled_components3 = __toESM(require("styled-components"));
|
|
114
113
|
|
|
115
114
|
// src/_lib/index.ts
|
|
116
115
|
function unreachable(value) {
|
|
@@ -134,6 +133,45 @@ function countCodePointsInString(string) {
|
|
|
134
133
|
return Array.from(string).length;
|
|
135
134
|
}
|
|
136
135
|
|
|
136
|
+
// src/components/Button/lib/variantToFont.tsx
|
|
137
|
+
function variantToFont(variant) {
|
|
138
|
+
switch (variant) {
|
|
139
|
+
case "Overlay":
|
|
140
|
+
return "text5";
|
|
141
|
+
case "Default":
|
|
142
|
+
return "text2";
|
|
143
|
+
case "Primary":
|
|
144
|
+
return "text5";
|
|
145
|
+
case "Navigation":
|
|
146
|
+
return "text5";
|
|
147
|
+
case "Danger":
|
|
148
|
+
return "text5";
|
|
149
|
+
default:
|
|
150
|
+
return unreachable(variant);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/components/Button/lib/variantToBackground.tsx
|
|
155
|
+
function variantToBackground(variant) {
|
|
156
|
+
switch (variant) {
|
|
157
|
+
case "Overlay":
|
|
158
|
+
return "surface4";
|
|
159
|
+
case "Default":
|
|
160
|
+
return "surface3";
|
|
161
|
+
case "Primary":
|
|
162
|
+
return "brand";
|
|
163
|
+
case "Navigation":
|
|
164
|
+
return "surface6";
|
|
165
|
+
case "Danger":
|
|
166
|
+
return "assertive";
|
|
167
|
+
default:
|
|
168
|
+
return unreachable(variant);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// src/components/Button/StyledButton.tsx
|
|
173
|
+
var import_styled_components3 = __toESM(require("styled-components"));
|
|
174
|
+
|
|
137
175
|
// src/components/Clickable/index.tsx
|
|
138
176
|
var React2 = __toESM(require("react"));
|
|
139
177
|
var import_styled_components2 = __toESM(require("styled-components"));
|
|
@@ -204,31 +242,7 @@ var StyledClickableDiv = import_styled_components2.default.div`
|
|
|
204
242
|
}
|
|
205
243
|
`;
|
|
206
244
|
|
|
207
|
-
// src/components/Button/
|
|
208
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
209
|
-
var Button = (0, import_react2.forwardRef)(function Button2({
|
|
210
|
-
children,
|
|
211
|
-
variant = "Default",
|
|
212
|
-
size = "M",
|
|
213
|
-
fullWidth: fixed = false,
|
|
214
|
-
disabled = false,
|
|
215
|
-
...rest
|
|
216
|
-
}, ref) {
|
|
217
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
218
|
-
StyledButton,
|
|
219
|
-
{
|
|
220
|
-
...rest,
|
|
221
|
-
disabled,
|
|
222
|
-
$background: variantToBackground(variant),
|
|
223
|
-
$color: variantToFont(variant),
|
|
224
|
-
$size: size,
|
|
225
|
-
$fullWidth: fixed,
|
|
226
|
-
ref,
|
|
227
|
-
children
|
|
228
|
-
}
|
|
229
|
-
);
|
|
230
|
-
});
|
|
231
|
-
var Button_default = Button;
|
|
245
|
+
// src/components/Button/StyledButton.tsx
|
|
232
246
|
var horizontalPaddingSmall = import_styled_components3.css`
|
|
233
247
|
padding-right: 16px;
|
|
234
248
|
padding-left: 16px;
|
|
@@ -251,7 +265,6 @@ var StyledButton = (0, import_styled_components3.default)(Clickable_default)`
|
|
|
251
265
|
font-weight: bold;
|
|
252
266
|
|
|
253
267
|
${(p) => p.$size === "M" ? horizontalPaddingMedium : horizontalPaddingSmall}
|
|
254
|
-
|
|
255
268
|
color: var(--charcoal-${(p) => p.$color});
|
|
256
269
|
background-color: var(--charcoal-${(p) => p.$background});
|
|
257
270
|
transition: 0.2s color, 0.2s background-color, 0.2s box-shadow;
|
|
@@ -279,42 +292,34 @@ var StyledButton = (0, import_styled_components3.default)(Clickable_default)`
|
|
|
279
292
|
&[aria-disabled]:not([aria-disabled='false']) {
|
|
280
293
|
opacity: 0.32;
|
|
281
294
|
}
|
|
282
|
-
|
|
283
|
-
/* よく考えたらheight=32って定義が存在しないな... */
|
|
284
295
|
height: ${(p) => p.$size === "M" ? 40 : 32}px;
|
|
285
296
|
`;
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
case "Danger":
|
|
313
|
-
return "text5";
|
|
314
|
-
default:
|
|
315
|
-
return unreachable(variant);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
297
|
+
|
|
298
|
+
// src/components/Button/index.tsx
|
|
299
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
300
|
+
var Button = (0, import_react2.forwardRef)(function Button2({
|
|
301
|
+
children,
|
|
302
|
+
variant = "Default",
|
|
303
|
+
size = "M",
|
|
304
|
+
fullWidth: fixed = false,
|
|
305
|
+
disabled = false,
|
|
306
|
+
...rest
|
|
307
|
+
}, ref) {
|
|
308
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
309
|
+
StyledButton,
|
|
310
|
+
{
|
|
311
|
+
...rest,
|
|
312
|
+
disabled,
|
|
313
|
+
$background: variantToBackground(variant),
|
|
314
|
+
$color: variantToFont(variant),
|
|
315
|
+
$size: size,
|
|
316
|
+
$fullWidth: fixed,
|
|
317
|
+
ref,
|
|
318
|
+
children
|
|
319
|
+
}
|
|
320
|
+
);
|
|
321
|
+
});
|
|
322
|
+
var Button_default = Button;
|
|
318
323
|
|
|
319
324
|
// src/components/IconButton/index.tsx
|
|
320
325
|
var import_react3 = require("react");
|
|
@@ -2236,6 +2241,7 @@ var DropdownButton = import_styled_components17.default.button`
|
|
|
2236
2241
|
box-sizing: border-box;
|
|
2237
2242
|
border: none;
|
|
2238
2243
|
cursor: pointer;
|
|
2244
|
+
gap: 4px;
|
|
2239
2245
|
|
|
2240
2246
|
${import_utils8.disabledSelector} {
|
|
2241
2247
|
cursor: default;
|
|
@@ -2246,7 +2252,7 @@ var DropdownButton = import_styled_components17.default.button`
|
|
|
2246
2252
|
background-color: var(--charcoal-surface3);
|
|
2247
2253
|
border-radius: 4px;
|
|
2248
2254
|
|
|
2249
|
-
transition: 0.2s box-shadow;
|
|
2255
|
+
transition: 0.2s box-shadow, 0.2s background-color;
|
|
2250
2256
|
|
|
2251
2257
|
&:not(:disabled):not([aria-disabled]),
|
|
2252
2258
|
&[aria-disabled='false'] {
|
|
@@ -2256,6 +2262,9 @@ var DropdownButton = import_styled_components17.default.button`
|
|
|
2256
2262
|
outline: none;
|
|
2257
2263
|
box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
|
|
2258
2264
|
}
|
|
2265
|
+
&:hover {
|
|
2266
|
+
background-color: var(--charcoal-surface3-hover);
|
|
2267
|
+
}
|
|
2259
2268
|
}
|
|
2260
2269
|
|
|
2261
2270
|
${({ invalid }) => invalid === true && import_styled_components17.css`
|
|
@@ -2271,20 +2280,9 @@ var DropdownButtonText = import_styled_components17.default.span`
|
|
|
2271
2280
|
line-height: 22px;
|
|
2272
2281
|
display: flow-root;
|
|
2273
2282
|
color: var(--charcoal-text2);
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
height: 0;
|
|
2278
|
-
content: '';
|
|
2279
|
-
margin-top: -4px;
|
|
2280
|
-
}
|
|
2281
|
-
&::after {
|
|
2282
|
-
display: block;
|
|
2283
|
-
width: 0;
|
|
2284
|
-
height: 0;
|
|
2285
|
-
content: '';
|
|
2286
|
-
margin-bottom: -4px;
|
|
2287
|
-
}
|
|
2283
|
+
overflow: hidden;
|
|
2284
|
+
text-overflow: ellipsis;
|
|
2285
|
+
white-space: nowrap;
|
|
2288
2286
|
`;
|
|
2289
2287
|
var DropdownButtonIcon = (0, import_styled_components17.default)(Icon_default)`
|
|
2290
2288
|
color: var(--charcoal-text2);
|
|
@@ -2452,20 +2450,7 @@ var StyledSpan = import_styled_components19.default.span`
|
|
|
2452
2450
|
font-size: 14px;
|
|
2453
2451
|
line-height: 22px;
|
|
2454
2452
|
color: var(--charcoal-text2);
|
|
2455
|
-
|
|
2456
|
-
display: block;
|
|
2457
|
-
width: 0;
|
|
2458
|
-
height: 0;
|
|
2459
|
-
content: '';
|
|
2460
|
-
margin-top: -4px;
|
|
2461
|
-
}
|
|
2462
|
-
&::after {
|
|
2463
|
-
display: block;
|
|
2464
|
-
width: 0;
|
|
2465
|
-
height: 0;
|
|
2466
|
-
content: '';
|
|
2467
|
-
margin-bottom: -4px;
|
|
2468
|
-
}
|
|
2453
|
+
padding: 9px 0;
|
|
2469
2454
|
|
|
2470
2455
|
display: flex;
|
|
2471
2456
|
align-items: center;
|
|
@@ -2505,15 +2490,248 @@ var StyledLi2 = import_styled_components20.default.li`
|
|
|
2505
2490
|
`;
|
|
2506
2491
|
|
|
2507
2492
|
// src/components/SegmentedControl/index.tsx
|
|
2493
|
+
var import_react27 = require("react");
|
|
2494
|
+
|
|
2495
|
+
// ../../node_modules/@react-stately/form/dist/import.mjs
|
|
2496
|
+
var import_react23 = require("react");
|
|
2497
|
+
var $e5be200c675c3b3a$export$aca958c65c314e6c = {
|
|
2498
|
+
badInput: false,
|
|
2499
|
+
customError: false,
|
|
2500
|
+
patternMismatch: false,
|
|
2501
|
+
rangeOverflow: false,
|
|
2502
|
+
rangeUnderflow: false,
|
|
2503
|
+
stepMismatch: false,
|
|
2504
|
+
tooLong: false,
|
|
2505
|
+
tooShort: false,
|
|
2506
|
+
typeMismatch: false,
|
|
2507
|
+
valueMissing: false,
|
|
2508
|
+
valid: true
|
|
2509
|
+
};
|
|
2510
|
+
var $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE = {
|
|
2511
|
+
...$e5be200c675c3b3a$export$aca958c65c314e6c,
|
|
2512
|
+
customError: true,
|
|
2513
|
+
valid: false
|
|
2514
|
+
};
|
|
2515
|
+
var $e5be200c675c3b3a$export$dad6ae84456c676a = {
|
|
2516
|
+
isInvalid: false,
|
|
2517
|
+
validationDetails: $e5be200c675c3b3a$export$aca958c65c314e6c,
|
|
2518
|
+
validationErrors: []
|
|
2519
|
+
};
|
|
2520
|
+
var $e5be200c675c3b3a$export$571b5131b7e65c11 = (0, import_react23.createContext)({});
|
|
2521
|
+
var $e5be200c675c3b3a$export$a763b9476acd3eb = "__formValidationState" + Date.now();
|
|
2522
|
+
function $e5be200c675c3b3a$export$fc1a364ae1f3ff10(props) {
|
|
2523
|
+
if (props[$e5be200c675c3b3a$export$a763b9476acd3eb]) {
|
|
2524
|
+
let { realtimeValidation, displayValidation, updateValidation, resetValidation, commitValidation } = props[$e5be200c675c3b3a$export$a763b9476acd3eb];
|
|
2525
|
+
return {
|
|
2526
|
+
realtimeValidation,
|
|
2527
|
+
displayValidation,
|
|
2528
|
+
updateValidation,
|
|
2529
|
+
resetValidation,
|
|
2530
|
+
commitValidation
|
|
2531
|
+
};
|
|
2532
|
+
}
|
|
2533
|
+
return $e5be200c675c3b3a$var$useFormValidationStateImpl(props);
|
|
2534
|
+
}
|
|
2535
|
+
function $e5be200c675c3b3a$var$useFormValidationStateImpl(props) {
|
|
2536
|
+
let { isInvalid, validationState, name, value, builtinValidation, validate, validationBehavior = "aria" } = props;
|
|
2537
|
+
if (validationState)
|
|
2538
|
+
isInvalid || (isInvalid = validationState === "invalid");
|
|
2539
|
+
let controlledError = isInvalid ? {
|
|
2540
|
+
isInvalid: true,
|
|
2541
|
+
validationErrors: [],
|
|
2542
|
+
validationDetails: $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE
|
|
2543
|
+
} : null;
|
|
2544
|
+
let clientError = (0, import_react23.useMemo)(() => $e5be200c675c3b3a$var$getValidationResult($e5be200c675c3b3a$var$runValidate(validate, value)), [
|
|
2545
|
+
validate,
|
|
2546
|
+
value
|
|
2547
|
+
]);
|
|
2548
|
+
if (builtinValidation === null || builtinValidation === void 0 ? void 0 : builtinValidation.validationDetails.valid)
|
|
2549
|
+
builtinValidation = null;
|
|
2550
|
+
let serverErrors = (0, import_react23.useContext)($e5be200c675c3b3a$export$571b5131b7e65c11);
|
|
2551
|
+
let serverErrorMessages = (0, import_react23.useMemo)(() => {
|
|
2552
|
+
if (name)
|
|
2553
|
+
return Array.isArray(name) ? name.flatMap((name2) => $e5be200c675c3b3a$var$asArray(serverErrors[name2])) : $e5be200c675c3b3a$var$asArray(serverErrors[name]);
|
|
2554
|
+
return [];
|
|
2555
|
+
}, [
|
|
2556
|
+
serverErrors,
|
|
2557
|
+
name
|
|
2558
|
+
]);
|
|
2559
|
+
let [lastServerErrors, setLastServerErrors] = (0, import_react23.useState)(serverErrors);
|
|
2560
|
+
let [isServerErrorCleared, setServerErrorCleared] = (0, import_react23.useState)(false);
|
|
2561
|
+
if (serverErrors !== lastServerErrors) {
|
|
2562
|
+
setLastServerErrors(serverErrors);
|
|
2563
|
+
setServerErrorCleared(false);
|
|
2564
|
+
}
|
|
2565
|
+
let serverError = (0, import_react23.useMemo)(() => $e5be200c675c3b3a$var$getValidationResult(isServerErrorCleared ? [] : serverErrorMessages), [
|
|
2566
|
+
isServerErrorCleared,
|
|
2567
|
+
serverErrorMessages
|
|
2568
|
+
]);
|
|
2569
|
+
let nextValidation = (0, import_react23.useRef)($e5be200c675c3b3a$export$dad6ae84456c676a);
|
|
2570
|
+
let [currentValidity, setCurrentValidity] = (0, import_react23.useState)($e5be200c675c3b3a$export$dad6ae84456c676a);
|
|
2571
|
+
let lastError = (0, import_react23.useRef)($e5be200c675c3b3a$export$dad6ae84456c676a);
|
|
2572
|
+
let commitValidation = () => {
|
|
2573
|
+
if (!commitQueued)
|
|
2574
|
+
return;
|
|
2575
|
+
setCommitQueued(false);
|
|
2576
|
+
let error = clientError || builtinValidation || nextValidation.current;
|
|
2577
|
+
if (!$e5be200c675c3b3a$var$isEqualValidation(error, lastError.current)) {
|
|
2578
|
+
lastError.current = error;
|
|
2579
|
+
setCurrentValidity(error);
|
|
2580
|
+
}
|
|
2581
|
+
};
|
|
2582
|
+
let [commitQueued, setCommitQueued] = (0, import_react23.useState)(false);
|
|
2583
|
+
(0, import_react23.useEffect)(commitValidation);
|
|
2584
|
+
let realtimeValidation = controlledError || serverError || clientError || builtinValidation || $e5be200c675c3b3a$export$dad6ae84456c676a;
|
|
2585
|
+
let displayValidation = validationBehavior === "native" ? controlledError || serverError || currentValidity : controlledError || serverError || clientError || builtinValidation || currentValidity;
|
|
2586
|
+
return {
|
|
2587
|
+
realtimeValidation,
|
|
2588
|
+
displayValidation,
|
|
2589
|
+
updateValidation(value2) {
|
|
2590
|
+
if (validationBehavior === "aria" && !$e5be200c675c3b3a$var$isEqualValidation(currentValidity, value2))
|
|
2591
|
+
setCurrentValidity(value2);
|
|
2592
|
+
else
|
|
2593
|
+
nextValidation.current = value2;
|
|
2594
|
+
},
|
|
2595
|
+
resetValidation() {
|
|
2596
|
+
let error = $e5be200c675c3b3a$export$dad6ae84456c676a;
|
|
2597
|
+
if (!$e5be200c675c3b3a$var$isEqualValidation(error, lastError.current)) {
|
|
2598
|
+
lastError.current = error;
|
|
2599
|
+
setCurrentValidity(error);
|
|
2600
|
+
}
|
|
2601
|
+
if (validationBehavior === "native")
|
|
2602
|
+
setCommitQueued(false);
|
|
2603
|
+
setServerErrorCleared(true);
|
|
2604
|
+
},
|
|
2605
|
+
commitValidation() {
|
|
2606
|
+
if (validationBehavior === "native")
|
|
2607
|
+
setCommitQueued(true);
|
|
2608
|
+
setServerErrorCleared(true);
|
|
2609
|
+
}
|
|
2610
|
+
};
|
|
2611
|
+
}
|
|
2612
|
+
function $e5be200c675c3b3a$var$asArray(v) {
|
|
2613
|
+
if (!v)
|
|
2614
|
+
return [];
|
|
2615
|
+
return Array.isArray(v) ? v : [
|
|
2616
|
+
v
|
|
2617
|
+
];
|
|
2618
|
+
}
|
|
2619
|
+
function $e5be200c675c3b3a$var$runValidate(validate, value) {
|
|
2620
|
+
if (typeof validate === "function") {
|
|
2621
|
+
let e = validate(value);
|
|
2622
|
+
if (e && typeof e !== "boolean")
|
|
2623
|
+
return $e5be200c675c3b3a$var$asArray(e);
|
|
2624
|
+
}
|
|
2625
|
+
return [];
|
|
2626
|
+
}
|
|
2627
|
+
function $e5be200c675c3b3a$var$getValidationResult(errors) {
|
|
2628
|
+
return errors.length ? {
|
|
2629
|
+
isInvalid: true,
|
|
2630
|
+
validationErrors: errors,
|
|
2631
|
+
validationDetails: $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE
|
|
2632
|
+
} : null;
|
|
2633
|
+
}
|
|
2634
|
+
function $e5be200c675c3b3a$var$isEqualValidation(a, b) {
|
|
2635
|
+
if (a === b)
|
|
2636
|
+
return true;
|
|
2637
|
+
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);
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
// ../../node_modules/@react-stately/utils/dist/import.mjs
|
|
2508
2641
|
var import_react24 = require("react");
|
|
2509
|
-
|
|
2510
|
-
|
|
2642
|
+
function $458b0a5536c1a7cf$export$40bfa8c7b0832715(value, defaultValue, onChange) {
|
|
2643
|
+
let [stateValue, setStateValue] = (0, import_react24.useState)(value || defaultValue);
|
|
2644
|
+
let isControlledRef = (0, import_react24.useRef)(value !== void 0);
|
|
2645
|
+
let isControlled = value !== void 0;
|
|
2646
|
+
(0, import_react24.useEffect)(() => {
|
|
2647
|
+
let wasControlled = isControlledRef.current;
|
|
2648
|
+
if (wasControlled !== isControlled)
|
|
2649
|
+
console.warn(`WARN: A component changed from ${wasControlled ? "controlled" : "uncontrolled"} to ${isControlled ? "controlled" : "uncontrolled"}.`);
|
|
2650
|
+
isControlledRef.current = isControlled;
|
|
2651
|
+
}, [
|
|
2652
|
+
isControlled
|
|
2653
|
+
]);
|
|
2654
|
+
let currentValue = isControlled ? value : stateValue;
|
|
2655
|
+
let setValue = (0, import_react24.useCallback)((value2, ...args) => {
|
|
2656
|
+
let onChangeCaller = (value3, ...onChangeArgs) => {
|
|
2657
|
+
if (onChange) {
|
|
2658
|
+
if (!Object.is(currentValue, value3))
|
|
2659
|
+
onChange(value3, ...onChangeArgs);
|
|
2660
|
+
}
|
|
2661
|
+
if (!isControlled)
|
|
2662
|
+
currentValue = value3;
|
|
2663
|
+
};
|
|
2664
|
+
if (typeof value2 === "function") {
|
|
2665
|
+
console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320");
|
|
2666
|
+
let updateFunction = (oldValue, ...functionArgs) => {
|
|
2667
|
+
let interceptedValue = value2(isControlled ? currentValue : oldValue, ...functionArgs);
|
|
2668
|
+
onChangeCaller(interceptedValue, ...args);
|
|
2669
|
+
if (!isControlled)
|
|
2670
|
+
return interceptedValue;
|
|
2671
|
+
return oldValue;
|
|
2672
|
+
};
|
|
2673
|
+
setStateValue(updateFunction);
|
|
2674
|
+
} else {
|
|
2675
|
+
if (!isControlled)
|
|
2676
|
+
setStateValue(value2);
|
|
2677
|
+
onChangeCaller(value2, ...args);
|
|
2678
|
+
}
|
|
2679
|
+
}, [
|
|
2680
|
+
isControlled,
|
|
2681
|
+
currentValue,
|
|
2682
|
+
onChange
|
|
2683
|
+
]);
|
|
2684
|
+
return [
|
|
2685
|
+
currentValue,
|
|
2686
|
+
setValue
|
|
2687
|
+
];
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2690
|
+
// ../../node_modules/@react-stately/radio/dist/import.mjs
|
|
2691
|
+
var import_react25 = require("react");
|
|
2692
|
+
var $a54cdc5c1942b639$var$instance = Math.round(Math.random() * 1e10);
|
|
2693
|
+
var $a54cdc5c1942b639$var$i = 0;
|
|
2694
|
+
function $a54cdc5c1942b639$export$bca9d026f8e704eb(props) {
|
|
2695
|
+
let name = (0, import_react25.useMemo)(() => props.name || `radio-group-${$a54cdc5c1942b639$var$instance}-${++$a54cdc5c1942b639$var$i}`, [
|
|
2696
|
+
props.name
|
|
2697
|
+
]);
|
|
2698
|
+
var _props_defaultValue;
|
|
2699
|
+
let [selectedValue, setSelected] = (0, $458b0a5536c1a7cf$export$40bfa8c7b0832715)(props.value, (_props_defaultValue = props.defaultValue) !== null && _props_defaultValue !== void 0 ? _props_defaultValue : null, props.onChange);
|
|
2700
|
+
let [lastFocusedValue, setLastFocusedValue] = (0, import_react25.useState)(null);
|
|
2701
|
+
let validation = (0, $e5be200c675c3b3a$export$fc1a364ae1f3ff10)({
|
|
2702
|
+
...props,
|
|
2703
|
+
value: selectedValue
|
|
2704
|
+
});
|
|
2705
|
+
let setSelectedValue = (value) => {
|
|
2706
|
+
if (!props.isReadOnly && !props.isDisabled) {
|
|
2707
|
+
setSelected(value);
|
|
2708
|
+
validation.commitValidation();
|
|
2709
|
+
}
|
|
2710
|
+
};
|
|
2711
|
+
let isInvalid = validation.displayValidation.isInvalid;
|
|
2712
|
+
return {
|
|
2713
|
+
...validation,
|
|
2714
|
+
name,
|
|
2715
|
+
selectedValue,
|
|
2716
|
+
setSelectedValue,
|
|
2717
|
+
lastFocusedValue,
|
|
2718
|
+
setLastFocusedValue,
|
|
2719
|
+
isDisabled: props.isDisabled || false,
|
|
2720
|
+
isReadOnly: props.isReadOnly || false,
|
|
2721
|
+
isRequired: props.isRequired || false,
|
|
2722
|
+
validationState: props.validationState || (isInvalid ? "invalid" : null),
|
|
2723
|
+
isInvalid
|
|
2724
|
+
};
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
// src/components/SegmentedControl/index.tsx
|
|
2728
|
+
var import_radio2 = require("@react-aria/radio");
|
|
2511
2729
|
var import_styled_components21 = __toESM(require("styled-components"));
|
|
2512
2730
|
|
|
2513
2731
|
// src/components/SegmentedControl/RadioGroupContext.tsx
|
|
2514
|
-
var
|
|
2732
|
+
var import_react26 = require("react");
|
|
2515
2733
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2516
|
-
var RadioContext = (0,
|
|
2734
|
+
var RadioContext = (0, import_react26.createContext)(null);
|
|
2517
2735
|
var RadioProvider = ({
|
|
2518
2736
|
value,
|
|
2519
2737
|
children
|
|
@@ -2521,7 +2739,7 @@ var RadioProvider = ({
|
|
|
2521
2739
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(RadioContext.Provider, { value, children });
|
|
2522
2740
|
};
|
|
2523
2741
|
var useRadioContext = () => {
|
|
2524
|
-
const state = (0,
|
|
2742
|
+
const state = (0, import_react26.useContext)(RadioContext);
|
|
2525
2743
|
if (state === null)
|
|
2526
2744
|
throw new Error("`<RadioProvider>` is not likely mounted.");
|
|
2527
2745
|
return state;
|
|
@@ -2529,9 +2747,9 @@ var useRadioContext = () => {
|
|
|
2529
2747
|
|
|
2530
2748
|
// src/components/SegmentedControl/index.tsx
|
|
2531
2749
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2532
|
-
var SegmentedControl = (0,
|
|
2750
|
+
var SegmentedControl = (0, import_react27.forwardRef)(
|
|
2533
2751
|
function SegmentedControlInner(props, ref) {
|
|
2534
|
-
const ariaRadioGroupProps = (0,
|
|
2752
|
+
const ariaRadioGroupProps = (0, import_react27.useMemo)(
|
|
2535
2753
|
() => ({
|
|
2536
2754
|
...props,
|
|
2537
2755
|
isDisabled: props.disabled,
|
|
@@ -2541,9 +2759,9 @@ var SegmentedControl = (0, import_react24.forwardRef)(
|
|
|
2541
2759
|
}),
|
|
2542
2760
|
[props]
|
|
2543
2761
|
);
|
|
2544
|
-
const state = (
|
|
2545
|
-
const { radioGroupProps } = (0,
|
|
2546
|
-
const segmentedControlItems = (0,
|
|
2762
|
+
const state = $a54cdc5c1942b639$export$bca9d026f8e704eb(ariaRadioGroupProps);
|
|
2763
|
+
const { radioGroupProps } = (0, import_radio2.useRadioGroup)(ariaRadioGroupProps, state);
|
|
2764
|
+
const segmentedControlItems = (0, import_react27.useMemo)(() => {
|
|
2547
2765
|
return props.data.map(
|
|
2548
2766
|
(d) => typeof d === "string" ? { value: d, label: d } : d
|
|
2549
2767
|
);
|
|
@@ -2567,11 +2785,11 @@ var SegmentedControl = (0, import_react24.forwardRef)(
|
|
|
2567
2785
|
);
|
|
2568
2786
|
}
|
|
2569
2787
|
);
|
|
2570
|
-
var SegmentedControl_default = (0,
|
|
2788
|
+
var SegmentedControl_default = (0, import_react27.memo)(SegmentedControl);
|
|
2571
2789
|
var Segmented = (props) => {
|
|
2572
2790
|
const state = useRadioContext();
|
|
2573
|
-
const ref = (0,
|
|
2574
|
-
const ariaRadioProps = (0,
|
|
2791
|
+
const ref = (0, import_react27.useRef)(null);
|
|
2792
|
+
const ariaRadioProps = (0, import_react27.useMemo)(
|
|
2575
2793
|
() => ({
|
|
2576
2794
|
value: props.value,
|
|
2577
2795
|
isDisabled: props.disabled,
|
|
@@ -2579,7 +2797,7 @@ var Segmented = (props) => {
|
|
|
2579
2797
|
}),
|
|
2580
2798
|
[props]
|
|
2581
2799
|
);
|
|
2582
|
-
const { inputProps, isDisabled, isSelected } = (0,
|
|
2800
|
+
const { inputProps, isDisabled, isSelected } = (0, import_radio2.useRadio)(
|
|
2583
2801
|
ariaRadioProps,
|
|
2584
2802
|
state,
|
|
2585
2803
|
ref
|
|
@@ -2667,16 +2885,16 @@ var SegmentedLabelInner = import_styled_components21.default.div`
|
|
|
2667
2885
|
`;
|
|
2668
2886
|
|
|
2669
2887
|
// src/components/Checkbox/index.tsx
|
|
2670
|
-
var
|
|
2888
|
+
var import_react28 = require("react");
|
|
2671
2889
|
var import_styled_components22 = __toESM(require("styled-components"));
|
|
2672
2890
|
var import_checkbox = require("@react-aria/checkbox");
|
|
2673
|
-
var
|
|
2674
|
-
var
|
|
2675
|
-
var
|
|
2891
|
+
var import_utils10 = require("@react-aria/utils");
|
|
2892
|
+
var import_react_stately2 = require("react-stately");
|
|
2893
|
+
var import_utils11 = require("@charcoal-ui/utils");
|
|
2676
2894
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2677
|
-
var Checkbox = (0,
|
|
2895
|
+
var Checkbox = (0, import_react28.forwardRef)(
|
|
2678
2896
|
function CheckboxInner({ invalid = false, ...props }, ref) {
|
|
2679
|
-
const ariaCheckboxProps = (0,
|
|
2897
|
+
const ariaCheckboxProps = (0, import_react28.useMemo)(
|
|
2680
2898
|
() => ({
|
|
2681
2899
|
...props,
|
|
2682
2900
|
isInValid: invalid,
|
|
@@ -2688,8 +2906,8 @@ var Checkbox = (0, import_react25.forwardRef)(
|
|
|
2688
2906
|
}),
|
|
2689
2907
|
[invalid, props]
|
|
2690
2908
|
);
|
|
2691
|
-
const state = (0,
|
|
2692
|
-
const objectRef = (0,
|
|
2909
|
+
const state = (0, import_react_stately2.useToggleState)(ariaCheckboxProps);
|
|
2910
|
+
const objectRef = (0, import_utils10.useObjectRef)(ref);
|
|
2693
2911
|
const { inputProps } = (0, import_checkbox.useCheckbox)(ariaCheckboxProps, state, objectRef);
|
|
2694
2912
|
const isDisabled = (props.disabled ?? false) || (props.readonly ?? false);
|
|
2695
2913
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(InputRoot, { "aria-disabled": isDisabled, className: props.className, children: [
|
|
@@ -2701,7 +2919,7 @@ var Checkbox = (0, import_react25.forwardRef)(
|
|
|
2701
2919
|
] });
|
|
2702
2920
|
}
|
|
2703
2921
|
);
|
|
2704
|
-
var Checkbox_default = (0,
|
|
2922
|
+
var Checkbox_default = (0, import_react28.memo)(Checkbox);
|
|
2705
2923
|
var hiddenCss = import_styled_components22.css`
|
|
2706
2924
|
visibility: hidden;
|
|
2707
2925
|
`;
|
|
@@ -2710,7 +2928,7 @@ var InputRoot = import_styled_components22.default.label`
|
|
|
2710
2928
|
display: flex;
|
|
2711
2929
|
|
|
2712
2930
|
cursor: pointer;
|
|
2713
|
-
${
|
|
2931
|
+
${import_utils11.disabledSelector} {
|
|
2714
2932
|
cursor: default;
|
|
2715
2933
|
}
|
|
2716
2934
|
|
|
@@ -2796,17 +3014,17 @@ var InputLabel = import_styled_components22.default.div`
|
|
|
2796
3014
|
`;
|
|
2797
3015
|
|
|
2798
3016
|
// src/components/TagItem/index.tsx
|
|
2799
|
-
var
|
|
2800
|
-
var
|
|
3017
|
+
var import_react29 = require("react");
|
|
3018
|
+
var import_utils12 = require("@react-aria/utils");
|
|
2801
3019
|
var import_styled_components23 = __toESM(require("styled-components"));
|
|
2802
|
-
var
|
|
3020
|
+
var import_utils13 = require("@charcoal-ui/utils");
|
|
2803
3021
|
var import_button = require("@react-aria/button");
|
|
2804
3022
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
2805
3023
|
var sizeMap = {
|
|
2806
3024
|
S: 32,
|
|
2807
3025
|
M: 40
|
|
2808
3026
|
};
|
|
2809
|
-
var TagItem = (0,
|
|
3027
|
+
var TagItem = (0, import_react29.forwardRef)(
|
|
2810
3028
|
function TagItemInner({
|
|
2811
3029
|
label,
|
|
2812
3030
|
translatedLabel,
|
|
@@ -2818,8 +3036,8 @@ var TagItem = (0, import_react26.forwardRef)(
|
|
|
2818
3036
|
className,
|
|
2819
3037
|
...props
|
|
2820
3038
|
}, _ref) {
|
|
2821
|
-
const ref = (0,
|
|
2822
|
-
const ariaButtonProps = (0,
|
|
3039
|
+
const ref = (0, import_utils12.useObjectRef)(_ref);
|
|
3040
|
+
const ariaButtonProps = (0, import_react29.useMemo)(
|
|
2823
3041
|
() => ({
|
|
2824
3042
|
elementType: "a",
|
|
2825
3043
|
isDisabled: disabled,
|
|
@@ -2851,10 +3069,10 @@ var TagItem = (0, import_react26.forwardRef)(
|
|
|
2851
3069
|
);
|
|
2852
3070
|
}
|
|
2853
3071
|
);
|
|
2854
|
-
var TagItem_default = (0,
|
|
3072
|
+
var TagItem_default = (0, import_react29.memo)(TagItem);
|
|
2855
3073
|
var horizontalPadding = ({ left, right }) => import_styled_components23.css`
|
|
2856
|
-
padding-right: ${(0,
|
|
2857
|
-
padding-left: ${(0,
|
|
3074
|
+
padding-right: ${(0, import_utils13.px)(right)};
|
|
3075
|
+
padding-left: ${(0, import_utils13.px)(left)};
|
|
2858
3076
|
`;
|
|
2859
3077
|
var tagItemRootSize = (size) => {
|
|
2860
3078
|
switch (size) {
|