@bigtablet/design-system 1.11.2 → 1.11.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.d.ts +10 -11
- package/dist/index.js +70 -69
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -120,31 +120,30 @@ interface TextFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement
|
|
|
120
120
|
leftIcon?: React.ReactNode;
|
|
121
121
|
rightIcon?: React.ReactNode;
|
|
122
122
|
fullWidth?: boolean;
|
|
123
|
-
/**
|
|
124
|
-
* 외부에 최종 값만 전달하는 콜백
|
|
125
|
-
* IME 조합 중 값은 내부에서만 관리된다.
|
|
126
|
-
*/
|
|
127
123
|
onChangeAction?: (value: string) => void;
|
|
128
|
-
/**
|
|
129
|
-
* controlled / uncontrolled 모두 지원
|
|
130
|
-
*/
|
|
131
124
|
value?: string;
|
|
132
125
|
defaultValue?: string;
|
|
126
|
+
transformValue?: (value: string) => string;
|
|
133
127
|
}
|
|
134
128
|
declare const TextField: React.ForwardRefExoticComponent<TextFieldProps & React.RefAttributes<HTMLInputElement>>;
|
|
135
129
|
|
|
136
130
|
type DatePickerMode = "year-month" | "year-month-day";
|
|
137
131
|
interface DatePickerProps {
|
|
138
|
-
label?: string;
|
|
139
|
-
required?: boolean;
|
|
140
132
|
value?: string;
|
|
141
133
|
onChange: (value: string) => void;
|
|
142
134
|
mode?: DatePickerMode;
|
|
143
135
|
startYear?: number;
|
|
144
136
|
endYear?: number;
|
|
137
|
+
minDate?: string;
|
|
145
138
|
disabled?: boolean;
|
|
146
|
-
|
|
147
|
-
|
|
139
|
+
width?: {
|
|
140
|
+
container?: number | string;
|
|
141
|
+
year?: number | string;
|
|
142
|
+
month?: number | string;
|
|
143
|
+
day?: number | string;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
declare const DatePicker: ({ value, onChange, mode, startYear, endYear, minDate, disabled, width, }: DatePickerProps) => react_jsx_runtime.JSX.Element;
|
|
148
147
|
|
|
149
148
|
interface PaginationProps {
|
|
150
149
|
page: number;
|
package/dist/index.js
CHANGED
|
@@ -511,20 +511,21 @@ var TextField = React3.forwardRef(
|
|
|
511
511
|
onChangeAction,
|
|
512
512
|
value,
|
|
513
513
|
defaultValue,
|
|
514
|
+
transformValue,
|
|
514
515
|
...props
|
|
515
516
|
}, ref) => {
|
|
516
517
|
const inputId = id ?? React3.useId();
|
|
517
518
|
const helperId = helperText ? `${inputId}-help` : void 0;
|
|
518
519
|
const isControlled = value !== void 0;
|
|
520
|
+
const applyTransform = (nextValue) => transformValue ? transformValue(nextValue) : nextValue;
|
|
519
521
|
const [innerValue, setInnerValue] = React3.useState(
|
|
520
|
-
value ?? defaultValue ?? ""
|
|
522
|
+
() => applyTransform(value ?? defaultValue ?? "")
|
|
521
523
|
);
|
|
522
524
|
const isComposingRef = React3.useRef(false);
|
|
523
525
|
React3.useEffect(() => {
|
|
524
|
-
if (isControlled)
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
}, [isControlled, value]);
|
|
526
|
+
if (!isControlled) return;
|
|
527
|
+
setInnerValue(applyTransform(value ?? ""));
|
|
528
|
+
}, [isControlled, value, transformValue]);
|
|
528
529
|
const rootClassName = [
|
|
529
530
|
"text_field",
|
|
530
531
|
fullWidth && "text_field_full_width",
|
|
@@ -563,14 +564,19 @@ var TextField = React3.forwardRef(
|
|
|
563
564
|
},
|
|
564
565
|
onCompositionEnd: (event) => {
|
|
565
566
|
isComposingRef.current = false;
|
|
566
|
-
const
|
|
567
|
+
const rawValue = event.currentTarget.value;
|
|
568
|
+
const nextValue = applyTransform(rawValue);
|
|
567
569
|
setInnerValue(nextValue);
|
|
568
570
|
onChangeAction?.(nextValue);
|
|
569
571
|
},
|
|
570
572
|
onChange: (event) => {
|
|
571
|
-
const
|
|
573
|
+
const rawValue = event.target.value;
|
|
574
|
+
if (isComposingRef.current) {
|
|
575
|
+
setInnerValue(rawValue);
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
const nextValue = applyTransform(rawValue);
|
|
572
579
|
setInnerValue(nextValue);
|
|
573
|
-
if (isComposingRef.current) return;
|
|
574
580
|
onChangeAction?.(nextValue);
|
|
575
581
|
}
|
|
576
582
|
}
|
|
@@ -584,83 +590,78 @@ var TextField = React3.forwardRef(
|
|
|
584
590
|
TextField.displayName = "TextField";
|
|
585
591
|
var pad = (n) => String(n).padStart(2, "0");
|
|
586
592
|
var getDaysInMonth = (year, month) => new Date(year, month, 0).getDate();
|
|
593
|
+
var normalizeWidth = (v) => typeof v === "number" ? `${v}px` : v;
|
|
587
594
|
var DatePicker = ({
|
|
588
|
-
label,
|
|
589
|
-
required,
|
|
590
595
|
value,
|
|
591
596
|
onChange,
|
|
592
597
|
mode = "year-month-day",
|
|
593
598
|
startYear = 1950,
|
|
594
599
|
endYear = (/* @__PURE__ */ new Date()).getFullYear() + 10,
|
|
595
|
-
|
|
600
|
+
minDate,
|
|
601
|
+
disabled,
|
|
602
|
+
width
|
|
596
603
|
}) => {
|
|
597
604
|
const [y, m, d] = value?.split("-").map(Number) ?? [];
|
|
605
|
+
const [minY, minM, minD] = minDate?.split("-").map(Number) ?? [];
|
|
598
606
|
const year = y ?? "";
|
|
599
607
|
const month = m ?? "";
|
|
600
608
|
const day = d ?? "";
|
|
609
|
+
const minMonth = minY && year === minY ? minM : 1;
|
|
610
|
+
const minDay = minY && minM && year === minY && month === minM ? minD : 1;
|
|
601
611
|
const days = year && month ? getDaysInMonth(year, month) : 31;
|
|
602
612
|
const emit = (yy, mm, dd) => {
|
|
603
|
-
const result = mode === "year-month" ? `${yy}-${pad(mm)}
|
|
613
|
+
const result = mode === "year-month" ? `${yy}-${pad(mm)}` : `${yy}-${pad(mm)}-${pad(dd ?? 1)}`;
|
|
604
614
|
onChange(result);
|
|
605
615
|
};
|
|
606
|
-
return /* @__PURE__ */ jsxs(
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
/* @__PURE__ */
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
/* @__PURE__ */ jsxs(
|
|
635
|
-
"select",
|
|
636
|
-
{
|
|
637
|
-
value: month,
|
|
638
|
-
disabled: disabled || !year,
|
|
639
|
-
onChange: (e) => emit(year, Number(e.target.value), day || 1),
|
|
640
|
-
children: [
|
|
641
|
-
/* @__PURE__ */ jsx("option", { value: "", disabled: true }),
|
|
642
|
-
Array.from({ length: 12 }, (_, i) => i + 1).map((m2) => /* @__PURE__ */ jsx("option", { value: m2, children: pad(m2) }, m2))
|
|
643
|
-
]
|
|
644
|
-
}
|
|
645
|
-
),
|
|
646
|
-
mode === "year-month-day" && /* @__PURE__ */ jsxs(
|
|
647
|
-
"select",
|
|
648
|
-
{
|
|
649
|
-
value: day,
|
|
650
|
-
disabled: disabled || !month,
|
|
651
|
-
onChange: (e) => emit(year, month, Number(e.target.value)),
|
|
652
|
-
children: [
|
|
653
|
-
/* @__PURE__ */ jsx("option", { value: "", disabled: true }),
|
|
654
|
-
Array.from({ length: days }, (_, i) => i + 1).map(
|
|
655
|
-
(d2) => /* @__PURE__ */ jsx("option", { value: d2, children: pad(d2) }, d2)
|
|
656
|
-
)
|
|
657
|
-
]
|
|
658
|
-
}
|
|
616
|
+
return /* @__PURE__ */ jsxs("div", { className: "date_picker", style: { width: normalizeWidth(width?.container) }, children: [
|
|
617
|
+
/* @__PURE__ */ jsxs(
|
|
618
|
+
"select",
|
|
619
|
+
{
|
|
620
|
+
style: { width: normalizeWidth(width?.year) },
|
|
621
|
+
value: year,
|
|
622
|
+
disabled,
|
|
623
|
+
onChange: (e) => emit(Number(e.target.value), month || minMonth, day || minDay),
|
|
624
|
+
children: [
|
|
625
|
+
/* @__PURE__ */ jsx("option", { value: "", disabled: true }),
|
|
626
|
+
Array.from(
|
|
627
|
+
{ length: endYear - startYear + 1 },
|
|
628
|
+
(_, i) => startYear + i
|
|
629
|
+
).map((y2) => /* @__PURE__ */ jsx("option", { value: y2, children: y2 }, y2))
|
|
630
|
+
]
|
|
631
|
+
}
|
|
632
|
+
),
|
|
633
|
+
/* @__PURE__ */ jsxs(
|
|
634
|
+
"select",
|
|
635
|
+
{
|
|
636
|
+
style: { width: normalizeWidth(width?.month) },
|
|
637
|
+
value: month,
|
|
638
|
+
disabled: disabled || !year,
|
|
639
|
+
onChange: (e) => emit(year, Number(e.target.value), day || minDay),
|
|
640
|
+
children: [
|
|
641
|
+
/* @__PURE__ */ jsx("option", { value: "", disabled: true }),
|
|
642
|
+
Array.from({ length: 12 - minMonth + 1 }, (_, i) => minMonth + i).map(
|
|
643
|
+
(m2) => /* @__PURE__ */ jsx("option", { value: m2, children: pad(m2) }, m2)
|
|
659
644
|
)
|
|
660
|
-
]
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
645
|
+
]
|
|
646
|
+
}
|
|
647
|
+
),
|
|
648
|
+
mode === "year-month-day" && /* @__PURE__ */ jsxs(
|
|
649
|
+
"select",
|
|
650
|
+
{
|
|
651
|
+
style: { width: normalizeWidth(width?.day) },
|
|
652
|
+
value: day,
|
|
653
|
+
disabled: disabled || !month,
|
|
654
|
+
onChange: (e) => emit(year, month, Number(e.target.value)),
|
|
655
|
+
children: [
|
|
656
|
+
/* @__PURE__ */ jsx("option", { value: "", disabled: true }),
|
|
657
|
+
Array.from(
|
|
658
|
+
{ length: days - minDay + 1 },
|
|
659
|
+
(_, i) => minDay + i
|
|
660
|
+
).map((d2) => /* @__PURE__ */ jsx("option", { value: d2, children: pad(d2) }, d2))
|
|
661
|
+
]
|
|
662
|
+
}
|
|
663
|
+
)
|
|
664
|
+
] });
|
|
664
665
|
};
|
|
665
666
|
var range = (start, end) => {
|
|
666
667
|
const out = [];
|