@bigtablet/design-system 1.11.3 → 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 +9 -4
- package/dist/index.js +56 -61
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -129,16 +129,21 @@ declare const TextField: React.ForwardRefExoticComponent<TextFieldProps & React.
|
|
|
129
129
|
|
|
130
130
|
type DatePickerMode = "year-month" | "year-month-day";
|
|
131
131
|
interface DatePickerProps {
|
|
132
|
-
label?: string;
|
|
133
|
-
required?: boolean;
|
|
134
132
|
value?: string;
|
|
135
133
|
onChange: (value: string) => void;
|
|
136
134
|
mode?: DatePickerMode;
|
|
137
135
|
startYear?: number;
|
|
138
136
|
endYear?: number;
|
|
137
|
+
minDate?: string;
|
|
139
138
|
disabled?: boolean;
|
|
140
|
-
|
|
141
|
-
|
|
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;
|
|
142
147
|
|
|
143
148
|
interface PaginationProps {
|
|
144
149
|
page: number;
|
package/dist/index.js
CHANGED
|
@@ -590,83 +590,78 @@ var TextField = React3.forwardRef(
|
|
|
590
590
|
TextField.displayName = "TextField";
|
|
591
591
|
var pad = (n) => String(n).padStart(2, "0");
|
|
592
592
|
var getDaysInMonth = (year, month) => new Date(year, month, 0).getDate();
|
|
593
|
+
var normalizeWidth = (v) => typeof v === "number" ? `${v}px` : v;
|
|
593
594
|
var DatePicker = ({
|
|
594
|
-
label,
|
|
595
|
-
required,
|
|
596
595
|
value,
|
|
597
596
|
onChange,
|
|
598
597
|
mode = "year-month-day",
|
|
599
598
|
startYear = 1950,
|
|
600
599
|
endYear = (/* @__PURE__ */ new Date()).getFullYear() + 10,
|
|
601
|
-
|
|
600
|
+
minDate,
|
|
601
|
+
disabled,
|
|
602
|
+
width
|
|
602
603
|
}) => {
|
|
603
604
|
const [y, m, d] = value?.split("-").map(Number) ?? [];
|
|
605
|
+
const [minY, minM, minD] = minDate?.split("-").map(Number) ?? [];
|
|
604
606
|
const year = y ?? "";
|
|
605
607
|
const month = m ?? "";
|
|
606
608
|
const day = d ?? "";
|
|
609
|
+
const minMonth = minY && year === minY ? minM : 1;
|
|
610
|
+
const minDay = minY && minM && year === minY && month === minM ? minD : 1;
|
|
607
611
|
const days = year && month ? getDaysInMonth(year, month) : 31;
|
|
608
612
|
const emit = (yy, mm, dd) => {
|
|
609
|
-
const result = mode === "year-month" ? `${yy}-${pad(mm)}
|
|
613
|
+
const result = mode === "year-month" ? `${yy}-${pad(mm)}` : `${yy}-${pad(mm)}-${pad(dd ?? 1)}`;
|
|
610
614
|
onChange(result);
|
|
611
615
|
};
|
|
612
|
-
return /* @__PURE__ */ jsxs(
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
/* @__PURE__ */
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
/* @__PURE__ */ jsxs(
|
|
641
|
-
"select",
|
|
642
|
-
{
|
|
643
|
-
value: month,
|
|
644
|
-
disabled: disabled || !year,
|
|
645
|
-
onChange: (e) => emit(year, Number(e.target.value), day || 1),
|
|
646
|
-
children: [
|
|
647
|
-
/* @__PURE__ */ jsx("option", { value: "", disabled: true }),
|
|
648
|
-
Array.from({ length: 12 }, (_, i) => i + 1).map((m2) => /* @__PURE__ */ jsx("option", { value: m2, children: pad(m2) }, m2))
|
|
649
|
-
]
|
|
650
|
-
}
|
|
651
|
-
),
|
|
652
|
-
mode === "year-month-day" && /* @__PURE__ */ jsxs(
|
|
653
|
-
"select",
|
|
654
|
-
{
|
|
655
|
-
value: day,
|
|
656
|
-
disabled: disabled || !month,
|
|
657
|
-
onChange: (e) => emit(year, month, Number(e.target.value)),
|
|
658
|
-
children: [
|
|
659
|
-
/* @__PURE__ */ jsx("option", { value: "", disabled: true }),
|
|
660
|
-
Array.from({ length: days }, (_, i) => i + 1).map(
|
|
661
|
-
(d2) => /* @__PURE__ */ jsx("option", { value: d2, children: pad(d2) }, d2)
|
|
662
|
-
)
|
|
663
|
-
]
|
|
664
|
-
}
|
|
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)
|
|
665
644
|
)
|
|
666
|
-
]
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
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
|
+
] });
|
|
670
665
|
};
|
|
671
666
|
var range = (start, end) => {
|
|
672
667
|
const out = [];
|