@tide-design/components 0.11.1 → 0.11.3
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 +15 -0
- package/dist/Accordion/Accordion.js +29 -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 +10 -0
- package/dist/Accordion/components/AccordionPanel.js +27 -0
- package/dist/Accordion/components/AccordionTrigger.d.ts +13 -0
- package/dist/Accordion/components/AccordionTrigger.js +38 -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/Alert.d.ts +24 -0
- package/dist/{Alert.js → Alert/Alert.js} +6 -9
- 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} +3 -5
- package/dist/{Avatar.js → Avatar/Avatar.js} +3 -7
- package/dist/Avatar/index.d.ts +2 -0
- package/dist/Badge/Badge.d.ts +17 -0
- package/dist/{Badge.js → Badge/Badge.js} +3 -7
- package/dist/Badge/index.d.ts +2 -0
- package/dist/Breadcrumb/Breadcrumb.d.ts +10 -0
- package/dist/Breadcrumb/Breadcrumb.js +20 -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 +7 -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/Button.d.ts +25 -0
- package/dist/Button/Button.js +55 -0
- 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/Checkbox.d.ts +21 -0
- package/dist/{Checkbox.js → Checkbox/Checkbox.js} +6 -11
- package/dist/Checkbox/index.d.ts +2 -0
- package/dist/{CheckboxGroup.d.ts → CheckboxGroup/CheckboxGroup.d.ts} +6 -9
- package/dist/{CheckboxGroup.js → CheckboxGroup/CheckboxGroup.js} +8 -12
- package/dist/CheckboxGroup/index.d.ts +3 -0
- package/dist/Combobox/Combobox.d.ts +34 -0
- package/dist/Combobox/Combobox.js +110 -0
- package/dist/Combobox/components/ComboboxItem.d.ts +7 -0
- package/dist/Combobox/components/ComboboxItem.js +15 -0
- package/dist/Combobox/components/ComboboxPopover.js +18 -0
- package/dist/Combobox/components/ComboboxPopoverInner.js +46 -0
- package/dist/Combobox/components/ComboboxSection.d.ts +7 -0
- package/dist/Combobox/components/ComboboxSection.js +15 -0
- package/dist/Combobox/constants/comboboxClass.js +16 -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 +10 -0
- package/dist/Dialog/components/DialogClose.js +35 -0
- package/dist/Dialog/components/DialogContent.d.ts +13 -0
- package/dist/Dialog/components/DialogContent.js +29 -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.d.ts → Field/Field.d.ts} +4 -11
- package/dist/{Field.js → Field/Field.js} +5 -7
- package/dist/Field/index.d.ts +2 -0
- package/dist/IconButton/IconButton.d.ts +27 -0
- package/dist/{IconButton.js → IconButton/IconButton.js} +6 -11
- 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/Link.d.ts +10 -0
- package/dist/{Link.js → Link/Link.js} +3 -6
- package/dist/Link/index.d.ts +2 -0
- package/dist/Menu/Menu.d.ts +13 -0
- package/dist/Menu/Menu.js +40 -0
- package/dist/Menu/components/MenuContent.d.ts +15 -0
- package/dist/Menu/components/MenuContent.js +29 -0
- package/dist/Menu/components/MenuContentInner.js +66 -0
- package/dist/Menu/components/MenuItem.d.ts +13 -0
- package/dist/Menu/components/MenuItem.js +15 -0
- package/dist/Menu/components/MenuItemView.js +33 -0
- package/dist/Menu/components/MenuSection.d.ts +13 -0
- package/dist/Menu/components/MenuSection.js +15 -0
- package/dist/Menu/components/MenuSectionView.js +32 -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 +10 -0
- package/dist/Pagination/Pagination.js +20 -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 +12 -0
- package/dist/Pagination/components/PaginationLink.js +20 -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 +13 -0
- package/dist/Popover/components/PopoverContent.js +29 -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/Progress.d.ts +24 -0
- package/dist/{Progress.js → Progress/Progress.js} +3 -7
- package/dist/Progress/index.d.ts +2 -0
- package/dist/Radio/Radio.d.ts +21 -0
- package/dist/{Radio.js → Radio/Radio.js} +6 -10
- 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/Select.d.ts +37 -0
- package/dist/Select/Select.js +93 -0
- package/dist/Select/components/SelectItem.d.ts +7 -0
- package/dist/Select/components/SelectItem.js +15 -0
- package/dist/Select/components/SelectPopover.js +23 -0
- package/dist/Select/components/SelectPopoverInner.js +48 -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.d.ts → Separator/Separator.d.ts} +2 -9
- package/dist/{Separator.js → Separator/Separator.js} +3 -6
- package/dist/Separator/index.d.ts +2 -0
- package/dist/{Skeleton.d.ts → Skeleton/Skeleton.d.ts} +5 -9
- package/dist/{Skeleton.js → Skeleton/Skeleton.js} +3 -3
- package/dist/Skeleton/index.d.ts +2 -0
- package/dist/Spinner/Spinner.d.ts +14 -0
- package/dist/{Spinner.js → Spinner/Spinner.js} +3 -5
- package/dist/Spinner/index.d.ts +2 -0
- package/dist/{Switch.d.ts → Switch/Switch.d.ts} +5 -11
- package/dist/{Switch.js → Switch/Switch.js} +4 -7
- 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 +28 -0
- package/dist/Tabs/Tabs.js +56 -0
- package/dist/Tabs/components/Tab.d.ts +11 -0
- package/dist/Tabs/components/Tab.js +15 -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 +14 -0
- package/dist/Tag/Tag.js +15 -0
- package/dist/Tag/components/TagGroup.d.ts +28 -0
- package/dist/Tag/components/TagGroup.js +48 -0
- package/dist/Tag/components/TagView.js +48 -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} +2 -5
- package/dist/{Textarea.js → Textarea/Textarea.js} +4 -5
- package/dist/Textarea/index.d.ts +2 -0
- package/dist/Toast/Toast.d.ts +13 -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 +13 -0
- package/dist/Toast/libs/toastQueue.js +42 -0
- package/dist/Toast/types.d.ts +38 -0
- package/dist/Tooltip/Tooltip.d.ts +25 -0
- package/dist/Tooltip/Tooltip.js +42 -0
- package/dist/Tooltip/components/TooltipContent.d.ts +13 -0
- package/dist/Tooltip/components/TooltipContent.js +30 -0
- package/dist/Tooltip/components/TooltipContentInner.js +43 -0
- package/dist/Tooltip/components/TooltipTrigger.d.ts +13 -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.d.ts → Typography/Typography.d.ts} +4 -10
- package/dist/{Typography.js → Typography/Typography.js} +4 -4
- 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 +33 -0
- package/dist/_internal/components/ListBoxNodes/components/ListBoxOptionView.js +39 -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/_internal/components/OverlayPortal.js +19 -0
- package/dist/_internal/constants/alertClass.js +18 -0
- package/dist/{constants → _internal/constants}/choiceClass.js +3 -3
- package/dist/_internal/constants/choiceGroupClass.d.ts +1 -0
- package/dist/_internal/constants/choiceGroupClass.js +7 -0
- package/dist/_internal/constants/inputClass.d.ts +3 -0
- package/dist/{constants → _internal/constants}/inputClass.js +2 -3
- package/dist/_internal/constants/listClass.js +21 -0
- package/dist/_internal/constants/overlayClass.js +40 -0
- package/dist/{constants → _internal/constants}/pressableClass.js +4 -7
- package/dist/{hooks → _internal/hooks}/useChoiceGroup.js +2 -5
- package/dist/_internal/hooks/useCloseOnTab.js +23 -0
- package/dist/_internal/hooks/useDialogContext.js +14 -0
- package/dist/{hooks → _internal/hooks}/useFieldControl.js +2 -5
- package/dist/{hooks → _internal/hooks}/useOverlayPresence.js +2 -8
- package/dist/_internal/hooks/useOverlayTheme.js +16 -0
- package/dist/_internal/hooks/usePopoverOverlay.js +19 -0
- 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 +6 -24
- package/dist/_internal/libs/overlayPosition.d.ts +3 -0
- package/dist/_internal/libs/overlayPosition.js +17 -0
- package/dist/{libs → _internal/libs}/pressableState.js +3 -6
- package/dist/{libs → _internal/libs}/renderElement.js +2 -2
- package/dist/index.d.ts +119 -36
- package/dist/index.js +75 -36
- package/dist/types.d.ts +2 -5
- package/package.json +3 -3
- package/dist/Accordion.d.ts +0 -66
- package/dist/Accordion.js +0 -127
- package/dist/Alert.d.ts +0 -32
- package/dist/Badge.d.ts +0 -32
- package/dist/Breadcrumb.d.ts +0 -26
- package/dist/Breadcrumb.js +0 -53
- package/dist/Button.d.ts +0 -42
- package/dist/Button.js +0 -77
- package/dist/Checkbox.d.ts +0 -30
- package/dist/Combobox.d.ts +0 -59
- package/dist/Combobox.js +0 -209
- package/dist/Dialog.d.ts +0 -70
- package/dist/Dialog.js +0 -257
- package/dist/IconButton.d.ts +0 -42
- package/dist/Link.d.ts +0 -20
- 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/Progress.d.ts +0 -32
- package/dist/Radio.d.ts +0 -27
- package/dist/Select.d.ts +0 -62
- package/dist/Select.js +0 -173
- package/dist/Spinner.d.ts +0 -20
- 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.d.ts +0 -48
- package/dist/Tag.js +0 -102
- package/dist/Toast.d.ts +0 -71
- 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/components/OverlayPortal.js +0 -21
- package/dist/constants/alertClass.js +0 -31
- package/dist/constants/inputClass.d.ts +0 -3
- package/dist/constants/listClass.js +0 -46
- package/dist/constants/overlayClass.js +0 -84
- package/dist/hooks/useCloseOnTab.js +0 -29
- package/dist/hooks/useOverlayTheme.js +0 -20
- package/dist/hooks/usePopoverOverlay.js +0 -25
- package/dist/libs/overlayPosition.d.ts +0 -6
- package/dist/libs/overlayPosition.js +0 -20
- /package/dist/{Card.d.ts → Card/Card.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
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Size } from "../types.js";
|
|
2
|
+
import { ComponentProps, ReactElement } from "react";
|
|
3
|
+
type SpinnerSize = Extract<Size, "xs" | "sm" | "md" | "lg">;
|
|
4
|
+
export interface SpinnerProps extends Omit<ComponentProps<"svg">, "children"> {
|
|
5
|
+
/** `xs`·`sm` 14px, `md` 16px, `lg` 20px(같은 size Component의 텍스트 옆 아이콘 크기). 기본값 `md`. */
|
|
6
|
+
size?: SpinnerSize;
|
|
7
|
+
/** 접근 가능한 이름. 기본값은 `"로딩 중"`이다. 무엇을 불러오는지 적으면 더 좋다. */
|
|
8
|
+
"aria-label"?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 로딩 중임을 알리는 회전 표시(`role="status"`). 색은 주변 글자색을 따르고, 움직임 줄이기에서도 멈추지 않는다.
|
|
12
|
+
*/
|
|
13
|
+
export declare function Spinner({ size, className, "aria-label": ariaLabel, ...props }: SpinnerProps): ReactElement;
|
|
14
|
+
export {};
|
|
@@ -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/Spinner.tsx
|
|
4
|
+
// src/Spinner/Spinner.tsx
|
|
5
5
|
const sizeClass = {
|
|
6
6
|
xs: "size-3.5",
|
|
7
7
|
sm: "size-3.5",
|
|
@@ -9,9 +9,7 @@ const sizeClass = {
|
|
|
9
9
|
lg: "size-5"
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
|
-
* 로딩 중임을 알리는 회전
|
|
13
|
-
* 회전은 keyframe(`animate-spin`)이고 움직임 줄이기에서도 멈추지 않는다(로딩 여부 자체가 정보다).
|
|
14
|
-
* 색은 `currentColor`라 주변 글자색을 따른다. 서버 컴포넌트로 쓸 수 있다.
|
|
12
|
+
* 로딩 중임을 알리는 회전 표시(`role="status"`). 색은 주변 글자색을 따르고, 움직임 줄이기에서도 멈추지 않는다.
|
|
15
13
|
*/
|
|
16
14
|
function Spinner({ size = "md", className, "aria-label": ariaLabel = "로딩 중", ...props }) {
|
|
17
15
|
return /* @__PURE__ */ jsx("svg", {
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import { Role, Size } from "
|
|
1
|
+
import { Role, Size } from "../types.js";
|
|
2
2
|
import { CSSProperties, ComponentProps, ReactElement, ReactNode } from "react";
|
|
3
3
|
/** Switch의 size. `xs`는 track이 너무 작아 받지 않는다. */
|
|
4
4
|
type SwitchSize = Extract<Size, "sm" | "md" | "lg">;
|
|
5
5
|
export interface SwitchProps extends Omit<ComponentProps<"input">, "type" | "size" | "color" | "role" | "children"> {
|
|
6
6
|
/** 스위치 옆에 보이는 label. 스위치의 이름이 된다. Field 안에서는 Field의 `label`을 쓰고 비워 둔다. */
|
|
7
7
|
children?: ReactNode;
|
|
8
|
-
/** track 크기 `sm` 28×16px, `md` 36×20px, `lg` 44×24px. label
|
|
8
|
+
/** track 크기 `sm` 28×16px, `md` 36×20px, `lg` 44×24px. label 글자 크기도 함께 바뀐다. 기본값 `md`. */
|
|
9
9
|
size?: SwitchSize;
|
|
10
|
-
/**
|
|
11
|
-
* 켜졌을 때 track 색. Role(Tide Role 6개와 앱이 `RoleRegistry`에 더한 Role)을 받는다. 기본값은 `primary`다.
|
|
12
|
-
* 루트에 `data-color`로 붙어 accent 색을 정한다. 바깥 요소의 색을 물려받지 않는다.
|
|
13
|
-
*/
|
|
10
|
+
/** 켜졌을 때 track 색. Role(Tide Role + 앱 Role). 기본값 `primary`. 색 계열 이름은 받지 않는다(ADR 0016). */
|
|
14
11
|
color?: Role;
|
|
15
|
-
/**
|
|
16
|
-
* 오류 상태. `aria-invalid="true"`와 `data-invalid`가 붙고 꺼진 track 경계가 danger 색이 된다.
|
|
17
|
-
* Field 안에서는 Field의 값을 따르고, 여기에 준 값이 이긴다.
|
|
18
|
-
*/
|
|
12
|
+
/** 오류 상태. `aria-invalid="true"`와 `data-invalid`가 붙는다. Field 값보다 여기 준 값이 이긴다. */
|
|
19
13
|
invalid?: boolean;
|
|
20
14
|
/** 루트 `<label>`의 class. 기본 class를 이긴다. track과 thumb 모양은 바꾸지 않는다. */
|
|
21
15
|
className?: string;
|
|
@@ -23,7 +17,7 @@ export interface SwitchProps extends Omit<ComponentProps<"input">, "type" | "siz
|
|
|
23
17
|
style?: CSSProperties;
|
|
24
18
|
}
|
|
25
19
|
/**
|
|
26
|
-
* 켜고 끄는
|
|
20
|
+
* 켜고 끄는 스위치. 네이티브 체크박스(`role="switch"`)라 form 제출이 그대로 된다.
|
|
27
21
|
* `children`이 label이 된다. Field 안에 두면 Field의 label·설명·오류가 연결된다.
|
|
28
22
|
*/
|
|
29
23
|
export declare function Switch({ children, size, color, invalid, id, disabled, required, className, style, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...props }: SwitchProps): ReactElement;
|
|
@@ -1,23 +1,20 @@
|
|
|
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
|
|
8
|
-
/** 루트 높이는 최소 24px라 track이 작아도 누르는 영역이 24×24px 이상이다. */
|
|
7
|
+
// src/Switch/Switch.tsx
|
|
9
8
|
const rootSizeClass = {
|
|
10
9
|
sm: "gap-1.5 text-body-sm",
|
|
11
10
|
md: "gap-2 text-body-md",
|
|
12
11
|
lg: "gap-2.5 text-body-lg"
|
|
13
12
|
};
|
|
14
|
-
/** track 크기(border 1px 포함). thumb은 track 안쪽에서 2px 떨어진다. */
|
|
15
13
|
const trackSizeClass = {
|
|
16
14
|
sm: "h-4 w-7",
|
|
17
15
|
md: "h-5 w-9",
|
|
18
16
|
lg: "h-6 w-11"
|
|
19
17
|
};
|
|
20
|
-
/** thumb 크기와 켜졌을 때 이동 거리(track 폭 - border 2px - 여백 4px - thumb 크기). RTL에서는 반대로 움직인다. */
|
|
21
18
|
const thumbSizeClass = {
|
|
22
19
|
sm: "size-2.5 peer-checked:translate-x-3 rtl:peer-checked:-translate-x-3",
|
|
23
20
|
md: "size-3.5 peer-checked:translate-x-4 rtl:peer-checked:-translate-x-4",
|
|
@@ -28,7 +25,7 @@ const thumbClass = "pointer-events-none absolute start-0.75 top-0.75 rounded-ful
|
|
|
28
25
|
const trackForcedClass = "forced-colors:forced-color-adjust-none forced-colors:[--tide-border-strong:CanvasText] forced-colors:[--tide-border-danger:CanvasText] forced-colors:[--tide-accent-border:Highlight] forced-colors:[--tide-accent-solid:Highlight] forced-colors:[--tide-accent-solid-hover:Highlight] forced-colors:[--tide-accent-solid-active:Highlight] forced-colors:[--tide-accent-subtle:Canvas] forced-colors:[--tide-accent-subtle-active:Canvas] forced-colors:[--tide-border-default:GrayText] forced-colors:[--tide-bg-disabled:Canvas] forced-colors:[--tide-outline-focus:Highlight]";
|
|
29
26
|
const thumbForcedClass = "forced-colors:forced-color-adjust-none forced-colors:[--tide-text-muted:CanvasText] forced-colors:[--tide-accent-text:CanvasText] forced-colors:[--tide-accent-on-solid:HighlightText] forced-colors:[--tide-text-disabled:GrayText]";
|
|
30
27
|
/**
|
|
31
|
-
* 켜고 끄는
|
|
28
|
+
* 켜고 끄는 스위치. 네이티브 체크박스(`role="switch"`)라 form 제출이 그대로 된다.
|
|
32
29
|
* `children`이 label이 된다. Field 안에 두면 Field의 label·설명·오류가 연결된다.
|
|
33
30
|
*/
|
|
34
31
|
function Switch({ children, size = "md", color = "primary", invalid, id, disabled, required, className, style, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...props }) {
|
|
@@ -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,28 @@
|
|
|
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
|
+
onValueChange?: (value: string) => void;
|
|
15
|
+
/** 탭 목록의 방향. 기본값은 `horizontal`이다. 세로면 ↓↑로 옮기고 탭 목록이 패널의 시작쪽에 선다. */
|
|
16
|
+
orientation?: TabsOrientation;
|
|
17
|
+
/** 키보드로 옮기면 바로 고를지(`automatic`, 기본값), Enter·Space로 고를지(`manual`). 패널이 느리면 `manual`. */
|
|
18
|
+
activationMode?: TabsActivationMode;
|
|
19
|
+
/** `TabList` 하나와 `TabPanel`들 */
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
export type TabsProps = TabsBaseProps & TabsValueProps;
|
|
23
|
+
/**
|
|
24
|
+
* 같은 영역의 여러 패널 중 하나를 고르는 탭 묶음. 루트는 `<div>`이고 방향이 `data-orientation`으로 붙는다.
|
|
25
|
+
* 안에 `TabList` 하나와 탭마다 `TabPanel`을 둔다.
|
|
26
|
+
*/
|
|
27
|
+
export declare function Tabs({ value: valueProp, defaultValue, onValueChange, orientation, activationMode, ref, className, children, ...props }: TabsProps): ReactElement;
|
|
28
|
+
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,11 @@
|
|
|
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"`다. `disabled`면 고를 수 없고 키보드 이동도 건너뛴다.
|
|
10
|
+
*/
|
|
11
|
+
export declare function Tab(_props: TabProps): null;
|
|
@@ -0,0 +1,15 @@
|
|
|
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"`다. `disabled`면 고를 수 없고 키보드 이동도 건너뛴다.
|
|
9
|
+
*/
|
|
10
|
+
function Tab(_props) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
asCollectionComponent(Tab, valueItemCollectionNode);
|
|
14
|
+
|
|
15
|
+
export { Tab };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
2
|
+
export interface TabListProps extends Omit<ComponentProps<"div">, "role" | "children"> {
|
|
3
|
+
/** `Tab`. 바로 아래(또는 Fragment·배열 안)에 둔다. */
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 탭 목록(`role="tablist"`). 화살표로 탭을 옮기고(끝에서 처음으로 돈다) Home·End로 처음·마지막 탭에 간다.
|
|
8
|
+
* 비활성 탭은 건너뛴다. 이름은 `aria-label`이나 `aria-labelledby`로 준다.
|
|
9
|
+
*/
|
|
10
|
+
export declare function TabList({ ref, className, children, ...props }: TabListProps): ReactElement;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../_internal/libs/cn.js";
|
|
4
|
+
import { resolveCollectionChildren } from "../../_internal/libs/listCollection.js";
|
|
5
|
+
import { tabListOrientationClass } from "../constants/tabsClass.js";
|
|
6
|
+
import { useTabsContext } from "../hooks/useTabsContext.js";
|
|
7
|
+
import { TabView } from "./TabView.js";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
import { isValidElement, useMemo, useRef } from "react";
|
|
10
|
+
import { mergeProps, mergeRefs, useTabList } from "react-aria";
|
|
11
|
+
import { useTabListState } from "react-stately";
|
|
12
|
+
|
|
13
|
+
// src/Tabs/components/TabList.tsx
|
|
14
|
+
/**
|
|
15
|
+
* 탭 목록(`role="tablist"`). 화살표로 탭을 옮기고(끝에서 처음으로 돈다) Home·End로 처음·마지막 탭에 간다.
|
|
16
|
+
* 비활성 탭은 건너뛴다. 이름은 `aria-label`이나 `aria-labelledby`로 준다.
|
|
17
|
+
*/
|
|
18
|
+
function TabList({ ref, className, children, ...props }) {
|
|
19
|
+
const context = useTabsContext("TabList");
|
|
20
|
+
const listRef = useRef(null);
|
|
21
|
+
const items = useMemo(() => resolveCollectionChildren(children), [children]);
|
|
22
|
+
const known = items.some((item) => isValidElement(item) && item.props.value === context.value);
|
|
23
|
+
const state = useTabListState({
|
|
24
|
+
children: items,
|
|
25
|
+
selectedKey: known ? context.value : null,
|
|
26
|
+
onSelectionChange: (key) => context.setValue(String(key))
|
|
27
|
+
});
|
|
28
|
+
const { tabListProps } = useTabList({
|
|
29
|
+
orientation: context.orientation,
|
|
30
|
+
keyboardActivation: context.activationMode,
|
|
31
|
+
"aria-label": props["aria-label"],
|
|
32
|
+
"aria-labelledby": props["aria-labelledby"]
|
|
33
|
+
}, state, listRef);
|
|
34
|
+
const mergedRef = useMemo(() => mergeRefs(ref, listRef), [ref, listRef]);
|
|
35
|
+
return /* @__PURE__ */ jsx("div", {
|
|
36
|
+
...mergeProps(props, tabListProps),
|
|
37
|
+
ref: mergedRef,
|
|
38
|
+
className: cn(tabListOrientationClass[context.orientation], className),
|
|
39
|
+
children: [...state.collection].map((node) => /* @__PURE__ */ jsx(TabView, {
|
|
40
|
+
node,
|
|
41
|
+
state,
|
|
42
|
+
context
|
|
43
|
+
}, node.key))
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { TabList };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ComponentProps, ReactElement } from "react";
|
|
2
|
+
export interface TabPanelProps extends Omit<ComponentProps<"div">, "id" | "role"> {
|
|
3
|
+
/** 이어지는 `Tab`의 값. 그 탭을 고른 동안만 렌더한다. */
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 탭 하나의 내용(`role="tabpanel"`). 같은 `value`의 탭을 고른 동안만 렌더하고, 그 탭이 이름이 된다.
|
|
8
|
+
* 탭 다음 Tab 순서에 들어간다(`tabIndex` 기본 `0`). 첫 내용이 조작 요소면 `tabIndex={-1}`로 뺄 수 있다.
|
|
9
|
+
*/
|
|
10
|
+
export declare function TabPanel({ value, ref, className, tabIndex, ...props }: TabPanelProps): ReactElement | null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../_internal/libs/cn.js";
|
|
4
|
+
import { tabPanelClass } from "../constants/tabsClass.js";
|
|
5
|
+
import { useTabsContext } from "../hooks/useTabsContext.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
// src/Tabs/components/TabPanel.tsx
|
|
9
|
+
/**
|
|
10
|
+
* 탭 하나의 내용(`role="tabpanel"`). 같은 `value`의 탭을 고른 동안만 렌더하고, 그 탭이 이름이 된다.
|
|
11
|
+
* 탭 다음 Tab 순서에 들어간다(`tabIndex` 기본 `0`). 첫 내용이 조작 요소면 `tabIndex={-1}`로 뺄 수 있다.
|
|
12
|
+
*/
|
|
13
|
+
function TabPanel({ value, ref, className, tabIndex = 0, ...props }) {
|
|
14
|
+
const context = useTabsContext("TabPanel");
|
|
15
|
+
if (context.value !== value) return null;
|
|
16
|
+
return /* @__PURE__ */ jsx("div", {
|
|
17
|
+
...props,
|
|
18
|
+
ref,
|
|
19
|
+
role: "tabpanel",
|
|
20
|
+
id: context.panelId(value),
|
|
21
|
+
"aria-labelledby": context.tabId(value),
|
|
22
|
+
tabIndex,
|
|
23
|
+
className: cn(tabPanelClass, className)
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { TabPanel };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../_internal/libs/cn.js";
|
|
4
|
+
import { tabBaseClass, tabOrientationClass } from "../constants/tabsClass.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { useMemo, useRef } from "react";
|
|
7
|
+
import { mergeProps, mergeRefs, useTab } from "react-aria";
|
|
8
|
+
|
|
9
|
+
// src/Tabs/components/TabView.tsx
|
|
10
|
+
/** 탭 하나를 그린다. node.props는 앱이 Tab에 준 props(와 컬렉션이 더한 isDisabled)다. */
|
|
11
|
+
function TabView({ node, state, context }) {
|
|
12
|
+
const tabRef = useRef(null);
|
|
13
|
+
const { ref, className, value, disabled: _disabled, isDisabled: _isDisabled, children: _children, onFocus: _onFocus, onBlur: _onBlur, onKeyDown: _onKeyDown, onKeyUp: _onKeyUp, autoFocus: _autoFocus, ...props } = node.props;
|
|
14
|
+
const { tabProps, isSelected, isDisabled } = useTab({ key: node.key }, state, tabRef);
|
|
15
|
+
const mergedRef = useMemo(() => mergeRefs(ref, tabRef), [ref, tabRef]);
|
|
16
|
+
return /* @__PURE__ */ jsx("button", {
|
|
17
|
+
...mergeProps(props, tabProps),
|
|
18
|
+
ref: mergedRef,
|
|
19
|
+
type: "button",
|
|
20
|
+
id: context.tabId(value),
|
|
21
|
+
"aria-controls": isSelected ? context.panelId(value) : void 0,
|
|
22
|
+
disabled: isDisabled || void 0,
|
|
23
|
+
"data-selected": isSelected ? "" : void 0,
|
|
24
|
+
className: cn(tabBaseClass, tabOrientationClass[context.orientation], className),
|
|
25
|
+
children: node.rendered
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { TabView };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/Tabs/constants/tabsClass.ts
|
|
2
|
+
const tabsOrientationClass = {
|
|
3
|
+
horizontal: "flex flex-col gap-4",
|
|
4
|
+
vertical: "flex flex-row gap-6"
|
|
5
|
+
};
|
|
6
|
+
const tabListOrientationClass = {
|
|
7
|
+
horizontal: "flex shrink-0 gap-1 border-b border-default",
|
|
8
|
+
vertical: "flex shrink-0 flex-col gap-1 border-e border-default"
|
|
9
|
+
};
|
|
10
|
+
const tabBaseClass = [
|
|
11
|
+
"relative flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-label-md whitespace-nowrap text-muted outline-none select-none [&>svg]:size-4 [&>svg]:shrink-0",
|
|
12
|
+
"hover:not-data-selected:enabled:text-default data-selected:text-primary focus-visible:focus-ring",
|
|
13
|
+
"disabled:cursor-not-allowed disabled:text-disabled",
|
|
14
|
+
"after:pointer-events-none after:absolute after:border-primary after:opacity-0 after:transition-opacity data-selected:after:opacity-100",
|
|
15
|
+
"forced-colors:after:forced-color-adjust-none forced-colors:after:border-[Highlight]"
|
|
16
|
+
].join(" ");
|
|
17
|
+
const tabOrientationClass = {
|
|
18
|
+
horizontal: "after:inset-x-0 after:-bottom-px after:border-b-2 motion-safe:after:scale-x-0 motion-safe:after:transition-[opacity,scale] motion-safe:data-selected:after:scale-x-100",
|
|
19
|
+
vertical: "after:inset-y-0 after:-end-px after:border-e-2 motion-safe:after:scale-y-0 motion-safe:after:transition-[opacity,scale] motion-safe:data-selected:after:scale-y-100"
|
|
20
|
+
};
|
|
21
|
+
const tabPanelClass = "min-w-0 flex-1 rounded-md outline-none focus-visible:focus-ring";
|
|
22
|
+
|
|
23
|
+
export { tabBaseClass, tabListOrientationClass, tabOrientationClass, tabPanelClass, tabsOrientationClass };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, use } from "react";
|
|
4
|
+
|
|
5
|
+
// src/Tabs/hooks/useTabsContext.ts
|
|
6
|
+
const TabsContext = createContext(null);
|
|
7
|
+
function useTabsContext(part) {
|
|
8
|
+
const context = use(TabsContext);
|
|
9
|
+
if (!context) throw new Error(`${part}는 Tabs 안에 둔다.`);
|
|
10
|
+
return context;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { TabsContext, useTabsContext };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Tabs, TabsProps } from "./Tabs.js";
|
|
2
|
+
import { TabList, TabListProps } from "./components/TabList.js";
|
|
3
|
+
import { Tab, TabProps } from "./components/Tab.js";
|
|
4
|
+
import { TabPanel, TabPanelProps } from "./components/TabPanel.js";
|
|
5
|
+
import { TabsActivationMode, TabsOrientation } from "./types.js";
|
|
6
|
+
export { Tab, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsActivationMode, type TabsOrientation, type TabsProps };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CollectionValueItemProps } from "../_internal/libs/listCollection.js";
|
|
2
|
+
import { ColorFamilyName } from "../types.js";
|
|
3
|
+
import { ComponentProps, ReactNode } from "react";
|
|
4
|
+
export interface TagProps extends Omit<ComponentProps<"div">, "color" | "role" | "id" | "tabIndex" | "children">, CollectionValueItemProps {
|
|
5
|
+
/** 태그 글자. 필수다. 아이콘(장식용)을 앞에 함께 둘 수 있다. */
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
/** 색 계열 이름(Tide 8개 + 앱 장식 계열). 기본값 `gray`. 분류용 뜻 없는 색이라 Role은 받지 않는다. */
|
|
8
|
+
color?: ColorFamilyName;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 태그 하나(`role="row"`). `TagGroup` 바로 안에 둔다. `value`가 묶음 안의 key이고 `onRemove`에 넘어오는 값이다.
|
|
12
|
+
* `disabled`면 지울 수 없고 키보드 이동도 건너뛴다(`aria-disabled`).
|
|
13
|
+
*/
|
|
14
|
+
export declare function Tag(_props: TagProps): null;
|
package/dist/Tag/Tag.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { asCollectionComponent, valueItemCollectionNode } from "../_internal/libs/listCollection.js";
|
|
4
|
+
|
|
5
|
+
// src/Tag/Tag.tsx
|
|
6
|
+
/**
|
|
7
|
+
* 태그 하나(`role="row"`). `TagGroup` 바로 안에 둔다. `value`가 묶음 안의 key이고 `onRemove`에 넘어오는 값이다.
|
|
8
|
+
* `disabled`면 지울 수 없고 키보드 이동도 건너뛴다(`aria-disabled`).
|
|
9
|
+
*/
|
|
10
|
+
function Tag(_props) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
asCollectionComponent(Tag, valueItemCollectionNode);
|
|
14
|
+
|
|
15
|
+
export { Tag };
|