@bigtablet/design-system 1.11.3 → 1.11.5

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 CHANGED
@@ -873,10 +873,11 @@
873
873
  gap: 0.25rem;
874
874
  }
875
875
  .date_picker_label {
876
- font-family: "Pretendard", sans-serif;
876
+ color: #1a1a1a;
877
+ margin-bottom: 0.25rem;
878
+ font-weight: 500;
877
879
  font-size: 0.875rem;
878
880
  line-height: 1.5;
879
- color: #666666;
880
881
  }
881
882
  .date_picker_required {
882
883
  margin-left: 0.25rem;
package/dist/index.d.ts CHANGED
@@ -130,15 +130,21 @@ declare const TextField: React.ForwardRefExoticComponent<TextFieldProps & React.
130
130
  type DatePickerMode = "year-month" | "year-month-day";
131
131
  interface DatePickerProps {
132
132
  label?: string;
133
- required?: boolean;
134
133
  value?: string;
135
134
  onChange: (value: string) => void;
136
135
  mode?: DatePickerMode;
137
136
  startYear?: number;
138
137
  endYear?: number;
138
+ minDate?: string;
139
139
  disabled?: boolean;
140
- }
141
- declare const DatePicker: ({ label, required, value, onChange, mode, startYear, endYear, disabled, }: DatePickerProps) => react_jsx_runtime.JSX.Element;
140
+ width?: {
141
+ container?: number | string;
142
+ year?: number | string;
143
+ month?: number | string;
144
+ day?: number | string;
145
+ };
146
+ }
147
+ declare const DatePicker: ({ label, value, onChange, mode, startYear, endYear, minDate, disabled, width, }: DatePickerProps) => react_jsx_runtime.JSX.Element;
142
148
 
143
149
  interface PaginationProps {
144
150
  page: number;
package/dist/index.js CHANGED
@@ -590,83 +590,88 @@ 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
595
  label,
595
- required,
596
596
  value,
597
597
  onChange,
598
598
  mode = "year-month-day",
599
599
  startYear = 1950,
600
600
  endYear = (/* @__PURE__ */ new Date()).getFullYear() + 10,
601
- disabled
601
+ minDate,
602
+ disabled,
603
+ width
602
604
  }) => {
603
605
  const [y, m, d] = value?.split("-").map(Number) ?? [];
606
+ const [minY, minM, minD] = minDate?.split("-").map(Number) ?? [];
604
607
  const year = y ?? "";
605
608
  const month = m ?? "";
606
609
  const day = d ?? "";
610
+ const minMonth = minY && year === minY ? minM : 1;
611
+ const minDay = minY && minM && year === minY && month === minM ? minD : 1;
607
612
  const days = year && month ? getDaysInMonth(year, month) : 31;
613
+ const clampDay = (year2, month2, day2) => {
614
+ const maxDay = getDaysInMonth(year2, month2);
615
+ return Math.min(day2, maxDay);
616
+ };
608
617
  const emit = (yy, mm, dd) => {
609
- const result = mode === "year-month" ? `${yy}-${pad(mm)}-01` : `${yy}-${pad(mm)}-${pad(dd ?? 1)}`;
610
- onChange(result);
618
+ if (mode === "year-month") {
619
+ onChange(`${yy}-${pad(mm)}`);
620
+ return;
621
+ }
622
+ const safeDay = clampDay(yy, mm, dd ?? 1);
623
+ onChange(`${yy}-${pad(mm)}-${pad(safeDay)}`);
611
624
  };
612
- return /* @__PURE__ */ jsxs(
613
- "div",
614
- {
615
- className: [
616
- "date_picker",
617
- disabled && "date_picker_disabled"
618
- ].filter(Boolean).join(" "),
619
- children: [
620
- label && /* @__PURE__ */ jsxs("label", { className: "date_picker_label", children: [
621
- label,
622
- required && /* @__PURE__ */ jsx("span", { className: "date_picker_required", children: "*" })
623
- ] }),
624
- /* @__PURE__ */ jsxs("div", { className: "date_picker_fields", children: [
625
- /* @__PURE__ */ jsxs(
626
- "select",
627
- {
628
- value: year,
629
- disabled,
630
- onChange: (e) => emit(Number(e.target.value), month || 1, day || 1),
631
- children: [
632
- /* @__PURE__ */ jsx("option", { value: "", disabled: true }),
633
- Array.from(
634
- { length: endYear - startYear + 1 },
635
- (_, i) => startYear + i
636
- ).map((y2) => /* @__PURE__ */ jsx("option", { value: y2, children: y2 }, y2))
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
- }
625
+ return /* @__PURE__ */ jsxs("div", { className: "date_picker", style: { width: normalizeWidth(width?.container) }, children: [
626
+ label && /* @__PURE__ */ jsx("label", { className: "date_picker_label", children: label }),
627
+ /* @__PURE__ */ jsxs(
628
+ "select",
629
+ {
630
+ style: { width: normalizeWidth(width?.year) },
631
+ value: year,
632
+ disabled,
633
+ onChange: (e) => emit(Number(e.target.value), month || minMonth, day || minDay),
634
+ children: [
635
+ /* @__PURE__ */ jsx("option", { value: "", disabled: true }),
636
+ Array.from(
637
+ { length: endYear - startYear + 1 },
638
+ (_, i) => startYear + i
639
+ ).map((y2) => /* @__PURE__ */ jsx("option", { value: y2, children: y2 }, y2))
640
+ ]
641
+ }
642
+ ),
643
+ /* @__PURE__ */ jsxs(
644
+ "select",
645
+ {
646
+ style: { width: normalizeWidth(width?.month) },
647
+ value: month,
648
+ disabled: disabled || !year,
649
+ onChange: (e) => emit(year, Number(e.target.value), day || minDay),
650
+ children: [
651
+ /* @__PURE__ */ jsx("option", { value: "", disabled: true }),
652
+ Array.from({ length: 12 - minMonth + 1 }, (_, i) => minMonth + i).map(
653
+ (m2) => /* @__PURE__ */ jsx("option", { value: m2, children: pad(m2) }, m2)
665
654
  )
666
- ] })
667
- ]
668
- }
669
- );
655
+ ]
656
+ }
657
+ ),
658
+ mode === "year-month-day" && /* @__PURE__ */ jsxs(
659
+ "select",
660
+ {
661
+ style: { width: normalizeWidth(width?.day) },
662
+ value: day,
663
+ disabled: disabled || !month,
664
+ onChange: (e) => emit(year, month, Number(e.target.value)),
665
+ children: [
666
+ /* @__PURE__ */ jsx("option", { value: "", disabled: true }),
667
+ Array.from(
668
+ { length: days - minDay + 1 },
669
+ (_, i) => minDay + i
670
+ ).map((d2) => /* @__PURE__ */ jsx("option", { value: d2, children: pad(d2) }, d2))
671
+ ]
672
+ }
673
+ )
674
+ ] });
670
675
  };
671
676
  var range = (start, end) => {
672
677
  const out = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigtablet/design-system",
3
- "version": "1.11.3",
3
+ "version": "1.11.5",
4
4
  "description": "Bigtablet Design System UI Components",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",