@tide-design/components 0.11.1 → 0.11.2
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/Accordion/Accordion.d.ts +24 -0
- package/dist/Accordion/Accordion.js +32 -0
- package/dist/Accordion/components/AccordionItem.d.ts +14 -0
- package/dist/Accordion/components/AccordionItem.js +51 -0
- package/dist/Accordion/components/AccordionPanel.d.ts +13 -0
- package/dist/Accordion/components/AccordionPanel.js +27 -0
- package/dist/Accordion/components/AccordionTrigger.d.ts +17 -0
- package/dist/Accordion/components/AccordionTrigger.js +39 -0
- package/dist/Accordion/constants/accordionClass.js +12 -0
- package/dist/Accordion/hooks/useAccordionContext.js +8 -0
- package/dist/Accordion/hooks/useAccordionItemContext.js +13 -0
- package/dist/Accordion/index.d.ts +6 -0
- package/dist/Accordion/types.d.ts +2 -0
- package/dist/{Alert.d.ts → Alert/Alert.d.ts} +1 -1
- package/dist/{Alert.js → Alert/Alert.js} +5 -5
- package/dist/Alert/index.d.ts +2 -0
- package/dist/{AlertDialog.d.ts → AlertDialog/AlertDialog.d.ts} +1 -1
- package/dist/{AlertDialog.js → AlertDialog/AlertDialog.js} +2 -2
- package/dist/AlertDialog/index.d.ts +2 -0
- package/dist/{Avatar.d.ts → Avatar/Avatar.d.ts} +1 -1
- package/dist/{Avatar.js → Avatar/Avatar.js} +2 -2
- package/dist/Avatar/index.d.ts +2 -0
- package/dist/{Badge.d.ts → Badge/Badge.d.ts} +1 -1
- package/dist/{Badge.js → Badge/Badge.js} +2 -2
- package/dist/Badge/index.d.ts +2 -0
- package/dist/Breadcrumb/Breadcrumb.d.ts +11 -0
- package/dist/Breadcrumb/Breadcrumb.js +21 -0
- package/dist/Breadcrumb/components/BreadcrumbCurrent.d.ts +4 -0
- package/dist/Breadcrumb/components/BreadcrumbCurrent.js +15 -0
- package/dist/Breadcrumb/components/BreadcrumbItem.d.ts +4 -0
- package/dist/Breadcrumb/components/BreadcrumbItem.js +16 -0
- package/dist/Breadcrumb/components/BreadcrumbLink.d.ts +10 -0
- package/dist/Breadcrumb/components/BreadcrumbLink.js +15 -0
- package/dist/Breadcrumb/constants/breadcrumbClass.js +8 -0
- package/dist/Breadcrumb/index.d.ts +5 -0
- package/dist/{Button.d.ts → Button/Button.d.ts} +3 -7
- package/dist/{Button.js → Button/Button.js} +8 -27
- package/dist/Button/components/Icon.js +13 -0
- package/dist/Button/constants/buttonClass.js +17 -0
- package/dist/Button/index.d.ts +2 -0
- package/dist/Button/types.d.ts +5 -0
- package/dist/{Card.js → Card/Card.js} +2 -2
- package/dist/Card/index.d.ts +2 -0
- package/dist/{Checkbox.d.ts → Checkbox/Checkbox.d.ts} +2 -2
- package/dist/{Checkbox.js → Checkbox/Checkbox.js} +5 -5
- package/dist/Checkbox/index.d.ts +2 -0
- package/dist/{CheckboxGroup.d.ts → CheckboxGroup/CheckboxGroup.d.ts} +3 -3
- package/dist/{CheckboxGroup.js → CheckboxGroup/CheckboxGroup.js} +6 -10
- package/dist/CheckboxGroup/index.d.ts +3 -0
- package/dist/{Combobox.d.ts → Combobox/Combobox.d.ts} +2 -17
- package/dist/{Combobox.js → Combobox/Combobox.js} +10 -99
- package/dist/Combobox/components/ComboboxItem.d.ts +9 -0
- package/dist/Combobox/components/ComboboxItem.js +17 -0
- package/dist/Combobox/components/ComboboxPopover.js +23 -0
- package/dist/Combobox/components/ComboboxPopoverInner.js +50 -0
- package/dist/Combobox/components/ComboboxSection.d.ts +7 -0
- package/dist/Combobox/components/ComboboxSection.js +15 -0
- package/dist/Combobox/constants/comboboxClass.js +21 -0
- package/dist/Combobox/index.d.ts +4 -0
- package/dist/Dialog/Dialog.d.ts +8 -0
- package/dist/Dialog/Dialog.js +18 -0
- package/dist/Dialog/components/DialogClose.d.ts +13 -0
- package/dist/Dialog/components/DialogClose.js +35 -0
- package/dist/Dialog/components/DialogContent.d.ts +15 -0
- package/dist/Dialog/components/DialogContent.js +31 -0
- package/dist/Dialog/components/DialogContentInner.js +68 -0
- package/dist/Dialog/components/DialogDescription.d.ts +7 -0
- package/dist/Dialog/components/DialogDescription.js +23 -0
- package/dist/Dialog/components/DialogFooter.d.ts +4 -0
- package/dist/Dialog/components/DialogFooter.js +13 -0
- package/dist/Dialog/components/DialogTitle.d.ts +7 -0
- package/dist/Dialog/components/DialogTitle.js +23 -0
- package/dist/Dialog/components/DialogTrigger.d.ts +13 -0
- package/dist/Dialog/components/DialogTrigger.js +49 -0
- package/dist/Dialog/constants/dialogClass.js +12 -0
- package/dist/Dialog/hooks/useDialogPartsContext.js +13 -0
- package/dist/Dialog/hooks/usePartId.js +17 -0
- package/dist/Dialog/index.d.ts +10 -0
- package/dist/Dialog/types.d.ts +2 -0
- package/dist/{Field.js → Field/Field.js} +3 -3
- package/dist/Field/index.d.ts +2 -0
- package/dist/{IconButton.d.ts → IconButton/IconButton.d.ts} +1 -1
- package/dist/{IconButton.js → IconButton/IconButton.js} +5 -5
- package/dist/IconButton/index.d.ts +2 -0
- package/dist/{Input.d.ts → Input/Input.d.ts} +1 -1
- package/dist/{Input.js → Input/Input.js} +4 -4
- package/dist/Input/index.d.ts +2 -0
- package/dist/{Link.d.ts → Link/Link.d.ts} +1 -1
- package/dist/{Link.js → Link/Link.js} +2 -2
- package/dist/Link/index.d.ts +2 -0
- package/dist/Menu/Menu.d.ts +16 -0
- package/dist/Menu/Menu.js +43 -0
- package/dist/Menu/components/MenuContent.d.ts +16 -0
- package/dist/Menu/components/MenuContent.js +30 -0
- package/dist/Menu/components/MenuContentInner.js +67 -0
- package/dist/Menu/components/MenuItem.d.ts +17 -0
- package/dist/Menu/components/MenuItem.js +16 -0
- package/dist/Menu/components/MenuItemView.js +34 -0
- package/dist/Menu/components/MenuSection.d.ts +13 -0
- package/dist/Menu/components/MenuSection.js +15 -0
- package/dist/Menu/components/MenuSectionView.js +33 -0
- package/dist/Menu/components/MenuTrigger.d.ts +13 -0
- package/dist/Menu/components/MenuTrigger.js +53 -0
- package/dist/Menu/hooks/useMenuContext.js +13 -0
- package/dist/Menu/index.d.ts +7 -0
- package/dist/Menu/types.d.ts +4 -0
- package/dist/Pagination/Pagination.d.ts +11 -0
- package/dist/Pagination/Pagination.js +21 -0
- package/dist/Pagination/components/PaginationEllipsis.d.ts +7 -0
- package/dist/Pagination/components/PaginationEllipsis.js +17 -0
- package/dist/Pagination/components/PaginationItem.d.ts +4 -0
- package/dist/Pagination/components/PaginationItem.js +9 -0
- package/dist/Pagination/components/PaginationLink.d.ts +15 -0
- package/dist/Pagination/components/PaginationLink.js +23 -0
- package/dist/Pagination/components/PaginationNext.d.ts +5 -0
- package/dist/Pagination/components/PaginationNext.js +18 -0
- package/dist/Pagination/components/PaginationPrevious.d.ts +5 -0
- package/dist/Pagination/components/PaginationPrevious.js +18 -0
- package/dist/Pagination/constants/paginationClass.js +6 -0
- package/dist/Pagination/index.d.ts +7 -0
- package/dist/Pagination/types.d.ts +6 -0
- package/dist/Popover/Popover.d.ts +16 -0
- package/dist/Popover/Popover.js +43 -0
- package/dist/Popover/components/PopoverContent.d.ts +14 -0
- package/dist/Popover/components/PopoverContent.js +30 -0
- package/dist/Popover/components/PopoverContentInner.js +48 -0
- package/dist/Popover/components/PopoverTrigger.d.ts +13 -0
- package/dist/Popover/components/PopoverTrigger.js +51 -0
- package/dist/Popover/constants/popoverClass.js +6 -0
- package/dist/Popover/hooks/usePopoverContext.js +13 -0
- package/dist/Popover/index.d.ts +5 -0
- package/dist/Popover/types.d.ts +3 -0
- package/dist/{Progress.d.ts → Progress/Progress.d.ts} +1 -1
- package/dist/{Progress.js → Progress/Progress.js} +2 -2
- package/dist/Progress/index.d.ts +2 -0
- package/dist/{Radio.d.ts → Radio/Radio.d.ts} +2 -2
- package/dist/{Radio.js → Radio/Radio.js} +5 -5
- package/dist/Radio/index.d.ts +2 -0
- package/dist/{RadioGroup.d.ts → RadioGroup/RadioGroup.d.ts} +1 -1
- package/dist/{RadioGroup.js → RadioGroup/RadioGroup.js} +5 -5
- package/dist/RadioGroup/index.d.ts +2 -0
- package/dist/{Select.d.ts → Select/Select.d.ts} +2 -17
- package/dist/Select/Select.js +97 -0
- package/dist/Select/components/SelectItem.d.ts +9 -0
- package/dist/Select/components/SelectItem.js +17 -0
- package/dist/Select/components/SelectPopover.js +23 -0
- package/dist/Select/components/SelectPopoverInner.js +51 -0
- package/dist/Select/components/SelectSection.d.ts +7 -0
- package/dist/Select/components/SelectSection.js +15 -0
- package/dist/Select/constants/selectClass.js +7 -0
- package/dist/Select/index.d.ts +4 -0
- package/dist/{Separator.js → Separator/Separator.js} +2 -2
- package/dist/Separator/index.d.ts +2 -0
- package/dist/{Skeleton.d.ts → Skeleton/Skeleton.d.ts} +1 -1
- package/dist/{Skeleton.js → Skeleton/Skeleton.js} +2 -2
- package/dist/Skeleton/index.d.ts +2 -0
- package/dist/{Spinner.d.ts → Spinner/Spinner.d.ts} +1 -1
- package/dist/{Spinner.js → Spinner/Spinner.js} +2 -2
- package/dist/Spinner/index.d.ts +2 -0
- package/dist/{Switch.d.ts → Switch/Switch.d.ts} +1 -1
- package/dist/{Switch.js → Switch/Switch.js} +3 -3
- package/dist/Switch/index.d.ts +2 -0
- package/dist/Table/Table.d.ts +7 -0
- package/dist/Table/Table.js +17 -0
- package/dist/Table/components/TableBody.d.ts +4 -0
- package/dist/Table/components/TableBody.js +9 -0
- package/dist/Table/components/TableCell.d.ts +4 -0
- package/dist/Table/components/TableCell.js +14 -0
- package/dist/Table/components/TableHead.d.ts +4 -0
- package/dist/Table/components/TableHead.js +9 -0
- package/dist/Table/components/TableHeaderCell.d.ts +13 -0
- package/dist/Table/components/TableHeaderCell.js +18 -0
- package/dist/Table/components/TableRow.d.ts +4 -0
- package/dist/Table/components/TableRow.js +14 -0
- package/dist/Table/constants/tableClass.js +7 -0
- package/dist/Table/index.d.ts +7 -0
- package/dist/Tabs/Tabs.d.ts +34 -0
- package/dist/Tabs/Tabs.js +56 -0
- package/dist/Tabs/components/Tab.d.ts +12 -0
- package/dist/Tabs/components/Tab.js +16 -0
- package/dist/Tabs/components/TabList.d.ts +10 -0
- package/dist/Tabs/components/TabList.js +47 -0
- package/dist/Tabs/components/TabPanel.d.ts +10 -0
- package/dist/Tabs/components/TabPanel.js +27 -0
- package/dist/Tabs/components/TabView.js +29 -0
- package/dist/Tabs/constants/tabsClass.js +23 -0
- package/dist/Tabs/hooks/useTabsContext.js +13 -0
- package/dist/Tabs/index.d.ts +6 -0
- package/dist/Tabs/types.d.ts +5 -0
- package/dist/Tag/Tag.d.ts +18 -0
- package/dist/Tag/Tag.js +15 -0
- package/dist/{Tag.d.ts → Tag/components/TagGroup.d.ts} +0 -17
- package/dist/Tag/components/TagGroup.js +49 -0
- package/dist/Tag/components/TagView.js +49 -0
- package/dist/Tag/constants/tagClass.js +13 -0
- package/dist/Tag/hooks/useTagGroupContext.js +8 -0
- package/dist/Tag/index.d.ts +3 -0
- package/dist/{Textarea.d.ts → Textarea/Textarea.d.ts} +1 -1
- package/dist/{Textarea.js → Textarea/Textarea.js} +4 -4
- package/dist/Textarea/index.d.ts +2 -0
- package/dist/Toast/Toast.d.ts +15 -0
- package/dist/Toast/Toast.js +43 -0
- package/dist/Toast/components/Region.js +28 -0
- package/dist/Toast/components/ToastItem.js +82 -0
- package/dist/Toast/constants/toastClass.js +8 -0
- package/dist/Toast/index.d.ts +4 -0
- package/dist/Toast/libs/mergeEntries.js +19 -0
- package/dist/Toast/libs/toastQueue.d.ts +20 -0
- package/dist/Toast/libs/toastQueue.js +49 -0
- package/dist/{Toast.d.ts → Toast/types.d.ts} +4 -33
- package/dist/Tooltip/Tooltip.d.ts +25 -0
- package/dist/Tooltip/Tooltip.js +42 -0
- package/dist/Tooltip/components/TooltipContent.d.ts +14 -0
- package/dist/Tooltip/components/TooltipContent.js +31 -0
- package/dist/Tooltip/components/TooltipContentInner.js +43 -0
- package/dist/Tooltip/components/TooltipTrigger.d.ts +14 -0
- package/dist/Tooltip/components/TooltipTrigger.js +38 -0
- package/dist/Tooltip/constants/tooltipClass.js +6 -0
- package/dist/Tooltip/hooks/useTooltipContext.js +13 -0
- package/dist/Tooltip/index.d.ts +5 -0
- package/dist/Tooltip/types.d.ts +3 -0
- package/dist/{Typography.js → Typography/Typography.js} +2 -2
- package/dist/Typography/index.d.ts +2 -0
- package/dist/{VisuallyHidden.js → VisuallyHidden/VisuallyHidden.js} +2 -2
- package/dist/VisuallyHidden/index.d.ts +2 -0
- package/dist/_internal/components/DialogRoot.d.ts +11 -0
- package/dist/_internal/components/DialogRoot.js +41 -0
- package/dist/_internal/components/ListBoxNodes/ListBoxNodes.js +35 -0
- package/dist/_internal/components/ListBoxNodes/components/ListBoxOptionView.js +42 -0
- package/dist/_internal/components/ListBoxNodes/components/ListBoxSectionView.js +33 -0
- package/dist/{components/ListBoxNodes.d.ts → _internal/components/ListBoxNodes/types.d.ts} +1 -1
- package/dist/{components → _internal/components}/OverlayPortal.js +1 -1
- package/dist/{constants → _internal/constants}/alertClass.js +1 -1
- package/dist/{constants → _internal/constants}/choiceClass.js +1 -1
- package/dist/_internal/constants/choiceGroupClass.d.ts +2 -0
- package/dist/_internal/constants/choiceGroupClass.js +8 -0
- package/dist/{constants → _internal/constants}/inputClass.d.ts +1 -1
- package/dist/{constants → _internal/constants}/inputClass.js +1 -1
- package/dist/{constants → _internal/constants}/listClass.js +1 -1
- package/dist/{constants → _internal/constants}/overlayClass.js +1 -1
- package/dist/{constants → _internal/constants}/pressableClass.js +1 -1
- package/dist/{hooks → _internal/hooks}/useChoiceGroup.js +1 -1
- package/dist/{hooks → _internal/hooks}/useCloseOnTab.js +1 -1
- package/dist/_internal/hooks/useDialogContext.js +14 -0
- package/dist/{hooks → _internal/hooks}/useFieldControl.js +1 -1
- package/dist/{hooks → _internal/hooks}/useOverlayPresence.js +1 -1
- package/dist/{hooks → _internal/hooks}/useOverlayTheme.js +1 -1
- package/dist/{hooks → _internal/hooks}/usePopoverOverlay.js +1 -1
- package/dist/{libs → _internal/libs}/alertStatusIcon.js +1 -1
- package/dist/{libs → _internal/libs}/cn.js +1 -1
- package/dist/{libs → _internal/libs}/listCollection.js +1 -1
- package/dist/{libs → _internal/libs}/overlayPosition.js +1 -1
- package/dist/{libs → _internal/libs}/pressableState.js +1 -1
- package/dist/{libs → _internal/libs}/renderElement.js +1 -1
- package/dist/index.d.ts +119 -36
- package/dist/index.js +75 -36
- package/package.json +3 -3
- package/dist/Accordion.d.ts +0 -66
- package/dist/Accordion.js +0 -127
- package/dist/Breadcrumb.d.ts +0 -26
- package/dist/Breadcrumb.js +0 -53
- package/dist/Dialog.d.ts +0 -70
- package/dist/Dialog.js +0 -257
- package/dist/Menu.d.ts +0 -72
- package/dist/Menu.js +0 -230
- package/dist/Pagination.d.ts +0 -46
- package/dist/Pagination.js +0 -79
- package/dist/Popover.d.ts +0 -43
- package/dist/Popover.js +0 -150
- package/dist/Select.js +0 -173
- package/dist/Table.d.ts +0 -31
- package/dist/Table.js +0 -53
- package/dist/Tabs.d.ts +0 -66
- package/dist/Tabs.js +0 -159
- package/dist/Tag.js +0 -102
- package/dist/Toast.js +0 -193
- package/dist/Tooltip.d.ts +0 -53
- package/dist/Tooltip.js +0 -132
- package/dist/components/ListBoxNodes.js +0 -90
- /package/dist/{Card.d.ts → Card/Card.d.ts} +0 -0
- /package/dist/{Field.d.ts → Field/Field.d.ts} +0 -0
- /package/dist/{Separator.d.ts → Separator/Separator.d.ts} +0 -0
- /package/dist/{Typography.d.ts → Typography/Typography.d.ts} +0 -0
- /package/dist/{VisuallyHidden.d.ts → VisuallyHidden/VisuallyHidden.d.ts} +0 -0
- /package/dist/{constants → _internal/constants}/choiceClass.d.ts +0 -0
- /package/dist/{libs → _internal/libs}/cn.d.ts +0 -0
- /package/dist/{libs → _internal/libs}/listCollection.d.ts +0 -0
- /package/dist/{libs → _internal/libs}/overlayPosition.d.ts +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { InputSize } from "
|
|
2
|
-
import { ListBoxOptionProps, ListBoxSectionProps } from "./components/ListBoxNodes.js";
|
|
1
|
+
import { InputSize } from "../_internal/constants/inputClass.js";
|
|
3
2
|
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
4
3
|
export interface SelectProps extends Omit<ComponentProps<"button">, "value" | "defaultValue" | "onChange" | "type" | "size" | "children" | "name" | "form"> {
|
|
5
4
|
/** 고른 값(제어). 고른 옵션의 `value`다. `null`이면 아무것도 고르지 않은 상태다. 주면 `onValueChange`로 바꾼다. */
|
|
@@ -45,18 +44,4 @@ export interface SelectProps extends Omit<ComponentProps<"button">, "value" | "d
|
|
|
45
44
|
* 상태는 `data-open`(트리거·목록), `data-invalid`(트리거), 네이티브 `:disabled`(트리거),
|
|
46
45
|
* `data-highlighted`·`data-selected`·`data-disabled`(옵션)로 노출한다.
|
|
47
46
|
*/
|
|
48
|
-
export declare function Select({ value, defaultValue, onValueChange, open, defaultOpen, onOpenChange, name, form, autoComplete, placeholder, size, invalid, disabled, required, id, ref, className, children, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }: SelectProps): ReactElement;
|
|
49
|
-
export interface SelectItemProps extends ListBoxOptionProps {}
|
|
50
|
-
/**
|
|
51
|
-
* Select의 옵션(`role="option"`). `Select`나 `SelectSection` 바로 안에 둔다. `value`가 고른 값이고 폼에 제출된다.
|
|
52
|
-
* 내용(아이콘과 글자)은 고르면 트리거에도 보인다. 키보드 위치와 마우스를 올린 옵션은 highlight(primary subtle 배경,
|
|
53
|
-
* primary 글자), 고른 옵션은 neutral subtle-active 배경과 끝의 체크 아이콘이다.
|
|
54
|
-
* 상태는 `data-highlighted`, `data-selected`, `data-disabled`로 노출한다.
|
|
55
|
-
*/
|
|
56
|
-
export declare function SelectItem(_props: SelectItemProps): null;
|
|
57
|
-
export interface SelectSectionProps extends ListBoxSectionProps {}
|
|
58
|
-
/**
|
|
59
|
-
* 옵션 묶음(`role="group"`). `heading`이 화면에 보이는 제목이자 묶음의 이름이고, 없으면 `aria-label`이 이름이다.
|
|
60
|
-
* 앞뒤 다른 옵션·묶음과의 사이에 구분선이 그려진다.
|
|
61
|
-
*/
|
|
62
|
-
export declare function SelectSection(_props: SelectSectionProps): null;
|
|
47
|
+
export declare function Select({ value, defaultValue, onValueChange, open, defaultOpen, onOpenChange, name, form, autoComplete, placeholder, size, invalid, disabled, required, id, ref, className, children, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }: SelectProps): ReactElement;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { inputBaseClass, inputSizeClass } from "../_internal/constants/inputClass.js";
|
|
4
|
+
import { FieldContext, useFieldControl } from "../_internal/hooks/useFieldControl.js";
|
|
5
|
+
import { cn } from "../_internal/libs/cn.js";
|
|
6
|
+
import { resolveCollectionChildren } from "../_internal/libs/listCollection.js";
|
|
7
|
+
import { SelectPopover } from "./components/SelectPopover.js";
|
|
8
|
+
import { chevronClass, placeholderClass, triggerClass, valueClass } from "./constants/selectClass.js";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { use, useMemo, useRef } from "react";
|
|
11
|
+
import { ChevronDownIcon } from "@tide-design/icons";
|
|
12
|
+
import { HiddenSelect, mergeProps, mergeRefs, useButton, useSelect } from "react-aria";
|
|
13
|
+
import { useSelectState } from "react-stately";
|
|
14
|
+
|
|
15
|
+
// src/Select/Select.tsx
|
|
16
|
+
/**
|
|
17
|
+
* 값 하나를 고르는 입력. 트리거를 누르거나(마우스는 누르는 순간) Enter·Space·↓·↑로 목록을 열고, 화살표·Home/End·
|
|
18
|
+
* 영문 글자로 옵션을 옮겨 Enter·Space·누름으로 고른다. 닫힌 채로 글자를 치면 바로 그 옵션을 고른다.
|
|
19
|
+
* 고르면 닫히고 포커스는 트리거로 돌아온다. Esc·바깥 누름·Tab으로도 닫힌다.
|
|
20
|
+
* Field 안에 두면 label·설명·오류가 자동으로 연결되고, `name`을 주면 고른 값이 폼에 제출된다.
|
|
21
|
+
* 상태는 `data-open`(트리거·목록), `data-invalid`(트리거), 네이티브 `:disabled`(트리거),
|
|
22
|
+
* `data-highlighted`·`data-selected`·`data-disabled`(옵션)로 노출한다.
|
|
23
|
+
*/
|
|
24
|
+
function Select({ value, defaultValue, onValueChange, open, defaultOpen, onOpenChange, name, form, autoComplete, placeholder = "선택하세요", size = "md", invalid, disabled, required, id, ref, className, children, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }) {
|
|
25
|
+
const field = use(FieldContext);
|
|
26
|
+
const control = useFieldControl({
|
|
27
|
+
id,
|
|
28
|
+
invalid,
|
|
29
|
+
disabled,
|
|
30
|
+
required,
|
|
31
|
+
"aria-describedby": ariaDescribedBy,
|
|
32
|
+
"aria-invalid": ariaInvalid
|
|
33
|
+
});
|
|
34
|
+
const isDisabled = control.disabled ?? false;
|
|
35
|
+
const isRequired = control.required ?? false;
|
|
36
|
+
const items = useMemo(() => resolveCollectionChildren(children), [children]);
|
|
37
|
+
const state = useSelectState({
|
|
38
|
+
children: items,
|
|
39
|
+
value,
|
|
40
|
+
defaultValue,
|
|
41
|
+
onChange: (key) => {
|
|
42
|
+
if (key != null) onValueChange?.(String(key));
|
|
43
|
+
},
|
|
44
|
+
isOpen: open,
|
|
45
|
+
defaultOpen,
|
|
46
|
+
onOpenChange,
|
|
47
|
+
isDisabled,
|
|
48
|
+
isRequired,
|
|
49
|
+
validationBehavior: "native"
|
|
50
|
+
});
|
|
51
|
+
const triggerRef = useRef(null);
|
|
52
|
+
const { triggerProps, valueProps, menuProps, hiddenSelectProps, isInvalid } = useSelect({
|
|
53
|
+
id: control.id,
|
|
54
|
+
"aria-label": ariaLabel,
|
|
55
|
+
"aria-labelledby": ariaLabelledBy ?? field?.labelId,
|
|
56
|
+
isDisabled,
|
|
57
|
+
isRequired,
|
|
58
|
+
validationBehavior: "native",
|
|
59
|
+
name,
|
|
60
|
+
form,
|
|
61
|
+
autoComplete
|
|
62
|
+
}, state, triggerRef);
|
|
63
|
+
const { buttonProps } = useButton(triggerProps, triggerRef);
|
|
64
|
+
const mergedRef = useMemo(() => mergeRefs(ref, triggerRef), [ref, triggerRef]);
|
|
65
|
+
const showInvalid = control["data-invalid"] === "" || isInvalid;
|
|
66
|
+
const selected = state.selectedItem;
|
|
67
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
68
|
+
/* @__PURE__ */ jsxs("button", {
|
|
69
|
+
...mergeProps(props, buttonProps),
|
|
70
|
+
ref: mergedRef,
|
|
71
|
+
"aria-describedby": control["aria-describedby"],
|
|
72
|
+
"aria-invalid": showInvalid ? true : control["aria-invalid"],
|
|
73
|
+
"data-invalid": showInvalid ? "" : void 0,
|
|
74
|
+
"data-open": state.isOpen ? "" : void 0,
|
|
75
|
+
className: cn(inputSizeClass[size], inputBaseClass, triggerClass, className),
|
|
76
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
77
|
+
...valueProps,
|
|
78
|
+
className: cn(valueClass, !selected && "text-muted group-disabled:text-disabled"),
|
|
79
|
+
children: selected ? selected.rendered : placeholder
|
|
80
|
+
}), /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
81
|
+
size: 16,
|
|
82
|
+
className: chevronClass
|
|
83
|
+
})]
|
|
84
|
+
}),
|
|
85
|
+
/* @__PURE__ */ jsx(HiddenSelect, {
|
|
86
|
+
...hiddenSelectProps,
|
|
87
|
+
autoComplete
|
|
88
|
+
}),
|
|
89
|
+
/* @__PURE__ */ jsx(SelectPopover, {
|
|
90
|
+
state,
|
|
91
|
+
triggerRef,
|
|
92
|
+
menuProps
|
|
93
|
+
})
|
|
94
|
+
] });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { Select };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ListBoxOptionProps } from "../../_internal/components/ListBoxNodes/types.js";
|
|
2
|
+
export interface SelectItemProps extends ListBoxOptionProps {}
|
|
3
|
+
/**
|
|
4
|
+
* Select의 옵션(`role="option"`). `Select`나 `SelectSection` 바로 안에 둔다. `value`가 고른 값이고 폼에 제출된다.
|
|
5
|
+
* 내용(아이콘과 글자)은 고르면 트리거에도 보인다. 키보드 위치와 마우스를 올린 옵션은 highlight(primary subtle 배경,
|
|
6
|
+
* primary 글자), 고른 옵션은 neutral subtle-active 배경과 끝의 체크 아이콘이다.
|
|
7
|
+
* 상태는 `data-highlighted`, `data-selected`, `data-disabled`로 노출한다.
|
|
8
|
+
*/
|
|
9
|
+
export declare function SelectItem(_props: SelectItemProps): null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { asCollectionComponent, valueItemCollectionNode } from "../../_internal/libs/listCollection.js";
|
|
4
|
+
|
|
5
|
+
// src/Select/components/SelectItem.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Select의 옵션(`role="option"`). `Select`나 `SelectSection` 바로 안에 둔다. `value`가 고른 값이고 폼에 제출된다.
|
|
8
|
+
* 내용(아이콘과 글자)은 고르면 트리거에도 보인다. 키보드 위치와 마우스를 올린 옵션은 highlight(primary subtle 배경,
|
|
9
|
+
* primary 글자), 고른 옵션은 neutral subtle-active 배경과 끝의 체크 아이콘이다.
|
|
10
|
+
* 상태는 `data-highlighted`, `data-selected`, `data-disabled`로 노출한다.
|
|
11
|
+
*/
|
|
12
|
+
function SelectItem(_props) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
asCollectionComponent(SelectItem, valueItemCollectionNode);
|
|
16
|
+
|
|
17
|
+
export { SelectItem };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { OverlayPortal } from "../../_internal/components/OverlayPortal.js";
|
|
4
|
+
import { useOverlayPresence } from "../../_internal/hooks/useOverlayPresence.js";
|
|
5
|
+
import { SelectPopoverInner } from "./SelectPopoverInner.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { useRef } from "react";
|
|
8
|
+
|
|
9
|
+
// src/Select/components/SelectPopover.tsx
|
|
10
|
+
/** 목록을 DOM에 둘지 정하고 portal한다. 닫혀도 퇴장 전환이 끝날 때까지 남긴다(ADR 0018). */
|
|
11
|
+
function SelectPopover(props) {
|
|
12
|
+
const popoverRef = useRef(null);
|
|
13
|
+
if (!useOverlayPresence(props.state.isOpen, popoverRef)) return null;
|
|
14
|
+
return /* @__PURE__ */ jsx(OverlayPortal, {
|
|
15
|
+
isExiting: !props.state.isOpen,
|
|
16
|
+
children: /* @__PURE__ */ jsx(SelectPopoverInner, {
|
|
17
|
+
...props,
|
|
18
|
+
popoverRef
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { SelectPopover };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { ListBoxNodes } from "../../_internal/components/ListBoxNodes/ListBoxNodes.js";
|
|
4
|
+
import { listPopupClass } from "../../_internal/constants/listClass.js";
|
|
5
|
+
import { useCloseOnTab } from "../../_internal/hooks/useCloseOnTab.js";
|
|
6
|
+
import { useOverlayTheme } from "../../_internal/hooks/useOverlayTheme.js";
|
|
7
|
+
import { usePopoverOverlay } from "../../_internal/hooks/usePopoverOverlay.js";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { useLayoutEffect, useRef } from "react";
|
|
10
|
+
import { DismissButton, useListBox } from "react-aria";
|
|
11
|
+
|
|
12
|
+
// src/Select/components/SelectPopoverInner.tsx
|
|
13
|
+
/**
|
|
14
|
+
* 목록 표면(`listPopupClass`)과 그 안의 `role="listbox"`. 트리거 아래 시작 끝에 4px 떨어져 붙고(Menu와 같다),
|
|
15
|
+
* 폭은 트리거보다 좁지 않다.
|
|
16
|
+
*/
|
|
17
|
+
function SelectPopoverInner({ state, triggerRef, menuProps, popoverRef }) {
|
|
18
|
+
const listRef = useRef(null);
|
|
19
|
+
useOverlayTheme(triggerRef, popoverRef);
|
|
20
|
+
useLayoutEffect(() => {
|
|
21
|
+
const popover = popoverRef.current;
|
|
22
|
+
const width = triggerRef.current?.offsetWidth;
|
|
23
|
+
if (popover && width) popover.style.minWidth = `${width}px`;
|
|
24
|
+
}, [triggerRef, popoverRef]);
|
|
25
|
+
const { overlayProps } = usePopoverOverlay({
|
|
26
|
+
triggerRef,
|
|
27
|
+
popoverRef,
|
|
28
|
+
placement: "bottom start",
|
|
29
|
+
offset: 4
|
|
30
|
+
}, state);
|
|
31
|
+
const { listBoxProps } = useListBox(menuProps, state, listRef);
|
|
32
|
+
useCloseOnTab(popoverRef, state.close);
|
|
33
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
34
|
+
...overlayProps,
|
|
35
|
+
ref: popoverRef,
|
|
36
|
+
"data-open": state.isOpen ? "" : void 0,
|
|
37
|
+
className: listPopupClass,
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ jsx(DismissButton, { onDismiss: state.close }),
|
|
40
|
+
/* @__PURE__ */ jsx("div", {
|
|
41
|
+
...listBoxProps,
|
|
42
|
+
ref: listRef,
|
|
43
|
+
className: "outline-none",
|
|
44
|
+
children: /* @__PURE__ */ jsx(ListBoxNodes, { state })
|
|
45
|
+
}),
|
|
46
|
+
/* @__PURE__ */ jsx(DismissButton, { onDismiss: state.close })
|
|
47
|
+
]
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { SelectPopoverInner };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ListBoxSectionProps } from "../../_internal/components/ListBoxNodes/types.js";
|
|
2
|
+
export interface SelectSectionProps extends ListBoxSectionProps {}
|
|
3
|
+
/**
|
|
4
|
+
* 옵션 묶음(`role="group"`). `heading`이 화면에 보이는 제목이자 묶음의 이름이고, 없으면 `aria-label`이 이름이다.
|
|
5
|
+
* 앞뒤 다른 옵션·묶음과의 사이에 구분선이 그려진다.
|
|
6
|
+
*/
|
|
7
|
+
export declare function SelectSection(_props: SelectSectionProps): null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { asCollectionComponent, sectionCollectionNode } from "../../_internal/libs/listCollection.js";
|
|
4
|
+
|
|
5
|
+
// src/Select/components/SelectSection.tsx
|
|
6
|
+
/**
|
|
7
|
+
* 옵션 묶음(`role="group"`). `heading`이 화면에 보이는 제목이자 묶음의 이름이고, 없으면 `aria-label`이 이름이다.
|
|
8
|
+
* 앞뒤 다른 옵션·묶음과의 사이에 구분선이 그려진다.
|
|
9
|
+
*/
|
|
10
|
+
function SelectSection(_props) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
asCollectionComponent(SelectSection, sectionCollectionNode);
|
|
14
|
+
|
|
15
|
+
export { SelectSection };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// src/Select/constants/selectClass.ts
|
|
2
|
+
const triggerClass = "group inline-flex items-center justify-between gap-2 text-start";
|
|
3
|
+
const valueClass = "min-w-0 flex-1 truncate [&>svg]:me-2 [&>svg]:inline-block [&>svg]:size-4 [&>svg]:align-[-0.125em]";
|
|
4
|
+
const placeholderClass = "text-muted group-disabled:text-disabled";
|
|
5
|
+
const chevronClass = "shrink-0 text-muted group-disabled:text-disabled";
|
|
6
|
+
|
|
7
|
+
export { chevronClass, placeholderClass, triggerClass, valueClass };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Select, SelectProps } from "./Select.js";
|
|
2
|
+
import { SelectItem, SelectItemProps } from "./components/SelectItem.js";
|
|
3
|
+
import { SelectSection, SelectSectionProps } from "./components/SelectSection.js";
|
|
4
|
+
export { Select, SelectItem, type SelectItemProps, type SelectProps, SelectSection, type SelectSectionProps };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { cn } from "
|
|
1
|
+
import { cn } from "../_internal/libs/cn.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
|
|
4
|
-
// src/Separator.tsx
|
|
4
|
+
// src/Separator/Separator.tsx
|
|
5
5
|
const orientationClass = {
|
|
6
6
|
horizontal: "h-0 w-full border-t",
|
|
7
7
|
vertical: "h-auto w-0 self-stretch border-s"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { cn } from "
|
|
1
|
+
import { cn } from "../_internal/libs/cn.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
|
|
4
|
-
// src/Skeleton.tsx
|
|
4
|
+
// src/Skeleton/Skeleton.tsx
|
|
5
5
|
const variantClass = {
|
|
6
6
|
text: "h-[1em] w-full rounded-sm",
|
|
7
7
|
rect: "w-full rounded-md",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { cn } from "
|
|
4
|
-
import { useFieldControl } from "
|
|
3
|
+
import { cn } from "../_internal/libs/cn.js";
|
|
4
|
+
import { useFieldControl } from "../_internal/hooks/useFieldControl.js";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
|
|
7
|
-
// src/Switch.tsx
|
|
7
|
+
// src/Switch/Switch.tsx
|
|
8
8
|
/** 루트 높이는 최소 24px라 track이 작아도 누르는 영역이 24×24px 이상이다. */
|
|
9
9
|
const rootSizeClass = {
|
|
10
10
|
sm: "gap-1.5 text-body-sm",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentProps, ReactElement } from "react";
|
|
2
|
+
export interface TableProps extends ComponentProps<"table"> {}
|
|
3
|
+
/**
|
|
4
|
+
* 시맨틱 `<table>`. 행·열로 된 데이터를 보여 준다. 정렬·행 선택·가상화는 없다. 서버 컴포넌트로 쓸 수 있다.
|
|
5
|
+
* 표의 이름은 `<caption>`이나 `aria-label`·`aria-labelledby`로 준다.
|
|
6
|
+
*/
|
|
7
|
+
export declare function Table({ className, ...props }: TableProps): ReactElement;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { cn } from "../_internal/libs/cn.js";
|
|
2
|
+
import { tableClass } from "./constants/tableClass.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
// src/Table/Table.tsx
|
|
6
|
+
/**
|
|
7
|
+
* 시맨틱 `<table>`. 행·열로 된 데이터를 보여 준다. 정렬·행 선택·가상화는 없다. 서버 컴포넌트로 쓸 수 있다.
|
|
8
|
+
* 표의 이름은 `<caption>`이나 `aria-label`·`aria-labelledby`로 준다.
|
|
9
|
+
*/
|
|
10
|
+
function Table({ className, ...props }) {
|
|
11
|
+
return /* @__PURE__ */ jsx("table", {
|
|
12
|
+
...props,
|
|
13
|
+
className: cn(tableClass, className)
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { Table };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ComponentProps, ReactElement } from "react";
|
|
2
|
+
export interface TableCellProps extends ComponentProps<"td"> {}
|
|
3
|
+
/** 데이터 칸 `<td>`. 숫자 열은 `className="tabular-nums text-end"`로 자릿수를 맞춘다. */
|
|
4
|
+
export declare function TableCell({ className, ...props }: TableCellProps): ReactElement;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { cn } from "../../_internal/libs/cn.js";
|
|
2
|
+
import { cellClass } from "../constants/tableClass.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
// src/Table/components/TableCell.tsx
|
|
6
|
+
/** 데이터 칸 `<td>`. 숫자 열은 `className="tabular-nums text-end"`로 자릿수를 맞춘다. */
|
|
7
|
+
function TableCell({ className, ...props }) {
|
|
8
|
+
return /* @__PURE__ */ jsx("td", {
|
|
9
|
+
...props,
|
|
10
|
+
className: cn(cellClass, className)
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { TableCell };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentProps, ReactElement } from "react";
|
|
2
|
+
export interface TableHeaderCellProps extends ComponentProps<"th"> {
|
|
3
|
+
/**
|
|
4
|
+
* 이 머리 칸이 맡는 범위. 기본값은 `"col"`(아래 열)이다. 본문 행의 첫 칸처럼 행을 맡으면 `"row"`를 준다.
|
|
5
|
+
* 열 그룹·행 그룹 머리는 `"colgroup"`·`"rowgroup"`이다.
|
|
6
|
+
*/
|
|
7
|
+
scope?: "col" | "row" | "colgroup" | "rowgroup";
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 머리 칸 `<th>`. 기본은 `scope="col"`(열 머리, columnheader)이다. 본문 행의 행 머리는 `scope="row"`(rowheader)를 준다.
|
|
11
|
+
* 복잡한 표(여러 줄 머리)는 `id`와 칸의 `headers`로 직접 잇는다.
|
|
12
|
+
*/
|
|
13
|
+
export declare function TableHeaderCell({ scope, className, ...props }: TableHeaderCellProps): ReactElement;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { cn } from "../../_internal/libs/cn.js";
|
|
2
|
+
import { headerCellClass } from "../constants/tableClass.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
// src/Table/components/TableHeaderCell.tsx
|
|
6
|
+
/**
|
|
7
|
+
* 머리 칸 `<th>`. 기본은 `scope="col"`(열 머리, columnheader)이다. 본문 행의 행 머리는 `scope="row"`(rowheader)를 준다.
|
|
8
|
+
* 복잡한 표(여러 줄 머리)는 `id`와 칸의 `headers`로 직접 잇는다.
|
|
9
|
+
*/
|
|
10
|
+
function TableHeaderCell({ scope = "col", className, ...props }) {
|
|
11
|
+
return /* @__PURE__ */ jsx("th", {
|
|
12
|
+
...props,
|
|
13
|
+
scope,
|
|
14
|
+
className: cn(headerCellClass, className)
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { TableHeaderCell };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ComponentProps, ReactElement } from "react";
|
|
2
|
+
export interface TableRowProps extends ComponentProps<"tr"> {}
|
|
3
|
+
/** 행 `<tr>`. 아래 경계가 있고, `TableBody` 안에서는 hover 배경이 transition 없이 바로 바뀐다. */
|
|
4
|
+
export declare function TableRow({ className, ...props }: TableRowProps): ReactElement;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { cn } from "../../_internal/libs/cn.js";
|
|
2
|
+
import { rowClass } from "../constants/tableClass.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
// src/Table/components/TableRow.tsx
|
|
6
|
+
/** 행 `<tr>`. 아래 경계가 있고, `TableBody` 안에서는 hover 배경이 transition 없이 바로 바뀐다. */
|
|
7
|
+
function TableRow({ className, ...props }) {
|
|
8
|
+
return /* @__PURE__ */ jsx("tr", {
|
|
9
|
+
...props,
|
|
10
|
+
className: cn(rowClass, className)
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { TableRow };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// src/Table/constants/tableClass.ts
|
|
2
|
+
const tableClass = "w-full border-collapse text-body-sm text-default";
|
|
3
|
+
const rowClass = "border-b border-default [:where(tbody>&)]:hover:bg-hover";
|
|
4
|
+
const headerCellClass = "px-3 py-2.5 text-start align-middle text-label-md";
|
|
5
|
+
const cellClass = "px-3 py-2.5 text-start align-middle";
|
|
6
|
+
|
|
7
|
+
export { cellClass, headerCellClass, rowClass, tableClass };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Table, TableProps } from "./Table.js";
|
|
2
|
+
import { TableHead, TableHeadProps } from "./components/TableHead.js";
|
|
3
|
+
import { TableBody, TableBodyProps } from "./components/TableBody.js";
|
|
4
|
+
import { TableRow, TableRowProps } from "./components/TableRow.js";
|
|
5
|
+
import { TableHeaderCell, TableHeaderCellProps } from "./components/TableHeaderCell.js";
|
|
6
|
+
import { TableCell, TableCellProps } from "./components/TableCell.js";
|
|
7
|
+
export { Table, TableBody, type TableBodyProps, TableCell, type TableCellProps, TableHead, type TableHeadProps, TableHeaderCell, type TableHeaderCellProps, type TableProps, TableRow, type TableRowProps };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TabsActivationMode, TabsOrientation } from "./types.js";
|
|
2
|
+
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
3
|
+
type TabsValueProps = {
|
|
4
|
+
/** 고른 탭의 값(제어). 주면 `onValueChange`로 바꾼다. */
|
|
5
|
+
value: string;
|
|
6
|
+
defaultValue?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
value?: undefined;
|
|
9
|
+
/** 처음 고른 탭의 값(비제어). 서버 렌더에서도 그 패널이 바로 보이도록 `value`나 `defaultValue` 하나는 꼭 준다. */
|
|
10
|
+
defaultValue: string;
|
|
11
|
+
};
|
|
12
|
+
interface TabsBaseProps extends Omit<ComponentProps<"div">, "defaultValue" | "onChange"> {
|
|
13
|
+
/**
|
|
14
|
+
* 고른 탭이 바뀌려 할 때 새 값으로 부른다. 이미 고른 탭을 다시 눌러도 부르지 않는다.
|
|
15
|
+
* 준 값과 같은 탭이 없으면 첫 활성 탭을 고르며 부른다.
|
|
16
|
+
*/
|
|
17
|
+
onValueChange?: (value: string) => void;
|
|
18
|
+
/** 탭 목록의 방향. 기본값은 `horizontal`이다. 세로면 ↓↑로 옮기고 탭 목록이 패널의 시작쪽에 선다. */
|
|
19
|
+
orientation?: TabsOrientation;
|
|
20
|
+
/**
|
|
21
|
+
* 키보드로 탭을 옮겼을 때 바로 고를지(`automatic`, 기본값), Enter·Space로 고를지(`manual`)다.
|
|
22
|
+
* 패널을 그리는 데 시간이 걸리면(데이터를 불러오는 패널) `manual`을 쓴다(WAI-ARIA APG).
|
|
23
|
+
*/
|
|
24
|
+
activationMode?: TabsActivationMode;
|
|
25
|
+
/** `TabList` 하나와 `TabPanel`들 */
|
|
26
|
+
children?: ReactNode;
|
|
27
|
+
}
|
|
28
|
+
export type TabsProps = TabsBaseProps & TabsValueProps;
|
|
29
|
+
/**
|
|
30
|
+
* 같은 영역의 여러 패널 중 하나를 고르는 탭 묶음. 루트는 `<div>`이고 방향이 `data-orientation`으로 붙는다.
|
|
31
|
+
* 안에 `TabList` 하나와 탭마다 `TabPanel`을 둔다.
|
|
32
|
+
*/
|
|
33
|
+
export declare function Tabs({ value: valueProp, defaultValue, onValueChange, orientation, activationMode, ref, className, children, ...props }: TabsProps): ReactElement;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../_internal/libs/cn.js";
|
|
4
|
+
import { tabsOrientationClass } from "./constants/tabsClass.js";
|
|
5
|
+
import { TabsContext } from "./hooks/useTabsContext.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { useCallback, useId, useMemo, useState } from "react";
|
|
8
|
+
|
|
9
|
+
// src/Tabs/Tabs.tsx
|
|
10
|
+
/** id에 쓸 수 없는 공백을 뺀다(React Aria 탭 id와 같은 규칙). */
|
|
11
|
+
const idPart = (value) => value.replace(/\s+/g, "");
|
|
12
|
+
/**
|
|
13
|
+
* 같은 영역의 여러 패널 중 하나를 고르는 탭 묶음. 루트는 `<div>`이고 방향이 `data-orientation`으로 붙는다.
|
|
14
|
+
* 안에 `TabList` 하나와 탭마다 `TabPanel`을 둔다.
|
|
15
|
+
*/
|
|
16
|
+
function Tabs({ value: valueProp, defaultValue, onValueChange, orientation = "horizontal", activationMode = "automatic", ref, className, children, ...props }) {
|
|
17
|
+
const [internal, setInternal] = useState(defaultValue ?? "");
|
|
18
|
+
const controlled = valueProp !== void 0;
|
|
19
|
+
const value = controlled ? valueProp : internal;
|
|
20
|
+
const setValue = useCallback((next) => {
|
|
21
|
+
if (next === value) return;
|
|
22
|
+
if (!controlled) setInternal(next);
|
|
23
|
+
onValueChange?.(next);
|
|
24
|
+
}, [
|
|
25
|
+
controlled,
|
|
26
|
+
onValueChange,
|
|
27
|
+
value
|
|
28
|
+
]);
|
|
29
|
+
const baseId = useId();
|
|
30
|
+
const context = useMemo(() => ({
|
|
31
|
+
value,
|
|
32
|
+
setValue,
|
|
33
|
+
orientation,
|
|
34
|
+
activationMode,
|
|
35
|
+
tabId: (tab) => `${baseId}-tab-${idPart(tab)}`,
|
|
36
|
+
panelId: (tab) => `${baseId}-tabpanel-${idPart(tab)}`
|
|
37
|
+
}), [
|
|
38
|
+
value,
|
|
39
|
+
setValue,
|
|
40
|
+
orientation,
|
|
41
|
+
activationMode,
|
|
42
|
+
baseId
|
|
43
|
+
]);
|
|
44
|
+
return /* @__PURE__ */ jsx("div", {
|
|
45
|
+
...props,
|
|
46
|
+
ref,
|
|
47
|
+
"data-orientation": orientation,
|
|
48
|
+
className: cn(tabsOrientationClass[orientation], className),
|
|
49
|
+
children: /* @__PURE__ */ jsx(TabsContext, {
|
|
50
|
+
value: context,
|
|
51
|
+
children
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { Tabs };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CollectionValueItemProps } from "../../_internal/libs/listCollection.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
export interface TabProps extends Omit<ComponentProps<"button">, "value" | "type" | "role" | "id" | "disabled" | "children">, Omit<CollectionValueItemProps, "textValue"> {
|
|
4
|
+
/** 탭 글자. 아이콘(장식용)과 글자를 함께 둘 수 있다. */
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* 탭 하나(`role="tab"`). `TabList` 바로 안에 두고, 같은 `value`의 `TabPanel`과 이어진다.
|
|
9
|
+
* 고른 탭은 `data-selected`와 `aria-selected="true"`이고 primary 글자와 아래(세로면 끝쪽) 막대로 보인다.
|
|
10
|
+
* `disabled`면 네이티브 `disabled`라 고를 수 없고 키보드 이동도 건너뛴다.
|
|
11
|
+
*/
|
|
12
|
+
export declare function Tab(_props: TabProps): null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { asCollectionComponent, valueItemCollectionNode } from "../../_internal/libs/listCollection.js";
|
|
4
|
+
|
|
5
|
+
// src/Tabs/components/Tab.tsx
|
|
6
|
+
/**
|
|
7
|
+
* 탭 하나(`role="tab"`). `TabList` 바로 안에 두고, 같은 `value`의 `TabPanel`과 이어진다.
|
|
8
|
+
* 고른 탭은 `data-selected`와 `aria-selected="true"`이고 primary 글자와 아래(세로면 끝쪽) 막대로 보인다.
|
|
9
|
+
* `disabled`면 네이티브 `disabled`라 고를 수 없고 키보드 이동도 건너뛴다.
|
|
10
|
+
*/
|
|
11
|
+
function Tab(_props) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
asCollectionComponent(Tab, valueItemCollectionNode);
|
|
15
|
+
|
|
16
|
+
export { Tab };
|