@sarunyu/system-one 4.9.4 → 4.9.6

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
@@ -63,19 +63,17 @@ const roundedLabelClass = {
63
63
  lg: "rounded-lg",
64
64
  xl: "rounded-lg"
65
65
  };
66
+ const heightClass = {
67
+ xs: "h-[26px]",
68
+ sm: "h-[28px]",
69
+ md: "h-8",
70
+ // 32px
71
+ lg: "h-9",
72
+ // 36px
73
+ xl: "h-10"
74
+ // 40px
75
+ };
66
76
  function getPaddingClasses(size, hasLeft, hasRight) {
67
- const pyMap = {
68
- xs: "py-1",
69
- // 4px
70
- sm: "py-1",
71
- // 4px
72
- md: "py-1.5",
73
- // 6px
74
- lg: "py-2",
75
- // 8px
76
- xl: "py-2.5"
77
- // 10px
78
- };
79
77
  const pxMap = {
80
78
  xs: { l: "pl-1.5", r: "pr-1.5" },
81
79
  // 6px
@@ -97,8 +95,7 @@ function getPaddingClasses(size, hasLeft, hasRight) {
97
95
  };
98
96
  return [
99
97
  hasLeft ? reducedMap[size].l : pxMap[size].l,
100
- hasRight ? reducedMap[size].r : pxMap[size].r,
101
- pyMap[size]
98
+ hasRight ? reducedMap[size].r : pxMap[size].r
102
99
  ];
103
100
  }
104
101
  const iconSizeSpec = {
@@ -112,17 +109,17 @@ function getVariantClasses(variant, isDisabled) {
112
109
  if (isDisabled) {
113
110
  if (variant === "outline" || variant === "outline-black")
114
111
  return "bg-disabled-bg text-disabled border border-border-disabled cursor-not-allowed";
115
- return "bg-disabled-bg text-disabled cursor-not-allowed";
112
+ return "bg-disabled-bg text-disabled border border-transparent cursor-not-allowed";
116
113
  }
117
114
  if (variant === "outline")
118
115
  return "bg-background text-primary-action border border-border hover:bg-hover-bg active:bg-disabled-bg";
119
116
  if (variant === "plain")
120
- return "bg-transparent text-primary-action hover:bg-hover-bg active:bg-disabled-bg";
117
+ return "bg-transparent text-primary-action border border-transparent hover:bg-hover-bg active:bg-disabled-bg";
121
118
  if (variant === "outline-black")
122
119
  return "bg-background text-foreground border border-border hover:bg-hover-bg";
123
120
  if (variant === "plain-black")
124
- return "bg-transparent text-foreground hover:bg-hover-bg";
125
- return "bg-primary-action text-on-primary-action hover:bg-primary-action-hover active:bg-primary-action-active";
121
+ return "bg-transparent text-foreground border border-transparent hover:bg-hover-bg";
122
+ return "bg-primary-action text-on-primary-action border border-transparent hover:bg-primary-action-hover active:bg-primary-action-active";
126
123
  }
127
124
  const Button = React.forwardRef(function Button2({
128
125
  size = "md",
@@ -204,9 +201,9 @@ const Button = React.forwardRef(function Button2({
204
201
  className: cn(
205
202
  baseClasses,
206
203
  roundedLabelClass[labelSize],
204
+ heightClass[labelSize],
207
205
  paddingParts[0],
208
206
  paddingParts[1],
209
- paddingParts[2],
210
207
  hasLeft || hasRight ? gapClass[labelSize] : void 0,
211
208
  variantClasses,
212
209
  cursorClass,
@@ -1668,21 +1665,22 @@ const NAV_BTN_CLASS = cn(
1668
1665
  "p-0 outline-none"
1669
1666
  );
1670
1667
  function CustomCaption({
1671
- displayMonth,
1668
+ calendarMonth,
1672
1669
  displayIndex
1673
1670
  }) {
1674
- const { goToMonth, previousMonth, nextMonth, displayMonths } = reactDayPicker.useNavigation();
1671
+ const { goToMonth, previousMonth, nextMonth, months } = reactDayPicker.useDayPicker();
1675
1672
  const isDrawerRange = React.useContext(DrawerRangeCtx);
1676
1673
  const { disabledYears = [] } = React.useContext(DisabledDatesCtx);
1677
1674
  const [view, setView] = React.useState("days");
1675
+ const displayMonth = calendarMonth.date;
1678
1676
  const [pickerYear, setPickerYear] = React.useState(
1679
1677
  displayMonth.getFullYear()
1680
1678
  );
1681
1679
  const [yearRangeStart, setYearRangeStart] = React.useState(
1682
1680
  Math.floor(displayMonth.getFullYear() / 12) * 12
1683
1681
  );
1684
- const isFirst = displayMonths[0].getTime() === displayMonth.getTime();
1685
- const isLast = displayMonths[displayMonths.length - 1].getTime() === displayMonth.getTime();
1682
+ const isFirst = months[0].date.getTime() === displayMonth.getTime();
1683
+ const isLast = months[months.length - 1].date.getTime() === displayMonth.getTime();
1686
1684
  const idx = displayIndex ?? 0;
1687
1685
  const handlePrevYear = () => {
1688
1686
  const d = new Date(displayMonth);
@@ -1951,77 +1949,99 @@ function CustomCaption({
1951
1949
  const DAY_PICKER_CLASSES = {
1952
1950
  months: "flex flex-col sm:flex-row sm:gap-6",
1953
1951
  month: "space-y-2 relative",
1954
- caption: "flex justify-center pt-1 relative items-center mb-2",
1952
+ month_caption: "flex justify-center pt-1 relative items-center mb-2",
1955
1953
  caption_label: "text-[14px] leading-[20px] text-foreground",
1956
1954
  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(
1955
+ button_previous: "absolute left-1",
1956
+ button_next: "absolute right-1",
1957
+ month_grid: "w-full border-collapse",
1958
+ weekdays: "flex",
1959
+ weekday: "w-[36px] h-[32px] inline-flex items-center justify-center text-[12px] text-disabled font-normal",
1960
+ week: "flex w-full mt-1",
1961
+ // In v9 modifier classes (range_start, range_end, etc.) are placed on the
1962
+ // outer `day` wrapper element. We use semantic marker class names so both
1963
+ // the wrapper and button can reference them.
1964
+ day: cn(
1970
1965
  "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]",
1966
+ // Range band background on the wrapper
1967
+ "[&.is-range-middle]:bg-range-bg",
1968
+ "[&.is-range-start]:bg-range-bg",
1969
+ "[&.is-range-end]:bg-range-bg",
1970
+ "[&.is-range-start]:rounded-l-[6px]",
1971
+ "[&.is-range-end]:rounded-r-[6px]",
1972
+ "[&:first-child.is-range-middle]:rounded-l-[6px]",
1973
+ "[&:last-child.is-range-middle]:rounded-r-[6px]",
1974
+ "[&:first-child.is-range-end]:rounded-l-[6px]",
1975
+ "[&:last-child.is-range-start]:rounded-r-[6px]",
1980
1976
  "focus-within:relative focus-within:z-20"
1981
1977
  ),
1982
- day: cn(
1978
+ day_button: cn(
1983
1979
  "h-[36px] w-[36px] inline-flex items-center justify-center",
1984
1980
  "text-[14px] text-foreground rounded-[6px]",
1985
1981
  "border-0 bg-transparent cursor-pointer",
1986
1982
  "hover:bg-disabled-bg transition-colors duration-100",
1987
- "outline-none aria-selected:opacity-100 p-0"
1983
+ "outline-none p-0",
1984
+ // Selected (single mode)
1985
+ "[.is-selected_&]:!bg-primary-action [.is-selected_&]:!text-on-primary-action [.is-selected_&]:!rounded-[6px]",
1986
+ // Range start button styling
1987
+ "[.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",
1988
+ // Range end button styling
1989
+ "[.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",
1990
+ // Range middle button styling
1991
+ "[.is-range-middle_&]:!bg-range-bg [.is-range-middle_&]:!text-range-text [.is-range-middle_&]:!rounded-none",
1992
+ // Today (when not selected)
1993
+ "[.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",
1994
+ // Outside days
1995
+ "[.is-outside_&]:text-disabled [.is-outside_&]:opacity-50",
1996
+ "[.is-outside.is-selected_&]:!bg-transparent [.is-outside.is-selected_&]:!opacity-30",
1997
+ // Disabled days
1998
+ "[.is-disabled_&]:text-disabled [.is-disabled_&]:opacity-50 [.is-disabled_&]:cursor-not-allowed"
1988
1999
  ),
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"
2000
+ // Modifier classes applied to the `day` wrapper in v9
2001
+ selected: "is-selected",
2002
+ range_start: "is-range-start",
2003
+ range_end: "is-range-end",
2004
+ range_middle: "is-range-middle",
2005
+ today: "is-today",
2006
+ outside: "is-outside",
2007
+ disabled: "is-disabled",
2008
+ hidden: "invisible"
1997
2009
  };
1998
2010
  const DRAWER_DAY_PICKER_CLASSES = {
1999
2011
  ...DAY_PICKER_CLASSES,
2000
2012
  months: "flex flex-col gap-6 w-full",
2001
2013
  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(
2014
+ month_grid: "w-full border-collapse table-fixed",
2015
+ weekdays: "flex w-full",
2016
+ weekday: "flex-1 h-[40px] inline-flex items-center justify-center text-[13px] text-disabled font-normal",
2017
+ week: "flex w-full mt-1",
2018
+ day: cn(
2007
2019
  "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]",
2020
+ "[&.is-range-middle]:bg-range-bg",
2021
+ "[&.is-range-start]:bg-range-bg",
2022
+ "[&.is-range-end]:bg-range-bg",
2023
+ "[&.is-range-start]:rounded-l-[8px]",
2024
+ "[&.is-range-end]:rounded-r-[8px]",
2025
+ "[&:first-child.is-range-middle]:rounded-l-[8px]",
2026
+ "[&:last-child.is-range-middle]:rounded-r-[8px]",
2027
+ "[&:first-child.is-range-end]:rounded-l-[8px]",
2028
+ "[&:last-child.is-range-start]:rounded-r-[8px]",
2017
2029
  "focus-within:relative focus-within:z-20"
2018
2030
  ),
2019
- day: cn(
2031
+ day_button: cn(
2020
2032
  "h-[44px] w-full inline-flex items-center justify-center",
2021
2033
  "text-[16px] text-foreground rounded-[8px]",
2022
2034
  "border-0 bg-transparent cursor-pointer",
2023
2035
  "hover:bg-disabled-bg transition-colors duration-100",
2024
- "outline-none aria-selected:opacity-100 p-0"
2036
+ "outline-none p-0",
2037
+ "[.is-selected_&]:!bg-primary-action [.is-selected_&]:!text-on-primary-action [.is-selected_&]:!rounded-[8px]",
2038
+ "[.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",
2039
+ "[.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",
2040
+ "[.is-range-middle_&]:!bg-range-bg [.is-range-middle_&]:!text-range-text [.is-range-middle_&]:!rounded-none",
2041
+ "[.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",
2042
+ "[.is-outside_&]:text-disabled [.is-outside_&]:opacity-50",
2043
+ "[.is-outside.is-selected_&]:!bg-transparent [.is-outside.is-selected_&]:!opacity-30",
2044
+ "[.is-disabled_&]:text-disabled [.is-disabled_&]:opacity-50 [.is-disabled_&]:cursor-not-allowed"
2025
2045
  )
2026
2046
  };
2027
2047
  const DATE_ITEM_H = 40;
@@ -2489,7 +2509,7 @@ const DateInput = React.forwardRef(
2489
2509
  formatters: {
2490
2510
  formatWeekdayName: (date) => THAI_WEEKDAYS[date.getDay()]
2491
2511
  },
2492
- components: { Caption: CustomCaption }
2512
+ components: { MonthCaption: CustomCaption }
2493
2513
  }
2494
2514
  ) : /* @__PURE__ */ jsxRuntime.jsx(
2495
2515
  reactDayPicker.DayPicker,
@@ -2503,7 +2523,7 @@ const DateInput = React.forwardRef(
2503
2523
  formatters: {
2504
2524
  formatWeekdayName: (date) => THAI_WEEKDAYS[date.getDay()]
2505
2525
  },
2506
- components: { Caption: CustomCaption }
2526
+ components: { MonthCaption: CustomCaption }
2507
2527
  }
2508
2528
  );
2509
2529
  const calendarContent = /* @__PURE__ */ jsxRuntime.jsx(DisabledDatesCtx.Provider, { value: { disabledYears }, children: pickerInner });