@sarunyu/system-one 4.9.3 → 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.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) {
@@ -1649,21 +1649,22 @@ const NAV_BTN_CLASS = cn(
1649
1649
  "p-0 outline-none"
1650
1650
  );
1651
1651
  function CustomCaption({
1652
- displayMonth,
1652
+ calendarMonth,
1653
1653
  displayIndex
1654
1654
  }) {
1655
- const { goToMonth, previousMonth, nextMonth, displayMonths } = useNavigation();
1655
+ const { goToMonth, previousMonth, nextMonth, months } = useDayPicker();
1656
1656
  const isDrawerRange = React__default.useContext(DrawerRangeCtx);
1657
1657
  const { disabledYears = [] } = React__default.useContext(DisabledDatesCtx);
1658
1658
  const [view, setView] = useState("days");
1659
+ const displayMonth = calendarMonth.date;
1659
1660
  const [pickerYear, setPickerYear] = useState(
1660
1661
  displayMonth.getFullYear()
1661
1662
  );
1662
1663
  const [yearRangeStart, setYearRangeStart] = useState(
1663
1664
  Math.floor(displayMonth.getFullYear() / 12) * 12
1664
1665
  );
1665
- const isFirst = displayMonths[0].getTime() === displayMonth.getTime();
1666
- const isLast = displayMonths[displayMonths.length - 1].getTime() === displayMonth.getTime();
1666
+ const isFirst = months[0].date.getTime() === displayMonth.getTime();
1667
+ const isLast = months[months.length - 1].date.getTime() === displayMonth.getTime();
1667
1668
  const idx = displayIndex ?? 0;
1668
1669
  const handlePrevYear = () => {
1669
1670
  const d = new Date(displayMonth);
@@ -1932,77 +1933,99 @@ function CustomCaption({
1932
1933
  const DAY_PICKER_CLASSES = {
1933
1934
  months: "flex flex-col sm:flex-row sm:gap-6",
1934
1935
  month: "space-y-2 relative",
1935
- caption: "flex justify-center pt-1 relative items-center mb-2",
1936
+ month_caption: "flex justify-center pt-1 relative items-center mb-2",
1936
1937
  caption_label: "text-[14px] leading-[20px] text-foreground",
1937
1938
  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(
1939
+ button_previous: "absolute left-1",
1940
+ button_next: "absolute right-1",
1941
+ month_grid: "w-full border-collapse",
1942
+ weekdays: "flex",
1943
+ weekday: "w-[36px] h-[32px] inline-flex items-center justify-center text-[12px] text-disabled font-normal",
1944
+ week: "flex w-full mt-1",
1945
+ // In v9 modifier classes (range_start, range_end, etc.) are placed on the
1946
+ // outer `day` wrapper element. We use semantic marker class names so both
1947
+ // the wrapper and button can reference them.
1948
+ day: cn(
1951
1949
  "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]",
1950
+ // Range band background on the wrapper
1951
+ "[&.is-range-middle]:bg-range-bg",
1952
+ "[&.is-range-start]:bg-range-bg",
1953
+ "[&.is-range-end]:bg-range-bg",
1954
+ "[&.is-range-start]:rounded-l-[6px]",
1955
+ "[&.is-range-end]:rounded-r-[6px]",
1956
+ "[&:first-child.is-range-middle]:rounded-l-[6px]",
1957
+ "[&:last-child.is-range-middle]:rounded-r-[6px]",
1958
+ "[&:first-child.is-range-end]:rounded-l-[6px]",
1959
+ "[&:last-child.is-range-start]:rounded-r-[6px]",
1961
1960
  "focus-within:relative focus-within:z-20"
1962
1961
  ),
1963
- day: cn(
1962
+ day_button: cn(
1964
1963
  "h-[36px] w-[36px] inline-flex items-center justify-center",
1965
1964
  "text-[14px] text-foreground rounded-[6px]",
1966
1965
  "border-0 bg-transparent cursor-pointer",
1967
1966
  "hover:bg-disabled-bg transition-colors duration-100",
1968
- "outline-none aria-selected:opacity-100 p-0"
1967
+ "outline-none p-0",
1968
+ // Selected (single mode)
1969
+ "[.is-selected_&]:!bg-primary-action [.is-selected_&]:!text-on-primary-action [.is-selected_&]:!rounded-[6px]",
1970
+ // Range start button styling
1971
+ "[.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",
1972
+ // Range end button styling
1973
+ "[.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",
1974
+ // Range middle button styling
1975
+ "[.is-range-middle_&]:!bg-range-bg [.is-range-middle_&]:!text-range-text [.is-range-middle_&]:!rounded-none",
1976
+ // Today (when not selected)
1977
+ "[.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",
1978
+ // Outside days
1979
+ "[.is-outside_&]:text-disabled [.is-outside_&]:opacity-50",
1980
+ "[.is-outside.is-selected_&]:!bg-transparent [.is-outside.is-selected_&]:!opacity-30",
1981
+ // Disabled days
1982
+ "[.is-disabled_&]:text-disabled [.is-disabled_&]:opacity-50 [.is-disabled_&]:cursor-not-allowed"
1969
1983
  ),
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"
1984
+ // Modifier classes applied to the `day` wrapper in v9
1985
+ selected: "is-selected",
1986
+ range_start: "is-range-start",
1987
+ range_end: "is-range-end",
1988
+ range_middle: "is-range-middle",
1989
+ today: "is-today",
1990
+ outside: "is-outside",
1991
+ disabled: "is-disabled",
1992
+ hidden: "invisible"
1978
1993
  };
1979
1994
  const DRAWER_DAY_PICKER_CLASSES = {
1980
1995
  ...DAY_PICKER_CLASSES,
1981
1996
  months: "flex flex-col gap-6 w-full",
1982
1997
  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(
1998
+ month_grid: "w-full border-collapse table-fixed",
1999
+ weekdays: "flex w-full",
2000
+ weekday: "flex-1 h-[40px] inline-flex items-center justify-center text-[13px] text-disabled font-normal",
2001
+ week: "flex w-full mt-1",
2002
+ day: cn(
1988
2003
  "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]",
2004
+ "[&.is-range-middle]:bg-range-bg",
2005
+ "[&.is-range-start]:bg-range-bg",
2006
+ "[&.is-range-end]:bg-range-bg",
2007
+ "[&.is-range-start]:rounded-l-[8px]",
2008
+ "[&.is-range-end]:rounded-r-[8px]",
2009
+ "[&:first-child.is-range-middle]:rounded-l-[8px]",
2010
+ "[&:last-child.is-range-middle]:rounded-r-[8px]",
2011
+ "[&:first-child.is-range-end]:rounded-l-[8px]",
2012
+ "[&:last-child.is-range-start]:rounded-r-[8px]",
1998
2013
  "focus-within:relative focus-within:z-20"
1999
2014
  ),
2000
- day: cn(
2015
+ day_button: cn(
2001
2016
  "h-[44px] w-full inline-flex items-center justify-center",
2002
2017
  "text-[16px] text-foreground rounded-[8px]",
2003
2018
  "border-0 bg-transparent cursor-pointer",
2004
2019
  "hover:bg-disabled-bg transition-colors duration-100",
2005
- "outline-none aria-selected:opacity-100 p-0"
2020
+ "outline-none p-0",
2021
+ "[.is-selected_&]:!bg-primary-action [.is-selected_&]:!text-on-primary-action [.is-selected_&]:!rounded-[8px]",
2022
+ "[.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",
2023
+ "[.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",
2024
+ "[.is-range-middle_&]:!bg-range-bg [.is-range-middle_&]:!text-range-text [.is-range-middle_&]:!rounded-none",
2025
+ "[.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",
2026
+ "[.is-outside_&]:text-disabled [.is-outside_&]:opacity-50",
2027
+ "[.is-outside.is-selected_&]:!bg-transparent [.is-outside.is-selected_&]:!opacity-30",
2028
+ "[.is-disabled_&]:text-disabled [.is-disabled_&]:opacity-50 [.is-disabled_&]:cursor-not-allowed"
2006
2029
  )
2007
2030
  };
2008
2031
  const DATE_ITEM_H = 40;
@@ -2470,7 +2493,7 @@ const DateInput = forwardRef(
2470
2493
  formatters: {
2471
2494
  formatWeekdayName: (date) => THAI_WEEKDAYS[date.getDay()]
2472
2495
  },
2473
- components: { Caption: CustomCaption }
2496
+ components: { MonthCaption: CustomCaption }
2474
2497
  }
2475
2498
  ) : /* @__PURE__ */ jsx(
2476
2499
  DayPicker,
@@ -2484,7 +2507,7 @@ const DateInput = forwardRef(
2484
2507
  formatters: {
2485
2508
  formatWeekdayName: (date) => THAI_WEEKDAYS[date.getDay()]
2486
2509
  },
2487
- components: { Caption: CustomCaption }
2510
+ components: { MonthCaption: CustomCaption }
2488
2511
  }
2489
2512
  );
2490
2513
  const calendarContent = /* @__PURE__ */ jsx(DisabledDatesCtx.Provider, { value: { disabledYears }, children: pickerInner });
@@ -4596,37 +4619,43 @@ const sizeStyles = {
4596
4619
  const variantStyles = {
4597
4620
  blue: {
4598
4621
  bg: "bg-[var(--fill-blue-50)]",
4599
- text: "text-[var(--fill-blue-700)]"
4622
+ text: "text-[var(--fill-blue-700)]",
4623
+ color: "var(--fill-blue-700)"
4600
4624
  },
4601
4625
  green: {
4602
4626
  bg: "bg-[var(--fill-green-100)]",
4603
- text: "text-[var(--fill-green-600)]"
4627
+ text: "text-[var(--fill-green-600)]",
4628
+ color: "var(--fill-green-600)"
4604
4629
  },
4605
4630
  yellow: {
4606
4631
  bg: "bg-[var(--fill-yellow-100)]",
4607
- text: "text-[var(--fill-yellow-600)]"
4632
+ text: "text-[var(--fill-yellow-600)]",
4633
+ color: "var(--fill-yellow-600)"
4608
4634
  },
4609
4635
  red: {
4610
4636
  bg: "bg-[var(--fill-red-100)]",
4611
- text: "text-[var(--fill-red-600)]"
4637
+ text: "text-[var(--fill-red-600)]",
4638
+ color: "var(--fill-red-600)"
4612
4639
  },
4613
4640
  gray: {
4614
4641
  bg: "bg-[var(--fill-gray-100)]",
4615
- text: "text-subtle-text"
4642
+ text: "text-subtle-text",
4643
+ color: "var(--subtle-text)"
4616
4644
  },
4617
4645
  lime: {
4618
4646
  bg: "bg-[var(--fill-lime-100)]",
4619
- text: "text-[var(--fill-lime-600)]"
4647
+ text: "text-[var(--fill-lime-600)]",
4648
+ color: "var(--fill-lime-600)"
4620
4649
  }
4621
4650
  };
4622
- function CircleIcon({ disabled }) {
4651
+ function CircleIcon({ disabled, color }) {
4623
4652
  return /* @__PURE__ */ jsx(
4624
4653
  Circle,
4625
4654
  {
4626
4655
  "aria-hidden": "true",
4627
4656
  weight: "regular",
4628
4657
  className: "h-3.5 w-3.5 shrink-0",
4629
- color: disabled ? "var(--disabled)" : "var(--subtle-text)"
4658
+ color: disabled ? "var(--disabled)" : color
4630
4659
  }
4631
4660
  );
4632
4661
  }
@@ -4667,7 +4696,7 @@ const Tag = forwardRef(function Tag2({
4667
4696
  className
4668
4697
  ),
4669
4698
  children: [
4670
- icon && /* @__PURE__ */ jsx(CircleIcon, { disabled: isDisabled }),
4699
+ icon && /* @__PURE__ */ jsx(CircleIcon, { disabled: isDisabled, color: v.color }),
4671
4700
  /* @__PURE__ */ jsx("span", { className: cn("whitespace-nowrap font-normal", s.text, textClass), children: text }),
4672
4701
  close && /* @__PURE__ */ jsx(
4673
4702
  "span",