@charcoal-ui/react 2.9.0 → 2.10.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/components/Button/index.test.d.ts +4 -0
- package/dist/components/Button/index.test.d.ts.map +1 -0
- 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/LoadingSpinner/index.d.ts +8 -6
- package/dist/components/LoadingSpinner/index.d.ts.map +1 -1
- package/dist/components/LoadingSpinner/index.story.d.ts +2 -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 +13 -2
- package/dist/components/Modal/index.story.d.ts.map +1 -1
- package/dist/components/MultiSelect/index.d.ts +15 -1
- package/dist/components/MultiSelect/index.d.ts.map +1 -1
- package/dist/components/MultiSelect/index.story.d.ts +15 -2
- package/dist/components/MultiSelect/index.story.d.ts.map +1 -1
- package/dist/components/Radio/index.d.ts +10 -1
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/Radio/index.story.d.ts +9 -2
- 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 +2 -2
- package/dist/components/Switch/index.story.d.ts.map +1 -1
- package/dist/index.cjs.js +167 -141
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +185 -154
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
- package/src/components/Button/__snapshots__/index.test.tsx.snap +385 -0
- package/src/components/Button/index.test.tsx +25 -0
- package/src/components/Checkbox/index.story.tsx +1 -0
- package/src/components/Checkbox/index.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 +11 -3
- package/src/components/MultiSelect/index.tsx +77 -61
- package/src/components/Radio/index.story.tsx +3 -0
- package/src/components/Radio/index.tsx +11 -9
- package/src/components/SegmentedControl/index.tsx +15 -5
- package/src/components/Switch/index.tsx +37 -32
- package/src/components/TextField/index.story.tsx +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -314,16 +314,11 @@ function validateIconSize(size, icon) {
|
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
// src/components/Radio/index.tsx
|
|
317
|
-
import React6, { useCallback, useContext as useContext2 } from "react";
|
|
317
|
+
import React6, { forwardRef, memo, useCallback, useContext as useContext2 } from "react";
|
|
318
318
|
import styled5 from "styled-components";
|
|
319
319
|
import warning from "warning";
|
|
320
320
|
import { px } from "@charcoal-ui/utils";
|
|
321
|
-
|
|
322
|
-
value,
|
|
323
|
-
forceChecked = false,
|
|
324
|
-
disabled = false,
|
|
325
|
-
children
|
|
326
|
-
}) {
|
|
321
|
+
var Radio = forwardRef(function RadioInner({ value, forceChecked = false, disabled = false, children, className }, ref) {
|
|
327
322
|
const {
|
|
328
323
|
name,
|
|
329
324
|
selected,
|
|
@@ -345,7 +340,7 @@ function Radio({
|
|
|
345
340
|
},
|
|
346
341
|
[onChange]
|
|
347
342
|
);
|
|
348
|
-
return /* @__PURE__ */ React6.createElement(RadioRoot, { "aria-disabled": isDisabled || isReadonly }, /* @__PURE__ */ React6.createElement(
|
|
343
|
+
return /* @__PURE__ */ React6.createElement(RadioRoot, { "aria-disabled": isDisabled || isReadonly, className }, /* @__PURE__ */ React6.createElement(
|
|
349
344
|
RadioInput,
|
|
350
345
|
{
|
|
351
346
|
name,
|
|
@@ -353,10 +348,12 @@ function Radio({
|
|
|
353
348
|
checked: forceChecked || isSelected,
|
|
354
349
|
hasError,
|
|
355
350
|
onChange: handleChange,
|
|
356
|
-
disabled: isDisabled || isReadonly
|
|
351
|
+
disabled: isDisabled || isReadonly,
|
|
352
|
+
ref
|
|
357
353
|
}
|
|
358
354
|
), children != null && /* @__PURE__ */ React6.createElement(RadioLabel, null, children));
|
|
359
|
-
}
|
|
355
|
+
});
|
|
356
|
+
var Radio_default = memo(Radio);
|
|
360
357
|
var RadioRoot = styled5.label`
|
|
361
358
|
display: grid;
|
|
362
359
|
grid-template-columns: auto 1fr;
|
|
@@ -477,7 +474,12 @@ function RadioGroup({
|
|
|
477
474
|
}
|
|
478
475
|
|
|
479
476
|
// src/components/MultiSelect/index.tsx
|
|
480
|
-
import React7, {
|
|
477
|
+
import React7, {
|
|
478
|
+
forwardRef as forwardRef2,
|
|
479
|
+
memo as memo2,
|
|
480
|
+
useCallback as useCallback2,
|
|
481
|
+
useContext as useContext3
|
|
482
|
+
} from "react";
|
|
481
483
|
import styled6, { css as css2 } from "styled-components";
|
|
482
484
|
import warning2 from "warning";
|
|
483
485
|
import { disabledSelector as disabledSelector2, px as px2 } from "@charcoal-ui/utils";
|
|
@@ -498,63 +500,68 @@ var MultiSelectGroupContext = createContext({
|
|
|
498
500
|
});
|
|
499
501
|
|
|
500
502
|
// src/components/MultiSelect/index.tsx
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
503
|
+
var MultiSelect = forwardRef2(
|
|
504
|
+
function MultiSelectInner({
|
|
505
|
+
value,
|
|
506
|
+
forceChecked = false,
|
|
507
|
+
disabled = false,
|
|
508
|
+
onChange,
|
|
509
|
+
variant = "default",
|
|
510
|
+
className,
|
|
511
|
+
children
|
|
512
|
+
}, ref) {
|
|
513
|
+
const {
|
|
514
|
+
name,
|
|
515
|
+
selected,
|
|
516
|
+
disabled: parentDisabled,
|
|
517
|
+
readonly,
|
|
518
|
+
hasError,
|
|
519
|
+
onChange: parentOnChange
|
|
520
|
+
} = useContext3(MultiSelectGroupContext);
|
|
521
|
+
warning2(
|
|
522
|
+
name !== void 0,
|
|
523
|
+
`"name" is not Provided for <MultiSelect>. Perhaps you forgot to wrap with <MultiSelectGroup> ?`
|
|
524
|
+
);
|
|
525
|
+
const isSelected = selected.includes(value) || forceChecked;
|
|
526
|
+
const isDisabled = disabled || parentDisabled || readonly;
|
|
527
|
+
const handleChange = useCallback2(
|
|
528
|
+
(event) => {
|
|
529
|
+
if (!(event.currentTarget instanceof HTMLInputElement)) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
if (onChange)
|
|
533
|
+
onChange({ value, selected: event.currentTarget.checked });
|
|
534
|
+
parentOnChange({ value, selected: event.currentTarget.checked });
|
|
535
|
+
},
|
|
536
|
+
[onChange, parentOnChange, value]
|
|
537
|
+
);
|
|
538
|
+
return /* @__PURE__ */ React7.createElement(MultiSelectRoot, { "aria-disabled": isDisabled, className }, /* @__PURE__ */ React7.createElement(
|
|
539
|
+
MultiSelectInput,
|
|
540
|
+
{
|
|
541
|
+
...{
|
|
542
|
+
name,
|
|
543
|
+
value,
|
|
544
|
+
hasError
|
|
545
|
+
},
|
|
546
|
+
checked: isSelected,
|
|
547
|
+
disabled: isDisabled,
|
|
548
|
+
onChange: handleChange,
|
|
549
|
+
overlay: variant === "overlay",
|
|
550
|
+
"aria-invalid": hasError,
|
|
551
|
+
ref
|
|
527
552
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
return /* @__PURE__ */ React7.createElement(MultiSelectRoot, { "aria-disabled": isDisabled }, /* @__PURE__ */ React7.createElement(
|
|
535
|
-
MultiSelectInput,
|
|
536
|
-
{
|
|
537
|
-
...{
|
|
538
|
-
name,
|
|
539
|
-
value,
|
|
540
|
-
hasError
|
|
553
|
+
), /* @__PURE__ */ React7.createElement(
|
|
554
|
+
MultiSelectInputOverlay,
|
|
555
|
+
{
|
|
556
|
+
overlay: variant === "overlay",
|
|
557
|
+
hasError,
|
|
558
|
+
"aria-hidden": true
|
|
541
559
|
},
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
}
|
|
548
|
-
), /* @__PURE__ */ React7.createElement(
|
|
549
|
-
MultiSelectInputOverlay,
|
|
550
|
-
{
|
|
551
|
-
overlay: variant === "overlay",
|
|
552
|
-
hasError,
|
|
553
|
-
"aria-hidden": true
|
|
554
|
-
},
|
|
555
|
-
/* @__PURE__ */ React7.createElement("pixiv-icon", { name: "24/Check", "unsafe-non-guideline-scale": 16 / 24 })
|
|
556
|
-
), Boolean(children) && /* @__PURE__ */ React7.createElement(MultiSelectLabel, null, children));
|
|
557
|
-
}
|
|
560
|
+
/* @__PURE__ */ React7.createElement("pixiv-icon", { name: "24/Check", "unsafe-non-guideline-scale": 16 / 24 })
|
|
561
|
+
), Boolean(children) && /* @__PURE__ */ React7.createElement(MultiSelectLabel, null, children));
|
|
562
|
+
}
|
|
563
|
+
);
|
|
564
|
+
var MultiSelect_default = memo2(MultiSelect);
|
|
558
565
|
var MultiSelectRoot = styled6.label`
|
|
559
566
|
display: grid;
|
|
560
567
|
grid-template-columns: auto 1fr;
|
|
@@ -667,28 +674,32 @@ function MultiSelectGroup({
|
|
|
667
674
|
|
|
668
675
|
// src/components/Switch/index.tsx
|
|
669
676
|
import { useSwitch } from "@react-aria/switch";
|
|
670
|
-
import React8, {
|
|
677
|
+
import React8, { useMemo, memo as memo3, forwardRef as forwardRef3 } from "react";
|
|
671
678
|
import { useToggleState } from "react-stately";
|
|
672
679
|
import styled7 from "styled-components";
|
|
673
680
|
import { disabledSelector as disabledSelector3 } from "@charcoal-ui/utils";
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
}
|
|
681
|
+
import { useObjectRef } from "@react-aria/utils";
|
|
682
|
+
var SwitchCheckbox = forwardRef3(
|
|
683
|
+
function SwitchCheckboxInner(props, external) {
|
|
684
|
+
const { disabled, className } = props;
|
|
685
|
+
const ariaSwitchProps = useMemo(
|
|
686
|
+
() => ({
|
|
687
|
+
...props,
|
|
688
|
+
"aria-label": "children" in props ? void 0 : props.label,
|
|
689
|
+
isDisabled: props.disabled,
|
|
690
|
+
isSelected: props.checked
|
|
691
|
+
}),
|
|
692
|
+
[props]
|
|
693
|
+
);
|
|
694
|
+
const state = useToggleState(ariaSwitchProps);
|
|
695
|
+
const ref = useObjectRef(external);
|
|
696
|
+
const {
|
|
697
|
+
inputProps: { className: _className, type: _type, ...rest }
|
|
698
|
+
} = useSwitch(ariaSwitchProps, state, ref);
|
|
699
|
+
return /* @__PURE__ */ React8.createElement(Label, { className, "aria-disabled": disabled }, /* @__PURE__ */ React8.createElement(SwitchInput, { ...rest, ref }), "children" in props ? /* @__PURE__ */ React8.createElement(LabelInner, null, props.children) : void 0);
|
|
700
|
+
}
|
|
701
|
+
);
|
|
702
|
+
var Switch_default = memo3(SwitchCheckbox);
|
|
692
703
|
var Label = styled7.label`
|
|
693
704
|
display: inline-grid;
|
|
694
705
|
grid-template-columns: auto 1fr;
|
|
@@ -783,7 +794,7 @@ import { useVisuallyHidden } from "@react-aria/visually-hidden";
|
|
|
783
794
|
import React10, {
|
|
784
795
|
useCallback as useCallback3,
|
|
785
796
|
useEffect,
|
|
786
|
-
useRef
|
|
797
|
+
useRef,
|
|
787
798
|
useState
|
|
788
799
|
} from "react";
|
|
789
800
|
import styled9, { css as css3 } from "styled-components";
|
|
@@ -857,7 +868,7 @@ var TextField = React10.forwardRef(
|
|
|
857
868
|
}
|
|
858
869
|
);
|
|
859
870
|
var TextField_default = TextField;
|
|
860
|
-
var SingleLineTextField = React10.forwardRef(function SingleLineTextFieldInner({ onChange, ...props },
|
|
871
|
+
var SingleLineTextField = React10.forwardRef(function SingleLineTextFieldInner({ onChange, ...props }, forwardRef9) {
|
|
861
872
|
const {
|
|
862
873
|
className,
|
|
863
874
|
showLabel = false,
|
|
@@ -874,9 +885,9 @@ var SingleLineTextField = React10.forwardRef(function SingleLineTextFieldInner({
|
|
|
874
885
|
suffix = null
|
|
875
886
|
} = props;
|
|
876
887
|
const { visuallyHiddenProps } = useVisuallyHidden();
|
|
877
|
-
const ariaRef =
|
|
878
|
-
const prefixRef =
|
|
879
|
-
const suffixRef =
|
|
888
|
+
const ariaRef = useRef(null);
|
|
889
|
+
const prefixRef = useRef(null);
|
|
890
|
+
const suffixRef = useRef(null);
|
|
880
891
|
const [count, setCount] = useState(countCodePointsInString(props.value ?? ""));
|
|
881
892
|
const [prefixWidth, setPrefixWidth] = useState(0);
|
|
882
893
|
const [suffixWidth, setSuffixWidth] = useState(0);
|
|
@@ -941,7 +952,7 @@ var SingleLineTextField = React10.forwardRef(function SingleLineTextFieldInner({
|
|
|
941
952
|
), /* @__PURE__ */ React10.createElement(StyledInputContainer, null, /* @__PURE__ */ React10.createElement(PrefixContainer, { ref: prefixRef }, /* @__PURE__ */ React10.createElement(Affix, null, prefix)), /* @__PURE__ */ React10.createElement(
|
|
942
953
|
StyledInput,
|
|
943
954
|
{
|
|
944
|
-
ref: mergeRefs(
|
|
955
|
+
ref: mergeRefs(forwardRef9, ariaRef),
|
|
945
956
|
invalid,
|
|
946
957
|
extraLeftPadding: prefixWidth,
|
|
947
958
|
extraRightPadding: suffixWidth,
|
|
@@ -956,7 +967,7 @@ var SingleLineTextField = React10.forwardRef(function SingleLineTextFieldInner({
|
|
|
956
967
|
assistiveText
|
|
957
968
|
));
|
|
958
969
|
});
|
|
959
|
-
var MultiLineTextField = React10.forwardRef(function MultiLineTextFieldInner({ onChange, ...props },
|
|
970
|
+
var MultiLineTextField = React10.forwardRef(function MultiLineTextFieldInner({ onChange, ...props }, forwardRef9) {
|
|
960
971
|
const {
|
|
961
972
|
className,
|
|
962
973
|
showCount = false,
|
|
@@ -973,8 +984,8 @@ var MultiLineTextField = React10.forwardRef(function MultiLineTextFieldInner({ o
|
|
|
973
984
|
rows: initialRows = 4
|
|
974
985
|
} = props;
|
|
975
986
|
const { visuallyHiddenProps } = useVisuallyHidden();
|
|
976
|
-
const textareaRef =
|
|
977
|
-
const ariaRef =
|
|
987
|
+
const textareaRef = useRef(null);
|
|
988
|
+
const ariaRef = useRef(null);
|
|
978
989
|
const [count, setCount] = useState(countCodePointsInString(props.value ?? ""));
|
|
979
990
|
const [rows, setRows] = useState(initialRows);
|
|
980
991
|
const syncHeight = useCallback3(
|
|
@@ -1042,7 +1053,7 @@ var MultiLineTextField = React10.forwardRef(function MultiLineTextFieldInner({ o
|
|
|
1042
1053
|
/* @__PURE__ */ React10.createElement(
|
|
1043
1054
|
StyledTextarea,
|
|
1044
1055
|
{
|
|
1045
|
-
ref: mergeRefs(textareaRef,
|
|
1056
|
+
ref: mergeRefs(textareaRef, forwardRef9, ariaRef),
|
|
1046
1057
|
rows,
|
|
1047
1058
|
noBottomPadding: showCount,
|
|
1048
1059
|
...inputProps
|
|
@@ -1225,7 +1236,7 @@ var Icon = React11.forwardRef(function IconInner({ name, scale, unsafeNonGuideli
|
|
|
1225
1236
|
var Icon_default = Icon;
|
|
1226
1237
|
|
|
1227
1238
|
// src/components/Modal/index.tsx
|
|
1228
|
-
import React12, {
|
|
1239
|
+
import React12, { forwardRef as forwardRef4, memo as memo4, useContext as useContext4 } from "react";
|
|
1229
1240
|
import {
|
|
1230
1241
|
Overlay,
|
|
1231
1242
|
useModalOverlay,
|
|
@@ -1246,22 +1257,19 @@ function columnSystem(span, column, gutter) {
|
|
|
1246
1257
|
import { maxWidth } from "@charcoal-ui/utils";
|
|
1247
1258
|
import { useMedia } from "@charcoal-ui/styled";
|
|
1248
1259
|
import { animated, useTransition, easings } from "react-spring";
|
|
1260
|
+
import { useObjectRef as useObjectRef2 } from "@react-aria/utils";
|
|
1249
1261
|
var DEFAULT_Z_INDEX = 10;
|
|
1250
|
-
|
|
1251
|
-
children,
|
|
1252
|
-
zIndex = DEFAULT_Z_INDEX,
|
|
1253
|
-
portalContainer,
|
|
1254
|
-
...props
|
|
1255
|
-
}) {
|
|
1262
|
+
var Modal = forwardRef4(function ModalInner({ children, zIndex = DEFAULT_Z_INDEX, portalContainer, ...props }, external) {
|
|
1256
1263
|
const {
|
|
1257
1264
|
title,
|
|
1258
1265
|
size = "M",
|
|
1259
1266
|
bottomSheet = false,
|
|
1260
1267
|
isDismissable,
|
|
1261
1268
|
onClose,
|
|
1269
|
+
className,
|
|
1262
1270
|
isOpen = false
|
|
1263
1271
|
} = props;
|
|
1264
|
-
const ref =
|
|
1272
|
+
const ref = useObjectRef2(external);
|
|
1265
1273
|
const { overlayProps, underlayProps } = useOverlay(props, ref);
|
|
1266
1274
|
const { modalProps } = useModalOverlay(
|
|
1267
1275
|
props,
|
|
@@ -1314,7 +1322,8 @@ function Modal({
|
|
|
1314
1322
|
...dialogProps,
|
|
1315
1323
|
style: transitionEnabled ? { transform } : {},
|
|
1316
1324
|
size,
|
|
1317
|
-
bottomSheet
|
|
1325
|
+
bottomSheet,
|
|
1326
|
+
className
|
|
1318
1327
|
},
|
|
1319
1328
|
/* @__PURE__ */ React12.createElement(
|
|
1320
1329
|
ModalContext.Provider,
|
|
@@ -1334,7 +1343,8 @@ function Modal({
|
|
|
1334
1343
|
)))
|
|
1335
1344
|
))
|
|
1336
1345
|
);
|
|
1337
|
-
}
|
|
1346
|
+
});
|
|
1347
|
+
var Modal_default = memo4(Modal);
|
|
1338
1348
|
var ModalContext = React12.createContext({
|
|
1339
1349
|
titleProps: {},
|
|
1340
1350
|
title: "",
|
|
@@ -1448,15 +1458,24 @@ var ModalButtons = styled11.div`
|
|
|
1448
1458
|
`;
|
|
1449
1459
|
|
|
1450
1460
|
// src/components/LoadingSpinner/index.tsx
|
|
1451
|
-
import React14, { useImperativeHandle, useRef as
|
|
1461
|
+
import React14, { forwardRef as forwardRef5, memo as memo5, useImperativeHandle, useRef as useRef2 } from "react";
|
|
1452
1462
|
import styled12, { keyframes } from "styled-components";
|
|
1453
|
-
|
|
1454
|
-
size = 48,
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1463
|
+
var LoadingSpinner = forwardRef5(
|
|
1464
|
+
function LoadingSpinnerInner({ size = 48, padding = 16, transparent = false, className }, ref) {
|
|
1465
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1466
|
+
LoadingSpinnerRoot,
|
|
1467
|
+
{
|
|
1468
|
+
size,
|
|
1469
|
+
padding,
|
|
1470
|
+
transparent,
|
|
1471
|
+
className,
|
|
1472
|
+
ref
|
|
1473
|
+
},
|
|
1474
|
+
/* @__PURE__ */ React14.createElement(LoadingSpinnerIcon, null)
|
|
1475
|
+
);
|
|
1476
|
+
}
|
|
1477
|
+
);
|
|
1478
|
+
var LoadingSpinner_default = memo5(LoadingSpinner);
|
|
1460
1479
|
var LoadingSpinnerRoot = styled12.div.attrs({ role: "progressbar" })`
|
|
1461
1480
|
box-sizing: content-box;
|
|
1462
1481
|
margin: auto;
|
|
@@ -1495,7 +1514,7 @@ var Icon2 = styled12.div.attrs({ role: "presentation" })`
|
|
|
1495
1514
|
}
|
|
1496
1515
|
`;
|
|
1497
1516
|
var LoadingSpinnerIcon = React14.forwardRef(function LoadingSpinnerIcon2({ once = false }, ref) {
|
|
1498
|
-
const iconRef =
|
|
1517
|
+
const iconRef = useRef2(null);
|
|
1499
1518
|
useImperativeHandle(ref, () => ({
|
|
1500
1519
|
restart: () => {
|
|
1501
1520
|
if (!iconRef.current) {
|
|
@@ -1510,7 +1529,7 @@ var LoadingSpinnerIcon = React14.forwardRef(function LoadingSpinnerIcon2({ once
|
|
|
1510
1529
|
});
|
|
1511
1530
|
|
|
1512
1531
|
// src/components/DropdownSelector/index.tsx
|
|
1513
|
-
import React19, { useMemo as useMemo3, useRef as
|
|
1532
|
+
import React19, { useMemo as useMemo3, useRef as useRef6 } from "react";
|
|
1514
1533
|
import styled18 from "styled-components";
|
|
1515
1534
|
import { Item, useSelectState } from "react-stately";
|
|
1516
1535
|
import { disabledSelector as disabledSelector4 } from "@charcoal-ui/utils";
|
|
@@ -1519,7 +1538,7 @@ import { useSelect, HiddenSelect } from "@react-aria/select";
|
|
|
1519
1538
|
import { useButton } from "@react-aria/button";
|
|
1520
1539
|
|
|
1521
1540
|
// src/components/DropdownSelector/Listbox.tsx
|
|
1522
|
-
import React17, { memo, useRef as
|
|
1541
|
+
import React17, { memo as memo6, useRef as useRef4, Fragment, useMemo as useMemo2 } from "react";
|
|
1523
1542
|
import styled16 from "styled-components";
|
|
1524
1543
|
import { useListBox } from "@react-aria/listbox";
|
|
1525
1544
|
|
|
@@ -1530,14 +1549,14 @@ import React16 from "react";
|
|
|
1530
1549
|
import styled15 from "styled-components";
|
|
1531
1550
|
|
|
1532
1551
|
// src/components/DropdownSelector/Option.tsx
|
|
1533
|
-
import React15, { useRef as
|
|
1552
|
+
import React15, { useRef as useRef3 } from "react";
|
|
1534
1553
|
import styled13, { css as css5 } from "styled-components";
|
|
1535
1554
|
import { useOption } from "@react-aria/listbox";
|
|
1536
1555
|
import { mergeProps } from "@react-aria/utils";
|
|
1537
1556
|
import { useFocusRing } from "@react-aria/focus";
|
|
1538
1557
|
import { px as px3 } from "@charcoal-ui/utils";
|
|
1539
1558
|
function Option({ item, state, mode }) {
|
|
1540
|
-
const ref =
|
|
1559
|
+
const ref = useRef3(null);
|
|
1541
1560
|
const { optionProps, isSelected } = useOption(item, state, ref);
|
|
1542
1561
|
const { focusProps } = useFocusRing();
|
|
1543
1562
|
return /* @__PURE__ */ React15.createElement(OptionRoot, { ...mergeProps(optionProps, focusProps), ref, mode }, /* @__PURE__ */ React15.createElement(OptionCheckIcon, { name: "16/Check", isSelected }), /* @__PURE__ */ React15.createElement(OptionText, null, item.rendered));
|
|
@@ -1620,7 +1639,7 @@ var Listbox = ({
|
|
|
1620
1639
|
mode = "default",
|
|
1621
1640
|
...props
|
|
1622
1641
|
}) => {
|
|
1623
|
-
const ref =
|
|
1642
|
+
const ref = useRef4(null);
|
|
1624
1643
|
const { listBoxProps } = useListBox(props, state, ref);
|
|
1625
1644
|
const collection = useMemo2(
|
|
1626
1645
|
() => [...state.collection].map((node, index, self) => ({
|
|
@@ -1632,7 +1651,7 @@ var Listbox = ({
|
|
|
1632
1651
|
);
|
|
1633
1652
|
return /* @__PURE__ */ React17.createElement(ListboxRoot, { ref, ...listBoxProps }, collection.map(({ node, last }) => /* @__PURE__ */ React17.createElement(Fragment, { key: node.key }, node.type === "section" ? /* @__PURE__ */ React17.createElement(ListBoxSection, { section: node, state }) : /* @__PURE__ */ React17.createElement(Option, { item: node, state, mode }), !last && mode === "separator" && /* @__PURE__ */ React17.createElement(Divider, null))));
|
|
1634
1653
|
};
|
|
1635
|
-
var Listbox_default =
|
|
1654
|
+
var Listbox_default = memo6(Listbox);
|
|
1636
1655
|
var ListboxRoot = styled16.ul`
|
|
1637
1656
|
padding-left: 0;
|
|
1638
1657
|
margin: 0;
|
|
@@ -1651,7 +1670,7 @@ var ListboxRoot = styled16.ul`
|
|
|
1651
1670
|
`;
|
|
1652
1671
|
|
|
1653
1672
|
// src/components/DropdownSelector/DropdownPopover.tsx
|
|
1654
|
-
import React18, { useEffect as useEffect2, useRef as
|
|
1673
|
+
import React18, { useEffect as useEffect2, useRef as useRef5 } from "react";
|
|
1655
1674
|
import {
|
|
1656
1675
|
DismissButton,
|
|
1657
1676
|
Overlay as Overlay2,
|
|
@@ -1663,7 +1682,7 @@ var DropdownPopoverDiv = styled17.div`
|
|
|
1663
1682
|
${theme((o) => o.margin.top(4).bottom(4))}
|
|
1664
1683
|
`;
|
|
1665
1684
|
function DropdownPopover({ children, state, ...props }) {
|
|
1666
|
-
const ref =
|
|
1685
|
+
const ref = useRef5(null);
|
|
1667
1686
|
const { popoverProps, underlayProps } = usePopover(
|
|
1668
1687
|
{
|
|
1669
1688
|
...props,
|
|
@@ -1712,7 +1731,7 @@ var DropdownSelector = ({
|
|
|
1712
1731
|
...props
|
|
1713
1732
|
}) => {
|
|
1714
1733
|
const { visuallyHiddenProps } = useVisuallyHidden2();
|
|
1715
|
-
const triggerRef =
|
|
1734
|
+
const triggerRef = useRef6(null);
|
|
1716
1735
|
const selectProps = useMemo3(
|
|
1717
1736
|
() => ({
|
|
1718
1737
|
...props,
|
|
@@ -1836,7 +1855,7 @@ var AssertiveText = styled18.div`
|
|
|
1836
1855
|
`;
|
|
1837
1856
|
|
|
1838
1857
|
// src/components/SegmentedControl/index.tsx
|
|
1839
|
-
import React21, { forwardRef, memo as
|
|
1858
|
+
import React21, { forwardRef as forwardRef6, memo as memo7, useMemo as useMemo4, useRef as useRef7 } from "react";
|
|
1840
1859
|
import { useRadioGroupState } from "react-stately";
|
|
1841
1860
|
import {
|
|
1842
1861
|
useRadio,
|
|
@@ -1862,7 +1881,7 @@ var useRadioContext = () => {
|
|
|
1862
1881
|
};
|
|
1863
1882
|
|
|
1864
1883
|
// src/components/SegmentedControl/index.tsx
|
|
1865
|
-
var SegmentedControl =
|
|
1884
|
+
var SegmentedControl = forwardRef6(
|
|
1866
1885
|
function SegmentedControlInner(props, ref) {
|
|
1867
1886
|
const ariaRadioGroupProps = useMemo4(
|
|
1868
1887
|
() => ({
|
|
@@ -1881,23 +1900,35 @@ var SegmentedControl = forwardRef(
|
|
|
1881
1900
|
(d) => typeof d === "string" ? { value: d, label: d } : d
|
|
1882
1901
|
);
|
|
1883
1902
|
}, [props.data]);
|
|
1884
|
-
return /* @__PURE__ */ React21.createElement(
|
|
1885
|
-
|
|
1903
|
+
return /* @__PURE__ */ React21.createElement(
|
|
1904
|
+
SegmentedControlRoot,
|
|
1886
1905
|
{
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1906
|
+
ref,
|
|
1907
|
+
...radioGroupProps,
|
|
1908
|
+
className: props.className
|
|
1890
1909
|
},
|
|
1891
|
-
item.
|
|
1892
|
-
|
|
1910
|
+
/* @__PURE__ */ React21.createElement(RadioProvider, { value: state }, segmentedControlItems.map((item) => /* @__PURE__ */ React21.createElement(
|
|
1911
|
+
Segmented,
|
|
1912
|
+
{
|
|
1913
|
+
key: item.value,
|
|
1914
|
+
value: item.value,
|
|
1915
|
+
disabled: item.disabled
|
|
1916
|
+
},
|
|
1917
|
+
item.label
|
|
1918
|
+
)))
|
|
1919
|
+
);
|
|
1893
1920
|
}
|
|
1894
1921
|
);
|
|
1895
|
-
var SegmentedControl_default =
|
|
1896
|
-
var Segmented = (
|
|
1922
|
+
var SegmentedControl_default = memo7(SegmentedControl);
|
|
1923
|
+
var Segmented = (props) => {
|
|
1897
1924
|
const state = useRadioContext();
|
|
1898
|
-
const ref =
|
|
1925
|
+
const ref = useRef7(null);
|
|
1899
1926
|
const ariaRadioProps = useMemo4(
|
|
1900
|
-
() => ({
|
|
1927
|
+
() => ({
|
|
1928
|
+
value: props.value,
|
|
1929
|
+
isDisabled: props.disabled,
|
|
1930
|
+
children: props.children
|
|
1931
|
+
}),
|
|
1901
1932
|
[props]
|
|
1902
1933
|
);
|
|
1903
1934
|
const { inputProps, isDisabled, isSelected } = useRadio(
|
|
@@ -1912,7 +1943,7 @@ var Segmented = ({ children, ...props }) => {
|
|
|
1912
1943
|
checked: isSelected
|
|
1913
1944
|
},
|
|
1914
1945
|
/* @__PURE__ */ React21.createElement(SegmentedInput, { ...inputProps, ref }),
|
|
1915
|
-
/* @__PURE__ */ React21.createElement(RadioLabel2, null, /* @__PURE__ */ React21.createElement(SegmentedLabelInner, null, children))
|
|
1946
|
+
/* @__PURE__ */ React21.createElement(RadioLabel2, null, /* @__PURE__ */ React21.createElement(SegmentedLabelInner, null, props.children))
|
|
1916
1947
|
);
|
|
1917
1948
|
};
|
|
1918
1949
|
var SegmentedControlRoot = styled19.div`
|
|
@@ -1965,13 +1996,13 @@ var SegmentedLabelInner = styled19.div`
|
|
|
1965
1996
|
`;
|
|
1966
1997
|
|
|
1967
1998
|
// src/components/Checkbox/index.tsx
|
|
1968
|
-
import React22, { forwardRef as
|
|
1999
|
+
import React22, { forwardRef as forwardRef7, memo as memo8, useMemo as useMemo5 } from "react";
|
|
1969
2000
|
import styled20, { css as css6 } from "styled-components";
|
|
1970
2001
|
import { useCheckbox } from "@react-aria/checkbox";
|
|
1971
|
-
import { useObjectRef } from "@react-aria/utils";
|
|
2002
|
+
import { useObjectRef as useObjectRef3 } from "@react-aria/utils";
|
|
1972
2003
|
import { useToggleState as useToggleState2 } from "react-stately";
|
|
1973
2004
|
import { disabledSelector as disabledSelector6, px as px4 } from "@charcoal-ui/utils";
|
|
1974
|
-
var Checkbox =
|
|
2005
|
+
var Checkbox = forwardRef7(
|
|
1975
2006
|
function CheckboxInner(props, ref) {
|
|
1976
2007
|
const ariaCheckboxProps = useMemo5(
|
|
1977
2008
|
() => ({
|
|
@@ -1984,13 +2015,13 @@ var Checkbox = forwardRef2(
|
|
|
1984
2015
|
[props]
|
|
1985
2016
|
);
|
|
1986
2017
|
const state = useToggleState2(ariaCheckboxProps);
|
|
1987
|
-
const objectRef =
|
|
2018
|
+
const objectRef = useObjectRef3(ref);
|
|
1988
2019
|
const { inputProps } = useCheckbox(ariaCheckboxProps, state, objectRef);
|
|
1989
2020
|
const isDisabled = (props.disabled ?? false) || (props.readonly ?? false);
|
|
1990
|
-
return /* @__PURE__ */ React22.createElement(InputRoot, { "aria-disabled": isDisabled }, /* @__PURE__ */ React22.createElement(CheckboxRoot, null, /* @__PURE__ */ React22.createElement(CheckboxInput, { type: "checkbox", ...inputProps }), /* @__PURE__ */ React22.createElement(CheckboxInputOverlay, { "aria-hidden": true, checked: inputProps.checked }, /* @__PURE__ */ React22.createElement(Icon_default, { name: "24/Check", unsafeNonGuidelineScale: 2 / 3 }))), "children" in props && /* @__PURE__ */ React22.createElement(InputLabel, null, props.children));
|
|
2021
|
+
return /* @__PURE__ */ React22.createElement(InputRoot, { "aria-disabled": isDisabled, className: props.className }, /* @__PURE__ */ React22.createElement(CheckboxRoot, null, /* @__PURE__ */ React22.createElement(CheckboxInput, { type: "checkbox", ...inputProps }), /* @__PURE__ */ React22.createElement(CheckboxInputOverlay, { "aria-hidden": true, checked: inputProps.checked }, /* @__PURE__ */ React22.createElement(Icon_default, { name: "24/Check", unsafeNonGuidelineScale: 2 / 3 }))), "children" in props && /* @__PURE__ */ React22.createElement(InputLabel, null, props.children));
|
|
1991
2022
|
}
|
|
1992
2023
|
);
|
|
1993
|
-
var Checkbox_default =
|
|
2024
|
+
var Checkbox_default = memo8(Checkbox);
|
|
1994
2025
|
var hiddenCss = css6`
|
|
1995
2026
|
visibility: hidden;
|
|
1996
2027
|
`;
|
|
@@ -2055,11 +2086,11 @@ var InputLabel = styled20.div`
|
|
|
2055
2086
|
|
|
2056
2087
|
// src/components/TagItem/index.tsx
|
|
2057
2088
|
import React23, {
|
|
2058
|
-
forwardRef as
|
|
2059
|
-
memo as
|
|
2089
|
+
forwardRef as forwardRef8,
|
|
2090
|
+
memo as memo9,
|
|
2060
2091
|
useMemo as useMemo6
|
|
2061
2092
|
} from "react";
|
|
2062
|
-
import { useObjectRef as
|
|
2093
|
+
import { useObjectRef as useObjectRef4 } from "@react-aria/utils";
|
|
2063
2094
|
import styled21, { css as css7 } from "styled-components";
|
|
2064
2095
|
import { disabledSelector as disabledSelector7, px as px5 } from "@charcoal-ui/utils";
|
|
2065
2096
|
import { useButton as useButton2 } from "@react-aria/button";
|
|
@@ -2067,7 +2098,7 @@ var sizeMap = {
|
|
|
2067
2098
|
S: 32,
|
|
2068
2099
|
M: 40
|
|
2069
2100
|
};
|
|
2070
|
-
var TagItem =
|
|
2101
|
+
var TagItem = forwardRef8(
|
|
2071
2102
|
function TagItemInner({
|
|
2072
2103
|
label,
|
|
2073
2104
|
translatedLabel,
|
|
@@ -2079,7 +2110,7 @@ var TagItem = forwardRef3(
|
|
|
2079
2110
|
className,
|
|
2080
2111
|
...props
|
|
2081
2112
|
}, _ref) {
|
|
2082
|
-
const ref =
|
|
2113
|
+
const ref = useObjectRef4(_ref);
|
|
2083
2114
|
const ariaButtonProps = useMemo6(
|
|
2084
2115
|
() => ({
|
|
2085
2116
|
elementType: "a",
|
|
@@ -2104,7 +2135,7 @@ var TagItem = forwardRef3(
|
|
|
2104
2135
|
);
|
|
2105
2136
|
}
|
|
2106
2137
|
);
|
|
2107
|
-
var TagItem_default =
|
|
2138
|
+
var TagItem_default = memo9(TagItem);
|
|
2108
2139
|
var TagItemRoot = styled21.a`
|
|
2109
2140
|
isolation: isolate;
|
|
2110
2141
|
position: relative;
|
|
@@ -2197,21 +2228,21 @@ export {
|
|
|
2197
2228
|
DropdownSelectorItem,
|
|
2198
2229
|
Icon_default as Icon,
|
|
2199
2230
|
IconButton_default as IconButton,
|
|
2200
|
-
LoadingSpinner,
|
|
2231
|
+
LoadingSpinner_default as LoadingSpinner,
|
|
2201
2232
|
LoadingSpinnerIcon,
|
|
2202
|
-
Modal,
|
|
2233
|
+
Modal_default as Modal,
|
|
2203
2234
|
ModalAlign,
|
|
2204
2235
|
ModalBody,
|
|
2205
2236
|
ModalButtons,
|
|
2206
2237
|
ModalHeader,
|
|
2207
|
-
MultiSelect,
|
|
2238
|
+
MultiSelect_default as MultiSelect,
|
|
2208
2239
|
MultiSelectGroup,
|
|
2209
2240
|
OverlayProvider,
|
|
2210
|
-
Radio,
|
|
2241
|
+
Radio_default as Radio,
|
|
2211
2242
|
RadioGroup,
|
|
2212
2243
|
SSRProvider,
|
|
2213
2244
|
SegmentedControl_default as SegmentedControl,
|
|
2214
|
-
|
|
2245
|
+
Switch_default as Switch,
|
|
2215
2246
|
TagItem_default as TagItem,
|
|
2216
2247
|
TextField_default as TextField,
|
|
2217
2248
|
useComponentAbstraction
|