@x-plat/design-system 0.3.9 → 0.4.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.
@@ -1658,6 +1658,7 @@ var Calendar = (props) => {
1658
1658
  locale = "ko",
1659
1659
  minDate,
1660
1660
  maxDate,
1661
+ selectedColor,
1661
1662
  showToday = true,
1662
1663
  className
1663
1664
  } = props;
@@ -1701,90 +1702,97 @@ var Calendar = (props) => {
1701
1702
  };
1702
1703
  const getEventsForDay = (date) => events.filter((e) => isSameDay(e.date, date));
1703
1704
  const weekdays = WEEKDAY_LABELS[locale];
1704
- return /* @__PURE__ */ (0, import_jsx_runtime301.jsxs)("div", { className: clsx_default("lib-xplat-calendar", className), children: [
1705
- /* @__PURE__ */ (0, import_jsx_runtime301.jsxs)("div", { className: "calendar-header", children: [
1706
- /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("button", { className: "calendar-nav", onClick: handlePrev, "aria-label": "\uC774\uC804 \uB2EC", children: /* @__PURE__ */ (0, import_jsx_runtime301.jsx)(ChevronLeftIcon_default, {}) }),
1707
- /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("span", { className: "calendar-title", children: locale === "ko" ? `${year}\uB144 ${MONTH_LABELS.ko[month]}` : `${MONTH_LABELS.en[month]} ${year}` }),
1708
- /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("button", { className: "calendar-nav", onClick: handleNext, "aria-label": "\uB2E4\uC74C \uB2EC", children: /* @__PURE__ */ (0, import_jsx_runtime301.jsx)(ChevronRightIcon_default, {}) }),
1709
- showToday && /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("button", { className: "calendar-today-btn", onClick: handleToday, children: locale === "ko" ? "\uC624\uB298" : "Today" })
1710
- ] }),
1711
- /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("div", { className: "calendar-weekdays", children: weekdays.map((label, i) => /* @__PURE__ */ (0, import_jsx_runtime301.jsx)(
1712
- "div",
1713
- {
1714
- className: clsx_default(
1715
- "calendar-weekday",
1716
- i === 0 && "sunday",
1717
- i === 6 && "saturday"
1718
- ),
1719
- children: label
1720
- },
1721
- label
1722
- )) }),
1723
- /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("div", { className: "calendar-grid", children: days.map((day, idx) => {
1724
- const dayEvents = getEventsForDay(day.date);
1725
- const disabled = isDisabled(day.date);
1726
- const isSelected = selectedDate ? isSameDay(day.date, selectedDate) : false;
1727
- if (renderDay) {
1728
- return /* @__PURE__ */ (0, import_jsx_runtime301.jsx)(
1705
+ return /* @__PURE__ */ (0, import_jsx_runtime301.jsxs)(
1706
+ "div",
1707
+ {
1708
+ className: clsx_default("lib-xplat-calendar", className),
1709
+ style: selectedColor ? { "--calendar-selected-color": `var(--${selectedColor})` } : void 0,
1710
+ children: [
1711
+ /* @__PURE__ */ (0, import_jsx_runtime301.jsxs)("div", { className: "calendar-header", children: [
1712
+ /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("button", { className: "calendar-nav", onClick: handlePrev, "aria-label": "\uC774\uC804 \uB2EC", children: /* @__PURE__ */ (0, import_jsx_runtime301.jsx)(ChevronLeftIcon_default, {}) }),
1713
+ /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("span", { className: "calendar-title", children: locale === "ko" ? `${year}\uB144 ${MONTH_LABELS.ko[month]}` : `${MONTH_LABELS.en[month]} ${year}` }),
1714
+ /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("button", { className: "calendar-nav", onClick: handleNext, "aria-label": "\uB2E4\uC74C \uB2EC", children: /* @__PURE__ */ (0, import_jsx_runtime301.jsx)(ChevronRightIcon_default, {}) }),
1715
+ showToday && /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("button", { className: "calendar-today-btn", onClick: handleToday, children: locale === "ko" ? "\uC624\uB298" : "Today" })
1716
+ ] }),
1717
+ /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("div", { className: "calendar-weekdays", children: weekdays.map((label, i) => /* @__PURE__ */ (0, import_jsx_runtime301.jsx)(
1729
1718
  "div",
1730
1719
  {
1731
1720
  className: clsx_default(
1732
- "calendar-day",
1733
- !day.isCurrentMonth && "outside",
1734
- disabled && "disabled",
1735
- isSelected && "selected",
1736
- day.isToday && "today"
1721
+ "calendar-weekday",
1722
+ i === 0 && "sunday",
1723
+ i === 6 && "saturday"
1737
1724
  ),
1738
- onClick: () => {
1739
- if (!disabled && day.isCurrentMonth) onSelect?.(day.date);
1740
- },
1741
- children: renderDay(day, dayEvents)
1742
- },
1743
- idx
1744
- );
1745
- }
1746
- return /* @__PURE__ */ (0, import_jsx_runtime301.jsxs)(
1747
- "div",
1748
- {
1749
- className: clsx_default(
1750
- "calendar-day",
1751
- !day.isCurrentMonth && "outside",
1752
- disabled && "disabled",
1753
- isSelected && "selected",
1754
- day.isToday && "today",
1755
- day.isSunday && "sunday",
1756
- day.isSaturday && "saturday"
1757
- ),
1758
- onClick: () => {
1759
- if (!disabled && day.isCurrentMonth) onSelect?.(day.date);
1725
+ children: label
1760
1726
  },
1761
- children: [
1762
- /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("span", { className: "calendar-day-number", children: day.day }),
1763
- dayEvents.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime301.jsxs)("div", { className: "calendar-day-events", children: [
1764
- dayEvents.slice(0, 3).map((event, ei) => /* @__PURE__ */ (0, import_jsx_runtime301.jsx)(
1765
- "span",
1766
- {
1767
- className: "calendar-event-dot",
1768
- style: { backgroundColor: event.color ?? "var(--xplat-blue-500)" },
1769
- title: event.label,
1770
- onClick: (e) => {
1771
- e.stopPropagation();
1772
- onEventClick?.(event);
1773
- }
1727
+ label
1728
+ )) }),
1729
+ /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("div", { className: "calendar-grid", children: days.map((day, idx) => {
1730
+ const dayEvents = getEventsForDay(day.date);
1731
+ const disabled = isDisabled(day.date);
1732
+ const isSelected = selectedDate ? isSameDay(day.date, selectedDate) : false;
1733
+ if (renderDay) {
1734
+ return /* @__PURE__ */ (0, import_jsx_runtime301.jsx)(
1735
+ "div",
1736
+ {
1737
+ className: clsx_default(
1738
+ "calendar-day",
1739
+ !day.isCurrentMonth && "outside",
1740
+ disabled && "disabled",
1741
+ isSelected && "selected",
1742
+ day.isToday && "today"
1743
+ ),
1744
+ onClick: () => {
1745
+ if (!disabled && day.isCurrentMonth) onSelect?.(day.date);
1774
1746
  },
1775
- ei
1776
- )),
1777
- dayEvents.length > 3 && /* @__PURE__ */ (0, import_jsx_runtime301.jsxs)("span", { className: "calendar-event-more", children: [
1778
- "+",
1779
- dayEvents.length - 3
1780
- ] })
1781
- ] })
1782
- ]
1783
- },
1784
- idx
1785
- );
1786
- }) })
1787
- ] });
1747
+ children: renderDay(day, dayEvents)
1748
+ },
1749
+ idx
1750
+ );
1751
+ }
1752
+ return /* @__PURE__ */ (0, import_jsx_runtime301.jsxs)(
1753
+ "div",
1754
+ {
1755
+ className: clsx_default(
1756
+ "calendar-day",
1757
+ !day.isCurrentMonth && "outside",
1758
+ disabled && "disabled",
1759
+ isSelected && "selected",
1760
+ day.isToday && "today",
1761
+ day.isSunday && "sunday",
1762
+ day.isSaturday && "saturday"
1763
+ ),
1764
+ onClick: () => {
1765
+ if (!disabled && day.isCurrentMonth) onSelect?.(day.date);
1766
+ },
1767
+ children: [
1768
+ /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("span", { className: "calendar-day-number", children: day.day }),
1769
+ dayEvents.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime301.jsxs)("div", { className: "calendar-day-events", children: [
1770
+ dayEvents.slice(0, 3).map((event, ei) => /* @__PURE__ */ (0, import_jsx_runtime301.jsx)(
1771
+ "span",
1772
+ {
1773
+ className: "calendar-event-dot",
1774
+ style: { backgroundColor: event.color ?? "var(--xplat-blue-500)" },
1775
+ title: event.label,
1776
+ onClick: (e) => {
1777
+ e.stopPropagation();
1778
+ onEventClick?.(event);
1779
+ }
1780
+ },
1781
+ ei
1782
+ )),
1783
+ dayEvents.length > 3 && /* @__PURE__ */ (0, import_jsx_runtime301.jsxs)("span", { className: "calendar-event-more", children: [
1784
+ "+",
1785
+ dayEvents.length - 3
1786
+ ] })
1787
+ ] })
1788
+ ]
1789
+ },
1790
+ idx
1791
+ );
1792
+ }) })
1793
+ ]
1794
+ }
1795
+ );
1788
1796
  };
