@charcoal-ui/react 3.0.0-beta.3 → 3.0.0-beta.4
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 +18 -0
- package/dist/_lib/compat.d.ts.map +1 -1
- package/dist/_lib/index.d.ts +7 -0
- package/dist/_lib/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.d.ts +1 -0
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.story.d.ts +1 -0
- package/dist/components/Checkbox/index.story.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/components/LoadingSpinner/index.d.ts +8 -6
- package/dist/components/LoadingSpinner/index.d.ts.map +1 -1
- package/dist/components/LoadingSpinner/index.story.d.ts +1 -2
- package/dist/components/LoadingSpinner/index.story.d.ts.map +1 -1
- package/dist/components/Modal/index.d.ts +17 -26
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.story.d.ts +12 -2
- package/dist/components/Modal/index.story.d.ts.map +1 -1
- package/dist/components/MultiSelect/index.d.ts +14 -1
- package/dist/components/MultiSelect/index.d.ts.map +1 -1
- package/dist/components/MultiSelect/index.story.d.ts +14 -2
- package/dist/components/MultiSelect/index.story.d.ts.map +1 -1
- package/dist/components/Radio/index.d.ts +12 -5
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/Radio/index.story.d.ts +10 -6
- package/dist/components/Radio/index.story.d.ts.map +1 -1
- package/dist/components/SegmentedControl/index.d.ts +1 -0
- package/dist/components/SegmentedControl/index.d.ts.map +1 -1
- package/dist/components/Switch/index.d.ts +2 -1
- package/dist/components/Switch/index.d.ts.map +1 -1
- package/dist/components/Switch/index.story.d.ts +1 -2
- package/dist/components/Switch/index.story.d.ts.map +1 -1
- package/dist/components/TextArea/index.d.ts +3 -10
- package/dist/components/TextArea/index.d.ts.map +1 -1
- package/dist/components/TextField/TextField.story.d.ts +4 -5
- package/dist/components/TextField/TextField.story.d.ts.map +1 -1
- package/dist/components/TextField/index.d.ts +6 -29
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/components/TextField/index.story.d.ts +5 -4
- package/dist/components/TextField/index.story.d.ts.map +1 -1
- package/dist/index.cjs.js +636 -594
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +604 -563
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
- package/src/_lib/compat.ts +19 -0
- package/src/_lib/index.ts +23 -0
- package/src/components/Checkbox/index.story.tsx +1 -0
- package/src/components/Checkbox/index.tsx +2 -1
- package/src/components/DropdownSelector/DropdownMenuItem.tsx +1 -1
- package/src/components/DropdownSelector/ListItem/index.story.tsx +1 -1
- package/src/components/DropdownSelector/ListItem/index.tsx +1 -1
- package/src/components/DropdownSelector/MenuItem/index.tsx +0 -1
- package/src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx +1 -1
- package/src/components/DropdownSelector/MenuItemGroup/index.tsx +0 -1
- package/src/components/DropdownSelector/MenuList/index.story.tsx +0 -1
- package/src/components/DropdownSelector/MenuList/index.tsx +1 -1
- package/src/components/DropdownSelector/MenuList/internals/getValuesRecursive.tsx +1 -1
- package/src/components/DropdownSelector/Popover/index.story.tsx +1 -1
- package/src/components/DropdownSelector/Popover/index.tsx +1 -1
- package/src/components/DropdownSelector/index.tsx +16 -14
- package/src/components/DropdownSelector/utils/findPreviewRecursive.tsx +2 -1
- package/src/components/LoadingSpinner/index.story.tsx +7 -1
- package/src/components/LoadingSpinner/index.tsx +27 -11
- package/src/components/Modal/index.tsx +18 -12
- package/src/components/MultiSelect/index.story.tsx +16 -4
- package/src/components/MultiSelect/index.tsx +70 -60
- package/src/components/Radio/index.story.tsx +7 -8
- package/src/components/Radio/index.test.tsx +3 -3
- package/src/components/Radio/index.tsx +23 -23
- package/src/components/SegmentedControl/index.tsx +6 -1
- package/src/components/Switch/index.tsx +37 -32
- package/src/components/TextArea/TextArea.story.tsx +61 -0
- package/src/components/TextArea/index.tsx +246 -0
- package/src/components/TextField/{index.story.tsx → TextField.story.tsx} +6 -28
- package/src/components/TextField/index.tsx +146 -371
- package/src/index.ts +1 -2
- package/dist/components/DropdownSelector/OptionItem.d.ts +0 -7
- package/dist/components/DropdownSelector/OptionItem.d.ts.map +0 -1
- package/dist/components/DropdownSelector/utils/focusIfHTMLLIElement.d.ts +0 -6
- package/dist/components/DropdownSelector/utils/focusIfHTMLLIElement.d.ts.map +0 -1
- package/dist/components/DropdownSelector/utils/handleFocusByKeyBoard.d.ts +0 -6
- package/dist/components/DropdownSelector/utils/handleFocusByKeyBoard.d.ts.map +0 -1
- package/dist/types/CustomJSXElement.d.ts +0 -3
- package/dist/types/CustomJSXElement.d.ts.map +0 -1
package/dist/index.esm.js
CHANGED
|
@@ -57,6 +57,21 @@ function unreachable(value) {
|
|
|
57
57
|
arguments.length === 0 ? "unreachable" : `unreachable (${JSON.stringify(value)})`
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
|
+
function mergeRefs(...refs) {
|
|
61
|
+
return (value) => {
|
|
62
|
+
for (const ref of refs) {
|
|
63
|
+
if (typeof ref === "function") {
|
|
64
|
+
ref(value);
|
|
65
|
+
} else if (ref !== null) {
|
|
66
|
+
;
|
|
67
|
+
ref.current = value;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function countCodePointsInString(string) {
|
|
73
|
+
return Array.from(string).length;
|
|
74
|
+
}
|
|
60
75
|
|
|
61
76
|
// src/styled.ts
|
|
62
77
|
import styled from "styled-components";
|
|
@@ -322,24 +337,19 @@ function validateIconSize(size, icon) {
|
|
|
322
337
|
}
|
|
323
338
|
|
|
324
339
|
// src/components/Radio/index.tsx
|
|
325
|
-
import { useCallback, useContext as useContext2 } from "react";
|
|
340
|
+
import { memo, forwardRef as forwardRef5, useCallback, useContext as useContext2 } from "react";
|
|
326
341
|
import * as React3 from "react";
|
|
327
342
|
import styled5 from "styled-components";
|
|
328
343
|
import warning from "warning";
|
|
329
344
|
import { px } from "@charcoal-ui/utils";
|
|
330
345
|
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
331
|
-
|
|
332
|
-
value,
|
|
333
|
-
forceChecked = false,
|
|
334
|
-
disabled = false,
|
|
335
|
-
children
|
|
336
|
-
}) {
|
|
346
|
+
var Radio = forwardRef5(function RadioInner({ value, disabled = false, children, className }, ref) {
|
|
337
347
|
const {
|
|
338
348
|
name,
|
|
339
349
|
selected,
|
|
340
350
|
disabled: isParentDisabled,
|
|
341
351
|
readonly,
|
|
342
|
-
|
|
352
|
+
invalid,
|
|
343
353
|
onChange
|
|
344
354
|
} = useContext2(RadioGroupContext);
|
|
345
355
|
warning(
|
|
@@ -355,25 +365,27 @@ function Radio({
|
|
|
355
365
|
},
|
|
356
366
|
[onChange]
|
|
357
367
|
);
|
|
358
|
-
return /* @__PURE__ */ jsxs2(RadioRoot, { "aria-disabled": isDisabled || isReadonly, children: [
|
|
368
|
+
return /* @__PURE__ */ jsxs2(RadioRoot, { "aria-disabled": isDisabled || isReadonly, className, children: [
|
|
359
369
|
/* @__PURE__ */ jsx6(
|
|
360
370
|
RadioInput,
|
|
361
371
|
{
|
|
362
372
|
name,
|
|
363
373
|
value,
|
|
364
|
-
checked:
|
|
365
|
-
|
|
374
|
+
checked: isSelected,
|
|
375
|
+
invalid,
|
|
366
376
|
onChange: handleChange,
|
|
367
|
-
disabled: isDisabled || isReadonly
|
|
377
|
+
disabled: isDisabled || isReadonly,
|
|
378
|
+
ref
|
|
368
379
|
}
|
|
369
380
|
),
|
|
370
381
|
children != null && /* @__PURE__ */ jsx6(RadioLabel, { children })
|
|
371
382
|
] });
|
|
372
|
-
}
|
|
383
|
+
});
|
|
384
|
+
var Radio_default = memo(Radio);
|
|
373
385
|
var RadioRoot = styled5.label`
|
|
374
386
|
display: grid;
|
|
375
387
|
grid-template-columns: auto 1fr;
|
|
376
|
-
grid-gap: ${({ theme:
|
|
388
|
+
grid-gap: ${({ theme: theme3 }) => px(theme3.spacing[4])};
|
|
377
389
|
align-items: center;
|
|
378
390
|
cursor: pointer;
|
|
379
391
|
|
|
@@ -391,19 +403,18 @@ var RadioInput = styled5.input.attrs({ type: "radio" })`
|
|
|
391
403
|
|
|
392
404
|
width: 20px;
|
|
393
405
|
height: 20px;
|
|
394
|
-
|
|
395
406
|
cursor: pointer;
|
|
396
407
|
|
|
397
|
-
${({
|
|
408
|
+
${({ invalid = false }) => theme((o) => [
|
|
398
409
|
o.borderRadius("oval"),
|
|
399
410
|
o.bg.surface1.hover.press,
|
|
400
|
-
|
|
411
|
+
invalid && o.outline.assertive
|
|
401
412
|
])};
|
|
402
413
|
|
|
403
414
|
&:not(:checked) {
|
|
404
415
|
border-width: 2px;
|
|
405
416
|
border-style: solid;
|
|
406
|
-
border-color: ${({ theme:
|
|
417
|
+
border-color: ${({ theme: theme3 }) => theme3.color.text3};
|
|
407
418
|
}
|
|
408
419
|
|
|
409
420
|
&:checked {
|
|
@@ -432,14 +443,14 @@ var RadioLabel = styled5.div`
|
|
|
432
443
|
var StyledRadioGroup = styled5.div`
|
|
433
444
|
display: grid;
|
|
434
445
|
grid-template-columns: 1fr;
|
|
435
|
-
grid-gap: ${({ theme:
|
|
446
|
+
grid-gap: ${({ theme: theme3 }) => px(theme3.spacing[8])};
|
|
436
447
|
`;
|
|
437
448
|
var RadioGroupContext = React3.createContext({
|
|
438
449
|
name: void 0,
|
|
439
450
|
selected: void 0,
|
|
440
451
|
disabled: false,
|
|
441
452
|
readonly: false,
|
|
442
|
-
|
|
453
|
+
invalid: false,
|
|
443
454
|
onChange() {
|
|
444
455
|
throw new Error(
|
|
445
456
|
"Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?"
|
|
@@ -454,7 +465,7 @@ function RadioGroup({
|
|
|
454
465
|
onChange,
|
|
455
466
|
disabled,
|
|
456
467
|
readonly,
|
|
457
|
-
|
|
468
|
+
invalid,
|
|
458
469
|
children
|
|
459
470
|
}) {
|
|
460
471
|
const handleChange = useCallback(
|
|
@@ -471,7 +482,7 @@ function RadioGroup({
|
|
|
471
482
|
selected: value,
|
|
472
483
|
disabled: disabled ?? false,
|
|
473
484
|
readonly: readonly ?? false,
|
|
474
|
-
|
|
485
|
+
invalid: invalid ?? false,
|
|
475
486
|
onChange: handleChange
|
|
476
487
|
},
|
|
477
488
|
children: /* @__PURE__ */ jsx6(
|
|
@@ -480,7 +491,7 @@ function RadioGroup({
|
|
|
480
491
|
role: "radiogroup",
|
|
481
492
|
"aria-orientation": "vertical",
|
|
482
493
|
"aria-label": label,
|
|
483
|
-
"aria-invalid":
|
|
494
|
+
"aria-invalid": invalid,
|
|
484
495
|
className,
|
|
485
496
|
children
|
|
486
497
|
}
|
|
@@ -490,7 +501,7 @@ function RadioGroup({
|
|
|
490
501
|
}
|
|
491
502
|
|
|
492
503
|
// src/components/MultiSelect/index.tsx
|
|
493
|
-
import { useCallback as useCallback2, useContext as useContext3 } from "react";
|
|
504
|
+
import { useCallback as useCallback2, useContext as useContext3, forwardRef as forwardRef6, memo as memo2 } from "react";
|
|
494
505
|
import styled6, { css as css2 } from "styled-components";
|
|
495
506
|
import warning2 from "warning";
|
|
496
507
|
import { disabledSelector as disabledSelector2, px as px2 } from "@charcoal-ui/utils";
|
|
@@ -512,66 +523,71 @@ var MultiSelectGroupContext = createContext3({
|
|
|
512
523
|
|
|
513
524
|
// src/components/MultiSelect/index.tsx
|
|
514
525
|
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
526
|
+
var MultiSelect = forwardRef6(
|
|
527
|
+
function MultiSelectInner({
|
|
528
|
+
value,
|
|
529
|
+
disabled = false,
|
|
530
|
+
onChange,
|
|
531
|
+
variant = "default",
|
|
532
|
+
className,
|
|
533
|
+
children
|
|
534
|
+
}, ref) {
|
|
535
|
+
const {
|
|
536
|
+
name,
|
|
537
|
+
selected,
|
|
538
|
+
disabled: parentDisabled,
|
|
539
|
+
readonly,
|
|
540
|
+
invalid,
|
|
541
|
+
onChange: parentOnChange
|
|
542
|
+
} = useContext3(MultiSelectGroupContext);
|
|
543
|
+
warning2(
|
|
544
|
+
name !== void 0,
|
|
545
|
+
`"name" is not Provided for <MultiSelect>. Perhaps you forgot to wrap with <MultiSelectGroup> ?`
|
|
546
|
+
);
|
|
547
|
+
const isSelected = selected.includes(value);
|
|
548
|
+
const isDisabled = disabled || parentDisabled || readonly;
|
|
549
|
+
const handleChange = useCallback2(
|
|
550
|
+
(event) => {
|
|
551
|
+
if (!(event.currentTarget instanceof HTMLInputElement)) {
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
if (onChange)
|
|
555
|
+
onChange({ value, selected: event.currentTarget.checked });
|
|
556
|
+
parentOnChange({ value, selected: event.currentTarget.checked });
|
|
557
|
+
},
|
|
558
|
+
[onChange, parentOnChange, value]
|
|
559
|
+
);
|
|
560
|
+
return /* @__PURE__ */ jsxs3(MultiSelectRoot, { "aria-disabled": isDisabled, className, children: [
|
|
561
|
+
/* @__PURE__ */ jsx7(
|
|
562
|
+
MultiSelectInput,
|
|
563
|
+
{
|
|
564
|
+
...{
|
|
565
|
+
name,
|
|
566
|
+
value,
|
|
567
|
+
invalid
|
|
568
|
+
},
|
|
569
|
+
checked: isSelected,
|
|
570
|
+
disabled: isDisabled,
|
|
571
|
+
onChange: handleChange,
|
|
572
|
+
overlay: variant === "overlay",
|
|
573
|
+
"aria-invalid": invalid,
|
|
574
|
+
ref
|
|
575
|
+
}
|
|
576
|
+
),
|
|
577
|
+
/* @__PURE__ */ jsx7(
|
|
578
|
+
MultiSelectInputOverlay,
|
|
579
|
+
{
|
|
580
|
+
overlay: variant === "overlay",
|
|
581
|
+
invalid,
|
|
582
|
+
"aria-hidden": true,
|
|
583
|
+
children: /* @__PURE__ */ jsx7("pixiv-icon", { name: "24/Check", "unsafe-non-guideline-scale": 16 / 24 })
|
|
584
|
+
}
|
|
585
|
+
),
|
|
586
|
+
Boolean(children) && /* @__PURE__ */ jsx7(MultiSelectLabel, { children })
|
|
587
|
+
] });
|
|
588
|
+
}
|
|
589
|
+
);
|
|
590
|
+
var MultiSelect_default = memo2(MultiSelect);
|
|
575
591
|
var MultiSelectRoot = styled6.label`
|
|
576
592
|
display: grid;
|
|
577
593
|
grid-template-columns: auto 1fr;
|
|
@@ -581,7 +597,7 @@ var MultiSelectRoot = styled6.label`
|
|
|
581
597
|
${disabledSelector2} {
|
|
582
598
|
cursor: default;
|
|
583
599
|
}
|
|
584
|
-
gap: ${({ theme:
|
|
600
|
+
gap: ${({ theme: theme3 }) => px2(theme3.spacing[4])};
|
|
585
601
|
${theme((o) => o.disabled)}
|
|
586
602
|
`;
|
|
587
603
|
var MultiSelectLabel = styled6.div`
|
|
@@ -627,7 +643,7 @@ var MultiSelectInputOverlay = styled6.div`
|
|
|
627
643
|
])}
|
|
628
644
|
|
|
629
645
|
${({ overlay }) => overlay && css2`
|
|
630
|
-
border-color: ${({ theme:
|
|
646
|
+
border-color: ${({ theme: theme3 }) => theme3.color.text5};
|
|
631
647
|
border-width: 2px;
|
|
632
648
|
border-style: solid;
|
|
633
649
|
`}
|
|
@@ -676,32 +692,36 @@ function MultiSelectGroup({
|
|
|
676
692
|
|
|
677
693
|
// src/components/Switch/index.tsx
|
|
678
694
|
import { useSwitch } from "@react-aria/switch";
|
|
679
|
-
import {
|
|
695
|
+
import { useMemo, memo as memo3, forwardRef as forwardRef7 } from "react";
|
|
680
696
|
import { useToggleState } from "react-stately";
|
|
681
697
|
import styled7 from "styled-components";
|
|
682
698
|
import { disabledSelector as disabledSelector3 } from "@charcoal-ui/utils";
|
|
699
|
+
import { useObjectRef } from "@react-aria/utils";
|
|
683
700
|
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
/* @__PURE__ */
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
}
|
|
701
|
+
var SwitchCheckbox = forwardRef7(
|
|
702
|
+
function SwitchCheckboxInner(props, external) {
|
|
703
|
+
const { disabled, className } = props;
|
|
704
|
+
const ariaSwitchProps = useMemo(
|
|
705
|
+
() => ({
|
|
706
|
+
...props,
|
|
707
|
+
"aria-label": "children" in props ? void 0 : props.label,
|
|
708
|
+
isDisabled: props.disabled,
|
|
709
|
+
isSelected: props.checked
|
|
710
|
+
}),
|
|
711
|
+
[props]
|
|
712
|
+
);
|
|
713
|
+
const state = useToggleState(ariaSwitchProps);
|
|
714
|
+
const ref = useObjectRef(external);
|
|
715
|
+
const {
|
|
716
|
+
inputProps: { className: _className, type: _type, ...rest }
|
|
717
|
+
} = useSwitch(ariaSwitchProps, state, ref);
|
|
718
|
+
return /* @__PURE__ */ jsxs4(Label, { className, "aria-disabled": disabled, children: [
|
|
719
|
+
/* @__PURE__ */ jsx8(SwitchInput, { ...rest, ref }),
|
|
720
|
+
"children" in props ? /* @__PURE__ */ jsx8(LabelInner, { children: props.children }) : void 0
|
|
721
|
+
] });
|
|
722
|
+
}
|
|
723
|
+
);
|
|
724
|
+
var Switch_default = memo3(SwitchCheckbox);
|
|
705
725
|
var Label = styled7.label`
|
|
706
726
|
display: inline-grid;
|
|
707
727
|
grid-template-columns: auto 1fr;
|
|
@@ -793,9 +813,9 @@ var SwitchInput = styled7.input.attrs({
|
|
|
793
813
|
// src/components/TextField/index.tsx
|
|
794
814
|
import { useTextField } from "@react-aria/textfield";
|
|
795
815
|
import { useVisuallyHidden } from "@react-aria/visually-hidden";
|
|
796
|
-
import { useCallback as useCallback3, useEffect, useRef
|
|
816
|
+
import { useCallback as useCallback3, useEffect, useRef, useState } from "react";
|
|
797
817
|
import * as React5 from "react";
|
|
798
|
-
import styled9
|
|
818
|
+
import styled9 from "styled-components";
|
|
799
819
|
|
|
800
820
|
// src/components/FieldLabel/index.tsx
|
|
801
821
|
import * as React4 from "react";
|
|
@@ -848,248 +868,122 @@ var FieldLabelWrapper = styled8.div`
|
|
|
848
868
|
`;
|
|
849
869
|
|
|
850
870
|
// src/components/TextField/index.tsx
|
|
851
|
-
import { createTheme as createTheme3 } from "@charcoal-ui/styled";
|
|
852
871
|
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
853
|
-
var theme3 = createTheme3(styled9);
|
|
854
|
-
function mergeRefs(...refs) {
|
|
855
|
-
return (value) => {
|
|
856
|
-
for (const ref of refs) {
|
|
857
|
-
if (typeof ref === "function") {
|
|
858
|
-
ref(value);
|
|
859
|
-
} else if (ref !== null) {
|
|
860
|
-
;
|
|
861
|
-
ref.current = value;
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
};
|
|
865
|
-
}
|
|
866
|
-
function countCodePointsInString(string) {
|
|
867
|
-
return Array.from(string).length;
|
|
868
|
-
}
|
|
869
872
|
var TextField = React5.forwardRef(
|
|
870
|
-
function
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
setCount(countCodePointsInString(props.value ?? ""));
|
|
914
|
-
}, [props.value]);
|
|
915
|
-
const { inputProps, labelProps, descriptionProps, errorMessageProps } = useTextField(
|
|
916
|
-
{
|
|
917
|
-
inputElementType: "input",
|
|
918
|
-
isDisabled: disabled,
|
|
919
|
-
isRequired: required,
|
|
920
|
-
validationState: invalid ? "invalid" : "valid",
|
|
921
|
-
description: !invalid && assistiveText,
|
|
922
|
-
errorMessage: invalid && assistiveText,
|
|
923
|
-
onChange: handleChange,
|
|
924
|
-
...props
|
|
925
|
-
},
|
|
926
|
-
ariaRef
|
|
927
|
-
);
|
|
928
|
-
useEffect(() => {
|
|
929
|
-
const prefixObserver = new ResizeObserver((entries) => {
|
|
930
|
-
setPrefixWidth(entries[0].contentRect.width);
|
|
931
|
-
});
|
|
932
|
-
const suffixObserver = new ResizeObserver((entries) => {
|
|
933
|
-
setSuffixWidth(entries[0].contentRect.width);
|
|
934
|
-
});
|
|
935
|
-
if (prefixRef.current !== null) {
|
|
936
|
-
prefixObserver.observe(prefixRef.current);
|
|
937
|
-
}
|
|
938
|
-
if (suffixRef.current !== null) {
|
|
939
|
-
suffixObserver.observe(suffixRef.current);
|
|
940
|
-
}
|
|
941
|
-
return () => {
|
|
942
|
-
suffixObserver.disconnect();
|
|
943
|
-
prefixObserver.disconnect();
|
|
944
|
-
};
|
|
945
|
-
}, []);
|
|
946
|
-
return /* @__PURE__ */ jsxs6(TextFieldRoot, { className, isDisabled: disabled, children: [
|
|
947
|
-
/* @__PURE__ */ jsx10(
|
|
948
|
-
TextFieldLabel,
|
|
873
|
+
function SingleLineTextFieldInner({ onChange, ...props }, forwardRef16) {
|
|
874
|
+
const {
|
|
875
|
+
className,
|
|
876
|
+
showLabel = false,
|
|
877
|
+
showCount = false,
|
|
878
|
+
label,
|
|
879
|
+
requiredText,
|
|
880
|
+
subLabel,
|
|
881
|
+
disabled = false,
|
|
882
|
+
required,
|
|
883
|
+
invalid = false,
|
|
884
|
+
assistiveText,
|
|
885
|
+
maxLength,
|
|
886
|
+
prefix = null,
|
|
887
|
+
suffix = null
|
|
888
|
+
} = props;
|
|
889
|
+
const { visuallyHiddenProps } = useVisuallyHidden();
|
|
890
|
+
const ariaRef = useRef(null);
|
|
891
|
+
const prefixRef = useRef(null);
|
|
892
|
+
const suffixRef = useRef(null);
|
|
893
|
+
const [count, setCount] = useState(
|
|
894
|
+
countCodePointsInString(props.value ?? "")
|
|
895
|
+
);
|
|
896
|
+
const [prefixWidth, setPrefixWidth] = useState(0);
|
|
897
|
+
const [suffixWidth, setSuffixWidth] = useState(0);
|
|
898
|
+
const nonControlled = props.value === void 0;
|
|
899
|
+
const handleChange = useCallback3(
|
|
900
|
+
(value) => {
|
|
901
|
+
const count2 = countCodePointsInString(value);
|
|
902
|
+
if (maxLength !== void 0 && count2 > maxLength) {
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
if (nonControlled) {
|
|
906
|
+
setCount(count2);
|
|
907
|
+
}
|
|
908
|
+
onChange?.(value);
|
|
909
|
+
},
|
|
910
|
+
[maxLength, nonControlled, onChange]
|
|
911
|
+
);
|
|
912
|
+
useEffect(() => {
|
|
913
|
+
setCount(countCodePointsInString(props.value ?? ""));
|
|
914
|
+
}, [props.value]);
|
|
915
|
+
const { inputProps, labelProps, descriptionProps, errorMessageProps } = useTextField(
|
|
949
916
|
{
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
required,
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
917
|
+
inputElementType: "input",
|
|
918
|
+
isDisabled: disabled,
|
|
919
|
+
isRequired: required,
|
|
920
|
+
validationState: invalid ? "invalid" : "valid",
|
|
921
|
+
description: !invalid && assistiveText,
|
|
922
|
+
errorMessage: invalid && assistiveText,
|
|
923
|
+
onChange: handleChange,
|
|
924
|
+
...props
|
|
925
|
+
},
|
|
926
|
+
ariaRef
|
|
927
|
+
);
|
|
928
|
+
useEffect(() => {
|
|
929
|
+
const prefixObserver = new ResizeObserver((entries) => {
|
|
930
|
+
setPrefixWidth(entries[0].contentRect.width);
|
|
931
|
+
});
|
|
932
|
+
const suffixObserver = new ResizeObserver((entries) => {
|
|
933
|
+
setSuffixWidth(entries[0].contentRect.width);
|
|
934
|
+
});
|
|
935
|
+
if (prefixRef.current !== null) {
|
|
936
|
+
prefixObserver.observe(prefixRef.current);
|
|
956
937
|
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
938
|
+
if (suffixRef.current !== null) {
|
|
939
|
+
suffixObserver.observe(suffixRef.current);
|
|
940
|
+
}
|
|
941
|
+
return () => {
|
|
942
|
+
suffixObserver.disconnect();
|
|
943
|
+
prefixObserver.disconnect();
|
|
944
|
+
};
|
|
945
|
+
}, []);
|
|
946
|
+
return /* @__PURE__ */ jsxs6(TextFieldRoot, { className, isDisabled: disabled, children: [
|
|
960
947
|
/* @__PURE__ */ jsx10(
|
|
961
|
-
|
|
948
|
+
TextFieldLabel,
|
|
962
949
|
{
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
...
|
|
950
|
+
label,
|
|
951
|
+
requiredText,
|
|
952
|
+
required,
|
|
953
|
+
subLabel,
|
|
954
|
+
...labelProps,
|
|
955
|
+
...!showLabel ? visuallyHiddenProps : {}
|
|
968
956
|
}
|
|
969
957
|
),
|
|
970
|
-
/* @__PURE__ */ jsxs6(
|
|
971
|
-
/* @__PURE__ */ jsx10(Affix, { children:
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
})
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
rows: initialRows = 4
|
|
1000
|
-
} = props;
|
|
1001
|
-
const { visuallyHiddenProps } = useVisuallyHidden();
|
|
1002
|
-
const textareaRef = useRef2(null);
|
|
1003
|
-
const ariaRef = useRef2(null);
|
|
1004
|
-
const [count, setCount] = useState(countCodePointsInString(props.value ?? ""));
|
|
1005
|
-
const [rows, setRows] = useState(initialRows);
|
|
1006
|
-
const syncHeight = useCallback3(
|
|
1007
|
-
(textarea) => {
|
|
1008
|
-
const rows2 = (`${textarea.value}
|
|
1009
|
-
`.match(/\n/gu)?.length ?? 0) || 1;
|
|
1010
|
-
setRows(initialRows <= rows2 ? rows2 : initialRows);
|
|
1011
|
-
},
|
|
1012
|
-
[initialRows]
|
|
1013
|
-
);
|
|
1014
|
-
const nonControlled = props.value === void 0;
|
|
1015
|
-
const handleChange = useCallback3(
|
|
1016
|
-
(value) => {
|
|
1017
|
-
const count2 = countCodePointsInString(value);
|
|
1018
|
-
if (maxLength !== void 0 && count2 > maxLength) {
|
|
1019
|
-
return;
|
|
1020
|
-
}
|
|
1021
|
-
if (nonControlled) {
|
|
1022
|
-
setCount(count2);
|
|
1023
|
-
}
|
|
1024
|
-
if (autoHeight && textareaRef.current !== null) {
|
|
1025
|
-
syncHeight(textareaRef.current);
|
|
1026
|
-
}
|
|
1027
|
-
onChange?.(value);
|
|
1028
|
-
},
|
|
1029
|
-
[autoHeight, maxLength, nonControlled, onChange, syncHeight]
|
|
1030
|
-
);
|
|
1031
|
-
useEffect(() => {
|
|
1032
|
-
setCount(countCodePointsInString(props.value ?? ""));
|
|
1033
|
-
}, [props.value]);
|
|
1034
|
-
const { inputProps, labelProps, descriptionProps, errorMessageProps } = useTextField(
|
|
1035
|
-
{
|
|
1036
|
-
inputElementType: "textarea",
|
|
1037
|
-
isDisabled: disabled,
|
|
1038
|
-
isRequired: required,
|
|
1039
|
-
validationState: invalid ? "invalid" : "valid",
|
|
1040
|
-
description: !invalid && assistiveText,
|
|
1041
|
-
errorMessage: invalid && assistiveText,
|
|
1042
|
-
onChange: handleChange,
|
|
1043
|
-
...props
|
|
1044
|
-
},
|
|
1045
|
-
ariaRef
|
|
1046
|
-
);
|
|
1047
|
-
useEffect(() => {
|
|
1048
|
-
if (autoHeight && textareaRef.current !== null) {
|
|
1049
|
-
syncHeight(textareaRef.current);
|
|
1050
|
-
}
|
|
1051
|
-
}, [autoHeight, syncHeight]);
|
|
1052
|
-
return /* @__PURE__ */ jsxs6(TextFieldRoot, { className, isDisabled: disabled, children: [
|
|
1053
|
-
/* @__PURE__ */ jsx10(
|
|
1054
|
-
TextFieldLabel,
|
|
1055
|
-
{
|
|
1056
|
-
label,
|
|
1057
|
-
requiredText,
|
|
1058
|
-
required,
|
|
1059
|
-
subLabel,
|
|
1060
|
-
...labelProps,
|
|
1061
|
-
...!showLabel ? visuallyHiddenProps : {}
|
|
1062
|
-
}
|
|
1063
|
-
),
|
|
1064
|
-
/* @__PURE__ */ jsxs6(
|
|
1065
|
-
StyledTextareaContainer,
|
|
1066
|
-
{
|
|
1067
|
-
invalid,
|
|
1068
|
-
rows: showCount ? rows + 1 : rows,
|
|
1069
|
-
children: [
|
|
1070
|
-
/* @__PURE__ */ jsx10(
|
|
1071
|
-
StyledTextarea,
|
|
1072
|
-
{
|
|
1073
|
-
ref: mergeRefs(textareaRef, forwardRef12, ariaRef),
|
|
1074
|
-
rows,
|
|
1075
|
-
noBottomPadding: showCount,
|
|
1076
|
-
...inputProps
|
|
1077
|
-
}
|
|
1078
|
-
),
|
|
1079
|
-
showCount && /* @__PURE__ */ jsx10(MultiLineCounter, { children: maxLength !== void 0 ? `${count}/${maxLength}` : count })
|
|
1080
|
-
]
|
|
1081
|
-
}
|
|
1082
|
-
),
|
|
1083
|
-
assistiveText != null && assistiveText.length !== 0 && /* @__PURE__ */ jsx10(
|
|
1084
|
-
AssistiveText,
|
|
1085
|
-
{
|
|
1086
|
-
invalid,
|
|
1087
|
-
...invalid ? errorMessageProps : descriptionProps,
|
|
1088
|
-
children: assistiveText
|
|
1089
|
-
}
|
|
1090
|
-
)
|
|
1091
|
-
] });
|
|
1092
|
-
});
|
|
958
|
+
/* @__PURE__ */ jsxs6(StyledInputContainer, { children: [
|
|
959
|
+
/* @__PURE__ */ jsx10(PrefixContainer, { ref: prefixRef, children: /* @__PURE__ */ jsx10(Affix, { children: prefix }) }),
|
|
960
|
+
/* @__PURE__ */ jsx10(
|
|
961
|
+
StyledInput,
|
|
962
|
+
{
|
|
963
|
+
ref: mergeRefs(forwardRef16, ariaRef),
|
|
964
|
+
invalid,
|
|
965
|
+
extraLeftPadding: prefixWidth,
|
|
966
|
+
extraRightPadding: suffixWidth,
|
|
967
|
+
...inputProps
|
|
968
|
+
}
|
|
969
|
+
),
|
|
970
|
+
/* @__PURE__ */ jsxs6(SuffixContainer, { ref: suffixRef, children: [
|
|
971
|
+
/* @__PURE__ */ jsx10(Affix, { children: suffix }),
|
|
972
|
+
showCount && /* @__PURE__ */ jsx10(SingleLineCounter, { children: maxLength !== void 0 ? `${count}/${maxLength}` : count })
|
|
973
|
+
] })
|
|
974
|
+
] }),
|
|
975
|
+
assistiveText != null && assistiveText.length !== 0 && /* @__PURE__ */ jsx10(
|
|
976
|
+
AssistiveText,
|
|
977
|
+
{
|
|
978
|
+
invalid,
|
|
979
|
+
...invalid ? errorMessageProps : descriptionProps,
|
|
980
|
+
children: assistiveText
|
|
981
|
+
}
|
|
982
|
+
)
|
|
983
|
+
] });
|
|
984
|
+
}
|
|
985
|
+
);
|
|
986
|
+
var TextField_default = TextField;
|
|
1093
987
|
var TextFieldRoot = styled9.div`
|
|
1094
988
|
display: flex;
|
|
1095
989
|
flex-direction: column;
|
|
@@ -1097,7 +991,7 @@ var TextFieldRoot = styled9.div`
|
|
|
1097
991
|
${(p) => p.isDisabled && { opacity: p.theme.elementEffect.disabled.opacity }}
|
|
1098
992
|
`;
|
|
1099
993
|
var TextFieldLabel = styled9(FieldLabel_default)`
|
|
1100
|
-
${
|
|
994
|
+
${theme((o) => o.margin.bottom(8))}
|
|
1101
995
|
`;
|
|
1102
996
|
var StyledInputContainer = styled9.div`
|
|
1103
997
|
height: 40px;
|
|
@@ -1123,7 +1017,7 @@ var SuffixContainer = styled9.span`
|
|
|
1123
1017
|
var Affix = styled9.span`
|
|
1124
1018
|
user-select: none;
|
|
1125
1019
|
|
|
1126
|
-
${
|
|
1020
|
+
${theme((o) => [o.typography(14).preserveHalfLeading, o.font.text2])}
|
|
1127
1021
|
`;
|
|
1128
1022
|
var StyledInput = styled9.input`
|
|
1129
1023
|
border: none;
|
|
@@ -1145,7 +1039,7 @@ var StyledInput = styled9.input`
|
|
|
1145
1039
|
/* Display box-shadow for iOS Safari */
|
|
1146
1040
|
appearance: none;
|
|
1147
1041
|
|
|
1148
|
-
${(p) =>
|
|
1042
|
+
${(p) => theme((o) => [
|
|
1149
1043
|
o.bg.surface3.hover,
|
|
1150
1044
|
o.outline.default.focus,
|
|
1151
1045
|
p.invalid && o.outline.assertive,
|
|
@@ -1153,37 +1047,170 @@ var StyledInput = styled9.input`
|
|
|
1153
1047
|
])}
|
|
1154
1048
|
|
|
1155
1049
|
&::placeholder {
|
|
1156
|
-
${
|
|
1050
|
+
${theme((o) => o.font.text3)}
|
|
1051
|
+
}
|
|
1052
|
+
`;
|
|
1053
|
+
var SingleLineCounter = styled9.span`
|
|
1054
|
+
${theme((o) => [o.typography(14).preserveHalfLeading, o.font.text3])}
|
|
1055
|
+
`;
|
|
1056
|
+
var AssistiveText = styled9.p`
|
|
1057
|
+
${(p) => theme((o) => [
|
|
1058
|
+
o.typography(14),
|
|
1059
|
+
o.margin.top(8),
|
|
1060
|
+
o.margin.bottom(0),
|
|
1061
|
+
o.font[p.invalid ? "assertive" : "text1"]
|
|
1062
|
+
])}
|
|
1063
|
+
`;
|
|
1064
|
+
|
|
1065
|
+
// src/components/TextArea/index.tsx
|
|
1066
|
+
import { useTextField as useTextField2 } from "@react-aria/textfield";
|
|
1067
|
+
import { useVisuallyHidden as useVisuallyHidden2 } from "@react-aria/visually-hidden";
|
|
1068
|
+
import React6, { useCallback as useCallback4, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
1069
|
+
import styled10, { css as css3 } from "styled-components";
|
|
1070
|
+
import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1071
|
+
var TextArea = React6.forwardRef(
|
|
1072
|
+
function TextAreaInner({ onChange, ...props }, forwardRef16) {
|
|
1073
|
+
const {
|
|
1074
|
+
className,
|
|
1075
|
+
showCount = false,
|
|
1076
|
+
showLabel = false,
|
|
1077
|
+
label,
|
|
1078
|
+
requiredText,
|
|
1079
|
+
subLabel,
|
|
1080
|
+
disabled = false,
|
|
1081
|
+
required,
|
|
1082
|
+
invalid = false,
|
|
1083
|
+
assistiveText,
|
|
1084
|
+
maxLength,
|
|
1085
|
+
autoHeight = false,
|
|
1086
|
+
rows: initialRows = 4
|
|
1087
|
+
} = props;
|
|
1088
|
+
const { visuallyHiddenProps } = useVisuallyHidden2();
|
|
1089
|
+
const textareaRef = useRef2(null);
|
|
1090
|
+
const ariaRef = useRef2(null);
|
|
1091
|
+
const [count, setCount] = useState2(
|
|
1092
|
+
countCodePointsInString(props.value ?? "")
|
|
1093
|
+
);
|
|
1094
|
+
const [rows, setRows] = useState2(initialRows);
|
|
1095
|
+
const syncHeight = useCallback4(
|
|
1096
|
+
(textarea) => {
|
|
1097
|
+
const rows2 = (`${textarea.value}
|
|
1098
|
+
`.match(/\n/gu)?.length ?? 0) || 1;
|
|
1099
|
+
setRows(initialRows <= rows2 ? rows2 : initialRows);
|
|
1100
|
+
},
|
|
1101
|
+
[initialRows]
|
|
1102
|
+
);
|
|
1103
|
+
const nonControlled = props.value === void 0;
|
|
1104
|
+
const handleChange = useCallback4(
|
|
1105
|
+
(value) => {
|
|
1106
|
+
const count2 = countCodePointsInString(value);
|
|
1107
|
+
if (maxLength !== void 0 && count2 > maxLength) {
|
|
1108
|
+
return;
|
|
1109
|
+
}
|
|
1110
|
+
if (nonControlled) {
|
|
1111
|
+
setCount(count2);
|
|
1112
|
+
}
|
|
1113
|
+
if (autoHeight && textareaRef.current !== null) {
|
|
1114
|
+
syncHeight(textareaRef.current);
|
|
1115
|
+
}
|
|
1116
|
+
onChange?.(value);
|
|
1117
|
+
},
|
|
1118
|
+
[autoHeight, maxLength, nonControlled, onChange, syncHeight]
|
|
1119
|
+
);
|
|
1120
|
+
useEffect2(() => {
|
|
1121
|
+
setCount(countCodePointsInString(props.value ?? ""));
|
|
1122
|
+
}, [props.value]);
|
|
1123
|
+
const { inputProps, labelProps, descriptionProps, errorMessageProps } = useTextField2(
|
|
1124
|
+
{
|
|
1125
|
+
inputElementType: "textarea",
|
|
1126
|
+
isDisabled: disabled,
|
|
1127
|
+
isRequired: required,
|
|
1128
|
+
validationState: invalid ? "invalid" : "valid",
|
|
1129
|
+
description: !invalid && assistiveText,
|
|
1130
|
+
errorMessage: invalid && assistiveText,
|
|
1131
|
+
onChange: handleChange,
|
|
1132
|
+
...props
|
|
1133
|
+
},
|
|
1134
|
+
ariaRef
|
|
1135
|
+
);
|
|
1136
|
+
useEffect2(() => {
|
|
1137
|
+
if (autoHeight && textareaRef.current !== null) {
|
|
1138
|
+
syncHeight(textareaRef.current);
|
|
1139
|
+
}
|
|
1140
|
+
}, [autoHeight, syncHeight]);
|
|
1141
|
+
return /* @__PURE__ */ jsxs7(TextFieldRoot2, { className, isDisabled: disabled, children: [
|
|
1142
|
+
/* @__PURE__ */ jsx11(
|
|
1143
|
+
TextFieldLabel2,
|
|
1144
|
+
{
|
|
1145
|
+
label,
|
|
1146
|
+
requiredText,
|
|
1147
|
+
required,
|
|
1148
|
+
subLabel,
|
|
1149
|
+
...labelProps,
|
|
1150
|
+
...!showLabel ? visuallyHiddenProps : {}
|
|
1151
|
+
}
|
|
1152
|
+
),
|
|
1153
|
+
/* @__PURE__ */ jsxs7(
|
|
1154
|
+
StyledTextareaContainer,
|
|
1155
|
+
{
|
|
1156
|
+
invalid,
|
|
1157
|
+
rows: showCount ? rows + 1 : rows,
|
|
1158
|
+
children: [
|
|
1159
|
+
/* @__PURE__ */ jsx11(
|
|
1160
|
+
StyledTextarea,
|
|
1161
|
+
{
|
|
1162
|
+
ref: mergeRefs(textareaRef, forwardRef16, ariaRef),
|
|
1163
|
+
rows,
|
|
1164
|
+
noBottomPadding: showCount,
|
|
1165
|
+
...inputProps
|
|
1166
|
+
}
|
|
1167
|
+
),
|
|
1168
|
+
showCount && /* @__PURE__ */ jsx11(MultiLineCounter, { children: maxLength !== void 0 ? `${count}/${maxLength}` : count })
|
|
1169
|
+
]
|
|
1170
|
+
}
|
|
1171
|
+
),
|
|
1172
|
+
assistiveText != null && assistiveText.length !== 0 && /* @__PURE__ */ jsx11(
|
|
1173
|
+
AssistiveText2,
|
|
1174
|
+
{
|
|
1175
|
+
invalid,
|
|
1176
|
+
...invalid ? errorMessageProps : descriptionProps,
|
|
1177
|
+
children: assistiveText
|
|
1178
|
+
}
|
|
1179
|
+
)
|
|
1180
|
+
] });
|
|
1157
1181
|
}
|
|
1182
|
+
);
|
|
1183
|
+
var TextArea_default = TextArea;
|
|
1184
|
+
var TextFieldRoot2 = styled10.div`
|
|
1185
|
+
display: flex;
|
|
1186
|
+
flex-direction: column;
|
|
1187
|
+
|
|
1188
|
+
${(p) => p.isDisabled && { opacity: p.theme.elementEffect.disabled.opacity }}
|
|
1189
|
+
`;
|
|
1190
|
+
var TextFieldLabel2 = styled10(FieldLabel_default)`
|
|
1191
|
+
${theme((o) => o.margin.bottom(8))}
|
|
1158
1192
|
`;
|
|
1159
|
-
var StyledTextareaContainer =
|
|
1193
|
+
var StyledTextareaContainer = styled10.div`
|
|
1160
1194
|
position: relative;
|
|
1161
1195
|
overflow: hidden;
|
|
1162
1196
|
padding: 0 8px;
|
|
1163
1197
|
|
|
1164
|
-
${(p) =>
|
|
1198
|
+
${(p) => theme((o) => [
|
|
1165
1199
|
o.bg.surface3.hover,
|
|
1166
1200
|
p.invalid && o.outline.assertive,
|
|
1167
1201
|
o.font.text2,
|
|
1168
1202
|
o.borderRadius(4)
|
|
1169
1203
|
])}
|
|
1170
1204
|
|
|
1171
|
-
/**
|
|
1172
|
-
* FIXME: o.outline.default を &:focus-within 内に書いてると、外れるときに transition が効かない
|
|
1173
|
-
* 本来 o.outline.default.focus と書けば足してくれるような transition の内容を一旦明示している
|
|
1174
|
-
* o.outline.default.focusWithin のようなものがあればこの行は不要になるはず
|
|
1175
|
-
*/
|
|
1176
|
-
transition: box-shadow 0.2s;
|
|
1177
|
-
|
|
1178
1205
|
&:focus-within {
|
|
1179
|
-
${(p) =>
|
|
1206
|
+
${(p) => theme((o) => p.invalid ? o.outline.assertive : o.outline.default)}
|
|
1180
1207
|
}
|
|
1181
1208
|
|
|
1182
1209
|
${({ rows }) => css3`
|
|
1183
1210
|
height: calc(22px * ${rows} + 18px);
|
|
1184
1211
|
`};
|
|
1185
1212
|
`;
|
|
1186
|
-
var StyledTextarea =
|
|
1213
|
+
var StyledTextarea = styled10.textarea`
|
|
1187
1214
|
border: none;
|
|
1188
1215
|
outline: none;
|
|
1189
1216
|
resize: none;
|
|
@@ -1208,7 +1235,7 @@ var StyledTextarea = styled9.textarea`
|
|
|
1208
1235
|
background: none;
|
|
1209
1236
|
|
|
1210
1237
|
&::placeholder {
|
|
1211
|
-
${
|
|
1238
|
+
${theme((o) => o.font.text3)}
|
|
1212
1239
|
}
|
|
1213
1240
|
|
|
1214
1241
|
/* Hide scrollbar for Chrome, Safari and Opera */
|
|
@@ -1219,18 +1246,15 @@ var StyledTextarea = styled9.textarea`
|
|
|
1219
1246
|
-ms-overflow-style: none; /* IE and Edge */
|
|
1220
1247
|
scrollbar-width: none; /* Firefox */
|
|
1221
1248
|
`;
|
|
1222
|
-
var
|
|
1223
|
-
${theme3((o) => [o.typography(14).preserveHalfLeading, o.font.text3])}
|
|
1224
|
-
`;
|
|
1225
|
-
var MultiLineCounter = styled9.span`
|
|
1249
|
+
var MultiLineCounter = styled10.span`
|
|
1226
1250
|
position: absolute;
|
|
1227
1251
|
bottom: 9px;
|
|
1228
1252
|
right: 8px;
|
|
1229
1253
|
|
|
1230
|
-
${
|
|
1254
|
+
${theme((o) => [o.typography(14).preserveHalfLeading, o.font.text3])}
|
|
1231
1255
|
`;
|
|
1232
|
-
var
|
|
1233
|
-
${(p) =>
|
|
1256
|
+
var AssistiveText2 = styled10.p`
|
|
1257
|
+
${(p) => theme((o) => [
|
|
1234
1258
|
o.typography(14),
|
|
1235
1259
|
o.margin.top(8),
|
|
1236
1260
|
o.margin.bottom(0),
|
|
@@ -1239,11 +1263,11 @@ var AssistiveText = styled9.p`
|
|
|
1239
1263
|
`;
|
|
1240
1264
|
|
|
1241
1265
|
// src/components/Icon/index.tsx
|
|
1242
|
-
import * as
|
|
1266
|
+
import * as React7 from "react";
|
|
1243
1267
|
import "@charcoal-ui/icons";
|
|
1244
|
-
import { jsx as
|
|
1245
|
-
var Icon =
|
|
1246
|
-
return /* @__PURE__ */
|
|
1268
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1269
|
+
var Icon = React7.forwardRef(function IconInner({ name, scale, unsafeNonGuidelineScale, className, ...rest }, ref) {
|
|
1270
|
+
return /* @__PURE__ */ jsx12(
|
|
1247
1271
|
"pixiv-icon",
|
|
1248
1272
|
{
|
|
1249
1273
|
ref,
|
|
@@ -1258,14 +1282,14 @@ var Icon = React6.forwardRef(function IconInner({ name, scale, unsafeNonGuidelin
|
|
|
1258
1282
|
var Icon_default = Icon;
|
|
1259
1283
|
|
|
1260
1284
|
// src/components/Modal/index.tsx
|
|
1261
|
-
import { useContext as useContext4,
|
|
1262
|
-
import * as
|
|
1285
|
+
import { useContext as useContext4, forwardRef as forwardRef11, memo as memo4 } from "react";
|
|
1286
|
+
import * as React8 from "react";
|
|
1263
1287
|
import {
|
|
1264
1288
|
Overlay,
|
|
1265
1289
|
useModalOverlay,
|
|
1266
1290
|
useOverlay
|
|
1267
1291
|
} from "@react-aria/overlays";
|
|
1268
|
-
import
|
|
1292
|
+
import styled11, { css as css4, useTheme } from "styled-components";
|
|
1269
1293
|
import { FocusScope } from "@react-aria/focus";
|
|
1270
1294
|
import { useDialog } from "@react-aria/dialog";
|
|
1271
1295
|
|
|
@@ -1280,23 +1304,20 @@ function columnSystem(span, column, gutter) {
|
|
|
1280
1304
|
import { maxWidth } from "@charcoal-ui/utils";
|
|
1281
1305
|
import { useMedia } from "@charcoal-ui/styled";
|
|
1282
1306
|
import { animated, useTransition, easings } from "react-spring";
|
|
1283
|
-
import {
|
|
1307
|
+
import { useObjectRef as useObjectRef2 } from "@react-aria/utils";
|
|
1308
|
+
import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1284
1309
|
var DEFAULT_Z_INDEX = 10;
|
|
1285
|
-
|
|
1286
|
-
children,
|
|
1287
|
-
zIndex = DEFAULT_Z_INDEX,
|
|
1288
|
-
portalContainer,
|
|
1289
|
-
...props
|
|
1290
|
-
}) {
|
|
1310
|
+
var Modal = forwardRef11(function ModalInner({ children, zIndex = DEFAULT_Z_INDEX, portalContainer, ...props }, external) {
|
|
1291
1311
|
const {
|
|
1292
1312
|
title,
|
|
1293
1313
|
size = "M",
|
|
1294
1314
|
bottomSheet = false,
|
|
1295
1315
|
isDismissable,
|
|
1296
1316
|
onClose,
|
|
1317
|
+
className,
|
|
1297
1318
|
isOpen = false
|
|
1298
1319
|
} = props;
|
|
1299
|
-
const ref =
|
|
1320
|
+
const ref = useObjectRef2(external);
|
|
1300
1321
|
const { overlayProps, underlayProps } = useOverlay(props, ref);
|
|
1301
1322
|
const { modalProps } = useModalOverlay(
|
|
1302
1323
|
props,
|
|
@@ -1313,8 +1334,8 @@ function Modal({
|
|
|
1313
1334
|
ref
|
|
1314
1335
|
);
|
|
1315
1336
|
const { dialogProps, titleProps } = useDialog(props, ref);
|
|
1316
|
-
const
|
|
1317
|
-
const isMobile = useMedia(maxWidth(
|
|
1337
|
+
const theme3 = useTheme();
|
|
1338
|
+
const isMobile = useMedia(maxWidth(theme3.breakpoint.screen1)) ?? false;
|
|
1318
1339
|
const transitionEnabled = isMobile && bottomSheet !== false;
|
|
1319
1340
|
const transition = useTransition(isOpen, {
|
|
1320
1341
|
from: {
|
|
@@ -1333,13 +1354,13 @@ function Modal({
|
|
|
1333
1354
|
});
|
|
1334
1355
|
const showDismiss = !isMobile || bottomSheet !== true;
|
|
1335
1356
|
return transition(
|
|
1336
|
-
({ backgroundColor, transform }, item) => item && /* @__PURE__ */
|
|
1357
|
+
({ backgroundColor, transform }, item) => item && /* @__PURE__ */ jsx13(Overlay, { portalContainer, children: /* @__PURE__ */ jsx13(
|
|
1337
1358
|
ModalBackground,
|
|
1338
1359
|
{
|
|
1339
1360
|
zIndex,
|
|
1340
1361
|
...underlayProps,
|
|
1341
1362
|
style: transitionEnabled ? { backgroundColor } : {},
|
|
1342
|
-
children: /* @__PURE__ */
|
|
1363
|
+
children: /* @__PURE__ */ jsx13(FocusScope, { contain: true, restoreFocus: true, autoFocus: true, children: /* @__PURE__ */ jsx13(DialogContainer, { bottomSheet, size, children: /* @__PURE__ */ jsx13(
|
|
1343
1364
|
ModalDialog,
|
|
1344
1365
|
{
|
|
1345
1366
|
ref,
|
|
@@ -1349,13 +1370,14 @@ function Modal({
|
|
|
1349
1370
|
style: transitionEnabled ? { transform } : {},
|
|
1350
1371
|
size,
|
|
1351
1372
|
bottomSheet,
|
|
1352
|
-
|
|
1373
|
+
className,
|
|
1374
|
+
children: /* @__PURE__ */ jsxs8(
|
|
1353
1375
|
ModalContext.Provider,
|
|
1354
1376
|
{
|
|
1355
1377
|
value: { titleProps, title, close: onClose, showDismiss },
|
|
1356
1378
|
children: [
|
|
1357
1379
|
children,
|
|
1358
|
-
isDismissable === true && /* @__PURE__ */
|
|
1380
|
+
isDismissable === true && /* @__PURE__ */ jsx13(
|
|
1359
1381
|
ModalCrossButton,
|
|
1360
1382
|
{
|
|
1361
1383
|
size: "S",
|
|
@@ -1371,14 +1393,15 @@ function Modal({
|
|
|
1371
1393
|
}
|
|
1372
1394
|
) })
|
|
1373
1395
|
);
|
|
1374
|
-
}
|
|
1375
|
-
var
|
|
1396
|
+
});
|
|
1397
|
+
var Modal_default = memo4(Modal);
|
|
1398
|
+
var ModalContext = React8.createContext({
|
|
1376
1399
|
titleProps: {},
|
|
1377
1400
|
title: "",
|
|
1378
1401
|
close: void 0,
|
|
1379
1402
|
showDismiss: true
|
|
1380
1403
|
});
|
|
1381
|
-
var ModalBackground = animated(
|
|
1404
|
+
var ModalBackground = animated(styled11.div`
|
|
1382
1405
|
z-index: ${({ zIndex }) => zIndex};
|
|
1383
1406
|
overflow: scroll;
|
|
1384
1407
|
display: flex;
|
|
@@ -1390,7 +1413,7 @@ var ModalBackground = animated(styled10.div`
|
|
|
1390
1413
|
|
|
1391
1414
|
${theme((o) => [o.bg.surface4])}
|
|
1392
1415
|
`);
|
|
1393
|
-
var DialogContainer =
|
|
1416
|
+
var DialogContainer = styled11.div`
|
|
1394
1417
|
position: relative;
|
|
1395
1418
|
margin: auto;
|
|
1396
1419
|
padding: 24px 0;
|
|
@@ -1411,7 +1434,7 @@ var DialogContainer = styled10.div`
|
|
|
1411
1434
|
}
|
|
1412
1435
|
}}px;
|
|
1413
1436
|
|
|
1414
|
-
@media ${({ theme:
|
|
1437
|
+
@media ${({ theme: theme3 }) => maxWidth(theme3.breakpoint.screen1)} {
|
|
1415
1438
|
width: calc(100% - 48px);
|
|
1416
1439
|
${(p) => p.bottomSheet !== false && css4`
|
|
1417
1440
|
margin: 0;
|
|
@@ -1423,13 +1446,13 @@ var DialogContainer = styled10.div`
|
|
|
1423
1446
|
`}
|
|
1424
1447
|
}
|
|
1425
1448
|
`;
|
|
1426
|
-
var ModalDialog = animated(
|
|
1449
|
+
var ModalDialog = animated(styled11.div`
|
|
1427
1450
|
position: relative;
|
|
1428
1451
|
margin: auto;
|
|
1429
1452
|
padding: 24px 0;
|
|
1430
1453
|
|
|
1431
1454
|
${theme((o) => [o.bg.background1, o.borderRadius(24)])}
|
|
1432
|
-
@media ${({ theme:
|
|
1455
|
+
@media ${({ theme: theme3 }) => maxWidth(theme3.breakpoint.screen1)} {
|
|
1433
1456
|
${(p) => p.bottomSheet !== false && css4`
|
|
1434
1457
|
border-radius: 0;
|
|
1435
1458
|
${p.bottomSheet === "full" && css4`
|
|
@@ -1438,7 +1461,7 @@ var ModalDialog = animated(styled10.div`
|
|
|
1438
1461
|
`}
|
|
1439
1462
|
}
|
|
1440
1463
|
`);
|
|
1441
|
-
var ModalCrossButton =
|
|
1464
|
+
var ModalCrossButton = styled11(IconButton_default)`
|
|
1442
1465
|
position: absolute;
|
|
1443
1466
|
top: 8px;
|
|
1444
1467
|
right: 8px;
|
|
@@ -1447,36 +1470,36 @@ var ModalCrossButton = styled10(IconButton_default)`
|
|
|
1447
1470
|
`;
|
|
1448
1471
|
function ModalTitle(props) {
|
|
1449
1472
|
const { titleProps, title } = useContext4(ModalContext);
|
|
1450
|
-
return /* @__PURE__ */
|
|
1473
|
+
return /* @__PURE__ */ jsx13(ModalHeading, { ...titleProps, ...props, children: title });
|
|
1451
1474
|
}
|
|
1452
|
-
var ModalHeading =
|
|
1475
|
+
var ModalHeading = styled11.h3`
|
|
1453
1476
|
margin: 0;
|
|
1454
1477
|
font-weight: inherit;
|
|
1455
1478
|
font-size: inherit;
|
|
1456
1479
|
`;
|
|
1457
1480
|
|
|
1458
1481
|
// src/components/Modal/ModalPlumbing.tsx
|
|
1459
|
-
import
|
|
1460
|
-
import { jsx as
|
|
1482
|
+
import styled12 from "styled-components";
|
|
1483
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1461
1484
|
function ModalHeader() {
|
|
1462
|
-
return /* @__PURE__ */
|
|
1485
|
+
return /* @__PURE__ */ jsx14(ModalHeaderRoot, { children: /* @__PURE__ */ jsx14(StyledModalTitle, {}) });
|
|
1463
1486
|
}
|
|
1464
|
-
var ModalHeaderRoot =
|
|
1487
|
+
var ModalHeaderRoot = styled12.div`
|
|
1465
1488
|
height: 64px;
|
|
1466
1489
|
display: grid;
|
|
1467
1490
|
align-content: center;
|
|
1468
1491
|
justify-content: center;
|
|
1469
1492
|
`;
|
|
1470
|
-
var StyledModalTitle =
|
|
1493
|
+
var StyledModalTitle = styled12(ModalTitle)`
|
|
1471
1494
|
${theme((o) => [o.font.text1, o.typography(16).bold])}
|
|
1472
1495
|
`;
|
|
1473
|
-
var ModalAlign =
|
|
1496
|
+
var ModalAlign = styled12.div`
|
|
1474
1497
|
${theme((o) => [o.padding.horizontal(16)])}
|
|
1475
1498
|
`;
|
|
1476
|
-
var ModalBody =
|
|
1499
|
+
var ModalBody = styled12.div`
|
|
1477
1500
|
${theme((o) => [o.padding.bottom(40)])}
|
|
1478
1501
|
`;
|
|
1479
|
-
var ModalButtons =
|
|
1502
|
+
var ModalButtons = styled12.div`
|
|
1480
1503
|
display: grid;
|
|
1481
1504
|
grid-auto-flow: row;
|
|
1482
1505
|
grid-row-gap: 8px;
|
|
@@ -1485,17 +1508,26 @@ var ModalButtons = styled11.div`
|
|
|
1485
1508
|
`;
|
|
1486
1509
|
|
|
1487
1510
|
// src/components/LoadingSpinner/index.tsx
|
|
1488
|
-
import { forwardRef as
|
|
1489
|
-
import
|
|
1490
|
-
import { jsx as
|
|
1491
|
-
|
|
1492
|
-
size = 48,
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1511
|
+
import { forwardRef as forwardRef12, useImperativeHandle, useRef as useRef3, memo as memo5 } from "react";
|
|
1512
|
+
import styled13, { keyframes } from "styled-components";
|
|
1513
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1514
|
+
var LoadingSpinner = forwardRef12(
|
|
1515
|
+
function LoadingSpinnerInner({ size = 48, padding = 16, transparent = false, className }, ref) {
|
|
1516
|
+
return /* @__PURE__ */ jsx15(
|
|
1517
|
+
LoadingSpinnerRoot,
|
|
1518
|
+
{
|
|
1519
|
+
size,
|
|
1520
|
+
padding,
|
|
1521
|
+
transparent,
|
|
1522
|
+
className,
|
|
1523
|
+
ref,
|
|
1524
|
+
children: /* @__PURE__ */ jsx15(LoadingSpinnerIcon, {})
|
|
1525
|
+
}
|
|
1526
|
+
);
|
|
1527
|
+
}
|
|
1528
|
+
);
|
|
1529
|
+
var LoadingSpinner_default = memo5(LoadingSpinner);
|
|
1530
|
+
var LoadingSpinnerRoot = styled13.div.attrs({ role: "progressbar" })`
|
|
1499
1531
|
box-sizing: content-box;
|
|
1500
1532
|
margin: auto;
|
|
1501
1533
|
padding: ${(props) => props.padding}px;
|
|
@@ -1520,7 +1552,7 @@ var scaleout = keyframes`
|
|
|
1520
1552
|
opacity: 0;
|
|
1521
1553
|
}
|
|
1522
1554
|
`;
|
|
1523
|
-
var Icon2 =
|
|
1555
|
+
var Icon2 = styled13.div.attrs({ role: "presentation" })`
|
|
1524
1556
|
width: 1em;
|
|
1525
1557
|
height: 1em;
|
|
1526
1558
|
border-radius: 1em;
|
|
@@ -1532,9 +1564,9 @@ var Icon2 = styled12.div.attrs({ role: "presentation" })`
|
|
|
1532
1564
|
animation: none;
|
|
1533
1565
|
}
|
|
1534
1566
|
`;
|
|
1535
|
-
var LoadingSpinnerIcon =
|
|
1567
|
+
var LoadingSpinnerIcon = forwardRef12(
|
|
1536
1568
|
function LoadingSpinnerIcon2({ once = false }, ref) {
|
|
1537
|
-
const iconRef =
|
|
1569
|
+
const iconRef = useRef3(null);
|
|
1538
1570
|
useImperativeHandle(ref, () => ({
|
|
1539
1571
|
restart: () => {
|
|
1540
1572
|
if (!iconRef.current) {
|
|
@@ -1545,26 +1577,26 @@ var LoadingSpinnerIcon = forwardRef8(
|
|
|
1545
1577
|
delete iconRef.current.dataset.resetAnimation;
|
|
1546
1578
|
}
|
|
1547
1579
|
}));
|
|
1548
|
-
return /* @__PURE__ */
|
|
1580
|
+
return /* @__PURE__ */ jsx15(Icon2, { ref: iconRef, once });
|
|
1549
1581
|
}
|
|
1550
1582
|
);
|
|
1551
1583
|
|
|
1552
1584
|
// src/components/DropdownSelector/index.tsx
|
|
1553
|
-
import { useState as
|
|
1554
|
-
import
|
|
1585
|
+
import { useState as useState3, useRef as useRef7 } from "react";
|
|
1586
|
+
import styled16 from "styled-components";
|
|
1555
1587
|
import { disabledSelector as disabledSelector4 } from "@charcoal-ui/utils";
|
|
1556
1588
|
|
|
1557
1589
|
// src/components/DropdownSelector/DropdownPopover.tsx
|
|
1558
|
-
import { useEffect as
|
|
1590
|
+
import { useEffect as useEffect3, useRef as useRef5 } from "react";
|
|
1559
1591
|
|
|
1560
1592
|
// src/components/DropdownSelector/Popover/index.tsx
|
|
1561
|
-
import { useRef as
|
|
1593
|
+
import { useRef as useRef4 } from "react";
|
|
1562
1594
|
import { DismissButton, Overlay as Overlay2, usePopover } from "@react-aria/overlays";
|
|
1563
|
-
import
|
|
1564
|
-
import { jsx as
|
|
1595
|
+
import styled14 from "styled-components";
|
|
1596
|
+
import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1565
1597
|
var _empty = () => null;
|
|
1566
1598
|
function Popover(props) {
|
|
1567
|
-
const defaultPopoverRef =
|
|
1599
|
+
const defaultPopoverRef = useRef4(null);
|
|
1568
1600
|
const finalPopoverRef = props.popoverRef === void 0 ? defaultPopoverRef : props.popoverRef;
|
|
1569
1601
|
const { popoverProps, underlayProps } = usePopover(
|
|
1570
1602
|
{
|
|
@@ -1582,16 +1614,16 @@ function Popover(props) {
|
|
|
1582
1614
|
);
|
|
1583
1615
|
if (!props.isOpen)
|
|
1584
1616
|
return null;
|
|
1585
|
-
return /* @__PURE__ */
|
|
1586
|
-
/* @__PURE__ */
|
|
1587
|
-
/* @__PURE__ */
|
|
1588
|
-
/* @__PURE__ */
|
|
1617
|
+
return /* @__PURE__ */ jsxs9(Overlay2, { portalContainer: document.body, children: [
|
|
1618
|
+
/* @__PURE__ */ jsx16("div", { ...underlayProps, style: { position: "fixed", inset: 0 } }),
|
|
1619
|
+
/* @__PURE__ */ jsxs9(DropdownPopoverDiv, { ...popoverProps, ref: finalPopoverRef, children: [
|
|
1620
|
+
/* @__PURE__ */ jsx16(DismissButton, { onDismiss: () => props.onClose() }),
|
|
1589
1621
|
props.children,
|
|
1590
|
-
/* @__PURE__ */
|
|
1622
|
+
/* @__PURE__ */ jsx16(DismissButton, { onDismiss: () => props.onClose() })
|
|
1591
1623
|
] })
|
|
1592
1624
|
] });
|
|
1593
1625
|
}
|
|
1594
|
-
var DropdownPopoverDiv =
|
|
1626
|
+
var DropdownPopoverDiv = styled14.div`
|
|
1595
1627
|
margin: 4px 0;
|
|
1596
1628
|
list-style: none;
|
|
1597
1629
|
overflow: auto;
|
|
@@ -1606,15 +1638,15 @@ var DropdownPopoverDiv = styled13.div`
|
|
|
1606
1638
|
`;
|
|
1607
1639
|
|
|
1608
1640
|
// src/components/DropdownSelector/DropdownPopover.tsx
|
|
1609
|
-
import { jsx as
|
|
1641
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1610
1642
|
function DropdownPopover({ children, ...props }) {
|
|
1611
|
-
const ref =
|
|
1612
|
-
|
|
1643
|
+
const ref = useRef5(null);
|
|
1644
|
+
useEffect3(() => {
|
|
1613
1645
|
if (props.isOpen && ref.current && props.triggerRef.current) {
|
|
1614
1646
|
ref.current.style.width = `${props.triggerRef.current.clientWidth}px`;
|
|
1615
1647
|
}
|
|
1616
1648
|
}, [props.triggerRef, props.isOpen]);
|
|
1617
|
-
|
|
1649
|
+
useEffect3(() => {
|
|
1618
1650
|
if (props.isOpen && props.value !== void 0) {
|
|
1619
1651
|
const windowScrollY = window.scrollY;
|
|
1620
1652
|
const windowScrollX = window.scrollX;
|
|
@@ -1626,7 +1658,7 @@ function DropdownPopover({ children, ...props }) {
|
|
|
1626
1658
|
window.scrollTo(windowScrollX, windowScrollY);
|
|
1627
1659
|
}
|
|
1628
1660
|
}, [props.value, props.isOpen]);
|
|
1629
|
-
return /* @__PURE__ */
|
|
1661
|
+
return /* @__PURE__ */ jsx17(
|
|
1630
1662
|
Popover,
|
|
1631
1663
|
{
|
|
1632
1664
|
isOpen: props.isOpen,
|
|
@@ -1639,12 +1671,12 @@ function DropdownPopover({ children, ...props }) {
|
|
|
1639
1671
|
}
|
|
1640
1672
|
|
|
1641
1673
|
// src/components/DropdownSelector/utils/findPreviewRecursive.tsx
|
|
1642
|
-
import
|
|
1674
|
+
import React10 from "react";
|
|
1643
1675
|
function findPreviewRecursive(children, value) {
|
|
1644
|
-
const childArray =
|
|
1676
|
+
const childArray = React10.Children.toArray(children);
|
|
1645
1677
|
for (let i = 0; i < childArray.length; i++) {
|
|
1646
1678
|
const child = childArray[i];
|
|
1647
|
-
if (
|
|
1679
|
+
if (React10.isValidElement(child)) {
|
|
1648
1680
|
if ("value" in child.props) {
|
|
1649
1681
|
const childValue = child.props.value;
|
|
1650
1682
|
if (childValue === value && "children" in child.props) {
|
|
@@ -1666,8 +1698,8 @@ function findPreviewRecursive(children, value) {
|
|
|
1666
1698
|
}
|
|
1667
1699
|
|
|
1668
1700
|
// src/components/DropdownSelector/MenuList/index.tsx
|
|
1669
|
-
import { useRef as
|
|
1670
|
-
import
|
|
1701
|
+
import { useRef as useRef6 } from "react";
|
|
1702
|
+
import styled15 from "styled-components";
|
|
1671
1703
|
|
|
1672
1704
|
// src/components/DropdownSelector/MenuList/MenuListContext.ts
|
|
1673
1705
|
import { createContext as createContext5 } from "react";
|
|
@@ -1680,12 +1712,12 @@ var MenuListContext = createContext5({
|
|
|
1680
1712
|
});
|
|
1681
1713
|
|
|
1682
1714
|
// src/components/DropdownSelector/MenuList/internals/getValuesRecursive.tsx
|
|
1683
|
-
import
|
|
1715
|
+
import React11 from "react";
|
|
1684
1716
|
function getValuesRecursive(children, values = []) {
|
|
1685
|
-
const childArray =
|
|
1717
|
+
const childArray = React11.Children.toArray(children);
|
|
1686
1718
|
for (let i = 0; i < childArray.length; i++) {
|
|
1687
1719
|
const child = childArray[i];
|
|
1688
|
-
if (
|
|
1720
|
+
if (React11.isValidElement(child)) {
|
|
1689
1721
|
const props = child.props;
|
|
1690
1722
|
if ("value" in props && typeof props.value === "string") {
|
|
1691
1723
|
const childValue = props.value;
|
|
@@ -1699,12 +1731,12 @@ function getValuesRecursive(children, values = []) {
|
|
|
1699
1731
|
}
|
|
1700
1732
|
|
|
1701
1733
|
// src/components/DropdownSelector/MenuList/index.tsx
|
|
1702
|
-
import { jsx as
|
|
1734
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1703
1735
|
function MenuList(props) {
|
|
1704
|
-
const root =
|
|
1736
|
+
const root = useRef6(null);
|
|
1705
1737
|
const values = [];
|
|
1706
1738
|
getValuesRecursive(props.children, values);
|
|
1707
|
-
return /* @__PURE__ */
|
|
1739
|
+
return /* @__PURE__ */ jsx18(StyledUl, { ref: root, children: /* @__PURE__ */ jsx18(
|
|
1708
1740
|
MenuListContext.Provider,
|
|
1709
1741
|
{
|
|
1710
1742
|
value: {
|
|
@@ -1719,20 +1751,20 @@ function MenuList(props) {
|
|
|
1719
1751
|
}
|
|
1720
1752
|
) });
|
|
1721
1753
|
}
|
|
1722
|
-
var StyledUl =
|
|
1754
|
+
var StyledUl = styled15.ul`
|
|
1723
1755
|
padding: 0;
|
|
1724
1756
|
margin: 0;
|
|
1725
1757
|
`;
|
|
1726
1758
|
|
|
1727
1759
|
// src/components/DropdownSelector/index.tsx
|
|
1728
|
-
import { jsx as
|
|
1760
|
+
import { jsx as jsx19, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1729
1761
|
var defaultRequiredText = "*\u5FC5\u9808";
|
|
1730
1762
|
function DropdownSelector(props) {
|
|
1731
|
-
const triggerRef =
|
|
1732
|
-
const [isOpen, setIsOpen] =
|
|
1763
|
+
const triggerRef = useRef7(null);
|
|
1764
|
+
const [isOpen, setIsOpen] = useState3(false);
|
|
1733
1765
|
const preview = findPreviewRecursive(props.children, props.value);
|
|
1734
|
-
return /* @__PURE__ */
|
|
1735
|
-
props.showLabel === true && /* @__PURE__ */
|
|
1766
|
+
return /* @__PURE__ */ jsxs10(DropdownSelectorRoot, { "aria-disabled": props.disabled, children: [
|
|
1767
|
+
props.showLabel === true && /* @__PURE__ */ jsx19(
|
|
1736
1768
|
DropdownFieldLabel,
|
|
1737
1769
|
{
|
|
1738
1770
|
label: props.label,
|
|
@@ -1741,7 +1773,7 @@ function DropdownSelector(props) {
|
|
|
1741
1773
|
subLabel: props.subLabel
|
|
1742
1774
|
}
|
|
1743
1775
|
),
|
|
1744
|
-
/* @__PURE__ */
|
|
1776
|
+
/* @__PURE__ */ jsxs10(
|
|
1745
1777
|
DropdownButton,
|
|
1746
1778
|
{
|
|
1747
1779
|
invalid: props.invalid,
|
|
@@ -1753,19 +1785,19 @@ function DropdownSelector(props) {
|
|
|
1753
1785
|
},
|
|
1754
1786
|
ref: triggerRef,
|
|
1755
1787
|
children: [
|
|
1756
|
-
/* @__PURE__ */
|
|
1757
|
-
/* @__PURE__ */
|
|
1788
|
+
/* @__PURE__ */ jsx19(DropdownButtonText, { children: props.placeholder !== void 0 && preview === void 0 ? props.placeholder : preview }),
|
|
1789
|
+
/* @__PURE__ */ jsx19(DropdownButtonIcon, { name: "16/Menu" })
|
|
1758
1790
|
]
|
|
1759
1791
|
}
|
|
1760
1792
|
),
|
|
1761
|
-
/* @__PURE__ */
|
|
1793
|
+
isOpen && /* @__PURE__ */ jsx19(
|
|
1762
1794
|
DropdownPopover,
|
|
1763
1795
|
{
|
|
1764
1796
|
isOpen,
|
|
1765
1797
|
onClose: () => setIsOpen(false),
|
|
1766
1798
|
triggerRef,
|
|
1767
1799
|
value: props.value,
|
|
1768
|
-
children: /* @__PURE__ */
|
|
1800
|
+
children: /* @__PURE__ */ jsx19(
|
|
1769
1801
|
MenuList,
|
|
1770
1802
|
{
|
|
1771
1803
|
value: props.value,
|
|
@@ -1778,10 +1810,10 @@ function DropdownSelector(props) {
|
|
|
1778
1810
|
)
|
|
1779
1811
|
}
|
|
1780
1812
|
),
|
|
1781
|
-
props.assistiveText !== void 0 && /* @__PURE__ */
|
|
1813
|
+
props.assistiveText !== void 0 && /* @__PURE__ */ jsx19(AssertiveText, { invalid: props.invalid, children: props.assistiveText })
|
|
1782
1814
|
] });
|
|
1783
1815
|
}
|
|
1784
|
-
var DropdownSelectorRoot =
|
|
1816
|
+
var DropdownSelectorRoot = styled16.div`
|
|
1785
1817
|
display: inline-block;
|
|
1786
1818
|
width: 100%;
|
|
1787
1819
|
|
|
@@ -1790,12 +1822,12 @@ var DropdownSelectorRoot = styled15.div`
|
|
|
1790
1822
|
${theme((o) => o.disabled)}
|
|
1791
1823
|
}
|
|
1792
1824
|
`;
|
|
1793
|
-
var DropdownFieldLabel =
|
|
1825
|
+
var DropdownFieldLabel = styled16(FieldLabel_default)`
|
|
1794
1826
|
width: 100%;
|
|
1795
1827
|
|
|
1796
1828
|
${theme((o) => o.margin.bottom(8))}
|
|
1797
1829
|
`;
|
|
1798
|
-
var DropdownButton =
|
|
1830
|
+
var DropdownButton = styled16.button`
|
|
1799
1831
|
display: flex;
|
|
1800
1832
|
justify-content: space-between;
|
|
1801
1833
|
align-items: center;
|
|
@@ -1818,15 +1850,15 @@ var DropdownButton = styled15.button`
|
|
|
1818
1850
|
invalid === true && o.outline.assertive
|
|
1819
1851
|
])}
|
|
1820
1852
|
`;
|
|
1821
|
-
var DropdownButtonText =
|
|
1853
|
+
var DropdownButtonText = styled16.span`
|
|
1822
1854
|
text-align: left;
|
|
1823
1855
|
|
|
1824
1856
|
${theme((o) => [o.typography(14), o.font.text2])}
|
|
1825
1857
|
`;
|
|
1826
|
-
var DropdownButtonIcon =
|
|
1858
|
+
var DropdownButtonIcon = styled16(Icon_default)`
|
|
1827
1859
|
${theme((o) => [o.font.text2])}
|
|
1828
1860
|
`;
|
|
1829
|
-
var AssertiveText =
|
|
1861
|
+
var AssertiveText = styled16.div`
|
|
1830
1862
|
${({ invalid }) => theme((o) => [
|
|
1831
1863
|
o.typography(14),
|
|
1832
1864
|
o.margin.top(8),
|
|
@@ -1835,19 +1867,19 @@ var AssertiveText = styled15.div`
|
|
|
1835
1867
|
`;
|
|
1836
1868
|
|
|
1837
1869
|
// src/components/DropdownSelector/DropdownMenuItem.tsx
|
|
1838
|
-
import
|
|
1870
|
+
import styled18 from "styled-components";
|
|
1839
1871
|
|
|
1840
1872
|
// src/components/DropdownSelector/ListItem/index.tsx
|
|
1841
|
-
import
|
|
1842
|
-
import { jsx as
|
|
1873
|
+
import styled17 from "styled-components";
|
|
1874
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
1843
1875
|
function ListItem(props) {
|
|
1844
1876
|
const { children, ...rest } = props;
|
|
1845
|
-
return /* @__PURE__ */
|
|
1877
|
+
return /* @__PURE__ */ jsx20(StyledLi, { role: "option", children: /* @__PURE__ */ jsx20(ItemDiv, { ...rest, children: props.children }) });
|
|
1846
1878
|
}
|
|
1847
|
-
var StyledLi =
|
|
1879
|
+
var StyledLi = styled17.li`
|
|
1848
1880
|
list-style: none;
|
|
1849
1881
|
`;
|
|
1850
|
-
var ItemDiv =
|
|
1882
|
+
var ItemDiv = styled17.div`
|
|
1851
1883
|
display: flex;
|
|
1852
1884
|
align-items: center;
|
|
1853
1885
|
min-height: 40px;
|
|
@@ -1868,7 +1900,7 @@ var ItemDiv = styled16.div`
|
|
|
1868
1900
|
`;
|
|
1869
1901
|
|
|
1870
1902
|
// src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx
|
|
1871
|
-
import { useCallback as
|
|
1903
|
+
import { useCallback as useCallback5, useContext as useContext5 } from "react";
|
|
1872
1904
|
|
|
1873
1905
|
// src/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.tsx
|
|
1874
1906
|
function handleFocusByKeyBoard(element, parent) {
|
|
@@ -1902,11 +1934,11 @@ function scrollIfNeeded(element) {
|
|
|
1902
1934
|
// src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx
|
|
1903
1935
|
function useMenuItemHandleKeyDown(value) {
|
|
1904
1936
|
const { setValue, root, values } = useContext5(MenuListContext);
|
|
1905
|
-
const setContextValue =
|
|
1937
|
+
const setContextValue = useCallback5(() => {
|
|
1906
1938
|
if (value !== void 0)
|
|
1907
1939
|
setValue(value);
|
|
1908
1940
|
}, [value, setValue]);
|
|
1909
|
-
const handleKeyDown =
|
|
1941
|
+
const handleKeyDown = useCallback5(
|
|
1910
1942
|
(e) => {
|
|
1911
1943
|
if (e.key === "Enter") {
|
|
1912
1944
|
setContextValue();
|
|
@@ -1933,11 +1965,11 @@ function useMenuItemHandleKeyDown(value) {
|
|
|
1933
1965
|
}
|
|
1934
1966
|
|
|
1935
1967
|
// src/components/DropdownSelector/MenuItem/index.tsx
|
|
1936
|
-
import { jsx as
|
|
1968
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
1937
1969
|
function MenuItem(props) {
|
|
1938
1970
|
const { children, as, ...rest } = props;
|
|
1939
1971
|
const [handleKeyDown, setContextValue] = useMenuItemHandleKeyDown(props.value);
|
|
1940
|
-
return /* @__PURE__ */
|
|
1972
|
+
return /* @__PURE__ */ jsx21(
|
|
1941
1973
|
ListItem,
|
|
1942
1974
|
{
|
|
1943
1975
|
...rest,
|
|
@@ -1954,74 +1986,74 @@ function MenuItem(props) {
|
|
|
1954
1986
|
|
|
1955
1987
|
// src/components/DropdownSelector/DropdownMenuItem.tsx
|
|
1956
1988
|
import { useContext as useContext6 } from "react";
|
|
1957
|
-
import { jsx as
|
|
1989
|
+
import { jsx as jsx22, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1958
1990
|
function DropdownMenuItem(props) {
|
|
1959
1991
|
const { value: ctxValue } = useContext6(MenuListContext);
|
|
1960
1992
|
const isSelected = props.value === ctxValue;
|
|
1961
1993
|
const { children, ...rest } = props;
|
|
1962
|
-
return /* @__PURE__ */
|
|
1963
|
-
isSelected && /* @__PURE__ */
|
|
1964
|
-
/* @__PURE__ */
|
|
1994
|
+
return /* @__PURE__ */ jsxs11(MenuItem, { ...rest, children: [
|
|
1995
|
+
isSelected && /* @__PURE__ */ jsx22(Text2ColorIcon, { name: "16/Check" }),
|
|
1996
|
+
/* @__PURE__ */ jsx22(StyledSpan, { isSelected, children: props.children })
|
|
1965
1997
|
] });
|
|
1966
1998
|
}
|
|
1967
|
-
var StyledSpan =
|
|
1999
|
+
var StyledSpan = styled18.span`
|
|
1968
2000
|
${theme((o) => [o.typography(14), o.font.text2])};
|
|
1969
2001
|
display: flex;
|
|
1970
2002
|
align-items: center;
|
|
1971
2003
|
width: 100%;
|
|
1972
2004
|
margin-left: ${({ isSelected }) => isSelected === true ? 0 : 20}px;
|
|
1973
2005
|
`;
|
|
1974
|
-
var Text2ColorIcon =
|
|
2006
|
+
var Text2ColorIcon = styled18(Icon_default)`
|
|
1975
2007
|
${theme((o) => [o.font.text2])}
|
|
1976
2008
|
padding-right: 4px;
|
|
1977
2009
|
`;
|
|
1978
2010
|
|
|
1979
2011
|
// src/components/DropdownSelector/MenuItemGroup/index.tsx
|
|
1980
|
-
import
|
|
1981
|
-
import { jsx as
|
|
2012
|
+
import styled19 from "styled-components";
|
|
2013
|
+
import { jsx as jsx23, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1982
2014
|
function MenuItemGroup(props) {
|
|
1983
|
-
return /* @__PURE__ */
|
|
1984
|
-
/* @__PURE__ */
|
|
1985
|
-
/* @__PURE__ */
|
|
2015
|
+
return /* @__PURE__ */ jsxs12(StyledLi2, { role: "presentation", children: [
|
|
2016
|
+
/* @__PURE__ */ jsx23(TextSpan, { children: props.text }),
|
|
2017
|
+
/* @__PURE__ */ jsx23(StyledUl2, { role: "group", children: props.children })
|
|
1986
2018
|
] });
|
|
1987
2019
|
}
|
|
1988
|
-
var TextSpan =
|
|
2020
|
+
var TextSpan = styled19.span`
|
|
1989
2021
|
display: block;
|
|
1990
|
-
color: ${({ theme:
|
|
2022
|
+
color: ${({ theme: theme3 }) => theme3.color.text3};
|
|
1991
2023
|
font-size: 12px;
|
|
1992
2024
|
font-weight: bold;
|
|
1993
2025
|
padding: 12px 0 8px 16px;
|
|
1994
2026
|
`;
|
|
1995
|
-
var StyledUl2 =
|
|
2027
|
+
var StyledUl2 = styled19.ul`
|
|
1996
2028
|
padding-left: 0;
|
|
1997
2029
|
margin: 0;
|
|
1998
2030
|
box-sizing: border-box;
|
|
1999
2031
|
list-style: none;
|
|
2000
2032
|
overflow: hidden;
|
|
2001
2033
|
`;
|
|
2002
|
-
var StyledLi2 =
|
|
2034
|
+
var StyledLi2 = styled19.li`
|
|
2003
2035
|
display: block;
|
|
2004
2036
|
`;
|
|
2005
2037
|
|
|
2006
2038
|
// src/components/SegmentedControl/index.tsx
|
|
2007
|
-
import { forwardRef as
|
|
2039
|
+
import { forwardRef as forwardRef13, memo as memo6, useMemo as useMemo2, useRef as useRef8 } from "react";
|
|
2008
2040
|
import { useRadioGroupState } from "react-stately";
|
|
2009
2041
|
import {
|
|
2010
2042
|
useRadio,
|
|
2011
2043
|
useRadioGroup
|
|
2012
2044
|
} from "@react-aria/radio";
|
|
2013
|
-
import
|
|
2045
|
+
import styled20 from "styled-components";
|
|
2014
2046
|
import { disabledSelector as disabledSelector5 } from "@charcoal-ui/utils";
|
|
2015
2047
|
|
|
2016
2048
|
// src/components/SegmentedControl/RadioGroupContext.tsx
|
|
2017
2049
|
import { createContext as createContext6, useContext as useContext7 } from "react";
|
|
2018
|
-
import { jsx as
|
|
2050
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
2019
2051
|
var RadioContext = createContext6(null);
|
|
2020
2052
|
var RadioProvider = ({
|
|
2021
2053
|
value,
|
|
2022
2054
|
children
|
|
2023
2055
|
}) => {
|
|
2024
|
-
return /* @__PURE__ */
|
|
2056
|
+
return /* @__PURE__ */ jsx24(RadioContext.Provider, { value, children });
|
|
2025
2057
|
};
|
|
2026
2058
|
var useRadioContext = () => {
|
|
2027
2059
|
const state = useContext7(RadioContext);
|
|
@@ -2031,8 +2063,8 @@ var useRadioContext = () => {
|
|
|
2031
2063
|
};
|
|
2032
2064
|
|
|
2033
2065
|
// src/components/SegmentedControl/index.tsx
|
|
2034
|
-
import { jsx as
|
|
2035
|
-
var SegmentedControl =
|
|
2066
|
+
import { jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2067
|
+
var SegmentedControl = forwardRef13(
|
|
2036
2068
|
function SegmentedControlInner(props, ref) {
|
|
2037
2069
|
const ariaRadioGroupProps = useMemo2(
|
|
2038
2070
|
() => ({
|
|
@@ -2051,21 +2083,29 @@ var SegmentedControl = forwardRef9(
|
|
|
2051
2083
|
(d) => typeof d === "string" ? { value: d, label: d } : d
|
|
2052
2084
|
);
|
|
2053
2085
|
}, [props.data]);
|
|
2054
|
-
return /* @__PURE__ */
|
|
2055
|
-
|
|
2086
|
+
return /* @__PURE__ */ jsx25(
|
|
2087
|
+
SegmentedControlRoot,
|
|
2056
2088
|
{
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2089
|
+
ref,
|
|
2090
|
+
...radioGroupProps,
|
|
2091
|
+
className: props.className,
|
|
2092
|
+
children: /* @__PURE__ */ jsx25(RadioProvider, { value: state, children: segmentedControlItems.map((item) => /* @__PURE__ */ jsx25(
|
|
2093
|
+
Segmented,
|
|
2094
|
+
{
|
|
2095
|
+
value: item.value,
|
|
2096
|
+
disabled: item.disabled,
|
|
2097
|
+
children: item.label
|
|
2098
|
+
},
|
|
2099
|
+
item.value
|
|
2100
|
+
)) })
|
|
2101
|
+
}
|
|
2102
|
+
);
|
|
2063
2103
|
}
|
|
2064
2104
|
);
|
|
2065
|
-
var SegmentedControl_default =
|
|
2105
|
+
var SegmentedControl_default = memo6(SegmentedControl);
|
|
2066
2106
|
var Segmented = (props) => {
|
|
2067
2107
|
const state = useRadioContext();
|
|
2068
|
-
const ref =
|
|
2108
|
+
const ref = useRef8(null);
|
|
2069
2109
|
const ariaRadioProps = useMemo2(
|
|
2070
2110
|
() => ({
|
|
2071
2111
|
value: props.value,
|
|
@@ -2079,25 +2119,25 @@ var Segmented = (props) => {
|
|
|
2079
2119
|
state,
|
|
2080
2120
|
ref
|
|
2081
2121
|
);
|
|
2082
|
-
return /* @__PURE__ */
|
|
2122
|
+
return /* @__PURE__ */ jsxs13(
|
|
2083
2123
|
SegmentedRoot,
|
|
2084
2124
|
{
|
|
2085
2125
|
"aria-disabled": isDisabled || state.isReadOnly,
|
|
2086
2126
|
checked: isSelected,
|
|
2087
2127
|
children: [
|
|
2088
|
-
/* @__PURE__ */
|
|
2089
|
-
/* @__PURE__ */
|
|
2128
|
+
/* @__PURE__ */ jsx25(SegmentedInput, { ...inputProps, ref }),
|
|
2129
|
+
/* @__PURE__ */ jsx25(RadioLabel2, { children: /* @__PURE__ */ jsx25(SegmentedLabelInner, { children: props.children }) })
|
|
2090
2130
|
]
|
|
2091
2131
|
}
|
|
2092
2132
|
);
|
|
2093
2133
|
};
|
|
2094
|
-
var SegmentedControlRoot =
|
|
2134
|
+
var SegmentedControlRoot = styled20.div`
|
|
2095
2135
|
display: inline-flex;
|
|
2096
2136
|
align-items: center;
|
|
2097
2137
|
|
|
2098
2138
|
${theme((o) => [o.bg.surface3, o.borderRadius(16)])}
|
|
2099
2139
|
`;
|
|
2100
|
-
var SegmentedRoot =
|
|
2140
|
+
var SegmentedRoot = styled20.label`
|
|
2101
2141
|
position: relative;
|
|
2102
2142
|
display: flex;
|
|
2103
2143
|
align-items: center;
|
|
@@ -2116,7 +2156,7 @@ var SegmentedRoot = styled19.label`
|
|
|
2116
2156
|
checked === true ? o.font.text5 : o.font.text2
|
|
2117
2157
|
])}
|
|
2118
2158
|
`;
|
|
2119
|
-
var SegmentedInput =
|
|
2159
|
+
var SegmentedInput = styled20.input`
|
|
2120
2160
|
position: absolute;
|
|
2121
2161
|
|
|
2122
2162
|
height: 0px;
|
|
@@ -2130,25 +2170,25 @@ var SegmentedInput = styled19.input`
|
|
|
2130
2170
|
white-space: nowrap;
|
|
2131
2171
|
opacity: 0;
|
|
2132
2172
|
`;
|
|
2133
|
-
var RadioLabel2 =
|
|
2173
|
+
var RadioLabel2 = styled20.div`
|
|
2134
2174
|
background: transparent;
|
|
2135
2175
|
display: flex;
|
|
2136
2176
|
align-items: center;
|
|
2137
2177
|
height: 22px;
|
|
2138
2178
|
`;
|
|
2139
|
-
var SegmentedLabelInner =
|
|
2179
|
+
var SegmentedLabelInner = styled20.div`
|
|
2140
2180
|
${theme((o) => [o.typography(14)])}
|
|
2141
2181
|
`;
|
|
2142
2182
|
|
|
2143
2183
|
// src/components/Checkbox/index.tsx
|
|
2144
|
-
import { forwardRef as
|
|
2145
|
-
import
|
|
2184
|
+
import { forwardRef as forwardRef14, memo as memo7, useMemo as useMemo3 } from "react";
|
|
2185
|
+
import styled21, { css as css5 } from "styled-components";
|
|
2146
2186
|
import { useCheckbox } from "@react-aria/checkbox";
|
|
2147
|
-
import { useObjectRef } from "@react-aria/utils";
|
|
2187
|
+
import { useObjectRef as useObjectRef3 } from "@react-aria/utils";
|
|
2148
2188
|
import { useToggleState as useToggleState2 } from "react-stately";
|
|
2149
2189
|
import { disabledSelector as disabledSelector6, px as px3 } from "@charcoal-ui/utils";
|
|
2150
|
-
import { jsx as
|
|
2151
|
-
var Checkbox =
|
|
2190
|
+
import { jsx as jsx26, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2191
|
+
var Checkbox = forwardRef14(
|
|
2152
2192
|
function CheckboxInner(props, ref) {
|
|
2153
2193
|
const ariaCheckboxProps = useMemo3(
|
|
2154
2194
|
() => ({
|
|
@@ -2161,23 +2201,23 @@ var Checkbox = forwardRef10(
|
|
|
2161
2201
|
[props]
|
|
2162
2202
|
);
|
|
2163
2203
|
const state = useToggleState2(ariaCheckboxProps);
|
|
2164
|
-
const objectRef =
|
|
2204
|
+
const objectRef = useObjectRef3(ref);
|
|
2165
2205
|
const { inputProps } = useCheckbox(ariaCheckboxProps, state, objectRef);
|
|
2166
2206
|
const isDisabled = (props.disabled ?? false) || (props.readonly ?? false);
|
|
2167
|
-
return /* @__PURE__ */
|
|
2168
|
-
/* @__PURE__ */
|
|
2169
|
-
/* @__PURE__ */
|
|
2170
|
-
/* @__PURE__ */
|
|
2207
|
+
return /* @__PURE__ */ jsxs14(InputRoot, { "aria-disabled": isDisabled, className: props.className, children: [
|
|
2208
|
+
/* @__PURE__ */ jsxs14(CheckboxRoot, { children: [
|
|
2209
|
+
/* @__PURE__ */ jsx26(CheckboxInput, { type: "checkbox", ...inputProps }),
|
|
2210
|
+
/* @__PURE__ */ jsx26(CheckboxInputOverlay, { "aria-hidden": true, checked: inputProps.checked, children: /* @__PURE__ */ jsx26(Icon_default, { name: "24/Check", unsafeNonGuidelineScale: 2 / 3 }) })
|
|
2171
2211
|
] }),
|
|
2172
|
-
"children" in props && /* @__PURE__ */
|
|
2212
|
+
"children" in props && /* @__PURE__ */ jsx26(InputLabel, { children: props.children })
|
|
2173
2213
|
] });
|
|
2174
2214
|
}
|
|
2175
2215
|
);
|
|
2176
|
-
var Checkbox_default =
|
|
2216
|
+
var Checkbox_default = memo7(Checkbox);
|
|
2177
2217
|
var hiddenCss = css5`
|
|
2178
2218
|
visibility: hidden;
|
|
2179
2219
|
`;
|
|
2180
|
-
var InputRoot =
|
|
2220
|
+
var InputRoot = styled21.label`
|
|
2181
2221
|
position: relative;
|
|
2182
2222
|
display: flex;
|
|
2183
2223
|
|
|
@@ -2186,13 +2226,13 @@ var InputRoot = styled20.label`
|
|
|
2186
2226
|
cursor: default;
|
|
2187
2227
|
}
|
|
2188
2228
|
|
|
2189
|
-
gap: ${({ theme:
|
|
2229
|
+
gap: ${({ theme: theme3 }) => px3(theme3.spacing[4])};
|
|
2190
2230
|
${theme((o) => [o.disabled])}
|
|
2191
2231
|
`;
|
|
2192
|
-
var CheckboxRoot =
|
|
2232
|
+
var CheckboxRoot = styled21.div`
|
|
2193
2233
|
position: relative;
|
|
2194
2234
|
`;
|
|
2195
|
-
var CheckboxInput =
|
|
2235
|
+
var CheckboxInput = styled21.input`
|
|
2196
2236
|
&[type='checkbox'] {
|
|
2197
2237
|
appearance: none;
|
|
2198
2238
|
display: block;
|
|
@@ -2207,7 +2247,7 @@ var CheckboxInput = styled20.input`
|
|
|
2207
2247
|
&:not(:checked) {
|
|
2208
2248
|
border-width: 2px;
|
|
2209
2249
|
border-style: solid;
|
|
2210
|
-
border-color: ${({ theme:
|
|
2250
|
+
border-color: ${({ theme: theme3 }) => theme3.color.text4};
|
|
2211
2251
|
}
|
|
2212
2252
|
${theme((o) => [o.outline.default.focus, o.borderRadius(4)])}
|
|
2213
2253
|
|
|
@@ -2215,7 +2255,7 @@ var CheckboxInput = styled20.input`
|
|
|
2215
2255
|
transition: all 0.2s !important;
|
|
2216
2256
|
}
|
|
2217
2257
|
`;
|
|
2218
|
-
var CheckboxInputOverlay =
|
|
2258
|
+
var CheckboxInputOverlay = styled21.div`
|
|
2219
2259
|
position: absolute;
|
|
2220
2260
|
top: -2px;
|
|
2221
2261
|
left: -2px;
|
|
@@ -2228,7 +2268,7 @@ var CheckboxInputOverlay = styled20.div`
|
|
|
2228
2268
|
|
|
2229
2269
|
${({ checked }) => checked !== true && hiddenCss};
|
|
2230
2270
|
`;
|
|
2231
|
-
var InputLabel =
|
|
2271
|
+
var InputLabel = styled21.div`
|
|
2232
2272
|
${theme((o) => [o.font.text2])}
|
|
2233
2273
|
|
|
2234
2274
|
font-size: 14px;
|
|
@@ -2237,17 +2277,17 @@ var InputLabel = styled20.div`
|
|
|
2237
2277
|
`;
|
|
2238
2278
|
|
|
2239
2279
|
// src/components/TagItem/index.tsx
|
|
2240
|
-
import { forwardRef as
|
|
2241
|
-
import { useObjectRef as
|
|
2242
|
-
import
|
|
2280
|
+
import { forwardRef as forwardRef15, memo as memo8, useMemo as useMemo4 } from "react";
|
|
2281
|
+
import { useObjectRef as useObjectRef4 } from "@react-aria/utils";
|
|
2282
|
+
import styled22, { css as css6 } from "styled-components";
|
|
2243
2283
|
import { disabledSelector as disabledSelector7, px as px4 } from "@charcoal-ui/utils";
|
|
2244
2284
|
import { useButton } from "@react-aria/button";
|
|
2245
|
-
import { jsx as
|
|
2285
|
+
import { jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2246
2286
|
var sizeMap = {
|
|
2247
2287
|
S: 32,
|
|
2248
2288
|
M: 40
|
|
2249
2289
|
};
|
|
2250
|
-
var TagItem =
|
|
2290
|
+
var TagItem = forwardRef15(
|
|
2251
2291
|
function TagItemInner({
|
|
2252
2292
|
label,
|
|
2253
2293
|
translatedLabel,
|
|
@@ -2259,7 +2299,7 @@ var TagItem = forwardRef11(
|
|
|
2259
2299
|
className,
|
|
2260
2300
|
...props
|
|
2261
2301
|
}, _ref) {
|
|
2262
|
-
const ref =
|
|
2302
|
+
const ref = useObjectRef4(_ref);
|
|
2263
2303
|
const ariaButtonProps = useMemo4(
|
|
2264
2304
|
() => ({
|
|
2265
2305
|
elementType: "a",
|
|
@@ -2270,7 +2310,7 @@ var TagItem = forwardRef11(
|
|
|
2270
2310
|
);
|
|
2271
2311
|
const { buttonProps } = useButton(ariaButtonProps, ref);
|
|
2272
2312
|
const hasTranslatedLabel = translatedLabel !== void 0 && translatedLabel.length > 0;
|
|
2273
|
-
return /* @__PURE__ */
|
|
2313
|
+
return /* @__PURE__ */ jsxs15(
|
|
2274
2314
|
TagItemRoot,
|
|
2275
2315
|
{
|
|
2276
2316
|
ref,
|
|
@@ -2279,21 +2319,21 @@ var TagItem = forwardRef11(
|
|
|
2279
2319
|
...buttonProps,
|
|
2280
2320
|
className,
|
|
2281
2321
|
children: [
|
|
2282
|
-
/* @__PURE__ */
|
|
2283
|
-
/* @__PURE__ */
|
|
2284
|
-
/* @__PURE__ */
|
|
2285
|
-
hasTranslatedLabel && /* @__PURE__ */
|
|
2286
|
-
/* @__PURE__ */
|
|
2322
|
+
/* @__PURE__ */ jsx27(Background, { bgColor, bgImage, status }),
|
|
2323
|
+
/* @__PURE__ */ jsxs15(Inner, { children: [
|
|
2324
|
+
/* @__PURE__ */ jsxs15(LabelWrapper, { isTranslate: hasTranslatedLabel, children: [
|
|
2325
|
+
hasTranslatedLabel && /* @__PURE__ */ jsx27(TranslatedLabel, { children: /* @__PURE__ */ jsx27(Label3, { children: translatedLabel }) }),
|
|
2326
|
+
/* @__PURE__ */ jsx27(Label3, { children: label })
|
|
2287
2327
|
] }),
|
|
2288
|
-
status === "active" && /* @__PURE__ */
|
|
2328
|
+
status === "active" && /* @__PURE__ */ jsx27(Icon_default, { name: "16/Remove" })
|
|
2289
2329
|
] })
|
|
2290
2330
|
]
|
|
2291
2331
|
}
|
|
2292
2332
|
);
|
|
2293
2333
|
}
|
|
2294
2334
|
);
|
|
2295
|
-
var TagItem_default =
|
|
2296
|
-
var TagItemRoot =
|
|
2335
|
+
var TagItem_default = memo8(TagItem);
|
|
2336
|
+
var TagItemRoot = styled22.a`
|
|
2297
2337
|
isolation: isolate;
|
|
2298
2338
|
position: relative;
|
|
2299
2339
|
height: ${({ size }) => sizeMap[size]}px;
|
|
@@ -2318,7 +2358,7 @@ var TagItemRoot = styled21.a`
|
|
|
2318
2358
|
cursor: default;
|
|
2319
2359
|
}
|
|
2320
2360
|
`;
|
|
2321
|
-
var Background =
|
|
2361
|
+
var Background = styled22.div`
|
|
2322
2362
|
position: absolute;
|
|
2323
2363
|
z-index: 1;
|
|
2324
2364
|
top: 0;
|
|
@@ -2345,9 +2385,9 @@ var Background = styled21.div`
|
|
|
2345
2385
|
}
|
|
2346
2386
|
`}
|
|
2347
2387
|
`;
|
|
2348
|
-
var Inner =
|
|
2388
|
+
var Inner = styled22.div`
|
|
2349
2389
|
display: inline-flex;
|
|
2350
|
-
gap: ${({ theme:
|
|
2390
|
+
gap: ${({ theme: theme3 }) => px4(theme3.spacing[8])};
|
|
2351
2391
|
align-items: center;
|
|
2352
2392
|
z-index: 2;
|
|
2353
2393
|
`;
|
|
@@ -2360,10 +2400,10 @@ var translateLabelCSS = css6`
|
|
|
2360
2400
|
flex-direction: column;
|
|
2361
2401
|
font-size: 10px;
|
|
2362
2402
|
`;
|
|
2363
|
-
var LabelWrapper =
|
|
2403
|
+
var LabelWrapper = styled22.div`
|
|
2364
2404
|
${({ isTranslate }) => isTranslate ?? false ? translateLabelCSS : labelCSS}
|
|
2365
2405
|
`;
|
|
2366
|
-
var Label3 =
|
|
2406
|
+
var Label3 = styled22.span`
|
|
2367
2407
|
max-width: 152px;
|
|
2368
2408
|
overflow: hidden;
|
|
2369
2409
|
text-overflow: ellipsis;
|
|
@@ -2372,7 +2412,7 @@ var Label3 = styled21.span`
|
|
|
2372
2412
|
color: inherit;
|
|
2373
2413
|
line-height: inherit;
|
|
2374
2414
|
`;
|
|
2375
|
-
var TranslatedLabel =
|
|
2415
|
+
var TranslatedLabel = styled22.div`
|
|
2376
2416
|
${theme((o) => [o.typography(12).bold])}
|
|
2377
2417
|
`;
|
|
2378
2418
|
export {
|
|
@@ -2385,23 +2425,24 @@ export {
|
|
|
2385
2425
|
DropdownSelector,
|
|
2386
2426
|
Icon_default as Icon,
|
|
2387
2427
|
IconButton_default as IconButton,
|
|
2388
|
-
LoadingSpinner,
|
|
2428
|
+
LoadingSpinner_default as LoadingSpinner,
|
|
2389
2429
|
LoadingSpinnerIcon,
|
|
2390
2430
|
MenuItemGroup,
|
|
2391
|
-
Modal,
|
|
2431
|
+
Modal_default as Modal,
|
|
2392
2432
|
ModalAlign,
|
|
2393
2433
|
ModalBody,
|
|
2394
2434
|
ModalButtons,
|
|
2395
2435
|
ModalHeader,
|
|
2396
|
-
MultiSelect,
|
|
2436
|
+
MultiSelect_default as MultiSelect,
|
|
2397
2437
|
MultiSelectGroup,
|
|
2398
2438
|
OverlayProvider,
|
|
2399
|
-
Radio,
|
|
2439
|
+
Radio_default as Radio,
|
|
2400
2440
|
RadioGroup,
|
|
2401
2441
|
SSRProvider,
|
|
2402
2442
|
SegmentedControl_default as SegmentedControl,
|
|
2403
|
-
|
|
2443
|
+
Switch_default as Switch,
|
|
2404
2444
|
TagItem_default as TagItem,
|
|
2445
|
+
TextArea_default as TextArea,
|
|
2405
2446
|
TextField_default as TextField,
|
|
2406
2447
|
useComponentAbstraction
|
|
2407
2448
|
};
|