@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
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cn } from "../../_internal/libs/cn.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
// src/Dialog/components/DialogFooter.tsx
|
|
5
|
+
/** 동작 버튼 줄. 끝쪽에 맞추고 버튼 사이는 8px이다. 앞에 덜 위험한 동작(취소)을, 끝에 주 동작을 둔다. */
|
|
6
|
+
function DialogFooter({ className, ...props }) {
|
|
7
|
+
return /* @__PURE__ */ jsx("div", {
|
|
8
|
+
...props,
|
|
9
|
+
className: cn("mt-2 flex flex-wrap justify-end gap-2", className)
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { DialogFooter };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentProps, ReactElement } from "react";
|
|
2
|
+
export type DialogTitleProps = ComponentProps<"h2">;
|
|
3
|
+
/**
|
|
4
|
+
* Dialog 제목(`<h2>`, `text-heading-sm`). 있으면 dialog의 `aria-labelledby`가 가리켜 이름이 된다.
|
|
5
|
+
* Dialog에서는 끝쪽 닫기 버튼과 겹치지 않게 끝 여백(36px)을 둔다.
|
|
6
|
+
*/
|
|
7
|
+
export declare function DialogTitle({ id, className, ...props }: DialogTitleProps): ReactElement;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../_internal/libs/cn.js";
|
|
4
|
+
import { useDialogPartsContext } from "../hooks/useDialogPartsContext.js";
|
|
5
|
+
import { usePartId } from "../hooks/usePartId.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
// src/Dialog/components/DialogTitle.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Dialog 제목(`<h2>`, `text-heading-sm`). 있으면 dialog의 `aria-labelledby`가 가리켜 이름이 된다.
|
|
11
|
+
* Dialog에서는 끝쪽 닫기 버튼과 겹치지 않게 끝 여백(36px)을 둔다.
|
|
12
|
+
*/
|
|
13
|
+
function DialogTitle({ id, className, ...props }) {
|
|
14
|
+
const { alert, setTitleId } = useDialogPartsContext("DialogTitle");
|
|
15
|
+
const resolvedId = usePartId(id, setTitleId);
|
|
16
|
+
return /* @__PURE__ */ jsx("h2", {
|
|
17
|
+
...props,
|
|
18
|
+
id: resolvedId,
|
|
19
|
+
className: cn("text-heading-sm text-default", !alert && "pe-9", className)
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { DialogTitle };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentProps, ReactElement } from "react";
|
|
2
|
+
export interface DialogTriggerProps extends ComponentProps<"button"> {
|
|
3
|
+
/**
|
|
4
|
+
* 다른 요소로 렌더한다. 예: `render={<Button variant="outline" />}`, `render={<IconButton aria-label="삭제" />}`.
|
|
5
|
+
* props, ref, className, 이벤트 핸들러를 그 요소에 병합한다. 기본은 class 없는 `<button type="button">`이다.
|
|
6
|
+
*/
|
|
7
|
+
render?: ReactElement;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Dialog를 여는 버튼. 누르면(마우스, 터치, Enter, Space) 연다. 열린 동안은 바깥이 inert라 다시 누를 수 없다.
|
|
11
|
+
* `aria-haspopup="dialog"`, `aria-expanded`, 열렸을 때 `aria-controls`와 `data-open`이 붙는다.
|
|
12
|
+
*/
|
|
13
|
+
export declare function DialogTrigger({ render, ref, id, className, ...props }: DialogTriggerProps): ReactElement;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useDialogContext } from "../../_internal/hooks/useDialogContext.js";
|
|
4
|
+
import { renderElement } from "../../_internal/libs/renderElement.js";
|
|
5
|
+
import { createElement, useId, useLayoutEffect, useMemo } from "react";
|
|
6
|
+
import { mergeProps, mergeRefs, usePress } from "react-aria";
|
|
7
|
+
|
|
8
|
+
// src/Dialog/components/DialogTrigger.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Dialog를 여는 버튼. 누르면(마우스, 터치, Enter, Space) 연다. 열린 동안은 바깥이 inert라 다시 누를 수 없다.
|
|
11
|
+
* `aria-haspopup="dialog"`, `aria-expanded`, 열렸을 때 `aria-controls`와 `data-open`이 붙는다.
|
|
12
|
+
*/
|
|
13
|
+
function DialogTrigger({ render, ref, id, className, ...props }) {
|
|
14
|
+
const { state, triggerRef, triggerProps, setTriggerId } = useDialogContext("DialogTrigger");
|
|
15
|
+
const { onPress, ...ariaProps } = triggerProps;
|
|
16
|
+
const { pressProps } = usePress({
|
|
17
|
+
onPress,
|
|
18
|
+
ref: triggerRef
|
|
19
|
+
});
|
|
20
|
+
const mergedRef = useMemo(() => mergeRefs(ref, triggerRef), [ref, triggerRef]);
|
|
21
|
+
const generatedId = useId();
|
|
22
|
+
const resolvedId = id ?? generatedId;
|
|
23
|
+
useLayoutEffect(() => {
|
|
24
|
+
setTriggerId(resolvedId);
|
|
25
|
+
return () => setTriggerId(null);
|
|
26
|
+
}, [resolvedId, setTriggerId]);
|
|
27
|
+
const merged = {
|
|
28
|
+
...mergeProps(props, ariaProps, pressProps),
|
|
29
|
+
id: resolvedId,
|
|
30
|
+
ref: mergedRef,
|
|
31
|
+
"data-open": state.isOpen ? "" : void 0
|
|
32
|
+
};
|
|
33
|
+
if (!render) return createElement("button", {
|
|
34
|
+
type: "button",
|
|
35
|
+
...merged,
|
|
36
|
+
className
|
|
37
|
+
});
|
|
38
|
+
return renderElement({
|
|
39
|
+
defaultElement: "button",
|
|
40
|
+
render,
|
|
41
|
+
baseClassName: "",
|
|
42
|
+
props: {
|
|
43
|
+
...merged,
|
|
44
|
+
className
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { DialogTrigger };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { backdropMotionClass, dialogMotionClass, dialogSurfaceClass } from "../../_internal/constants/overlayClass.js";
|
|
2
|
+
|
|
3
|
+
// src/Dialog/constants/dialogClass.ts
|
|
4
|
+
const backdropClass = `fixed inset-0 isolate z-modal flex items-center justify-center bg-overlay p-4 ${backdropMotionClass}`;
|
|
5
|
+
const contentClass = `relative flex max-h-full w-full flex-col gap-4 overflow-y-auto p-6 text-body-md outline-none ${dialogSurfaceClass} ${dialogMotionClass}`;
|
|
6
|
+
const sizeClass = {
|
|
7
|
+
sm: "max-w-96",
|
|
8
|
+
md: "max-w-128",
|
|
9
|
+
lg: "max-w-160"
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { backdropClass, contentClass, sizeClass };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, use } from "react";
|
|
4
|
+
|
|
5
|
+
// src/Dialog/hooks/useDialogPartsContext.ts
|
|
6
|
+
const DialogPartsContext = createContext(null);
|
|
7
|
+
function useDialogPartsContext(part) {
|
|
8
|
+
const context = use(DialogPartsContext);
|
|
9
|
+
if (!context) throw new Error(`${part}는 DialogContent 안에 둔다.`);
|
|
10
|
+
return context;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { DialogPartsContext, useDialogPartsContext };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useId, useLayoutEffect } from "react";
|
|
4
|
+
|
|
5
|
+
// src/Dialog/hooks/usePartId.ts
|
|
6
|
+
/** 부분 요소의 id를 정하고 열린 동안 dialog에 알린다. */
|
|
7
|
+
function usePartId(id, register) {
|
|
8
|
+
const generated = useId();
|
|
9
|
+
const resolved = id ?? generated;
|
|
10
|
+
useLayoutEffect(() => {
|
|
11
|
+
register(resolved);
|
|
12
|
+
return () => register(null);
|
|
13
|
+
}, [resolved, register]);
|
|
14
|
+
return resolved;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { usePartId };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DialogProps } from "../_internal/components/DialogRoot.js";
|
|
2
|
+
import { Dialog } from "./Dialog.js";
|
|
3
|
+
import { DialogTrigger, DialogTriggerProps } from "./components/DialogTrigger.js";
|
|
4
|
+
import { DialogSize } from "./types.js";
|
|
5
|
+
import { DialogContent, DialogContentProps } from "./components/DialogContent.js";
|
|
6
|
+
import { DialogTitle, DialogTitleProps } from "./components/DialogTitle.js";
|
|
7
|
+
import { DialogDescription, DialogDescriptionProps } from "./components/DialogDescription.js";
|
|
8
|
+
import { DialogFooter, DialogFooterProps } from "./components/DialogFooter.js";
|
|
9
|
+
import { DialogClose, DialogCloseProps } from "./components/DialogClose.js";
|
|
10
|
+
export { Dialog, DialogClose, type DialogCloseProps, DialogContent, type DialogContentProps, DialogDescription, type DialogDescriptionProps, DialogFooter, type DialogFooterProps, type DialogProps, type DialogSize, DialogTitle, type DialogTitleProps, DialogTrigger, type DialogTriggerProps };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { cn } from "
|
|
2
|
-
import { FieldContext } from "
|
|
1
|
+
import { cn } from "../_internal/libs/cn.js";
|
|
2
|
+
import { FieldContext } from "../_internal/hooks/useFieldControl.js";
|
|
3
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { useId } from "react";
|
|
5
5
|
import { CircleExclamationPointIcon } from "@tide-design/icons";
|
|
6
6
|
|
|
7
|
-
// src/Field.tsx
|
|
7
|
+
// src/Field/Field.tsx
|
|
8
8
|
/** 값이 화면에 그릴 내용인지(null·undefined·false·빈 문자열이 아닌지) */
|
|
9
9
|
const hasContent = (node) => node !== void 0 && node !== null && node !== false && node !== "";
|
|
10
10
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FillVariant, Role, Size } from "
|
|
1
|
+
import { FillVariant, Role, Size } from "../types.js";
|
|
2
2
|
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
3
3
|
/** IconButton의 채움 방식. Button과 같은 4개를 받는다. */
|
|
4
4
|
type IconButtonVariant = Extract<FillVariant, "solid" | "subtle" | "outline" | "ghost">;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { pressableBaseClass } from "
|
|
4
|
-
import { pressableState } from "
|
|
5
|
-
import { renderElement } from "
|
|
6
|
-
import { Spinner } from "
|
|
3
|
+
import { pressableBaseClass } from "../_internal/constants/pressableClass.js";
|
|
4
|
+
import { pressableState } from "../_internal/libs/pressableState.js";
|
|
5
|
+
import { renderElement } from "../_internal/libs/renderElement.js";
|
|
6
|
+
import { Spinner } from "../Spinner/Spinner.js";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
|
|
9
|
-
// src/IconButton.tsx
|
|
9
|
+
// src/IconButton/IconButton.tsx
|
|
10
10
|
/** 정사각형 크기(spec size 표의 높이). padding은 없고 아이콘을 가운데 둔다. 24×24px 밑으로 내려가지 않는다. */
|
|
11
11
|
const sizeClass = {
|
|
12
12
|
xs: "size-6",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InputSize } from "
|
|
1
|
+
import { InputSize } from "../_internal/constants/inputClass.js";
|
|
2
2
|
import { ComponentProps, ReactElement } from "react";
|
|
3
3
|
export interface InputProps extends Omit<ComponentProps<"input">, "size"> {
|
|
4
4
|
/** 높이 `sm` 32px, `md` 40px, `lg` 48px. 같은 size의 Button과 높이가 같다. 기본값은 `md`다. */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { cn } from "
|
|
4
|
-
import { useFieldControl } from "
|
|
5
|
-
import { inputBaseClass, inputSizeClass } from "
|
|
3
|
+
import { cn } from "../_internal/libs/cn.js";
|
|
4
|
+
import { useFieldControl } from "../_internal/hooks/useFieldControl.js";
|
|
5
|
+
import { inputBaseClass, inputSizeClass } from "../_internal/constants/inputClass.js";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
|
|
8
|
-
// src/Input.tsx
|
|
8
|
+
// src/Input/Input.tsx
|
|
9
9
|
/**
|
|
10
10
|
* 한 줄 텍스트를 입력하는 네이티브 `<input>`. `type`(`email`, `password`, `date` 등)을 그대로 받는다.
|
|
11
11
|
* Field 안에 두면 label, 설명, 오류 메시지가 자동으로 연결된다.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { renderElement } from "
|
|
1
|
+
import { renderElement } from "../_internal/libs/renderElement.js";
|
|
2
2
|
|
|
3
|
-
// src/Link.tsx
|
|
3
|
+
// src/Link/Link.tsx
|
|
4
4
|
const baseClass = "cursor-pointer rounded-sm text-accent underline decoration-1 underline-offset-2 hover:decoration-2 focus-visible:focus-ring";
|
|
5
5
|
/**
|
|
6
6
|
* 문장 안에서 다른 페이지나 위치로 이동하는 텍스트 링크.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
|
+
export interface MenuProps {
|
|
3
|
+
/** 열림 상태(제어). 주면 `onOpenChange`로 바꾼다. */
|
|
4
|
+
open?: boolean;
|
|
5
|
+
/** 처음 열림 상태(비제어). 기본값은 `false`다. */
|
|
6
|
+
defaultOpen?: boolean;
|
|
7
|
+
/** 열림 상태가 바뀌려 할 때 새 값으로 부른다. 항목을 실행해 닫힐 때도 부른다. */
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
/** `MenuTrigger`와 `MenuContent` */
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 트리거와 동작 목록을 잇는 열림 상태. DOM 요소를 만들지 않는다.
|
|
14
|
+
* 안에 `MenuTrigger` 하나와 `MenuContent` 하나를 둔다.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Menu({ open, defaultOpen, onOpenChange, children }: MenuProps): ReactElement;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { MenuContext } from "./hooks/useMenuContext.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { useId, useMemo, useRef, useState } from "react";
|
|
6
|
+
import { useMenuTrigger } from "react-aria";
|
|
7
|
+
import { useMenuTriggerState } from "react-stately";
|
|
8
|
+
|
|
9
|
+
// src/Menu/Menu.tsx
|
|
10
|
+
/**
|
|
11
|
+
* 트리거와 동작 목록을 잇는 열림 상태. DOM 요소를 만들지 않는다.
|
|
12
|
+
* 안에 `MenuTrigger` 하나와 `MenuContent` 하나를 둔다.
|
|
13
|
+
*/
|
|
14
|
+
function Menu({ open, defaultOpen, onOpenChange, children }) {
|
|
15
|
+
const state = useMenuTriggerState({
|
|
16
|
+
isOpen: open,
|
|
17
|
+
defaultOpen,
|
|
18
|
+
onOpenChange
|
|
19
|
+
});
|
|
20
|
+
const triggerRef = useRef(null);
|
|
21
|
+
const { menuTriggerProps, menuProps } = useMenuTrigger({}, state, triggerRef);
|
|
22
|
+
const generatedTriggerId = useId();
|
|
23
|
+
const [triggerId, setTriggerId] = useState(generatedTriggerId);
|
|
24
|
+
const value = useMemo(() => ({
|
|
25
|
+
state,
|
|
26
|
+
triggerRef,
|
|
27
|
+
menuTriggerProps,
|
|
28
|
+
menuProps,
|
|
29
|
+
triggerId,
|
|
30
|
+
setTriggerId
|
|
31
|
+
}), [
|
|
32
|
+
state,
|
|
33
|
+
menuTriggerProps,
|
|
34
|
+
menuProps,
|
|
35
|
+
triggerId
|
|
36
|
+
]);
|
|
37
|
+
return /* @__PURE__ */ jsx(MenuContext, {
|
|
38
|
+
value,
|
|
39
|
+
children
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { Menu };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MenuPlacement } from "../types.js";
|
|
2
|
+
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
3
|
+
export interface MenuContentProps extends Omit<ComponentProps<"div">, "id" | "role"> {
|
|
4
|
+
/** 트리거 기준 위치. 기본값은 `bottom start`(아래, 시작 끝 맞춤)다. 공간이 모자라면 반대쪽으로 뒤집힌다. */
|
|
5
|
+
placement?: MenuPlacement;
|
|
6
|
+
/** 트리거와의 간격(px). 기본값은 `4`다. */
|
|
7
|
+
offset?: number;
|
|
8
|
+
/** `MenuItem`과 `MenuSection`. 이 요소들을 바로 아래(또는 Fragment·배열 안)에 둔다. */
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 트리거 옆에 뜨는 동작 목록(`role="menu"`). 열릴 때만 `document.body`에 portal로 렌더하고 `z-popover`로 쌓는다.
|
|
13
|
+
* 바로 나타나고, 닫히면 opacity만 `fast`(150ms)로 사라진다.
|
|
14
|
+
* 열려 있으면 `data-open`이, 트리거 기준 방향이 `data-placement`(`top`/`bottom`/`left`/`right`)로 붙는다.
|
|
15
|
+
*/
|
|
16
|
+
export declare function MenuContent(props: MenuContentProps): ReactElement | null;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { OverlayPortal } from "../../_internal/components/OverlayPortal.js";
|
|
4
|
+
import { useOverlayPresence } from "../../_internal/hooks/useOverlayPresence.js";
|
|
5
|
+
import { useMenuContext } from "../hooks/useMenuContext.js";
|
|
6
|
+
import { MenuContentInner } from "./MenuContentInner.js";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { useRef } from "react";
|
|
9
|
+
|
|
10
|
+
// src/Menu/components/MenuContent.tsx
|
|
11
|
+
/**
|
|
12
|
+
* 트리거 옆에 뜨는 동작 목록(`role="menu"`). 열릴 때만 `document.body`에 portal로 렌더하고 `z-popover`로 쌓는다.
|
|
13
|
+
* 바로 나타나고, 닫히면 opacity만 `fast`(150ms)로 사라진다.
|
|
14
|
+
* 열려 있으면 `data-open`이, 트리거 기준 방향이 `data-placement`(`top`/`bottom`/`left`/`right`)로 붙는다.
|
|
15
|
+
*/
|
|
16
|
+
function MenuContent(props) {
|
|
17
|
+
const context = useMenuContext("MenuContent");
|
|
18
|
+
const popoverRef = useRef(null);
|
|
19
|
+
if (!useOverlayPresence(context.state.isOpen, popoverRef)) return null;
|
|
20
|
+
return /* @__PURE__ */ jsx(OverlayPortal, {
|
|
21
|
+
isExiting: !context.state.isOpen,
|
|
22
|
+
children: /* @__PURE__ */ jsx(MenuContentInner, {
|
|
23
|
+
...props,
|
|
24
|
+
context,
|
|
25
|
+
popoverRef
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { MenuContent };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { listPopupClass, listSeparatorClass } from "../../_internal/constants/listClass.js";
|
|
4
|
+
import { useCloseOnTab } from "../../_internal/hooks/useCloseOnTab.js";
|
|
5
|
+
import { useOverlayTheme } from "../../_internal/hooks/useOverlayTheme.js";
|
|
6
|
+
import { usePopoverOverlay } from "../../_internal/hooks/usePopoverOverlay.js";
|
|
7
|
+
import { cn } from "../../_internal/libs/cn.js";
|
|
8
|
+
import { resolveCollectionChildren } from "../../_internal/libs/listCollection.js";
|
|
9
|
+
import { MenuItemView } from "./MenuItemView.js";
|
|
10
|
+
import { MenuSectionView } from "./MenuSectionView.js";
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
import { useMemo } from "react";
|
|
13
|
+
import { mergeProps, mergeRefs, useMenu } from "react-aria";
|
|
14
|
+
import { useTreeState } from "react-stately";
|
|
15
|
+
|
|
16
|
+
// src/Menu/components/MenuContentInner.tsx
|
|
17
|
+
/** DOM에 있는 동안만 portal 안에서 렌더한다. React Aria 오버레이·목록 hook은 요소가 있다고 보고 동작한다. */
|
|
18
|
+
function MenuContentInner({ context, popoverRef, placement = "bottom start", offset = 4, ref, className, children, ...props }) {
|
|
19
|
+
const { state, triggerRef, menuProps, triggerId } = context;
|
|
20
|
+
useOverlayTheme(triggerRef, popoverRef);
|
|
21
|
+
const { overlayProps } = usePopoverOverlay({
|
|
22
|
+
triggerRef,
|
|
23
|
+
popoverRef,
|
|
24
|
+
placement,
|
|
25
|
+
offset
|
|
26
|
+
}, state);
|
|
27
|
+
const items = useMemo(() => resolveCollectionChildren(children), [children]);
|
|
28
|
+
const tree = useTreeState({ children: items });
|
|
29
|
+
const labelledBy = props["aria-labelledby"] ?? (props["aria-label"] ? void 0 : triggerId);
|
|
30
|
+
const { menuProps: ariaMenuProps } = useMenu({
|
|
31
|
+
...menuProps,
|
|
32
|
+
"aria-label": props["aria-label"],
|
|
33
|
+
"aria-labelledby": labelledBy
|
|
34
|
+
}, tree, popoverRef);
|
|
35
|
+
const mergedRef = useMemo(() => mergeRefs(ref, popoverRef), [ref, popoverRef]);
|
|
36
|
+
useCloseOnTab(popoverRef, state.close);
|
|
37
|
+
const { style: _style, ...rest } = mergeProps(props, overlayProps, ariaMenuProps);
|
|
38
|
+
const nodes = [...tree.collection];
|
|
39
|
+
return /* @__PURE__ */ jsx("div", {
|
|
40
|
+
...rest,
|
|
41
|
+
ref: mergedRef,
|
|
42
|
+
"data-open": state.isOpen ? "" : void 0,
|
|
43
|
+
className: cn(listPopupClass, className),
|
|
44
|
+
style: {
|
|
45
|
+
...overlayProps.style,
|
|
46
|
+
...props.style
|
|
47
|
+
},
|
|
48
|
+
children: nodes.map((node, index) => {
|
|
49
|
+
const previous = nodes[index - 1];
|
|
50
|
+
const separator = previous !== void 0 && (node.type === "section" || previous.type === "section");
|
|
51
|
+
const element = node.type === "section" ? /* @__PURE__ */ jsx(MenuSectionView, {
|
|
52
|
+
node,
|
|
53
|
+
tree
|
|
54
|
+
}, node.key) : /* @__PURE__ */ jsx(MenuItemView, {
|
|
55
|
+
node,
|
|
56
|
+
tree
|
|
57
|
+
}, node.key);
|
|
58
|
+
if (!separator) return element;
|
|
59
|
+
return [/* @__PURE__ */ jsx("div", {
|
|
60
|
+
role: "separator",
|
|
61
|
+
className: listSeparatorClass
|
|
62
|
+
}, `${String(node.key)}-separator`), element];
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { MenuContentInner };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CollectionItemProps } from "../../_internal/libs/listCollection.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
export interface MenuItemProps extends Omit<ComponentProps<"div">, "role" | "children">, CollectionItemProps {
|
|
4
|
+
/** 항목 내용. 아이콘(장식용)과 글자를 함께 둘 수 있다. */
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* 항목을 실행할 때 부른다. 마우스·터치 누름뿐 아니라 Enter·Space도 click으로 실행한다(네이티브 버튼과 같다).
|
|
8
|
+
* 실행하면 메뉴가 닫힌다. `disabled`면 부르지 않는다.
|
|
9
|
+
*/
|
|
10
|
+
onClick?: ComponentProps<"div">["onClick"];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Menu의 동작 항목(`role="menuitem"`). `MenuContent`나 `MenuSection` 바로 안에 둔다.
|
|
14
|
+
* 키보드 위치와 마우스를 올린 항목은 highlight(primary subtle 배경, primary 글자)로 바로 바뀐다.
|
|
15
|
+
* 상태는 `data-highlighted`(키보드 위치·hover), `data-disabled`(비활성)로 노출한다.
|
|
16
|
+
*/
|
|
17
|
+
export declare function MenuItem(_props: MenuItemProps): null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { asCollectionComponent, itemCollectionNode } from "../../_internal/libs/listCollection.js";
|
|
4
|
+
|
|
5
|
+
// src/Menu/components/MenuItem.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Menu의 동작 항목(`role="menuitem"`). `MenuContent`나 `MenuSection` 바로 안에 둔다.
|
|
8
|
+
* 키보드 위치와 마우스를 올린 항목은 highlight(primary subtle 배경, primary 글자)로 바로 바뀐다.
|
|
9
|
+
* 상태는 `data-highlighted`(키보드 위치·hover), `data-disabled`(비활성)로 노출한다.
|
|
10
|
+
*/
|
|
11
|
+
function MenuItem(_props) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
asCollectionComponent(MenuItem, itemCollectionNode);
|
|
15
|
+
|
|
16
|
+
export { MenuItem };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { listItemClass } from "../../_internal/constants/listClass.js";
|
|
4
|
+
import { cn } from "../../_internal/libs/cn.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { useMemo, useRef } from "react";
|
|
7
|
+
import { mergeProps, mergeRefs, useMenuItem } from "react-aria";
|
|
8
|
+
|
|
9
|
+
// src/Menu/components/MenuItemView.tsx
|
|
10
|
+
/** 항목 하나를 그린다. node.props는 앱이 MenuItem에 준 props(와 컬렉션이 더한 isDisabled)다. */
|
|
11
|
+
function MenuItemView({ node, tree }) {
|
|
12
|
+
const itemRef = useRef(null);
|
|
13
|
+
const { ref, className, onClick, disabled: _disabled, textValue: _textValue, isDisabled: _isDisabled, children: _children, id, ...props } = node.props;
|
|
14
|
+
const { menuItemProps, isFocused, isDisabled } = useMenuItem({
|
|
15
|
+
key: node.key,
|
|
16
|
+
id,
|
|
17
|
+
onClick,
|
|
18
|
+
"aria-label": props["aria-label"]
|
|
19
|
+
}, tree, itemRef);
|
|
20
|
+
const mergedRef = useMemo(() => mergeRefs(ref, itemRef), [ref, itemRef]);
|
|
21
|
+
const merged = mergeProps(props, menuItemProps);
|
|
22
|
+
return /* @__PURE__ */ jsx("div", {
|
|
23
|
+
...merged,
|
|
24
|
+
ref: mergedRef,
|
|
25
|
+
"aria-labelledby": props["aria-labelledby"],
|
|
26
|
+
"aria-describedby": props["aria-describedby"],
|
|
27
|
+
"data-highlighted": isFocused ? "" : void 0,
|
|
28
|
+
"data-disabled": isDisabled ? "" : void 0,
|
|
29
|
+
className: cn(listItemClass, className),
|
|
30
|
+
children: node.rendered
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { MenuItemView };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CollectionSectionProps } from "../../_internal/libs/listCollection.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
export interface MenuSectionProps extends CollectionSectionProps {
|
|
4
|
+
/** 묶음 감싸개(`<div role="presentation">`)에 붙는 class */
|
|
5
|
+
className?: string;
|
|
6
|
+
/** `MenuItem`. 바로 아래(또는 Fragment·배열 안)에 둔다. */
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 항목 묶음(`role="group"`). `heading`이 화면에 보이는 제목이자 묶음의 이름이고, 없으면 `aria-label`이 이름이다.
|
|
11
|
+
* 앞뒤 다른 항목·묶음과의 사이에 구분선(`role="separator"`)이 그려진다.
|
|
12
|
+
*/
|
|
13
|
+
export declare function MenuSection(_props: MenuSectionProps): null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { asCollectionComponent, sectionCollectionNode } from "../../_internal/libs/listCollection.js";
|
|
4
|
+
|
|
5
|
+
// src/Menu/components/MenuSection.tsx
|
|
6
|
+
/**
|
|
7
|
+
* 항목 묶음(`role="group"`). `heading`이 화면에 보이는 제목이자 묶음의 이름이고, 없으면 `aria-label`이 이름이다.
|
|
8
|
+
* 앞뒤 다른 항목·묶음과의 사이에 구분선(`role="separator"`)이 그려진다.
|
|
9
|
+
*/
|
|
10
|
+
function MenuSection(_props) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
asCollectionComponent(MenuSection, sectionCollectionNode);
|
|
14
|
+
|
|
15
|
+
export { MenuSection };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { listHeadingClass } from "../../_internal/constants/listClass.js";
|
|
4
|
+
import { MenuItemView } from "./MenuItemView.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useMenuSection } from "react-aria";
|
|
7
|
+
|
|
8
|
+
// src/Menu/components/MenuSectionView.tsx
|
|
9
|
+
/** 묶음 하나를 그린다. 제목은 보조기술에서 숨기고(`presentation`) 묶음의 이름으로만 쓴다(useMenuSection). */
|
|
10
|
+
function MenuSectionView({ node, tree }) {
|
|
11
|
+
const { className } = node.props;
|
|
12
|
+
const { itemProps, headingProps, groupProps } = useMenuSection({
|
|
13
|
+
heading: node.rendered,
|
|
14
|
+
"aria-label": node["aria-label"]
|
|
15
|
+
});
|
|
16
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
17
|
+
...itemProps,
|
|
18
|
+
className,
|
|
19
|
+
children: [node.rendered != null && /* @__PURE__ */ jsx("div", {
|
|
20
|
+
...headingProps,
|
|
21
|
+
className: "px-2 pt-1.5 pb-1 text-label-sm text-muted select-none",
|
|
22
|
+
children: node.rendered
|
|
23
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
24
|
+
...groupProps,
|
|
25
|
+
children: [...node.childNodes].map((child) => /* @__PURE__ */ jsx(MenuItemView, {
|
|
26
|
+
node: child,
|
|
27
|
+
tree
|
|
28
|
+
}, child.key))
|
|
29
|
+
})]
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { MenuSectionView };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentProps, ReactElement } from "react";
|
|
2
|
+
export interface MenuTriggerProps extends ComponentProps<"button"> {
|
|
3
|
+
/**
|
|
4
|
+
* 다른 요소로 렌더한다. 예: `render={<Button variant="outline" />}`, `render={<IconButton aria-label="더보기" />}`.
|
|
5
|
+
* props, ref, className, 이벤트 핸들러를 그 요소에 병합한다. 기본은 class 없는 `<button type="button">`이다.
|
|
6
|
+
*/
|
|
7
|
+
render?: ReactElement;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Menu를 여는 버튼. 마우스는 누르는 순간 열고, 키보드는 Enter·Space·↓로 열어 첫 항목에, ↑로 열어 마지막 항목에
|
|
11
|
+
* 위치한다. `aria-haspopup`, `aria-expanded`, 열렸을 때 `aria-controls`와 `data-open`이 붙는다.
|
|
12
|
+
*/
|
|
13
|
+
export declare function MenuTrigger({ render, ref, id, className, ...props }: MenuTriggerProps): ReactElement;
|