@sarunyu/system-one 4.9.4 → 4.9.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.cjs CHANGED
@@ -1668,21 +1668,22 @@ const NAV_BTN_CLASS = cn(
1668
1668
  "p-0 outline-none"
1669
1669
  );
1670
1670
  function CustomCaption({
1671
- displayMonth,
1671
+ calendarMonth,
1672
1672
  displayIndex
1673
1673
  }) {
1674
- const { goToMonth, previousMonth, nextMonth, displayMonths } = reactDayPicker.useNavigation();
1674
+ const { goToMonth, previousMonth, nextMonth, months } = reactDayPicker.useDayPicker();
1675
1675
  const isDrawerRange = React.useContext(DrawerRangeCtx);
1676
1676
  const { disabledYears = [] } = React.useContext(DisabledDatesCtx);
1677
1677
  const [view, setView] = React.useState("days");
1678
+ const displayMonth = calendarMonth.date;
1678
1679
  const [pickerYear, setPickerYear] = React.useState(
1679
1680
  displayMonth.getFullYear()
1680
1681
  );
1681
1682
  const [yearRangeStart, setYearRangeStart] = React.useState(
1682
1683
  Math.floor(displayMonth.getFullYear() / 12) * 12
1683
1684
  );
1684
- const isFirst = displayMonths[0].getTime() === displayMonth.getTime();
1685
- const isLast = displayMonths[displayMonths.length - 1].getTime() === displayMonth.getTime();
1685
+ const isFirst = months[0].date.getTime() === displayMonth.getTime();
1686
+ const isLast = months[months.length - 1].date.getTime() === displayMonth.getTime();
1686
1687
  const idx = displayIndex ?? 0;
1687
1688
  const handlePrevYear = () => {
1688
1689
  const d = new Date(displayMonth);
@@ -1951,77 +1952,99 @@ function CustomCaption({
1951
1952
  const DAY_PICKER_CLASSES = {
1952
1953
  months: "flex flex-col sm:flex-row sm:gap-6",
1953
1954
  month: "space-y-2 relative",
1954
- caption: "flex justify-center pt-1 relative items-center mb-2",
1955
+ month_caption: "flex justify-center pt-1 relative items-center mb-2",
1955
1956
  caption_label: "text-[14px] leading-[20px] text-foreground",
1956
1957
  nav: "hidden",
1957
- nav_button: cn(
1958
- "h-[28px] w-[28px] inline-flex items-center justify-center",
1959
- "rounded-[6px] bg-transparent border border-border cursor-pointer",
1960
- "text-muted-foreground hover:bg-disabled-bg transition-colors duration-100",
1961
- "p-0 outline-none"
1962
- ),
1963
- nav_button_previous: "absolute left-1",
1964
- nav_button_next: "absolute right-1",
1965
- table: "w-full border-collapse",
1966
- head_row: "flex",
1967
- head_cell: "w-[36px] h-[32px] inline-flex items-center justify-center text-[12px] text-disabled font-normal",
1968
- row: "flex w-full mt-1",
1969
- cell: cn(
1958
+ button_previous: "absolute left-1",
1959
+ button_next: "absolute right-1",
1960
+ month_grid: "w-full border-collapse",
1961
+ weekdays: "flex",
1962
+ weekday: "w-[36px] h-[32px] inline-flex items-center justify-center text-[12px] text-disabled font-normal",
1963
+ week: "flex w-full mt-1",
1964
+ // In v9 modifier classes (range_start, range_end, etc.) are placed on the
1965
+ // outer `day` wrapper element. We use semantic marker class names so both
1966
+ // the wrapper and button can reference them.
1967
+ day: cn(
1970
1968
  "h-[36px] w-[36px] text-center p-0 relative overflow-hidden",
1971
- "[&:has(.day-range-middle)]:bg-range-bg",
1972
- "[&:has(.day-range-start)]:bg-range-bg",
1973
- "[&:has(.day-range-end)]:bg-range-bg",
1974
- "[&:has(.day-range-start)]:rounded-l-[6px]",
1975
- "[&:has(.day-range-end)]:rounded-r-[6px]",
1976
- "[&:first-child:has(.day-range-middle)]:rounded-l-[6px]",
1977
- "[&:last-child:has(.day-range-middle)]:rounded-r-[6px]",
1978
- "[&:first-child:has(.day-range-end)]:rounded-l-[6px]",
1979
- "[&:last-child:has(.day-range-start)]:rounded-r-[6px]",
1969
+ // Range band background on the wrapper
1970
+ "[&.is-range-middle]:bg-range-bg",
1971
+ "[&.is-range-start]:bg-range-bg",
1972
+ "[&.is-range-end]:bg-range-bg",
1973
+ "[&.is-range-start]:rounded-l-[6px]",
1974
+ "[&.is-range-end]:rounded-r-[6px]",
1975
+ "[&:first-child.is-range-middle]:rounded-l-[6px]",
1976
+ "[&:last-child.is-range-middle]:rounded-r-[6px]",
1977
+ "[&:first-child.is-range-end]:rounded-l-[6px]",
1978
+ "[&:last-child.is-range-start]:rounded-r-[6px]",
1980
1979
  "focus-within:relative focus-within:z-20"
1981
1980
  ),
1982
- day: cn(
1981
+ day_button: cn(
1983
1982
  "h-[36px] w-[36px] inline-flex items-center justify-center",
1984
1983
  "text-[14px] text-foreground rounded-[6px]",
1985
1984
  "border-0 bg-transparent cursor-pointer",
1986
1985
  "hover:bg-disabled-bg transition-colors duration-100",
1987
- "outline-none aria-selected:opacity-100 p-0"
1986
+ "outline-none p-0",
1987
+ // Selected (single mode)
1988
+ "[.is-selected_&]:!bg-primary-action [.is-selected_&]:!text-on-primary-action [.is-selected_&]:!rounded-[6px]",
1989
+ // Range start button styling
1990
+ "[.is-range-start_&]:!bg-primary-action [.is-range-start_&]:!text-on-primary-action [.is-range-start_&]:!rounded-l-[6px] [.is-range-start_&]:!rounded-r-none",
1991
+ // Range end button styling
1992
+ "[.is-range-end_&]:!bg-primary-action [.is-range-end_&]:!text-on-primary-action [.is-range-end_&]:!rounded-r-[6px] [.is-range-end_&]:!rounded-l-none",
1993
+ // Range middle button styling
1994
+ "[.is-range-middle_&]:!bg-range-bg [.is-range-middle_&]:!text-range-text [.is-range-middle_&]:!rounded-none",
1995
+ // Today (when not selected)
1996
+ "[.is-today:not(.is-selected):not(.is-range-start):not(.is-range-end)_&]:!bg-primary-action-light [.is-today:not(.is-selected):not(.is-range-start):not(.is-range-end)_&]:!text-foreground",
1997
+ // Outside days
1998
+ "[.is-outside_&]:text-disabled [.is-outside_&]:opacity-50",
1999
+ "[.is-outside.is-selected_&]:!bg-transparent [.is-outside.is-selected_&]:!opacity-30",
2000
+ // Disabled days
2001
+ "[.is-disabled_&]:text-disabled [.is-disabled_&]:opacity-50 [.is-disabled_&]:cursor-not-allowed"
1988
2002
  ),
1989
- day_range_start: "day-range-start !bg-primary-action !text-on-primary-action !rounded-l-[6px] !rounded-r-none",
1990
- day_range_end: "day-range-end !bg-primary-action !text-on-primary-action !rounded-r-[6px] !rounded-l-none",
1991
- day_selected: "!bg-primary-action text-on-primary-action hover:!bg-primary-action focus:!bg-primary-action rounded-[6px]",
1992
- day_today: "[&:not([aria-selected=true])]:!bg-primary-action-light [&:not([aria-selected=true])]:text-foreground rounded-[6px]",
1993
- day_outside: "day-outside text-disabled opacity-50 aria-selected:bg-transparent aria-selected:opacity-30",
1994
- day_disabled: "text-disabled opacity-50 cursor-not-allowed",
1995
- day_range_middle: "day-range-middle !bg-range-bg !text-range-text !rounded-none",
1996
- day_hidden: "invisible"
2003
+ // Modifier classes applied to the `day` wrapper in v9
2004
+ selected: "is-selected",
2005
+ range_start: "is-range-start",
2006
+ range_end: "is-range-end",
2007
+ range_middle: "is-range-middle",
2008
+ today: "is-today",
2009
+ outside: "is-outside",
2010
+ disabled: "is-disabled",
2011
+ hidden: "invisible"
1997
2012
  };
1998
2013
  const DRAWER_DAY_PICKER_CLASSES = {
1999
2014
  ...DAY_PICKER_CLASSES,
2000
2015
  months: "flex flex-col gap-6 w-full",
2001
2016
  month: "space-y-2 relative w-full",
2002
- table: "w-full border-collapse table-fixed",
2003
- head_row: "flex w-full",
2004
- head_cell: "flex-1 h-[40px] inline-flex items-center justify-center text-[13px] text-disabled font-normal",
2005
- row: "flex w-full mt-1",
2006
- cell: cn(
2017
+ month_grid: "w-full border-collapse table-fixed",
2018
+ weekdays: "flex w-full",
2019
+ weekday: "flex-1 h-[40px] inline-flex items-center justify-center text-[13px] text-disabled font-normal",
2020
+ week: "flex w-full mt-1",
2021
+ day: cn(
2007
2022
  "h-[44px] flex-1 text-center p-0 relative overflow-hidden",
2008
- "[&:has(.day-range-middle)]:bg-range-bg",
2009
- "[&:has(.day-range-start)]:bg-range-bg",
2010
- "[&:has(.day-range-end)]:bg-range-bg",
2011
- "[&:has(.day-range-start)]:rounded-l-[8px]",
2012
- "[&:has(.day-range-end)]:rounded-r-[8px]",
2013
- "[&:first-child:has(.day-range-middle)]:rounded-l-[8px]",
2014
- "[&:last-child:has(.day-range-middle)]:rounded-r-[8px]",
2015
- "[&:first-child:has(.day-range-end)]:rounded-l-[8px]",
2016
- "[&:last-child:has(.day-range-start)]:rounded-r-[8px]",
2023
+ "[&.is-range-middle]:bg-range-bg",
2024
+ "[&.is-range-start]:bg-range-bg",
2025
+ "[&.is-range-end]:bg-range-bg",
2026
+ "[&.is-range-start]:rounded-l-[8px]",
2027
+ "[&.is-range-end]:rounded-r-[8px]",
2028
+ "[&:first-child.is-range-middle]:rounded-l-[8px]",
2029
+ "[&:last-child.is-range-middle]:rounded-r-[8px]",
2030
+ "[&:first-child.is-range-end]:rounded-l-[8px]",
2031
+ "[&:last-child.is-range-start]:rounded-r-[8px]",
2017
2032
  "focus-within:relative focus-within:z-20"
2018
2033
  ),
2019
- day: cn(
2034
+ day_button: cn(
2020
2035
  "h-[44px] w-full inline-flex items-center justify-center",
2021
2036
  "text-[16px] text-foreground rounded-[8px]",
2022
2037
  "border-0 bg-transparent cursor-pointer",
2023
2038
  "hover:bg-disabled-bg transition-colors duration-100",
2024
- "outline-none aria-selected:opacity-100 p-0"
2039
+ "outline-none p-0",
2040
+ "[.is-selected_&]:!bg-primary-action [.is-selected_&]:!text-on-primary-action [.is-selected_&]:!rounded-[8px]",
2041
+ "[.is-range-start_&]:!bg-primary-action [.is-range-start_&]:!text-on-primary-action [.is-range-start_&]:!rounded-l-[8px] [.is-range-start_&]:!rounded-r-none",
2042
+ "[.is-range-end_&]:!bg-primary-action [.is-range-end_&]:!text-on-primary-action [.is-range-end_&]:!rounded-r-[8px] [.is-range-end_&]:!rounded-l-none",
2043
+ "[.is-range-middle_&]:!bg-range-bg [.is-range-middle_&]:!text-range-text [.is-range-middle_&]:!rounded-none",
2044
+ "[.is-today:not(.is-selected):not(.is-range-start):not(.is-range-end)_&]:!bg-primary-action-light [.is-today:not(.is-selected):not(.is-range-start):not(.is-range-end)_&]:!text-foreground",
2045
+ "[.is-outside_&]:text-disabled [.is-outside_&]:opacity-50",
2046
+ "[.is-outside.is-selected_&]:!bg-transparent [.is-outside.is-selected_&]:!opacity-30",
2047
+ "[.is-disabled_&]:text-disabled [.is-disabled_&]:opacity-50 [.is-disabled_&]:cursor-not-allowed"
2025
2048
  )
2026
2049
  };
2027
2050
  const DATE_ITEM_H = 40;
@@ -2489,7 +2512,7 @@ const DateInput = React.forwardRef(
2489
2512
  formatters: {
2490
2513
  formatWeekdayName: (date) => THAI_WEEKDAYS[date.getDay()]
2491
2514
  },
2492
- components: { Caption: CustomCaption }
2515
+ components: { MonthCaption: CustomCaption }
2493
2516
  }
2494
2517
  ) : /* @__PURE__ */ jsxRuntime.jsx(
2495
2518
  reactDayPicker.DayPicker,
@@ -2503,7 +2526,7 @@ const DateInput = React.forwardRef(
2503
2526
  formatters: {
2504
2527
  formatWeekdayName: (date) => THAI_WEEKDAYS[date.getDay()]
2505
2528
  },
2506
- components: { Caption: CustomCaption }
2529
+ components: { MonthCaption: CustomCaption }
2507
2530
  }
2508
2531
  );
2509
2532
  const calendarContent = /* @__PURE__ */ jsxRuntime.jsx(DisabledDatesCtx.Provider, { value: { disabledYears }, children: pickerInner });