@tide-design/components 0.26.0 → 0.27.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.
@@ -1,5 +1,14 @@
1
1
  import { InputSize } from "../_internal/constants/inputClass.js";
2
2
  import { ComponentProps, ReactElement } from "react";
3
+ /** `isDateUnavailable` 함수가 받는 날 정보. 날짜 문자열을 `Date`로 바꾸지 않고 요일을 볼 수 있다. */
4
+ export interface DateUnavailableInfo {
5
+ /** 판정할 날. ISO `"YYYY-MM-DD"`. */
6
+ date: string;
7
+ /** DatePicker `locale` 기준 주말인지 */
8
+ isWeekend: boolean;
9
+ /** 요일. `locale`과 무관하게 0 일요일 … 6 토요일(`Date.getDay()`와 같다). */
10
+ dayOfWeek: number;
11
+ }
3
12
  export interface DatePickerOwnProps {
4
13
  /** 고른 날(제어). ISO `"YYYY-MM-DD"`. `null`이면 빈 값이다. 주면 `onValueChange`로 바꾼다. */
5
14
  value?: string | null;
@@ -27,8 +36,8 @@ export interface DatePickerOwnProps {
27
36
  min?: string;
28
37
  /** 고를 수 있는 마지막 날(ISO). */
29
38
  max?: string;
30
- /** `true`를 돌려준 날은 달력에서 고를 수 없다(포커스는 간다). 인자는 ISO 문자열이다. */
31
- isDateUnavailable?: (date: string) => boolean;
39
+ /** 고를 수 없는 날(포커스는 간다). `"weekend"`는 `locale`의 주말을 막는다. 함수는 {@link DateUnavailableInfo} 객체 하나를 받는다. */
40
+ isDateUnavailable?: "weekend" | ((info: DateUnavailableInfo) => boolean);
32
41
  /** 달력 제목·요일·주 시작과 스크린리더 문구의 언어. 기본값 `"ko-KR"`. 입력 칸 순서는 `format`이 정한다. */
33
42
  locale?: string;
34
43
  /** 표시 형식. 토큰 `yyyy`·`MM`·`dd`(대소문자 구분)와 구분자. 기본값 `"yyyy-MM-dd"`. 값과 제출 형식은 바꾸지 않는다. */
@@ -3,6 +3,7 @@
3
3
  import { maxYear } from "../constants/calendarPicker.js";
4
4
  import { calendarClass, calendarHeaderClass } from "../constants/calendarClass.js";
5
5
  import { clampKey, fromMonthKey, monthKey, shiftYearMonth } from "../libs/calendarPicker.js";
6
+ import { toUnavailableMatcher } from "../libs/dateUnavailable.js";
6
7
  import { parseIsoDate, toIsoDate } from "../libs/isoDate.js";
7
8
  import { CalendarGrid } from "./CalendarGrid.js";
8
9
  import { CalendarMonthView } from "./CalendarMonthView.js";
@@ -30,7 +31,7 @@ function Calendar({ value, onValueChange, onPickerValueChange = onValueChange, m
30
31
  onChange: (date) => onValueChange(toIsoDate(toCalendarDate(date))),
31
32
  minValue,
32
33
  maxValue,
33
- isDateUnavailable: isDateUnavailable ? (date) => isDateUnavailable(toIsoDate(toCalendarDate(date))) : void 0,
34
+ isDateUnavailable: useMemo(() => toUnavailableMatcher(isDateUnavailable, locale), [isDateUnavailable, locale]),
34
35
  defaultFocusedValue: selected ? void 0 : reference,
35
36
  autoFocus,
36
37
  isReadOnly: readOnly,
@@ -7,6 +7,7 @@ import { defaultDateFormat } from "../constants/dateFormat.js";
7
7
  import { calendarIconClass, groupClass } from "../constants/datePickerClass.js";
8
8
  import { resolveDateFormat } from "../libs/dateFormat.js";
9
9
  import { useOpenOnFocus } from "../hooks/useOpenOnFocus.js";
10
+ import { toUnavailableMatcher } from "../libs/dateUnavailable.js";
10
11
  import { parseIsoDate, toIsoDate } from "../libs/isoDate.js";
11
12
  import { Calendar } from "./Calendar.js";
12
13
  import { DatePickerPopover } from "./DatePickerPopover.js";
@@ -14,7 +15,7 @@ import { DateSegments } from "./DateSegments.js";
14
15
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
15
16
  import { useMemo, useRef, useState } from "react";
16
17
  import { CalendarIcon } from "@tide-design/icons";
17
- import { mergeProps, mergeRefs, useDatePicker } from "react-aria";
18
+ import { mergeProps, mergeRefs, useDatePicker, useLocale } from "react-aria";
18
19
  import { useDatePickerState } from "react-stately";
19
20
  import { toCalendarDate } from "@internationalized/date";
20
21
 
@@ -36,7 +37,8 @@ function DatePickerGroup({ value, defaultValue, onValueChange, onOpenChange, nam
36
37
  const [initial] = useState(() => parseIsoDate(defaultValue));
37
38
  const minValue = useMemo(() => parseIsoDate(min), [min]);
38
39
  const maxValue = useMemo(() => parseIsoDate(max), [max]);
39
- const unavailable = useMemo(() => isDateUnavailable ? (date) => isDateUnavailable(toIso(date)) : void 0, [isDateUnavailable]);
40
+ const { locale } = useLocale();
41
+ const unavailable = useMemo(() => toUnavailableMatcher(isDateUnavailable, locale), [isDateUnavailable, locale]);
40
42
  const parts = useMemo(() => resolveDateFormat(format), [format]);
41
43
  const pickerProps = {
42
44
  id: control.id,
@@ -1,2 +1,2 @@
1
- import { DatePicker, DatePickerOwnProps, DatePickerProps } from "./DatePicker.js";
2
- export { DatePicker, type DatePickerOwnProps, type DatePickerProps };
1
+ import { DatePicker, DatePickerOwnProps, DatePickerProps, DateUnavailableInfo } from "./DatePicker.js";
2
+ export { DatePicker, type DatePickerOwnProps, type DatePickerProps, type DateUnavailableInfo };
@@ -0,0 +1,16 @@
1
+ import { toIsoDate } from "./isoDate.js";
2
+ import { getDayOfWeek, isWeekend, toCalendarDate } from "@internationalized/date";
3
+
4
+ // src/DatePicker/libs/dateUnavailable.ts
5
+ /** `isDateUnavailable` prop을 React Aria가 받는 판정 함수로 바꾼다. 주말은 `locale`을 따른다. */
6
+ function toUnavailableMatcher(isDateUnavailable, locale) {
7
+ if (isDateUnavailable === void 0) return void 0;
8
+ if (isDateUnavailable === "weekend") return (date) => isWeekend(date, locale);
9
+ return (date) => isDateUnavailable({
10
+ date: toIsoDate(toCalendarDate(date)),
11
+ isWeekend: isWeekend(date, locale),
12
+ dayOfWeek: getDayOfWeek(date, locale, "sun")
13
+ });
14
+ }
15
+
16
+ export { toUnavailableMatcher };
package/dist/index.d.ts CHANGED
@@ -80,7 +80,7 @@ import { Combobox, ComboboxOwnProps, ComboboxProps } from "./Combobox/Combobox.j
80
80
  import { ComboboxItem, ComboboxItemOwnProps, ComboboxItemProps } from "./Combobox/components/ComboboxItem.js";
81
81
  import { ComboboxSection, ComboboxSectionProps } from "./Combobox/components/ComboboxSection.js";
82
82
  import "./DatePicker/index.js";
83
- import { DatePicker, DatePickerOwnProps, DatePickerProps } from "./DatePicker/DatePicker.js";
83
+ import { DatePicker, DatePickerOwnProps, DatePickerProps, DateUnavailableInfo } from "./DatePicker/DatePicker.js";
84
84
  import "./Select/index.js";
85
85
  import { Select, SelectOwnProps, SelectProps } from "./Select/Select.js";
86
86
  import { SelectItem, SelectItemOwnProps, SelectItemProps } from "./Select/components/SelectItem.js";
@@ -123,4 +123,4 @@ import { TooltipTrigger, TooltipTriggerOwnProps, TooltipTriggerProps } from "./T
123
123
  import { TooltipPlacement } from "./Tooltip/types.js";
124
124
  import { TooltipContent, TooltipContentOwnProps, TooltipContentProps } from "./Tooltip/components/TooltipContent.js";
125
125
  import { Color, ColorFamilyName, ColorFamilyRegistry, FillVariant, Role, RoleRegistry, Size } from "./types.js";
126
- export { Accordion, type AccordionHeadingLevel, AccordionItem, type AccordionItemOwnProps, type AccordionItemProps, type AccordionOwnProps, AccordionPanel, type AccordionPanelOwnProps, type AccordionPanelProps, type AccordionProps, AccordionTrigger, type AccordionTriggerOwnProps, type AccordionTriggerProps, Alert, AlertDialog, type AlertDialogProps, type AlertOwnProps, type AlertProps, Avatar, type AvatarOwnProps, type AvatarProps, Badge, type BadgeOwnProps, type BadgeProps, Breadcrumb, BreadcrumbCurrent, type BreadcrumbCurrentProps, BreadcrumbItem, type BreadcrumbItemProps, BreadcrumbLink, type BreadcrumbLinkOwnProps, type BreadcrumbLinkProps, type BreadcrumbOwnProps, type BreadcrumbProps, Button, type ButtonOwnProps, type ButtonProps, Card, type CardOwnProps, type CardProps, Checkbox, CheckboxGroup, type CheckboxGroupOwnProps, type CheckboxGroupProps, type CheckboxOwnProps, type CheckboxProps, type CheckboxShape, type ChoiceOrientation, type Color, type ColorFamilyName, type ColorFamilyRegistry, Combobox, ComboboxItem, type ComboboxItemOwnProps, type ComboboxItemProps, type ComboboxOwnProps, type ComboboxProps, ComboboxSection, type ComboboxSectionProps, DatePicker, type DatePickerOwnProps, type DatePickerProps, Dialog, DialogClose, type DialogCloseOwnProps, type DialogCloseProps, DialogContent, type DialogContentOwnProps, type DialogContentProps, DialogDescription, type DialogDescriptionProps, DialogFooter, type DialogFooterProps, DialogHeader, type DialogHeaderAlign, type DialogHeaderOwnProps, type DialogHeaderProps, type DialogProps, type DialogSize, DialogTitle, type DialogTitleProps, DialogTrigger, type DialogTriggerOwnProps, type DialogTriggerProps, Field, type FieldOwnProps, type FieldProps, type FillVariant, IconButton, type IconButtonOwnProps, type IconButtonProps, Input, type InputOwnProps, type InputProps, Link, type LinkOwnProps, type LinkProps, type MaskFormatOptions, Menu, MenuContent, type MenuContentOwnProps, type MenuContentProps, MenuItem, type MenuItemOwnProps, type MenuItemProps, type MenuPlacement, type MenuProps, MenuSection, type MenuSectionProps, MenuTrigger, type MenuTriggerOwnProps, type MenuTriggerProps, NumberFormatInput, type NumberFormatInputOwnProps, type NumberFormatInputProps, type NumberFormatOptions, type NumericFormatOptions, type NumericRangeOptions, Pagination, PaginationEllipsis, type PaginationEllipsisOwnProps, type PaginationEllipsisProps, PaginationItem, type PaginationItemProps, PaginationLink, type PaginationLinkOwnProps, type PaginationLinkProps, PaginationNext, type PaginationNextOwnProps, type PaginationNextProps, type PaginationOwnProps, PaginationPrevious, type PaginationPreviousOwnProps, type PaginationPreviousProps, type PaginationProps, Popover, PopoverContent, type PopoverContentOwnProps, type PopoverContentProps, type PopoverPlacement, type PopoverProps, PopoverTrigger, type PopoverTriggerOwnProps, type PopoverTriggerProps, Progress, type ProgressOwnProps, type ProgressProps, Radio, RadioGroup, type RadioGroupOwnProps, type RadioGroupProps, type RadioOwnProps, type RadioProps, type Role, type RoleRegistry, Select, SelectItem, type SelectItemOwnProps, type SelectItemProps, type SelectOwnProps, type SelectProps, SelectSection, type SelectSectionProps, Separator, type SeparatorOwnProps, type SeparatorProps, type Size, Skeleton, type SkeletonOwnProps, type SkeletonProps, Spinner, type SpinnerOwnProps, type SpinnerProps, Switch, type SwitchOwnProps, type SwitchProps, Tab, TabList, type TabListOwnProps, type TabListProps, type TabOwnProps, TabPanel, type TabPanelOwnProps, type TabPanelProps, type TabProps, Table, TableBody, type TableBodyProps, TableCell, type TableCellProps, TableHead, type TableHeadProps, TableHeaderCell, type TableHeaderCellOwnProps, type TableHeaderCellProps, type TableProps, TableRow, type TableRowProps, Tabs, type TabsActivationMode, type TabsOrientation, type TabsOwnProps, type TabsProps, type TabsShape, Tag, TagGroup, type TagGroupOwnProps, type TagGroupProps, type TagOwnProps, type TagProps, Textarea, type TextareaOwnProps, type TextareaProps, type ToastAction, type ToastOptions, ToastQueue, type ToastQueueOptions, ToastRegion, type ToastRegionOwnProps, type ToastRegionProps, Tooltip, TooltipContent, type TooltipContentOwnProps, type TooltipContentProps, type TooltipPlacement, type TooltipProps, TooltipTrigger, type TooltipTriggerOwnProps, type TooltipTriggerProps, VisuallyHidden, type VisuallyHiddenProps, cn, formatNumber };
126
+ export { Accordion, type AccordionHeadingLevel, AccordionItem, type AccordionItemOwnProps, type AccordionItemProps, type AccordionOwnProps, AccordionPanel, type AccordionPanelOwnProps, type AccordionPanelProps, type AccordionProps, AccordionTrigger, type AccordionTriggerOwnProps, type AccordionTriggerProps, Alert, AlertDialog, type AlertDialogProps, type AlertOwnProps, type AlertProps, Avatar, type AvatarOwnProps, type AvatarProps, Badge, type BadgeOwnProps, type BadgeProps, Breadcrumb, BreadcrumbCurrent, type BreadcrumbCurrentProps, BreadcrumbItem, type BreadcrumbItemProps, BreadcrumbLink, type BreadcrumbLinkOwnProps, type BreadcrumbLinkProps, type BreadcrumbOwnProps, type BreadcrumbProps, Button, type ButtonOwnProps, type ButtonProps, Card, type CardOwnProps, type CardProps, Checkbox, CheckboxGroup, type CheckboxGroupOwnProps, type CheckboxGroupProps, type CheckboxOwnProps, type CheckboxProps, type CheckboxShape, type ChoiceOrientation, type Color, type ColorFamilyName, type ColorFamilyRegistry, Combobox, ComboboxItem, type ComboboxItemOwnProps, type ComboboxItemProps, type ComboboxOwnProps, type ComboboxProps, ComboboxSection, type ComboboxSectionProps, DatePicker, type DatePickerOwnProps, type DatePickerProps, type DateUnavailableInfo, Dialog, DialogClose, type DialogCloseOwnProps, type DialogCloseProps, DialogContent, type DialogContentOwnProps, type DialogContentProps, DialogDescription, type DialogDescriptionProps, DialogFooter, type DialogFooterProps, DialogHeader, type DialogHeaderAlign, type DialogHeaderOwnProps, type DialogHeaderProps, type DialogProps, type DialogSize, DialogTitle, type DialogTitleProps, DialogTrigger, type DialogTriggerOwnProps, type DialogTriggerProps, Field, type FieldOwnProps, type FieldProps, type FillVariant, IconButton, type IconButtonOwnProps, type IconButtonProps, Input, type InputOwnProps, type InputProps, Link, type LinkOwnProps, type LinkProps, type MaskFormatOptions, Menu, MenuContent, type MenuContentOwnProps, type MenuContentProps, MenuItem, type MenuItemOwnProps, type MenuItemProps, type MenuPlacement, type MenuProps, MenuSection, type MenuSectionProps, MenuTrigger, type MenuTriggerOwnProps, type MenuTriggerProps, NumberFormatInput, type NumberFormatInputOwnProps, type NumberFormatInputProps, type NumberFormatOptions, type NumericFormatOptions, type NumericRangeOptions, Pagination, PaginationEllipsis, type PaginationEllipsisOwnProps, type PaginationEllipsisProps, PaginationItem, type PaginationItemProps, PaginationLink, type PaginationLinkOwnProps, type PaginationLinkProps, PaginationNext, type PaginationNextOwnProps, type PaginationNextProps, type PaginationOwnProps, PaginationPrevious, type PaginationPreviousOwnProps, type PaginationPreviousProps, type PaginationProps, Popover, PopoverContent, type PopoverContentOwnProps, type PopoverContentProps, type PopoverPlacement, type PopoverProps, PopoverTrigger, type PopoverTriggerOwnProps, type PopoverTriggerProps, Progress, type ProgressOwnProps, type ProgressProps, Radio, RadioGroup, type RadioGroupOwnProps, type RadioGroupProps, type RadioOwnProps, type RadioProps, type Role, type RoleRegistry, Select, SelectItem, type SelectItemOwnProps, type SelectItemProps, type SelectOwnProps, type SelectProps, SelectSection, type SelectSectionProps, Separator, type SeparatorOwnProps, type SeparatorProps, type Size, Skeleton, type SkeletonOwnProps, type SkeletonProps, Spinner, type SpinnerOwnProps, type SpinnerProps, Switch, type SwitchOwnProps, type SwitchProps, Tab, TabList, type TabListOwnProps, type TabListProps, type TabOwnProps, TabPanel, type TabPanelOwnProps, type TabPanelProps, type TabProps, Table, TableBody, type TableBodyProps, TableCell, type TableCellProps, TableHead, type TableHeadProps, TableHeaderCell, type TableHeaderCellOwnProps, type TableHeaderCellProps, type TableProps, TableRow, type TableRowProps, Tabs, type TabsActivationMode, type TabsOrientation, type TabsOwnProps, type TabsProps, type TabsShape, Tag, TagGroup, type TagGroupOwnProps, type TagGroupProps, type TagOwnProps, type TagProps, Textarea, type TextareaOwnProps, type TextareaProps, type ToastAction, type ToastOptions, ToastQueue, type ToastQueueOptions, ToastRegion, type ToastRegionOwnProps, type ToastRegionProps, Tooltip, TooltipContent, type TooltipContentOwnProps, type TooltipContentProps, type TooltipPlacement, type TooltipProps, TooltipTrigger, type TooltipTriggerOwnProps, type TooltipTriggerProps, VisuallyHidden, type VisuallyHiddenProps, cn, formatNumber };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tide-design/components",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "Tide 디자인 시스템의 React Component",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -38,8 +38,8 @@
38
38
  "@maskito/core": "5.6.1",
39
39
  "@maskito/kit": "5.6.1",
40
40
  "@maskito/react": "5.6.1",
41
- "@tide-design/foundation": "0.26.0",
42
- "@tide-design/icons": "0.26.0",
41
+ "@tide-design/foundation": "0.27.0",
42
+ "@tide-design/icons": "0.27.0",
43
43
  "clsx": "^2.1.1",
44
44
  "react-aria": "^3.53.1",
45
45
  "react-number-format": "^5.4.5",