1789
1797
  Calendar.displayName = "Calendar";
1790
1798
  var Calendar_default = Calendar;
@@ -16669,7 +16677,7 @@ var DayCell = import_react11.default.memo(
16669
16677
  disabled,
16670
16678
  selected,
16671
16679
  highlighted,
16672
- onClick
16680
+ onSelect
16673
16681
  }) => /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(
16674
16682
  "button",
16675
16683
  {
@@ -16685,10 +16693,13 @@ var DayCell = import_react11.default.memo(
16685
16693
  day.isSaturday && "saturday"
16686
16694
  ),
16687
16695
  disabled: disabled || !day.isCurrentMonth,
16688
- onClick,
16696
+ onClick: () => {
16697
+ if (!disabled && day.isCurrentMonth) onSelect(day.date);
16698
+ },
16689
16699
  children: day.day
16690
16700
  }
16691
- )
16701
+ ),
16702
+ (prev, next) => prev.selected === next.selected && prev.disabled === next.disabled && prev.highlighted === next.highlighted && prev.day === next.day
16692
16703
  );
16693
16704
  DayCell.displayName = "DayCell";
16694
16705
  var SingleDatePicker = (props) => {
@@ -16766,9 +16777,7 @@ var SingleDatePicker = (props) => {
16766
16777
  disabled,
16767
16778
  selected,
16768
16779
  highlighted,
16769
- onClick: () => {
16770
- if (!disabled && day.isCurrentMonth) handleSelect(day.date);
16771
- }
16780
+ onSelect: handleSelect
16772
16781
  },
16773
16782
  idx
16774
16783
  );
