@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.js CHANGED
@@ -5,7 +5,7 @@ import React__default, { forwardRef, useState, useRef, useEffect, useCallback, u
5
5
  import { clsx } from "clsx";
6
6
  import { twMerge } from "tailwind-merge";
7
7
  import { BellSimple, FunnelSimple, CheckCircle, Warning, XCircle, Info, BookmarkSimpleIcon, BroadcastIcon as BroadcastIcon$1, CalendarBlank, MapPin, Users, Lock, Check, Plus, Circle, Minus, CaretLeft, CaretRight, CaretDoubleLeft, CaretDoubleRight, CaretUp, CaretDown, X, ImageSquare, Gift, MegaphoneSimple, GearSix, MagnifyingGlass, ArrowUp, ArrowDown, ArrowsDownUp, Clock } from "@phosphor-icons/react";
8
- import { DayPicker, useNavigation } from "react-day-picker";
8
+ import { DayPicker, useDayPicker } from "react-day-picker";
9
9
  import * as Popover from "@radix-ui/react-popover";
10
10
  import { Drawer as Drawer$1 } from "vaul";
11
11
  function cn(...inputs) {
@@ -44,19 +44,17 @@ const roundedLabelClass = {
44
44
  lg: "rounded-lg",
45
45
  xl: "rounded-lg"
46
46
  };
47
+ const heightClass = {
48
+ xs: "h-[26px]",
49
+ sm: "h-[28px]",
50
+ md: "h-8",
51
+ // 32px
52
+ lg: "h-9",
53
+ // 36px
54
+ xl: "h-10"
55
+ // 40px
56
+ };
47
57
  function getPaddingClasses(size, hasLeft, hasRight) {
48
- const pyMap = {
49
- xs: "py-1",
50
- // 4px
51
- sm: "py-1",
52
- // 4px
53
- md: "py-1.5",
54
- // 6px
55
- lg: "py-2",
56
- // 8px
57
- xl: "py-2.5"
58
- // 10px
59
- };
60
58
  const pxMap = {
61
59
  xs: { l: "pl-1.5", r: "pr-1.5" },
62
60
  // 6px
@@ -78,8 +76,7 @@ function getPaddingClasses(size, hasLeft, hasRight) {
78
76
  };
79
77
  return [
80
78
  hasLeft ? reducedMap[size].l : pxMap[size].l,
81
- hasRight ? reducedMap[size].r : pxMap[size].r,
82
- pyMap[size]
79
+ hasRight ? reducedMap[size].r : pxMap[size].r
83
80
  ];
84
81
  }
85
82
  const iconSizeSpec = {
@@ -93,17 +90,17 @@ function getVariantClasses(variant, isDisabled) {
93
90
  if (isDisabled) {
94
91
  if (variant === "outline" || variant === "outline-black")
95
92
  return "bg-disabled-bg text-disabled border border-border-disabled cursor-not-allowed";
96
- return "bg-disabled-bg text-disabled cursor-not-allowed";
93
+ return "bg-disabled-bg text-disabled border border-transparent cursor-not-allowed";
97
94
  }
98
95
  if (variant === "outline")
99
96
  return "bg-background text-primary-action border border-border hover:bg-hover-bg active:bg-disabled-bg";
100
97
  if (variant === "plain")
101
- return "bg-transparent text-primary-action hover:bg-hover-bg active:bg-disabled-bg";
98
+ return "bg-transparent text-primary-action border border-transparent hover:bg-hover-bg active:bg-disabled-bg";
102
99
  if (variant === "outline-black")
103
100
  return "bg-background text-foreground border border-border hover:bg-hover-bg";
104
101
  if (variant === "plain-black")
105
- return "bg-transparent text-foreground hover:bg-hover-bg";
106
- return "bg-primary-action text-on-primary-action hover:bg-primary-action-hover active:bg-primary-action-active";
102
+ return "bg-transparent text-foreground border border-transparent hover:bg-hover-bg";
103
+ return "bg-primary-action text-on-primary-action border border-transparent hover:bg-primary-action-hover active:bg-primary-action-active";
107
104
  }
108
105
  const Button = forwardRef(function Button2({
109
106
  size = "md",
@@ -185,9 +182,9 @@ const Button = forwardRef(function Button2({
185
182
  className: cn(
186
183
  baseClasses,
187
184
  roundedLabelClass[labelSize],
185
+ heightClass[labelSize],
188
186
  paddingParts[0],
189
187
  paddingParts[1],
190
- paddingParts[2],
191
188
  hasLeft || hasRight ? gapClass[labelSize] : void 0,
192
189
  variantClasses,
193
190
  cursorClass,
@@ -1649,21 +1646,22 @@ const NAV_BTN_CLASS = cn(
1649
1646
  "p-0 outline-none"
1650
1647
  );
1651
1648
  function CustomCaption({
1652
- displayMonth,
1649
+ calendarMonth,
1653
1650
  displayIndex
1654
1651
  }) {
1655
- const { goToMonth, previousMonth, nextMonth, displayMonths } = useNavigation();
1652
+ const { goToMonth, previousMonth, nextMonth, months } = useDayPicker();
1656
1653
  const isDrawerRange = React__default.useContext(DrawerRangeCtx);
1657
1654
  const { disabledYears = [] } = React__default.useContext(DisabledDatesCtx);
1658
1655
  const [view, setView] = useState("days");
1656
+ const displayMonth = calendarMonth.date;
1659
1657
  const [pickerYear, setPickerYear] = useState(
1660
1658
  displayMonth.getFullYear()
1661
1659
  );
1662
1660
  const [yearRangeStart, setYearRangeStart] = useState(
1663
1661
  Math.floor(displayMonth.getFullYear() / 12) * 12
1664
1662
  );
1665
- const isFirst = displayMonths[0].getTime() === displayMonth.getTime();
1666
- const isLast = displayMonths[displayMonths.length - 1].getTime() === displayMonth.getTime();
1663
+ const isFirst = months[0].date.getTime() === displayMonth.getTime();
1664
+ const isLast = months[months.length - 1].date.getTime() === displayMonth.getTime();
1667
1665
  const idx = displayIndex ?? 0;
1668
1666
  const handlePrevYear = () => {
1669
1667
  const d = new Date(displayMonth);
@@ -1932,77 +1930,99 @@ function CustomCaption({
1932
1930
  const DAY_PICKER_CLASSES = {
1933
1931
  months: "flex flex-col sm:flex-row sm:gap-6",
1934
1932
  month: "space-y-2 relative",
1935
- caption: "flex justify-center pt-1 relative items-center mb-2",
1933
+ month_caption: "flex justify-center pt-1 relative items-center mb-2",
1936
1934
  caption_label: "text-[14px] leading-[20px] text-foreground",
1937
1935
  nav: "hidden",
1938
- nav_button: cn(
1939
- "h-[28px] w-[28px] inline-flex items-center justify-center",
1940
- "rounded-[6px] bg-transparent border border-border cursor-pointer",
1941
- "text-muted-foreground hover:bg-disabled-bg transition-colors duration-100",
1942
- "p-0 outline-none"
1943
- ),
1944
- nav_button_previous: "absolute left-1",
1945
- nav_button_next: "absolute right-1",
1946
- table: "w-full border-collapse",
1947
- head_row: "flex",
1948
- head_cell: "w-[36px] h-[32px] inline-flex items-center justify-center text-[12px] text-disabled font-normal",
1949
- row: "flex w-full mt-1",
1950
- cell: cn(
1936
+ button_previous: "absolute left-1",
1937
+ button_next: "absolute right-1",
1938
+ month_grid: "w-full border-collapse",
1939
+ weekdays: "flex",
1940
+ weekday: "w-[36px] h-[32px] inline-flex items-center justify-center text-[12px] text-disabled font-normal",
1941
+ week: "flex w-full mt-1",
1942
+ // In v9 modifier classes (range_start, range_end, etc.) are placed on the
1943
+ // outer `day` wrapper element. We use semantic marker class names so both
1944
+ // the wrapper and button can reference them.
1945
+ day: cn(
1951
1946
  "h-[36px] w-[36px] text-center p-0 relative overflow-hidden",
1952
- "[&:has(.day-range-middle)]:bg-range-bg",
1953
- "[&:has(.day-range-start)]:bg-range-bg",
1954
- "[&:has(.day-range-end)]:bg-range-bg",
1955
- "[&:has(.day-range-start)]:rounded-l-[6px]",
1956
- "[&:has(.day-range-end)]:rounded-r-[6px]",
1957
- "[&:first-child:has(.day-range-middle)]:rounded-l-[6px]",
1958
- "[&:last-child:has(.day-range-middle)]:rounded-r-[6px]",
1959
- "[&:first-child:has(.day-range-end)]:rounded-l-[6px]",
1960
- "[&:last-child:has(.day-range-start)]:rounded-r-[6px]",
1947
+ // Range band background on the wrapper
1948
+ "[&.is-range-middle]:bg-range-bg",
1949
+ "[&.is-range-start]:bg-range-bg",
1950
+ "[&.is-range-end]:bg-range-bg",
1951
+ "[&.is-range-start]:rounded-l-[6px]",
1952
+ "[&.is-range-end]:rounded-r-[6px]",
1953
+ "[&:first-child.is-range-middle]:rounded-l-[6px]",
1954
+ "[&:last-child.is-range-middle]:rounded-r-[6px]",
1955
+ "[&:first-child.is-range-end]:rounded-l-[6px]",
1956
+ "[&:last-child.is-range-start]:rounded-r-[6px]",
1961
1957
  "focus-within:relative focus-within:z-20"
1962
1958
  ),
1963
- day: cn(
1959
+ day_button: cn(
1964
1960
  "h-[36px] w-[36px] inline-flex items-center justify-center",
1965
1961
  "text-[14px] text-foreground rounded-[6px]",
1966
1962
  "border-0 bg-transparent cursor-pointer",
1967
1963
  "hover:bg-disabled-bg transition-colors duration-100",
1968
- "outline-none aria-selected:opacity-100 p-0"
1964
+ "outline-none p-0",
1965
+ // Selected (single mode)
1966
+ "[.is-selected_&]:!bg-primary-action [.is-selected_&]:!text-on-primary-action [.is-selected_&]:!rounded-[6px]",
1967
+ // Range start button styling
1968
+ "[.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",
1969
+ // Range end button styling
1970
+ "[.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",
1971
+ // Range middle button styling
1972
+ "[.is-range-middle_&]:!bg-range-bg [.is-range-middle_&]:!text-range-text [.is-range-middle_&]:!rounded-none",
1973
+ // Today (when not selected)
1974
+ "[.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",
1975
+ // Outside days
1976
+ "[.is-outside_&]:text-disabled [.is-outside_&]:opacity-50",
1977
+ "[.is-outside.is-selected_&]:!bg-transparent [.is-outside.is-selected_&]:!opacity-30",
1978
+ // Disabled days
1979
+ "[.is-disabled_&]:text-disabled [.is-disabled_&]:opacity-50 [.is-disabled_&]:cursor-not-allowed"
1969
1980
  ),
1970
- day_range_start: "day-range-start !bg-primary-action !text-on-primary-action !rounded-l-[6px] !rounded-r-none",
1971
- day_range_end: "day-range-end !bg-primary-action !text-on-primary-action !rounded-r-[6px] !rounded-l-none",
1972
- day_selected: "!bg-primary-action text-on-primary-action hover:!bg-primary-action focus:!bg-primary-action rounded-[6px]",
1973
- day_today: "[&:not([aria-selected=true])]:!bg-primary-action-light [&:not([aria-selected=true])]:text-foreground rounded-[6px]",
1974
- day_outside: "day-outside text-disabled opacity-50 aria-selected:bg-transparent aria-selected:opacity-30",
1975
- day_disabled: "text-disabled opacity-50 cursor-not-allowed",
1976
- day_range_middle: "day-range-middle !bg-range-bg !text-range-text !rounded-none",
1977
- day_hidden: "invisible"
1981
+ // Modifier classes applied to the `day` wrapper in v9
1982
+ selected: "is-selected",
1983
+ range_start: "is-range-start",
1984
+ range_end: "is-range-end",
1985
+ range_middle: "is-range-middle",
1986
+ today: "is-today",
1987
+ outside: "is-outside",
1988
+ disabled: "is-disabled",
1989
+ hidden: "invisible"
1978
1990
  };
1979
1991
  const DRAWER_DAY_PICKER_CLASSES = {
1980
1992
  ...DAY_PICKER_CLASSES,
1981
1993
  months: "flex flex-col gap-6 w-full",
1982
1994
  month: "space-y-2 relative w-full",
1983
- table: "w-full border-collapse table-fixed",
1984
- head_row: "flex w-full",
1985
- head_cell: "flex-1 h-[40px] inline-flex items-center justify-center text-[13px] text-disabled font-normal",
1986
- row: "flex w-full mt-1",
1987
- cell: cn(
1995
+ month_grid: "w-full border-collapse table-fixed",
1996
+ weekdays: "flex w-full",
1997
+ weekday: "flex-1 h-[40px] inline-flex items-center justify-center text-[13px] text-disabled font-normal",
1998
+ week: "flex w-full mt-1",
1999
+ day: cn(
1988
2000
  "h-[44px] flex-1 text-center p-0 relative overflow-hidden",
1989
- "[&:has(.day-range-middle)]:bg-range-bg",
1990
- "[&:has(.day-range-start)]:bg-range-bg",
1991
- "[&:has(.day-range-end)]:bg-range-bg",
1992
- "[&:has(.day-range-start)]:rounded-l-[8px]",
1993
- "[&:has(.day-range-end)]:rounded-r-[8px]",
1994
- "[&:first-child:has(.day-range-middle)]:rounded-l-[8px]",
1995
- "[&:last-child:has(.day-range-middle)]:rounded-r-[8px]",
1996
- "[&:first-child:has(.day-range-end)]:rounded-l-[8px]",
1997
- "[&:last-child:has(.day-range-start)]:rounded-r-[8px]",
2001
+ "[&.is-range-middle]:bg-range-bg",
2002
+ "[&.is-range-start]:bg-range-bg",
2003
+ "[&.is-range-end]:bg-range-bg",
2004
+ "[&.is-range-start]:rounded-l-[8px]",
2005
+ "[&.is-range-end]:rounded-r-[8px]",
2006
+ "[&:first-child.is-range-middle]:rounded-l-[8px]",
2007
+ "[&:last-child.is-range-middle]:rounded-r-[8px]",
2008
+ "[&:first-child.is-range-end]:rounded-l-[8px]",
2009
+ "[&:last-child.is-range-start]:rounded-r-[8px]",
1998
2010
  "focus-within:relative focus-within:z-20"
1999
2011
  ),
2000
- day: cn(
2012
+ day_button: cn(
2001
2013
  "h-[44px] w-full inline-flex items-center justify-center",
2002
2014
  "text-[16px] text-foreground rounded-[8px]",
2003
2015
  "border-0 bg-transparent cursor-pointer",
2004
2016
  "hover:bg-disabled-bg transition-colors duration-100",
2005
- "outline-none aria-selected:opacity-100 p-0"
2017
+ "outline-none p-0",
2018
+ "[.is-selected_&]:!bg-primary-action [.is-selected_&]:!text-on-primary-action [.is-selected_&]:!rounded-[8px]",
2019
+ "[.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",
2020
+ "[.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",
2021
+ "[.is-range-middle_&]:!bg-range-bg [.is-range-middle_&]:!text-range-text [.is-range-middle_&]:!rounded-none",
2022
+ "[.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",
2023
+ "[.is-outside_&]:text-disabled [.is-outside_&]:opacity-50",
2024
+ "[.is-outside.is-selected_&]:!bg-transparent [.is-outside.is-selected_&]:!opacity-30",
2025
+ "[.is-disabled_&]:text-disabled [.is-disabled_&]:opacity-50 [.is-disabled_&]:cursor-not-allowed"
2006
2026
  )
2007
2027
  };
2008
2028
  const DATE_ITEM_H = 40;
@@ -2470,7 +2490,7 @@ const DateInput = forwardRef(
2470
2490
  formatters: {
2471
2491
  formatWeekdayName: (date) => THAI_WEEKDAYS[date.getDay()]
2472
2492
  },
2473
- components: { Caption: CustomCaption }
2493
+ components: { MonthCaption: CustomCaption }
2474
2494
  }
2475
2495
  ) : /* @__PURE__ */ jsx(
2476
2496
  DayPicker,
@@ -2484,7 +2504,7 @@ const DateInput = forwardRef(
2484
2504
  formatters: {
2485
2505
  formatWeekdayName: (date) => THAI_WEEKDAYS[date.getDay()]
2486
2506
  },
2487
- components: { Caption: CustomCaption }
2507
+ components: { MonthCaption: CustomCaption }
2488
2508
  }
2489
2509
  );
2490
2510
  const calendarContent = /* @__PURE__ */ jsx(DisabledDatesCtx.Provider, { value: { disabledYears }, children: pickerInner });