@bigtablet/design-system 2.0.2 → 2.0.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/index.css +29 -12
- package/dist/index.d.ts +3 -2
- package/dist/index.js +94 -63
- package/package.json +2 -2
package/dist/index.css
CHANGED
|
@@ -513,6 +513,34 @@
|
|
|
513
513
|
border: 1px solid #E5E5E5;
|
|
514
514
|
overflow: hidden;
|
|
515
515
|
transition: border-color 0.2s ease-in-out;
|
|
516
|
+
position: relative;
|
|
517
|
+
}
|
|
518
|
+
.chip::before {
|
|
519
|
+
content: "";
|
|
520
|
+
position: absolute;
|
|
521
|
+
top: 0;
|
|
522
|
+
right: 0;
|
|
523
|
+
bottom: 0;
|
|
524
|
+
left: 0;
|
|
525
|
+
border-radius: inherit;
|
|
526
|
+
transition: background 0.2s ease-in-out;
|
|
527
|
+
pointer-events: none;
|
|
528
|
+
}
|
|
529
|
+
.chip:hover::before {
|
|
530
|
+
background: rgba(0, 0, 0, 0.05);
|
|
531
|
+
}
|
|
532
|
+
.chip:active::before {
|
|
533
|
+
background: rgba(26, 26, 26, 0.12);
|
|
534
|
+
}
|
|
535
|
+
.chip.chip_icon_hovered:hover::before,
|
|
536
|
+
.chip.chip_icon_hovered:active::before {
|
|
537
|
+
background: transparent;
|
|
538
|
+
}
|
|
539
|
+
.chip .chip_icon:hover {
|
|
540
|
+
background: rgba(0, 0, 0, 0.05);
|
|
541
|
+
}
|
|
542
|
+
.chip .chip_icon:active {
|
|
543
|
+
background: rgba(26, 26, 26, 0.12);
|
|
516
544
|
}
|
|
517
545
|
.chip_content {
|
|
518
546
|
flex: 1;
|
|
@@ -542,15 +570,9 @@
|
|
|
542
570
|
transition: background 0.2s ease-in-out;
|
|
543
571
|
pointer-events: none;
|
|
544
572
|
}
|
|
545
|
-
.chip_content:hover:not(:disabled)::before {
|
|
546
|
-
background: rgba(0, 0, 0, 0.05);
|
|
547
|
-
}
|
|
548
573
|
.chip_content:focus-visible:not(:disabled)::before {
|
|
549
574
|
background: rgba(0, 0, 0, 0.08);
|
|
550
575
|
}
|
|
551
|
-
.chip_content:active:not(:disabled)::before {
|
|
552
|
-
background: rgba(26, 26, 26, 0.12);
|
|
553
|
-
}
|
|
554
576
|
.chip_content:disabled {
|
|
555
577
|
cursor: not-allowed;
|
|
556
578
|
}
|
|
@@ -573,9 +595,6 @@
|
|
|
573
595
|
.chip_trailing:focus-visible:not(:disabled) .chip_icon {
|
|
574
596
|
background: rgba(0, 0, 0, 0.08);
|
|
575
597
|
}
|
|
576
|
-
.chip_trailing:active:not(:disabled) .chip_icon {
|
|
577
|
-
background: rgba(26, 26, 26, 0.12);
|
|
578
|
-
}
|
|
579
598
|
.chip_trailing:disabled {
|
|
580
599
|
cursor: not-allowed;
|
|
581
600
|
}
|
|
@@ -588,14 +607,12 @@
|
|
|
588
607
|
flex-shrink: 0;
|
|
589
608
|
border-radius: 9999px;
|
|
590
609
|
transition: background 0.2s ease-in-out;
|
|
610
|
+
position: relative;
|
|
591
611
|
}
|
|
592
612
|
.chip_icon svg {
|
|
593
613
|
width: 100%;
|
|
594
614
|
height: 100%;
|
|
595
615
|
}
|
|
596
|
-
.chip_trailing:hover:not(:disabled) .chip_icon {
|
|
597
|
-
background: rgba(0, 0, 0, 0.05);
|
|
598
|
-
}
|
|
599
616
|
.chip_label {
|
|
600
617
|
white-space: nowrap;
|
|
601
618
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React$1 from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
2
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
4
|
|
|
4
5
|
declare const a11y: {
|
|
@@ -537,7 +538,7 @@ declare const Checkbox: {
|
|
|
537
538
|
};
|
|
538
539
|
|
|
539
540
|
type ChipType = "basic" | "input" | "filter";
|
|
540
|
-
interface ChipProps extends Omit<
|
|
541
|
+
interface ChipProps extends Omit<React__default.HTMLAttributes<HTMLDivElement>, "onClick"> {
|
|
541
542
|
/** 칩 유형 (기본값: "basic") */
|
|
542
543
|
type?: ChipType;
|
|
543
544
|
/** 라벨 텍스트 */
|
|
@@ -551,7 +552,7 @@ interface ChipProps extends Omit<React$1.HTMLAttributes<HTMLDivElement>, "onClic
|
|
|
551
552
|
/** 팝업 열림 상태 (filter 타입에서 aria-expanded로 사용) */
|
|
552
553
|
open?: boolean;
|
|
553
554
|
/** 칩 클릭 시 콜백 */
|
|
554
|
-
onClick?: (event:
|
|
555
|
+
onClick?: (event: React__default.MouseEvent<HTMLButtonElement>) => void;
|
|
555
556
|
/** 삭제 버튼 클릭 시 콜백 */
|
|
556
557
|
onRemove?: () => void;
|
|
557
558
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import './index.css';
|
|
3
|
-
import * as
|
|
3
|
+
import * as React5 from 'react';
|
|
4
4
|
import { createContext, useContext, useState, useCallback } from 'react';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
6
6
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
@@ -483,8 +483,8 @@ var FOCUSABLE_SELECTORS = [
|
|
|
483
483
|
'[tabindex]:not([tabindex="-1"])'
|
|
484
484
|
].join(", ");
|
|
485
485
|
function useFocusTrap(containerRef, isActive) {
|
|
486
|
-
const previousActiveElement =
|
|
487
|
-
|
|
486
|
+
const previousActiveElement = React5.useRef(null);
|
|
487
|
+
React5.useEffect(() => {
|
|
488
488
|
if (!isActive) return;
|
|
489
489
|
const container = containerRef.current;
|
|
490
490
|
if (!container) return;
|
|
@@ -589,9 +589,9 @@ var AlertModal = ({
|
|
|
589
589
|
onCancel,
|
|
590
590
|
onClose
|
|
591
591
|
}) => {
|
|
592
|
-
const panelRef =
|
|
593
|
-
const titleId =
|
|
594
|
-
const messageId =
|
|
592
|
+
const panelRef = React5.useRef(null);
|
|
593
|
+
const titleId = React5.useId();
|
|
594
|
+
const messageId = React5.useId();
|
|
595
595
|
useFocusTrap(panelRef, true);
|
|
596
596
|
const modalClassName = cn("alert_modal", `alert_variant_${variant}`);
|
|
597
597
|
const actionsClassName = cn("alert_actions", `alert_actions_${actionsAlign}`);
|
|
@@ -683,12 +683,12 @@ var Checkbox = ({
|
|
|
683
683
|
ref,
|
|
684
684
|
...props
|
|
685
685
|
}) => {
|
|
686
|
-
const inputRef =
|
|
687
|
-
|
|
686
|
+
const inputRef = React5.useRef(null);
|
|
687
|
+
React5.useImperativeHandle(
|
|
688
688
|
ref,
|
|
689
689
|
() => inputRef.current
|
|
690
690
|
);
|
|
691
|
-
|
|
691
|
+
React5.useEffect(() => {
|
|
692
692
|
if (!inputRef.current) return;
|
|
693
693
|
inputRef.current.indeterminate = Boolean(indeterminate);
|
|
694
694
|
}, [indeterminate]);
|
|
@@ -731,9 +731,12 @@ var Chip = ({
|
|
|
731
731
|
className,
|
|
732
732
|
...props
|
|
733
733
|
}) => {
|
|
734
|
+
const [iconHovered, setIconHovered] = useState(false);
|
|
734
735
|
const hasLeading = selected;
|
|
735
736
|
const hasTrailingButton = type === "input" && removable;
|
|
736
737
|
const hasTrailingIcon = hasTrailingButton || type === "filter";
|
|
738
|
+
const enterIcon = () => setIconHovered(true);
|
|
739
|
+
const leaveIcon = () => setIconHovered(false);
|
|
737
740
|
const chipClassName = cn(
|
|
738
741
|
"chip",
|
|
739
742
|
`chip_type_${type}`,
|
|
@@ -741,6 +744,7 @@ var Chip = ({
|
|
|
741
744
|
hasLeading && "chip_has_leading",
|
|
742
745
|
hasTrailingIcon && "chip_has_trailing",
|
|
743
746
|
disabled && "chip_disabled",
|
|
747
|
+
iconHovered && "chip_icon_hovered",
|
|
744
748
|
className
|
|
745
749
|
);
|
|
746
750
|
return /* @__PURE__ */ jsxs("div", { className: chipClassName, ...props, children: [
|
|
@@ -753,9 +757,27 @@ var Chip = ({
|
|
|
753
757
|
onClick,
|
|
754
758
|
...type === "filter" ? { "aria-haspopup": "listbox", "aria-expanded": !!open } : {},
|
|
755
759
|
children: [
|
|
756
|
-
hasLeading && /* @__PURE__ */ jsx(
|
|
760
|
+
hasLeading && /* @__PURE__ */ jsx(
|
|
761
|
+
"span",
|
|
762
|
+
{
|
|
763
|
+
className: "chip_icon",
|
|
764
|
+
"aria-hidden": "true",
|
|
765
|
+
onPointerEnter: enterIcon,
|
|
766
|
+
onPointerLeave: leaveIcon,
|
|
767
|
+
children: /* @__PURE__ */ jsx(CheckIcon, {})
|
|
768
|
+
}
|
|
769
|
+
),
|
|
757
770
|
/* @__PURE__ */ jsx("span", { className: "chip_label", children: label }),
|
|
758
|
-
type === "filter" && /* @__PURE__ */ jsx(
|
|
771
|
+
type === "filter" && /* @__PURE__ */ jsx(
|
|
772
|
+
"span",
|
|
773
|
+
{
|
|
774
|
+
className: "chip_icon",
|
|
775
|
+
"aria-hidden": "true",
|
|
776
|
+
onPointerEnter: enterIcon,
|
|
777
|
+
onPointerLeave: leaveIcon,
|
|
778
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, {})
|
|
779
|
+
}
|
|
780
|
+
)
|
|
759
781
|
]
|
|
760
782
|
}
|
|
761
783
|
),
|
|
@@ -767,7 +789,16 @@ var Chip = ({
|
|
|
767
789
|
disabled,
|
|
768
790
|
onClick: onRemove,
|
|
769
791
|
"aria-label": "Remove",
|
|
770
|
-
children: /* @__PURE__ */ jsx(
|
|
792
|
+
children: /* @__PURE__ */ jsx(
|
|
793
|
+
"span",
|
|
794
|
+
{
|
|
795
|
+
className: "chip_icon",
|
|
796
|
+
"aria-hidden": "true",
|
|
797
|
+
onPointerEnter: enterIcon,
|
|
798
|
+
onPointerLeave: leaveIcon,
|
|
799
|
+
children: /* @__PURE__ */ jsx(CloseIcon, {})
|
|
800
|
+
}
|
|
801
|
+
)
|
|
771
802
|
}
|
|
772
803
|
)
|
|
773
804
|
] });
|
|
@@ -794,9 +825,9 @@ var DatePicker = ({
|
|
|
794
825
|
minDateSrFormat = "Minimum date: {date}",
|
|
795
826
|
selectableRangeUntilTodaySrText = "Selectable up to today"
|
|
796
827
|
}) => {
|
|
797
|
-
const groupId =
|
|
798
|
-
const constraintId =
|
|
799
|
-
const { todayYear, todayMonth, todayDay } =
|
|
828
|
+
const groupId = React5.useId();
|
|
829
|
+
const constraintId = React5.useId();
|
|
830
|
+
const { todayYear, todayMonth, todayDay } = React5.useMemo(() => {
|
|
800
831
|
const now = /* @__PURE__ */ new Date();
|
|
801
832
|
return {
|
|
802
833
|
todayYear: now.getFullYear(),
|
|
@@ -805,7 +836,7 @@ var DatePicker = ({
|
|
|
805
836
|
};
|
|
806
837
|
}, []);
|
|
807
838
|
const endYear = endYearProp ?? todayYear + 10;
|
|
808
|
-
const parsed =
|
|
839
|
+
const parsed = React5.useMemo(() => {
|
|
809
840
|
if (!value) return { year: 0, month: 0, day: 0 };
|
|
810
841
|
const [y, m, d] = value.split("-").map(Number);
|
|
811
842
|
return {
|
|
@@ -814,7 +845,7 @@ var DatePicker = ({
|
|
|
814
845
|
day: d || 0
|
|
815
846
|
};
|
|
816
847
|
}, [value]);
|
|
817
|
-
const min =
|
|
848
|
+
const min = React5.useMemo(() => {
|
|
818
849
|
if (!minDate) return { year: 0, month: 0, day: 0 };
|
|
819
850
|
const [y, m, d] = minDate.split("-").map(Number);
|
|
820
851
|
return {
|
|
@@ -828,7 +859,7 @@ var DatePicker = ({
|
|
|
828
859
|
const minMonth = min.year > 0 && year === min.year ? min.month : 1;
|
|
829
860
|
const maxMonth = selectableRange === "until-today" && year === todayYear ? todayMonth : 12;
|
|
830
861
|
const minDay = min.year > 0 && min.month > 0 && year === min.year && month === min.month ? min.day : 1;
|
|
831
|
-
const maxDay =
|
|
862
|
+
const maxDay = React5.useMemo(() => {
|
|
832
863
|
if (!year || !month) return 31;
|
|
833
864
|
const daysInMonth = getDaysInMonth(year, month);
|
|
834
865
|
if (selectableRange === "until-today" && year === todayYear && month === todayMonth) {
|
|
@@ -836,19 +867,19 @@ var DatePicker = ({
|
|
|
836
867
|
}
|
|
837
868
|
return daysInMonth;
|
|
838
869
|
}, [year, month, selectableRange, todayYear, todayMonth, todayDay]);
|
|
839
|
-
const yearOptions =
|
|
870
|
+
const yearOptions = React5.useMemo(
|
|
840
871
|
() => range(startYear, maxYear),
|
|
841
872
|
[startYear, maxYear]
|
|
842
873
|
);
|
|
843
|
-
const monthOptions =
|
|
874
|
+
const monthOptions = React5.useMemo(
|
|
844
875
|
() => range(minMonth, Math.max(minMonth, maxMonth)),
|
|
845
876
|
[minMonth, maxMonth]
|
|
846
877
|
);
|
|
847
|
-
const dayOptions =
|
|
878
|
+
const dayOptions = React5.useMemo(
|
|
848
879
|
() => range(minDay, Math.max(minDay, maxDay)),
|
|
849
880
|
[minDay, maxDay]
|
|
850
881
|
);
|
|
851
|
-
const emit =
|
|
882
|
+
const emit = React5.useCallback(
|
|
852
883
|
(yy, mm, dd) => {
|
|
853
884
|
if (mode === "year-month") {
|
|
854
885
|
onChange(`${yy}-${pad(mm)}`);
|
|
@@ -859,7 +890,7 @@ var DatePicker = ({
|
|
|
859
890
|
},
|
|
860
891
|
[mode, onChange]
|
|
861
892
|
);
|
|
862
|
-
const handleYearChange =
|
|
893
|
+
const handleYearChange = React5.useCallback(
|
|
863
894
|
(newYear) => {
|
|
864
895
|
let newMonth = month;
|
|
865
896
|
const newMinMonth = min.year > 0 && newYear === min.year ? min.month : 1;
|
|
@@ -874,14 +905,14 @@ var DatePicker = ({
|
|
|
874
905
|
},
|
|
875
906
|
[month, day, min.year, min.month, selectableRange, todayYear, todayMonth, emit]
|
|
876
907
|
);
|
|
877
|
-
const handleMonthChange =
|
|
908
|
+
const handleMonthChange = React5.useCallback(
|
|
878
909
|
(newMonth) => {
|
|
879
910
|
if (!year) return;
|
|
880
911
|
emit(year, newMonth, day || void 0);
|
|
881
912
|
},
|
|
882
913
|
[year, day, emit]
|
|
883
914
|
);
|
|
884
|
-
const handleDayChange =
|
|
915
|
+
const handleDayChange = React5.useCallback(
|
|
885
916
|
(newDay) => {
|
|
886
917
|
if (!year || !month) return;
|
|
887
918
|
emit(year, month, newDay);
|
|
@@ -986,9 +1017,9 @@ var FileInput = ({
|
|
|
986
1017
|
disabled,
|
|
987
1018
|
...props
|
|
988
1019
|
}) => {
|
|
989
|
-
const inputId =
|
|
990
|
-
const helperId =
|
|
991
|
-
const [previewUrls, setPreviewUrls] =
|
|
1020
|
+
const inputId = React5.useId();
|
|
1021
|
+
const helperId = React5.useId();
|
|
1022
|
+
const [previewUrls, setPreviewUrls] = React5.useState([]);
|
|
992
1023
|
const handleChange = (e) => {
|
|
993
1024
|
const files = e.currentTarget.files;
|
|
994
1025
|
onFiles?.(files);
|
|
@@ -1006,7 +1037,7 @@ var FileInput = ({
|
|
|
1006
1037
|
setPreviewUrls([]);
|
|
1007
1038
|
}
|
|
1008
1039
|
};
|
|
1009
|
-
|
|
1040
|
+
React5.useEffect(() => {
|
|
1010
1041
|
return () => {
|
|
1011
1042
|
previewUrls.forEach((url) => URL.revokeObjectURL(url));
|
|
1012
1043
|
};
|
|
@@ -1736,18 +1767,18 @@ var Modal = ({
|
|
|
1736
1767
|
ariaLabel,
|
|
1737
1768
|
...props
|
|
1738
1769
|
}) => {
|
|
1739
|
-
const panelRef =
|
|
1740
|
-
const titleId =
|
|
1770
|
+
const panelRef = React5.useRef(null);
|
|
1771
|
+
const titleId = React5.useId();
|
|
1741
1772
|
useFocusTrap(panelRef, open);
|
|
1742
|
-
const handleEscape =
|
|
1773
|
+
const handleEscape = React5.useEffectEvent((e) => {
|
|
1743
1774
|
if (e.key === "Escape") onClose?.();
|
|
1744
1775
|
});
|
|
1745
|
-
|
|
1776
|
+
React5.useEffect(() => {
|
|
1746
1777
|
if (!open) return;
|
|
1747
1778
|
document.addEventListener("keydown", handleEscape);
|
|
1748
1779
|
return () => document.removeEventListener("keydown", handleEscape);
|
|
1749
1780
|
}, [open]);
|
|
1750
|
-
|
|
1781
|
+
React5.useEffect(() => {
|
|
1751
1782
|
if (!open) return;
|
|
1752
1783
|
const body = document.body;
|
|
1753
1784
|
const openModals = parseInt(body.dataset.openModals || "0", 10);
|
|
@@ -1842,7 +1873,7 @@ var Pagination = ({
|
|
|
1842
1873
|
}) => {
|
|
1843
1874
|
const prevDisabled = page <= 1;
|
|
1844
1875
|
const nextDisabled = page >= totalPages;
|
|
1845
|
-
const items =
|
|
1876
|
+
const items = React5.useMemo(() => getPaginationItems(page, totalPages), [page, totalPages]);
|
|
1846
1877
|
return /* @__PURE__ */ jsxs("nav", { className: "pagination", "aria-label": "Pagination", children: [
|
|
1847
1878
|
/* @__PURE__ */ jsx(
|
|
1848
1879
|
"button",
|
|
@@ -1909,21 +1940,21 @@ var Select = ({
|
|
|
1909
1940
|
className,
|
|
1910
1941
|
textAlign = "left"
|
|
1911
1942
|
}) => {
|
|
1912
|
-
const internalId =
|
|
1943
|
+
const internalId = React5.useId();
|
|
1913
1944
|
const selectId = id ?? internalId;
|
|
1914
1945
|
const isControlled = value !== void 0;
|
|
1915
|
-
const [internalValue, setInternalValue] =
|
|
1946
|
+
const [internalValue, setInternalValue] = React5.useState(defaultValue);
|
|
1916
1947
|
const currentValue = isControlled ? value ?? null : internalValue;
|
|
1917
|
-
const [isOpen, setIsOpen] =
|
|
1918
|
-
const [activeIndex, setActiveIndex] =
|
|
1919
|
-
const [dropUp, setDropUp] =
|
|
1920
|
-
const wrapperRef =
|
|
1921
|
-
const controlRef =
|
|
1922
|
-
const currentOption =
|
|
1948
|
+
const [isOpen, setIsOpen] = React5.useState(false);
|
|
1949
|
+
const [activeIndex, setActiveIndex] = React5.useState(-1);
|
|
1950
|
+
const [dropUp, setDropUp] = React5.useState(false);
|
|
1951
|
+
const wrapperRef = React5.useRef(null);
|
|
1952
|
+
const controlRef = React5.useRef(null);
|
|
1953
|
+
const currentOption = React5.useMemo(
|
|
1923
1954
|
() => options.find((o) => o.value === currentValue) ?? null,
|
|
1924
1955
|
[options, currentValue]
|
|
1925
1956
|
);
|
|
1926
|
-
const setValue =
|
|
1957
|
+
const setValue = React5.useCallback(
|
|
1927
1958
|
(next) => {
|
|
1928
1959
|
const option = options.find((o) => o.value === next) ?? null;
|
|
1929
1960
|
if (!isControlled) setInternalValue(next);
|
|
@@ -1931,12 +1962,12 @@ var Select = ({
|
|
|
1931
1962
|
},
|
|
1932
1963
|
[isControlled, onChange, options]
|
|
1933
1964
|
);
|
|
1934
|
-
const handleOutsideClick =
|
|
1965
|
+
const handleOutsideClick = React5.useEffectEvent((e) => {
|
|
1935
1966
|
if (!wrapperRef.current?.contains(e.target)) {
|
|
1936
1967
|
setIsOpen(false);
|
|
1937
1968
|
}
|
|
1938
1969
|
});
|
|
1939
|
-
|
|
1970
|
+
React5.useEffect(() => {
|
|
1940
1971
|
document.addEventListener("mousedown", handleOutsideClick);
|
|
1941
1972
|
return () => document.removeEventListener("mousedown", handleOutsideClick);
|
|
1942
1973
|
}, []);
|
|
@@ -2001,7 +2032,7 @@ var Select = ({
|
|
|
2001
2032
|
break;
|
|
2002
2033
|
}
|
|
2003
2034
|
};
|
|
2004
|
-
|
|
2035
|
+
React5.useEffect(() => {
|
|
2005
2036
|
if (!isOpen) return;
|
|
2006
2037
|
const idx = options.findIndex((o) => o.value === currentValue && !o.disabled);
|
|
2007
2038
|
setActiveIndex(
|
|
@@ -2011,7 +2042,7 @@ var Select = ({
|
|
|
2011
2042
|
)
|
|
2012
2043
|
);
|
|
2013
2044
|
}, [isOpen, options, currentValue]);
|
|
2014
|
-
|
|
2045
|
+
React5.useLayoutEffect(() => {
|
|
2015
2046
|
if (!isOpen || !controlRef.current) return;
|
|
2016
2047
|
const rect = controlRef.current.getBoundingClientRect();
|
|
2017
2048
|
const listHeight = Math.min(options.length * 40, 288);
|
|
@@ -2126,7 +2157,7 @@ var Switch = ({
|
|
|
2126
2157
|
...props
|
|
2127
2158
|
}) => {
|
|
2128
2159
|
const isControlled = checked !== void 0;
|
|
2129
|
-
const [innerChecked, setInnerChecked] =
|
|
2160
|
+
const [innerChecked, setInnerChecked] = React5.useState(!!defaultChecked);
|
|
2130
2161
|
const isOn = isControlled ? !!checked : innerChecked;
|
|
2131
2162
|
const handleToggle = () => {
|
|
2132
2163
|
if (disabled) return;
|
|
@@ -2176,21 +2207,21 @@ var TextField = ({
|
|
|
2176
2207
|
ref,
|
|
2177
2208
|
...props
|
|
2178
2209
|
}) => {
|
|
2179
|
-
const generatedId =
|
|
2210
|
+
const generatedId = React5.useId();
|
|
2180
2211
|
const inputId = id ?? generatedId;
|
|
2181
2212
|
const helperId = supportingText ? `${inputId}-help` : void 0;
|
|
2182
2213
|
const isControlled = value !== void 0;
|
|
2183
2214
|
const applyTransform = (nextValue) => transformValue ? transformValue(nextValue) : nextValue;
|
|
2184
|
-
const [innerValue, setInnerValue] =
|
|
2215
|
+
const [innerValue, setInnerValue] = React5.useState(
|
|
2185
2216
|
() => applyTransform(value ?? defaultValue ?? "")
|
|
2186
2217
|
);
|
|
2187
|
-
const isComposingRef =
|
|
2188
|
-
|
|
2218
|
+
const isComposingRef = React5.useRef(false);
|
|
2219
|
+
React5.useEffect(() => {
|
|
2189
2220
|
if (!isControlled) return;
|
|
2190
2221
|
const nextValue = value ?? "";
|
|
2191
2222
|
setInnerValue(transformValue ? transformValue(nextValue) : nextValue);
|
|
2192
2223
|
}, [isControlled, value, transformValue]);
|
|
2193
|
-
const handleClear =
|
|
2224
|
+
const handleClear = React5.useCallback(() => {
|
|
2194
2225
|
setInnerValue("");
|
|
2195
2226
|
onChangeAction?.("");
|
|
2196
2227
|
}, [onChangeAction]);
|
|
@@ -2254,7 +2285,7 @@ var TextField = ({
|
|
|
2254
2285
|
] });
|
|
2255
2286
|
};
|
|
2256
2287
|
TextField.displayName = "TextField";
|
|
2257
|
-
var ToastContext =
|
|
2288
|
+
var ToastContext = React5.createContext(null);
|
|
2258
2289
|
var VARIANT_ICONS = {
|
|
2259
2290
|
success: /* @__PURE__ */ jsx(CheckCircle2, { size: 18 }),
|
|
2260
2291
|
error: /* @__PURE__ */ jsx(XCircle, { size: 18 }),
|
|
@@ -2263,9 +2294,9 @@ var VARIANT_ICONS = {
|
|
|
2263
2294
|
default: /* @__PURE__ */ jsx(Bell, { size: 18 })
|
|
2264
2295
|
};
|
|
2265
2296
|
var ToastItemComponent = ({ item, onRemove, closeAriaLabel }) => {
|
|
2266
|
-
const [exiting, setExiting] =
|
|
2267
|
-
const closingRef =
|
|
2268
|
-
const close =
|
|
2297
|
+
const [exiting, setExiting] = React5.useState(false);
|
|
2298
|
+
const closingRef = React5.useRef(false);
|
|
2299
|
+
const close = React5.useCallback(() => {
|
|
2269
2300
|
if (closingRef.current) return;
|
|
2270
2301
|
closingRef.current = true;
|
|
2271
2302
|
setExiting(true);
|
|
@@ -2292,19 +2323,19 @@ var ToastProvider = ({
|
|
|
2292
2323
|
maxCount = 5,
|
|
2293
2324
|
closeAriaLabel = "Close"
|
|
2294
2325
|
}) => {
|
|
2295
|
-
const [toasts, setToasts] =
|
|
2296
|
-
const [isMounted, setIsMounted] =
|
|
2297
|
-
|
|
2326
|
+
const [toasts, setToasts] = React5.useState([]);
|
|
2327
|
+
const [isMounted, setIsMounted] = React5.useState(false);
|
|
2328
|
+
React5.useEffect(() => {
|
|
2298
2329
|
setIsMounted(true);
|
|
2299
2330
|
}, []);
|
|
2300
|
-
const addToast =
|
|
2331
|
+
const addToast = React5.useCallback(
|
|
2301
2332
|
(message, variant, duration = 3e3) => {
|
|
2302
2333
|
const id = crypto.randomUUID();
|
|
2303
2334
|
setToasts((prev) => [{ id, message, variant, duration }, ...prev].slice(0, maxCount));
|
|
2304
2335
|
},
|
|
2305
2336
|
[maxCount]
|
|
2306
2337
|
);
|
|
2307
|
-
const removeToast =
|
|
2338
|
+
const removeToast = React5.useCallback((id) => {
|
|
2308
2339
|
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
2309
2340
|
}, []);
|
|
2310
2341
|
return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: { addToast }, children: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigtablet/design-system",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "Bigtablet Design System UI Components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"husky": "^9.1.7",
|
|
107
107
|
"jsdom": "^29.0.1",
|
|
108
108
|
"lucide-react": "^1.7.0",
|
|
109
|
-
"next": "^16.2.
|
|
109
|
+
"next": "^16.2.3",
|
|
110
110
|
"playwright": "^1.57.0",
|
|
111
111
|
"react": "^19.2.4",
|
|
112
112
|
"react-dom": "^19.2.4",
|