@@ -796,14 +796,14 @@
796
796
  background-color: var(--xplat-blue-600);
797
797
  }
798
798
  .lib-xplat-calendar .calendar-day.selected {
799
- background-color: var(--xplat-neutral-900);
799
+ background-color: var(--calendar-selected-color, var(--xplat-neutral-900));
800
800
  }
801
801
  .lib-xplat-calendar .calendar-day.selected .calendar-day-number {
802
802
  color: var(--xplat-white);
803
803
  font-weight: 600;
804
804
  }
805
805
  .lib-xplat-calendar .calendar-day.selected:hover {
806
- background-color: var(--xplat-neutral-800);
806
+ background-color: color-mix(in srgb, var(--calendar-selected-color, var(--xplat-neutral-900)), black 12%);
807
807
  }
808
808
  .lib-xplat-calendar .calendar-day.selected.today .calendar-day-number::before {
809
809
  background-color: var(--xplat-white);
@@ -1326,6 +1326,10 @@
1326
1326
  border-radius: 12px;
1327
1327
  background-color: #fff;
1328
1328
  padding: 24px;
1329
+ width: fit-content;
1330
+ max-width: calc(100vw - 2rem);
1331
+ max-height: calc(100vh - 2rem);
1332
+ overflow: auto;
1329
1333
  transform: translate(-50%, -50%) scale(0.9);
1330
1334
  opacity: 0;
1331
1335
  transition: transform 0.2s ease, opacity 0.2s ease;
@@ -1572,6 +1572,7 @@ var Calendar = (props) => {
1572
1572
  locale = "ko",
1573
1573
  minDate,
1574
1574
  maxDate,
1575
+ selectedColor,
1575
1576
  showToday = true,
1576
1577
  className
1577
1578
  } = props;
@@ -1615,90 +1616,97 @@ var Calendar = (props) => {
1615
1616
  };
1616
1617
  const getEventsForDay = (date) => events.filter((e) => isSameDay(e.date, date));
1617
1618
  const weekdays = WEEKDAY_LABELS[locale];
1618
- return /* @__PURE__ */ jsxs193("div", { className: clsx_default("lib-xplat-calendar", className), children: [
1619
- /* @__PURE__ */ jsxs193("div", { className: "calendar-header", children: [
1620
- /* @__PURE__ */ jsx301("button", { className: "calendar-nav", onClick: handlePrev, "aria-label": "\uC774\uC804 \uB2EC", children: /* @__PURE__ */ jsx301(ChevronLeftIcon_default, {}) }),
1621
- /* @__PURE__ */ jsx301("span", { className: "calendar-title", children: locale === "ko" ? `${year}\uB144 ${MONTH_LABELS.ko[month]}` : `${MONTH_LABELS.en[month]} ${year}` }),
1622
- /* @__PURE__ */ jsx301("button", { className: "calendar-nav", onClick: handleNext, "aria-label": "\uB2E4\uC74C \uB2EC", children: /* @__PURE__ */ jsx301(ChevronRightIcon_default, {}) }),
1623
- showToday && /* @__PURE__ */ jsx301("button", { className: "calendar-today-btn", onClick: handleToday, children: locale === "ko" ? "\uC624\uB298" : "Today" })
1624
- ] }),
1625
- /* @__PURE__ */ jsx301("div", { className: "calendar-weekdays", children: weekdays.map((label, i) => /* @__PURE__ */ jsx301(
1626
- "div",
1627
- {
1628
- className: clsx_default(
1629
- "calendar-weekday",
1630
- i === 0 && "sunday",
1631
- i === 6 && "saturday"
1632
- ),
1633
- children: label
1634
- },
1635
- label
1636
- )) }),
1637
- /* @__PURE__ */ jsx301("div", { className: "calendar-grid", children: days.map((day, idx) => {
1638
- const dayEvents = getEventsForDay(day.date);
1639
- const disabled = isDisabled(day.date);
1640
- const isSelected = selectedDate ? isSameDay(day.date, selectedDate) : false;
1641
- if (renderDay) {
1642
- return /* @__PURE__ */ jsx301(
1619
+ return /* @__PURE__ */ jsxs193(
1620
+ "div",
1621
+ {
1622
+ className: clsx_default("lib-xplat-calendar", className),
1623
+ style: selectedColor ? { "--calendar-selected-color": `var(--${selectedColor})` } : void 0,
1624
+ children: [
1625
+ /* @__PURE__ */ jsxs193("div", { className: "calendar-header", children: [
1626
+ /* @__PURE__ */ jsx301("button", { className: "calendar-nav", onClick: handlePrev, "aria-label": "\uC774\uC804 \uB2EC", children: /* @__PURE__ */ jsx301(ChevronLeftIcon_default, {}) }),
1627
+ /* @__PURE__ */ jsx301("span", { className: "calendar-title", children: locale === "ko" ? `${year}\uB144 ${MONTH_LABELS.ko[month]}` : `${MONTH_LABELS.en[month]} ${year}` }),
1628
+ /* @__PURE__ */ jsx301("button", { className: "calendar-nav", onClick: handleNext, "aria-label": "\uB2E4\uC74C \uB2EC", children: /* @__PURE__ */ jsx301(ChevronRightIcon_default, {}) }),
1629
+ showToday && /* @__PURE__ */ jsx301("button", { className: "calendar-today-btn", onClick: handleToday, children: locale === "ko" ? "\uC624\uB298" : "Today" })
1630
+ ] }),
1631
+ /* @__PURE__ */ jsx301("div", { className: "calendar-weekdays", children: weekdays.map((label, i) => /* @__PURE__ */ jsx301(
1643
1632
  "div",
1644
1633
  {
1645
1634
  className: clsx_default(
1646
- "calendar-day",
1647
- !day.isCurrentMonth && "outside",
1648
- disabled && "disabled",
1649
- isSelected && "selected",
1650
- day.isToday && "today"
1635
+ "calendar-weekday",
1636
+ i === 0 && "sunday",
1637
+ i === 6 && "saturday"
1651
1638
  ),
1652
- onClick: () => {
1653
- if (!disabled && day.isCurrentMonth) onSelect?.(day.date);
1654
- },
1655
- children: renderDay(day, dayEvents)
1656
- },
1657
- idx
1658
- );
1659
- }
1660
- return /* @__PURE__ */ jsxs193(
1661
- "div",
1662
- {
1663
- className: clsx_default(
1664
- "calendar-day",
1665
- !day.isCurrentMonth && "outside",
1666
- disabled && "disabled",
1667
- isSelected && "selected",
1668
- day.isToday && "today",
1669
- day.isSunday && "sunday",
1670
- day.isSaturday && "saturday"
1671
- ),
1672
- onClick: () => {
1673
- if (!disabled && day.isCurrentMonth) onSelect?.(day.date);
1639
+ children: label
1674
1640
  },
1675
- children: [
1676
- /* @__PURE__ */ jsx301("span", { className: "calendar-day-number", children: day.day }),
1677
- dayEvents.length > 0 && /* @__PURE__ */ jsxs193("div", { className: "calendar-day-events", children: [
1678
- dayEvents.slice(0, 3).map((event, ei) => /* @__PURE__ */ jsx301(
1679
- "span",
1680
- {
1681
- className: "calendar-event-dot",
1682
- style: { backgroundColor: event.color ?? "var(--xplat-blue-500)" },
1683
- title: event.label,
1684
- onClick: (e) => {
1685
- e.stopPropagation();
1686
- onEventClick?.(event);
1687
- }
1641
+ label
1642
+ )) }),
1643
+ /* @__PURE__ */ jsx301("div", { className: "calendar-grid", children: days.map((day, idx) => {
1644
+ const dayEvents = getEventsForDay(day.date);
1645
+ const disabled = isDisabled(day.date);
1646
+ const isSelected = selectedDate ? isSameDay(day.date, selectedDate) : false;
1647
+ if (renderDay) {
1648
+ return /* @__PURE__ */ jsx301(
1649
+ "div",
1650
+ {
1651
+ className: clsx_default(
1652
+ "calendar-day",
1653
+ !day.isCurrentMonth && "outside",
1654
+ disabled && "disabled",
1655
+ isSelected && "selected",
1656
+ day.isToday && "today"
1657
+ ),
1658
+ onClick: () => {
1659
+ if (!disabled && day.isCurrentMonth) onSelect?.(day.date);
1688
1660
  },
1689
- ei
1690
- )),
1691
- dayEvents.length > 3 && /* @__PURE__ */ jsxs193("span", { className: "calendar-event-more", children: [
1692
- "+",
1693
- dayEvents.length - 3
1694
- ] })
1695
- ] })
1696
- ]
1697
- },
1698
- idx
1699
- );
1700
- }) })
1701
- ] });
1661
+ children: renderDay(day, dayEvents)
1662
+ },
1663
+ idx
1664
+ );
1665
+ }
1666
+ return /* @__PURE__ */ jsxs193(
1667
+ "div",
1668
+ {
1669
+ className: clsx_default(
1670
+ "calendar-day",
1671
+ !day.isCurrentMonth && "outside",
1672
+ disabled && "disabled",
1673
+ isSelected && "selected",
1674
+ day.isToday && "today",
1675
+ day.isSunday && "sunday",
1676
+ day.isSaturday && "saturday"
1677
+ ),
1678
+ onClick: () => {
1679
+ if (!disabled && day.isCurrentMonth) onSelect?.(day.date);
1680
+ },
1681
+ children: [
1682
+ /* @__PURE__ */ jsx301("span", { className: "calendar-day-number", children: day.day }),
1683
+ dayEvents.length > 0 && /* @__PURE__ */ jsxs193("div", { className: "calendar-day-events", children: [
1684
+ dayEvents.slice(0, 3).map((event, ei) => /* @__PURE__ */ jsx301(
1685
+ "span",
1686
+ {
1687
+ className: "calendar-event-dot",
1688
+ style: { backgroundColor: event.color ?? "var(--xplat-blue-500)" },
1689
+ title: event.label,
1690
+ onClick: (e) => {
1691
+ e.stopPropagation();
1692
+ onEventClick?.(event);
1693
+ }
1694
+ },
1695
+ ei
1696
+ )),
1697
+ dayEvents.length > 3 && /* @__PURE__ */ jsxs193("span", { className: "calendar-event-more", children: [
1698
+ "+",
1699
+ dayEvents.length - 3
1700
+ ] })
1701
+ ] })
1702
+ ]
1703
+ },
1704
+ idx
1705
+ );
1706
+ }) })
1707
+ ]
1708
+ }
1709
+ );
1702
1710
  };
1703
1711
  Calendar.displayName = "Calendar";
1704
1712
  var Calendar_default = Calendar;
@@ -16583,7 +16591,7 @@ var DayCell = React9.memo(
16583
16591
  disabled,
16584
16592
  selected,
16585
16593
  highlighted,
16586
- onClick
16594
+ onSelect
16587
16595
  }) => /* @__PURE__ */ jsx312(
16588
16596
  "button",
16589
16597
  {
@@ -16599,10 +16607,13 @@ var DayCell = React9.memo(
16599
16607
  day.isSaturday && "saturday"
16600
16608
  ),
16601
16609
  disabled: disabled || !day.isCurrentMonth,
16602
- onClick,
16610
+ onClick: () => {
16611
+ if (!disabled && day.isCurrentMonth) onSelect(day.date);
16612
+ },
16603
16613
  children: day.day
16604
16614
  }
16605
- )
16615
+ ),
16616
+ (prev, next) => prev.selected === next.selected && prev.disabled === next.disabled && prev.highlighted === next.highlighted && prev.day === next.day
16606
16617
  );
16607
16618
  DayCell.displayName = "DayCell";
16608
16619
  var SingleDatePicker = (props) => {
@@ -16680,9 +16691,7 @@ var SingleDatePicker = (props) => {
16680
16691
  disabled,
16681
16692
  selected,
16682
16693
  highlighted,
16683
- onClick: () => {
16684
- if (!disabled && day.isCurrentMonth) handleSelect(day.date);
16685
- }
16694
+ onSelect: handleSelect
16686
16695
  },
16687
16696
  idx
16688
16697
  );