@tide-design/components 0.11.0 → 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 -4
- 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 -26
- 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 -96
- 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 -4
- 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/{listbox.d.ts → _internal/components/ListBoxNodes/types.d.ts} +1 -1
- package/dist/_internal/components/OverlayPortal.js +21 -0
- package/dist/{alert-style.js → _internal/constants/alertClass.js} +2 -16
- package/dist/{choice-style.js → _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/{input-style.d.ts → _internal/constants/inputClass.d.ts} +1 -1
- package/dist/{input-style.js → _internal/constants/inputClass.js} +1 -1
- package/dist/{list-style.js → _internal/constants/listClass.js} +2 -2
- package/dist/{overlay-style.js → _internal/constants/overlayClass.js} +1 -1
- package/dist/_internal/constants/pressableClass.js +33 -0
- package/dist/{choice-group.js → _internal/hooks/useChoiceGroup.js} +2 -2
- package/dist/_internal/hooks/useCloseOnTab.js +29 -0
- package/dist/_internal/hooks/useDialogContext.js +14 -0
- package/dist/{field-context.js → _internal/hooks/useFieldControl.js} +1 -1
- package/dist/_internal/hooks/useOverlayPresence.js +46 -0
- package/dist/_internal/hooks/useOverlayTheme.js +20 -0
- package/dist/_internal/hooks/usePopoverOverlay.js +25 -0
- package/dist/_internal/libs/alertStatusIcon.js +17 -0
- package/dist/{cn.js → _internal/libs/cn.js} +1 -1
- package/dist/{list-collection.js → _internal/libs/listCollection.js} +1 -1
- package/dist/{overlay.d.ts → _internal/libs/overlayPosition.d.ts} +0 -1
- package/dist/_internal/libs/overlayPosition.js +20 -0
- package/dist/_internal/libs/pressableState.js +43 -0
- package/dist/{render.js → _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 -255
- package/dist/Menu.d.ts +0 -72
- package/dist/Menu.js +0 -226
- 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 -147
- package/dist/Select.js +0 -169
- 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 -191
- package/dist/Tooltip.d.ts +0 -53
- package/dist/Tooltip.js +0 -129
- package/dist/listbox.js +0 -90
- package/dist/overlay.js +0 -130
- package/dist/pressable.js +0 -70
- /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/{choice-style.d.ts → _internal/constants/choiceClass.d.ts} +0 -0
- /package/dist/{cn.d.ts → _internal/libs/cn.d.ts} +0 -0
- /package/dist/{list-collection.d.ts → _internal/libs/listCollection.d.ts} +0 -0
package/dist/Menu.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { CollectionItemProps, CollectionSectionProps } from "./list-collection.js";
|
|
2
|
-
import { OverlayPlacement } from "./overlay.js";
|
|
3
|
-
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
4
|
-
/** Menu 목록의 위치. 앞은 트리거의 어느 쪽, 뒤는 그 변에서 맞출 끝이다. 공간이 모자라면 반대쪽으로 뒤집힌다. */
|
|
5
|
-
export type MenuPlacement = OverlayPlacement;
|
|
6
|
-
export interface MenuProps {
|
|
7
|
-
/** 열림 상태(제어). 주면 `onOpenChange`로 바꾼다. */
|
|
8
|
-
open?: boolean;
|
|
9
|
-
/** 처음 열림 상태(비제어). 기본값은 `false`다. */
|
|
10
|
-
defaultOpen?: boolean;
|
|
11
|
-
/** 열림 상태가 바뀌려 할 때 새 값으로 부른다. 항목을 실행해 닫힐 때도 부른다. */
|
|
12
|
-
onOpenChange?: (open: boolean) => void;
|
|
13
|
-
/** `MenuTrigger`와 `MenuContent` */
|
|
14
|
-
children: ReactNode;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* 트리거와 동작 목록을 잇는 열림 상태. DOM 요소를 만들지 않는다.
|
|
18
|
-
* 안에 `MenuTrigger` 하나와 `MenuContent` 하나를 둔다.
|
|
19
|
-
*/
|
|
20
|
-
export declare function Menu({ open, defaultOpen, onOpenChange, children }: MenuProps): ReactElement;
|
|
21
|
-
export interface MenuTriggerProps extends ComponentProps<"button"> {
|
|
22
|
-
/**
|
|
23
|
-
* 다른 요소로 렌더한다. 예: `render={<Button variant="outline" />}`, `render={<IconButton aria-label="더보기" />}`.
|
|
24
|
-
* props, ref, className, 이벤트 핸들러를 그 요소에 병합한다. 기본은 class 없는 `<button type="button">`이다.
|
|
25
|
-
*/
|
|
26
|
-
render?: ReactElement;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Menu를 여는 버튼. 마우스는 누르는 순간 열고, 키보드는 Enter·Space·↓로 열어 첫 항목에, ↑로 열어 마지막 항목에
|
|
30
|
-
* 위치한다. `aria-haspopup`, `aria-expanded`, 열렸을 때 `aria-controls`와 `data-open`이 붙는다.
|
|
31
|
-
*/
|
|
32
|
-
export declare function MenuTrigger({ render, ref, id, className, ...props }: MenuTriggerProps): ReactElement;
|
|
33
|
-
export interface MenuContentProps extends Omit<ComponentProps<"div">, "id" | "role"> {
|
|
34
|
-
/** 트리거 기준 위치. 기본값은 `bottom start`(아래, 시작 끝 맞춤)다. 공간이 모자라면 반대쪽으로 뒤집힌다. */
|
|
35
|
-
placement?: MenuPlacement;
|
|
36
|
-
/** 트리거와의 간격(px). 기본값은 `4`다. */
|
|
37
|
-
offset?: number;
|
|
38
|
-
/** `MenuItem`과 `MenuSection`. 이 요소들을 바로 아래(또는 Fragment·배열 안)에 둔다. */
|
|
39
|
-
children?: ReactNode;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* 트리거 옆에 뜨는 동작 목록(`role="menu"`). 열릴 때만 `document.body`에 portal로 렌더하고 `z-popover`로 쌓는다.
|
|
43
|
-
* 바로 나타나고, 닫히면 opacity만 `fast`(150ms)로 사라진다.
|
|
44
|
-
* 열려 있으면 `data-open`이, 트리거 기준 방향이 `data-placement`(`top`/`bottom`/`left`/`right`)로 붙는다.
|
|
45
|
-
*/
|
|
46
|
-
export declare function MenuContent(props: MenuContentProps): ReactElement | null;
|
|
47
|
-
export interface MenuItemProps extends Omit<ComponentProps<"div">, "role" | "children">, CollectionItemProps {
|
|
48
|
-
/** 항목 내용. 아이콘(장식용)과 글자를 함께 둘 수 있다. */
|
|
49
|
-
children?: ReactNode;
|
|
50
|
-
/**
|
|
51
|
-
* 항목을 실행할 때 부른다. 마우스·터치 누름뿐 아니라 Enter·Space도 click으로 실행한다(네이티브 버튼과 같다).
|
|
52
|
-
* 실행하면 메뉴가 닫힌다. `disabled`면 부르지 않는다.
|
|
53
|
-
*/
|
|
54
|
-
onClick?: ComponentProps<"div">["onClick"];
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Menu의 동작 항목(`role="menuitem"`). `MenuContent`나 `MenuSection` 바로 안에 둔다.
|
|
58
|
-
* 키보드 위치와 마우스를 올린 항목은 highlight(primary subtle 배경, primary 글자)로 바로 바뀐다.
|
|
59
|
-
* 상태는 `data-highlighted`(키보드 위치·hover), `data-disabled`(비활성)로 노출한다.
|
|
60
|
-
*/
|
|
61
|
-
export declare function MenuItem(_props: MenuItemProps): null;
|
|
62
|
-
export interface MenuSectionProps extends CollectionSectionProps {
|
|
63
|
-
/** 묶음 감싸개(`<div role="presentation">`)에 붙는 class */
|
|
64
|
-
className?: string;
|
|
65
|
-
/** `MenuItem`. 바로 아래(또는 Fragment·배열 안)에 둔다. */
|
|
66
|
-
children?: ReactNode;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* 항목 묶음(`role="group"`). `heading`이 화면에 보이는 제목이자 묶음의 이름이고, 없으면 `aria-label`이 이름이다.
|
|
70
|
-
* 앞뒤 다른 항목·묶음과의 사이에 구분선(`role="separator"`)이 그려진다.
|
|
71
|
-
*/
|
|
72
|
-
export declare function MenuSection(_props: MenuSectionProps): null;
|
package/dist/Menu.js
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "./cn.js";
|
|
4
|
-
import { asCollectionComponent, itemCollectionNode, resolveCollectionChildren, sectionCollectionNode } from "./list-collection.js";
|
|
5
|
-
import { listHeadingClass, listItemClass, listPopupClass, listSeparatorClass } from "./list-style.js";
|
|
6
|
-
import { OverlayPortal, useCloseOnTab, useOverlayPresence, useOverlayTheme, usePopoverOverlay } from "./overlay.js";
|
|
7
|
-
import { renderElement } from "./render.js";
|
|
8
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
import { createContext, createElement, use, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
10
|
-
import { mergeProps, mergeRefs, useMenu, useMenuItem, useMenuSection, useMenuTrigger, usePress } from "react-aria";
|
|
11
|
-
import { useMenuTriggerState, useTreeState } from "react-stately";
|
|
12
|
-
|
|
13
|
-
// src/Menu.tsx
|
|
14
|
-
const MenuContext = createContext(null);
|
|
15
|
-
function useMenuContext(part) {
|
|
16
|
-
const context = use(MenuContext);
|
|
17
|
-
if (!context) throw new Error(`${part}는 Menu 안에 둔다.`);
|
|
18
|
-
return context;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* 트리거와 동작 목록을 잇는 열림 상태. DOM 요소를 만들지 않는다.
|
|
22
|
-
* 안에 `MenuTrigger` 하나와 `MenuContent` 하나를 둔다.
|
|
23
|
-
*/
|
|
24
|
-
function Menu({ open, defaultOpen, onOpenChange, children }) {
|
|
25
|
-
const state = useMenuTriggerState({
|
|
26
|
-
isOpen: open,
|
|
27
|
-
defaultOpen,
|
|
28
|
-
onOpenChange
|
|
29
|
-
});
|
|
30
|
-
const triggerRef = useRef(null);
|
|
31
|
-
const { menuTriggerProps, menuProps } = useMenuTrigger({}, state, triggerRef);
|
|
32
|
-
const generatedTriggerId = useId();
|
|
33
|
-
const [triggerId, setTriggerId] = useState(generatedTriggerId);
|
|
34
|
-
const value = useMemo(() => ({
|
|
35
|
-
state,
|
|
36
|
-
triggerRef,
|
|
37
|
-
menuTriggerProps,
|
|
38
|
-
menuProps,
|
|
39
|
-
triggerId,
|
|
40
|
-
setTriggerId
|
|
41
|
-
}), [
|
|
42
|
-
state,
|
|
43
|
-
menuTriggerProps,
|
|
44
|
-
menuProps,
|
|
45
|
-
triggerId
|
|
46
|
-
]);
|
|
47
|
-
return /* @__PURE__ */ jsx(MenuContext, {
|
|
48
|
-
value,
|
|
49
|
-
children
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Menu를 여는 버튼. 마우스는 누르는 순간 열고, 키보드는 Enter·Space·↓로 열어 첫 항목에, ↑로 열어 마지막 항목에
|
|
54
|
-
* 위치한다. `aria-haspopup`, `aria-expanded`, 열렸을 때 `aria-controls`와 `data-open`이 붙는다.
|
|
55
|
-
*/
|
|
56
|
-
function MenuTrigger({ render, ref, id, className, ...props }) {
|
|
57
|
-
const { state, triggerRef, menuTriggerProps, triggerId, setTriggerId } = useMenuContext("MenuTrigger");
|
|
58
|
-
const { onPressStart, onPress, preventFocusOnPress, id: _ariaId, isDisabled: _isDisabled, ...ariaProps } = menuTriggerProps;
|
|
59
|
-
const { pressProps } = usePress({
|
|
60
|
-
onPressStart,
|
|
61
|
-
onPress,
|
|
62
|
-
preventFocusOnPress,
|
|
63
|
-
ref: triggerRef
|
|
64
|
-
});
|
|
65
|
-
const mergedRef = useMemo(() => mergeRefs(ref, triggerRef), [ref, triggerRef]);
|
|
66
|
-
const resolvedId = id ?? triggerId;
|
|
67
|
-
useLayoutEffect(() => {
|
|
68
|
-
if (resolvedId !== triggerId) setTriggerId(resolvedId);
|
|
69
|
-
}, [
|
|
70
|
-
resolvedId,
|
|
71
|
-
triggerId,
|
|
72
|
-
setTriggerId
|
|
73
|
-
]);
|
|
74
|
-
const merged = {
|
|
75
|
-
...mergeProps(props, ariaProps, pressProps),
|
|
76
|
-
id: resolvedId,
|
|
77
|
-
ref: mergedRef,
|
|
78
|
-
"data-open": state.isOpen ? "" : void 0
|
|
79
|
-
};
|
|
80
|
-
if (!render) return createElement("button", {
|
|
81
|
-
type: "button",
|
|
82
|
-
...merged,
|
|
83
|
-
className
|
|
84
|
-
});
|
|
85
|
-
return renderElement({
|
|
86
|
-
defaultElement: "button",
|
|
87
|
-
render,
|
|
88
|
-
baseClassName: "",
|
|
89
|
-
props: {
|
|
90
|
-
...merged,
|
|
91
|
-
className
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* 트리거 옆에 뜨는 동작 목록(`role="menu"`). 열릴 때만 `document.body`에 portal로 렌더하고 `z-popover`로 쌓는다.
|
|
97
|
-
* 바로 나타나고, 닫히면 opacity만 `fast`(150ms)로 사라진다.
|
|
98
|
-
* 열려 있으면 `data-open`이, 트리거 기준 방향이 `data-placement`(`top`/`bottom`/`left`/`right`)로 붙는다.
|
|
99
|
-
*/
|
|
100
|
-
function MenuContent(props) {
|
|
101
|
-
const context = useMenuContext("MenuContent");
|
|
102
|
-
const popoverRef = useRef(null);
|
|
103
|
-
if (!useOverlayPresence(context.state.isOpen, popoverRef)) return null;
|
|
104
|
-
return /* @__PURE__ */ jsx(OverlayPortal, {
|
|
105
|
-
isExiting: !context.state.isOpen,
|
|
106
|
-
children: /* @__PURE__ */ jsx(MenuContentInner, {
|
|
107
|
-
...props,
|
|
108
|
-
context,
|
|
109
|
-
popoverRef
|
|
110
|
-
})
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
/** DOM에 있는 동안만 portal 안에서 렌더한다. React Aria 오버레이·목록 hook은 요소가 있다고 보고 동작한다. */
|
|
114
|
-
function MenuContentInner({ context, popoverRef, placement = "bottom start", offset = 4, ref, className, children, ...props }) {
|
|
115
|
-
const { state, triggerRef, menuProps, triggerId } = context;
|
|
116
|
-
useOverlayTheme(triggerRef, popoverRef);
|
|
117
|
-
const { overlayProps } = usePopoverOverlay({
|
|
118
|
-
triggerRef,
|
|
119
|
-
popoverRef,
|
|
120
|
-
placement,
|
|
121
|
-
offset
|
|
122
|
-
}, state);
|
|
123
|
-
const items = useMemo(() => resolveCollectionChildren(children), [children]);
|
|
124
|
-
const tree = useTreeState({ children: items });
|
|
125
|
-
const labelledBy = props["aria-labelledby"] ?? (props["aria-label"] ? void 0 : triggerId);
|
|
126
|
-
const { menuProps: ariaMenuProps } = useMenu({
|
|
127
|
-
...menuProps,
|
|
128
|
-
"aria-label": props["aria-label"],
|
|
129
|
-
"aria-labelledby": labelledBy
|
|
130
|
-
}, tree, popoverRef);
|
|
131
|
-
const mergedRef = useMemo(() => mergeRefs(ref, popoverRef), [ref, popoverRef]);
|
|
132
|
-
useCloseOnTab(popoverRef, state.close);
|
|
133
|
-
const { style: _style, ...rest } = mergeProps(props, overlayProps, ariaMenuProps);
|
|
134
|
-
const nodes = [...tree.collection];
|
|
135
|
-
return /* @__PURE__ */ jsx("div", {
|
|
136
|
-
...rest,
|
|
137
|
-
ref: mergedRef,
|
|
138
|
-
"data-open": state.isOpen ? "" : void 0,
|
|
139
|
-
className: cn(listPopupClass, className),
|
|
140
|
-
style: {
|
|
141
|
-
...overlayProps.style,
|
|
142
|
-
...props.style
|
|
143
|
-
},
|
|
144
|
-
children: nodes.map((node, index) => {
|
|
145
|
-
const previous = nodes[index - 1];
|
|
146
|
-
const separator = previous !== void 0 && (node.type === "section" || previous.type === "section");
|
|
147
|
-
const element = node.type === "section" ? /* @__PURE__ */ jsx(MenuSectionView, {
|
|
148
|
-
node,
|
|
149
|
-
tree
|
|
150
|
-
}, node.key) : /* @__PURE__ */ jsx(MenuItemView, {
|
|
151
|
-
node,
|
|
152
|
-
tree
|
|
153
|
-
}, node.key);
|
|
154
|
-
if (!separator) return element;
|
|
155
|
-
return [/* @__PURE__ */ jsx("div", {
|
|
156
|
-
role: "separator",
|
|
157
|
-
className: listSeparatorClass
|
|
158
|
-
}, `${String(node.key)}-separator`), element];
|
|
159
|
-
})
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Menu의 동작 항목(`role="menuitem"`). `MenuContent`나 `MenuSection` 바로 안에 둔다.
|
|
164
|
-
* 키보드 위치와 마우스를 올린 항목은 highlight(primary subtle 배경, primary 글자)로 바로 바뀐다.
|
|
165
|
-
* 상태는 `data-highlighted`(키보드 위치·hover), `data-disabled`(비활성)로 노출한다.
|
|
166
|
-
*/
|
|
167
|
-
function MenuItem(_props) {
|
|
168
|
-
return null;
|
|
169
|
-
}
|
|
170
|
-
asCollectionComponent(MenuItem, itemCollectionNode);
|
|
171
|
-
/**
|
|
172
|
-
* 항목 묶음(`role="group"`). `heading`이 화면에 보이는 제목이자 묶음의 이름이고, 없으면 `aria-label`이 이름이다.
|
|
173
|
-
* 앞뒤 다른 항목·묶음과의 사이에 구분선(`role="separator"`)이 그려진다.
|
|
174
|
-
*/
|
|
175
|
-
function MenuSection(_props) {
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
asCollectionComponent(MenuSection, sectionCollectionNode);
|
|
179
|
-
/** 항목 하나를 그린다. node.props는 앱이 MenuItem에 준 props(와 컬렉션이 더한 isDisabled)다. */
|
|
180
|
-
function MenuItemView({ node, tree }) {
|
|
181
|
-
const itemRef = useRef(null);
|
|
182
|
-
const { ref, className, onClick, disabled: _disabled, textValue: _textValue, isDisabled: _isDisabled, children: _children, id, ...props } = node.props;
|
|
183
|
-
const { menuItemProps, isFocused, isDisabled } = useMenuItem({
|
|
184
|
-
key: node.key,
|
|
185
|
-
id,
|
|
186
|
-
onClick,
|
|
187
|
-
"aria-label": props["aria-label"]
|
|
188
|
-
}, tree, itemRef);
|
|
189
|
-
const mergedRef = useMemo(() => mergeRefs(ref, itemRef), [ref, itemRef]);
|
|
190
|
-
const merged = mergeProps(props, menuItemProps);
|
|
191
|
-
return /* @__PURE__ */ jsx("div", {
|
|
192
|
-
...merged,
|
|
193
|
-
ref: mergedRef,
|
|
194
|
-
"aria-labelledby": props["aria-labelledby"],
|
|
195
|
-
"aria-describedby": props["aria-describedby"],
|
|
196
|
-
"data-highlighted": isFocused ? "" : void 0,
|
|
197
|
-
"data-disabled": isDisabled ? "" : void 0,
|
|
198
|
-
className: cn(listItemClass, className),
|
|
199
|
-
children: node.rendered
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
/** 묶음 하나를 그린다. 제목은 보조기술에서 숨기고(`presentation`) 묶음의 이름으로만 쓴다(useMenuSection). */
|
|
203
|
-
function MenuSectionView({ node, tree }) {
|
|
204
|
-
const { className } = node.props;
|
|
205
|
-
const { itemProps, headingProps, groupProps } = useMenuSection({
|
|
206
|
-
heading: node.rendered,
|
|
207
|
-
"aria-label": node["aria-label"]
|
|
208
|
-
});
|
|
209
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
210
|
-
...itemProps,
|
|
211
|
-
className,
|
|
212
|
-
children: [node.rendered != null && /* @__PURE__ */ jsx("div", {
|
|
213
|
-
...headingProps,
|
|
214
|
-
className: "px-2 pt-1.5 pb-1 text-label-sm text-muted select-none",
|
|
215
|
-
children: node.rendered
|
|
216
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
217
|
-
...groupProps,
|
|
218
|
-
children: [...node.childNodes].map((child) => /* @__PURE__ */ jsx(MenuItemView, {
|
|
219
|
-
node: child,
|
|
220
|
-
tree
|
|
221
|
-
}, child.key))
|
|
222
|
-
})]
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export { Menu, MenuContent, MenuItem, MenuSection, MenuTrigger };
|
package/dist/Pagination.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { IconButtonProps } from "./IconButton.js";
|
|
2
|
-
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
3
|
-
export interface PaginationProps extends ComponentProps<"nav"> {
|
|
4
|
-
/** 탐색 영역 이름. 기본값은 `"페이지 이동"`이다. 한 화면에 목록이 여럿이면 `"댓글 페이지"`처럼 구분한다. */
|
|
5
|
-
"aria-label"?: string;
|
|
6
|
-
}
|
|
7
|
-
export interface PaginationItemProps extends ComponentProps<"li"> {}
|
|
8
|
-
export interface PaginationLinkProps extends Omit<ComponentProps<"a">, "color"> {
|
|
9
|
-
/** 현재 페이지인지. `aria-current="page"`를 붙이고 subtle 채움으로 보인다. 기본값은 `false`다. */
|
|
10
|
-
current?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* 다른 요소로 렌더한다. 예: `render={<NextLink href="?page=2" />}`.
|
|
13
|
-
* 상태로 페이지를 바꾸면 `render={<button type="button" onClick={...} />}`를 쓴다. props, ref, className을 병합한다.
|
|
14
|
-
*/
|
|
15
|
-
render?: ReactElement;
|
|
16
|
-
}
|
|
17
|
-
/** 이전/다음 항목 props. IconButton의 props에서 모양(variant·color·size)과 아이콘·로딩을 고정했다. */
|
|
18
|
-
export interface PaginationArrowProps extends Omit<IconButtonProps, "aria-label" | "children" | "variant" | "color" | "size" | "loading" | "loadingLabel"> {
|
|
19
|
-
/** 버튼 이름. 기본값은 이전 `"이전 페이지"`, 다음 `"다음 페이지"`다. */
|
|
20
|
-
"aria-label"?: string;
|
|
21
|
-
}
|
|
22
|
-
export interface PaginationPreviousProps extends PaginationArrowProps {}
|
|
23
|
-
export interface PaginationNextProps extends PaginationArrowProps {}
|
|
24
|
-
export interface PaginationEllipsisProps extends Omit<ComponentProps<"span">, "children"> {
|
|
25
|
-
/** 스크린리더가 읽는 텍스트. 화면에는 「…」 아이콘만 보인다. 기본값은 `"페이지 생략"`이다. */
|
|
26
|
-
children?: ReactNode;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* 페이지 이동 탐색 영역. `<nav>` 안의 `<ul>`이다.
|
|
30
|
-
* 자식은 `PaginationItem`이고, 그 안에 `PaginationPrevious`·`PaginationLink`·`PaginationEllipsis`·`PaginationNext`를 둔다.
|
|
31
|
-
* `ref`·`className`은 `<nav>`에 붙는다.
|
|
32
|
-
*/
|
|
33
|
-
export declare function Pagination({ "aria-label": ariaLabel, children, ...props }: PaginationProps): ReactElement;
|
|
34
|
-
/** 목록의 한 항목 `<li>`. 기본 class가 없다. */
|
|
35
|
-
export declare function PaginationItem(props: PaginationItemProps): ReactElement;
|
|
36
|
-
/**
|
|
37
|
-
* 페이지 번호 링크. 기본은 `<a>`이고 Button(ghost, 32px) 모양이다. 현재 페이지는 `current`를 준다.
|
|
38
|
-
* Next.js에서는 `render={<NextLink href="?page=2" />}`를 쓴다.
|
|
39
|
-
*/
|
|
40
|
-
export declare function PaginationLink({ current, render, className, ...props }: PaginationLinkProps): ReactElement;
|
|
41
|
-
/** 이전 페이지로 가는 IconButton(ghost, 32px, ‹). 첫 페이지에서는 `disabled`를 준다. */
|
|
42
|
-
export declare function PaginationPrevious({ "aria-label": ariaLabel, ...props }: PaginationPreviousProps): ReactElement;
|
|
43
|
-
/** 다음 페이지로 가는 IconButton(ghost, 32px, ›). 마지막 페이지에서는 `disabled`를 준다. */
|
|
44
|
-
export declare function PaginationNext({ "aria-label": ariaLabel, ...props }: PaginationNextProps): ReactElement;
|
|
45
|
-
/** 생략된 번호 자리 `<span>`. 화면에는 「…」 아이콘, 스크린리더에는 텍스트(기본 `"페이지 생략"`)를 보인다. */
|
|
46
|
-
export declare function PaginationEllipsis({ className, children, ...props }: PaginationEllipsisProps): ReactElement;
|
package/dist/Pagination.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { Button } from "./Button.js";
|
|
2
|
-
import { cn } from "./cn.js";
|
|
3
|
-
import { IconButton } from "./IconButton.js";
|
|
4
|
-
import { VisuallyHidden } from "./VisuallyHidden.js";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { ChevronLeftIcon, ChevronRightIcon, EllipsisIcon } from "@tide-design/icons";
|
|
7
|
-
|
|
8
|
-
// src/Pagination.tsx
|
|
9
|
-
/** 페이지 번호·이전/다음 항목의 고정 size. 둘 다 32×32px다(24×24 이상). */
|
|
10
|
-
const itemSize = "sm";
|
|
11
|
-
const listClass = "flex flex-wrap items-center gap-1";
|
|
12
|
-
const linkClass = "min-w-8 px-2 tabular-nums";
|
|
13
|
-
const ellipsisClass = "inline-flex size-8 items-center justify-center text-muted";
|
|
14
|
-
/**
|
|
15
|
-
* 페이지 이동 탐색 영역. `<nav>` 안의 `<ul>`이다.
|
|
16
|
-
* 자식은 `PaginationItem`이고, 그 안에 `PaginationPrevious`·`PaginationLink`·`PaginationEllipsis`·`PaginationNext`를 둔다.
|
|
17
|
-
* `ref`·`className`은 `<nav>`에 붙는다.
|
|
18
|
-
*/
|
|
19
|
-
function Pagination({ "aria-label": ariaLabel = "페이지 이동", children, ...props }) {
|
|
20
|
-
return /* @__PURE__ */ jsx("nav", {
|
|
21
|
-
...props,
|
|
22
|
-
"aria-label": ariaLabel,
|
|
23
|
-
children: /* @__PURE__ */ jsx("ul", {
|
|
24
|
-
className: listClass,
|
|
25
|
-
children
|
|
26
|
-
})
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
/** 목록의 한 항목 `<li>`. 기본 class가 없다. */
|
|
30
|
-
function PaginationItem(props) {
|
|
31
|
-
return /* @__PURE__ */ jsx("li", { ...props });
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* 페이지 번호 링크. 기본은 `<a>`이고 Button(ghost, 32px) 모양이다. 현재 페이지는 `current`를 준다.
|
|
35
|
-
* Next.js에서는 `render={<NextLink href="?page=2" />}`를 쓴다.
|
|
36
|
-
*/
|
|
37
|
-
function PaginationLink({ current = false, render, className, ...props }) {
|
|
38
|
-
return /* @__PURE__ */ jsx(Button, {
|
|
39
|
-
...props,
|
|
40
|
-
render: render ?? /* @__PURE__ */ jsx("a", {}),
|
|
41
|
-
variant: current ? "subtle" : "ghost",
|
|
42
|
-
color: current ? "primary" : "neutral",
|
|
43
|
-
size: itemSize,
|
|
44
|
-
"aria-current": current ? "page" : props["aria-current"],
|
|
45
|
-
className: cn(linkClass, className)
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/** 이전 페이지로 가는 IconButton(ghost, 32px, ‹). 첫 페이지에서는 `disabled`를 준다. */
|
|
49
|
-
function PaginationPrevious({ "aria-label": ariaLabel = "이전 페이지", ...props }) {
|
|
50
|
-
return /* @__PURE__ */ jsx(IconButton, {
|
|
51
|
-
...props,
|
|
52
|
-
"aria-label": ariaLabel,
|
|
53
|
-
variant: "ghost",
|
|
54
|
-
color: "neutral",
|
|
55
|
-
size: itemSize,
|
|
56
|
-
children: /* @__PURE__ */ jsx(ChevronLeftIcon, {})
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
/** 다음 페이지로 가는 IconButton(ghost, 32px, ›). 마지막 페이지에서는 `disabled`를 준다. */
|
|
60
|
-
function PaginationNext({ "aria-label": ariaLabel = "다음 페이지", ...props }) {
|
|
61
|
-
return /* @__PURE__ */ jsx(IconButton, {
|
|
62
|
-
...props,
|
|
63
|
-
"aria-label": ariaLabel,
|
|
64
|
-
variant: "ghost",
|
|
65
|
-
color: "neutral",
|
|
66
|
-
size: itemSize,
|
|
67
|
-
children: /* @__PURE__ */ jsx(ChevronRightIcon, {})
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
/** 생략된 번호 자리 `<span>`. 화면에는 「…」 아이콘, 스크린리더에는 텍스트(기본 `"페이지 생략"`)를 보인다. */
|
|
71
|
-
function PaginationEllipsis({ className, children = "페이지 생략", ...props }) {
|
|
72
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
73
|
-
...props,
|
|
74
|
-
className: cn(ellipsisClass, className),
|
|
75
|
-
children: [/* @__PURE__ */ jsx(EllipsisIcon, {}), /* @__PURE__ */ jsx(VisuallyHidden, { children })]
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export { Pagination, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious };
|
package/dist/Popover.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { OverlayPlacement } from "./overlay.js";
|
|
2
|
-
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
3
|
-
/** Popover 내용의 위치. 앞은 트리거의 어느 쪽, 뒤는 그 변에서 맞출 끝이다. 공간이 모자라면 반대쪽으로 뒤집힌다. */
|
|
4
|
-
export type PopoverPlacement = OverlayPlacement;
|
|
5
|
-
export interface PopoverProps {
|
|
6
|
-
/** 열림 상태(제어). 주면 `onOpenChange`로 바꾼다. */
|
|
7
|
-
open?: boolean;
|
|
8
|
-
/** 처음 열림 상태(비제어). 기본값은 `false`다. */
|
|
9
|
-
defaultOpen?: boolean;
|
|
10
|
-
/** 열림 상태가 바뀌려 할 때 새 값으로 부른다. */
|
|
11
|
-
onOpenChange?: (open: boolean) => void;
|
|
12
|
-
/** `PopoverTrigger`와 `PopoverContent` */
|
|
13
|
-
children: ReactNode;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* 트리거와 내용을 잇는 열림 상태. DOM 요소를 만들지 않는다.
|
|
17
|
-
* 안에 `PopoverTrigger` 하나와 `PopoverContent` 하나를 둔다.
|
|
18
|
-
*/
|
|
19
|
-
export declare function Popover({ open, defaultOpen, onOpenChange, children }: PopoverProps): ReactElement;
|
|
20
|
-
export interface PopoverTriggerProps extends ComponentProps<"button"> {
|
|
21
|
-
/**
|
|
22
|
-
* 다른 요소로 렌더한다. 예: `render={<Button variant="outline" />}`, `render={<IconButton aria-label="설정" />}`.
|
|
23
|
-
* props, ref, className, 이벤트 핸들러를 그 요소에 병합한다. 기본은 class 없는 `<button type="button">`이다.
|
|
24
|
-
*/
|
|
25
|
-
render?: ReactElement;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Popover를 여닫는 버튼. 누르면(마우스, 터치, Enter, Space) 열림 상태를 뒤집는다.
|
|
29
|
-
* `aria-expanded`, 열렸을 때 `aria-controls`, 열렸을 때 `data-open`이 붙는다.
|
|
30
|
-
*/
|
|
31
|
-
export declare function PopoverTrigger({ render, ref, id, className, ...props }: PopoverTriggerProps): ReactElement;
|
|
32
|
-
export interface PopoverContentProps extends Omit<ComponentProps<"div">, "id" | "role"> {
|
|
33
|
-
/** 트리거 기준 위치. 기본값은 `bottom`(아래, 가운데 맞춤)이다. 공간이 모자라면 반대쪽으로 뒤집힌다. */
|
|
34
|
-
placement?: PopoverPlacement;
|
|
35
|
-
/** 트리거와의 간격(px). 기본값은 `8`이다. */
|
|
36
|
-
offset?: number;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* 트리거 옆에 뜨는 내용(`role="dialog"`). 열릴 때만 `document.body`에 portal로 렌더하고 `z-popover`로 쌓는다.
|
|
40
|
-
* 등장은 opacity + blur 4px + 4px 이동(`normal`), 퇴장은 그 절반(`fast`)이다. 움직임 줄이기에서는 opacity만 바뀐다.
|
|
41
|
-
* 열려 있으면 `data-open`이, 트리거 기준 방향이 `data-placement`(`top`/`bottom`/`left`/`right`)로 붙는다.
|
|
42
|
-
*/
|
|
43
|
-
export declare function PopoverContent(props: PopoverContentProps): ReactElement | null;
|
package/dist/Popover.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "./cn.js";
|
|
4
|
-
import { OverlayPortal, useOverlayPresence, useOverlayTheme, usePopoverOverlay } from "./overlay.js";
|
|
5
|
-
import { overlaySurfaceClass, popoverMotionClass } from "./overlay-style.js";
|
|
6
|
-
import { renderElement } from "./render.js";
|
|
7
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import { createContext, createElement, use, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
9
|
-
import { DismissButton, mergeProps, mergeRefs, useDialog, useOverlayTrigger, usePress } from "react-aria";
|
|
10
|
-
import { useOverlayTriggerState } from "react-stately";
|
|
11
|
-
|
|
12
|
-
// src/Popover.tsx
|
|
13
|
-
const PopoverContext = createContext(null);
|
|
14
|
-
function usePopoverContext(part) {
|
|
15
|
-
const context = use(PopoverContext);
|
|
16
|
-
if (!context) throw new Error(`${part}는 Popover 안에 둔다.`);
|
|
17
|
-
return context;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* 트리거와 내용을 잇는 열림 상태. DOM 요소를 만들지 않는다.
|
|
21
|
-
* 안에 `PopoverTrigger` 하나와 `PopoverContent` 하나를 둔다.
|
|
22
|
-
*/
|
|
23
|
-
function Popover({ open, defaultOpen, onOpenChange, children }) {
|
|
24
|
-
const state = useOverlayTriggerState({
|
|
25
|
-
isOpen: open,
|
|
26
|
-
defaultOpen,
|
|
27
|
-
onOpenChange
|
|
28
|
-
});
|
|
29
|
-
const triggerRef = useRef(null);
|
|
30
|
-
const { triggerProps, overlayProps } = useOverlayTrigger({ type: "dialog" }, state, triggerRef);
|
|
31
|
-
const generatedTriggerId = useId();
|
|
32
|
-
const [triggerId, setTriggerId] = useState(generatedTriggerId);
|
|
33
|
-
const value = useMemo(() => ({
|
|
34
|
-
state,
|
|
35
|
-
triggerRef,
|
|
36
|
-
triggerProps,
|
|
37
|
-
contentId: overlayProps.id,
|
|
38
|
-
triggerId,
|
|
39
|
-
setTriggerId
|
|
40
|
-
}), [
|
|
41
|
-
state,
|
|
42
|
-
triggerProps,
|
|
43
|
-
overlayProps.id,
|
|
44
|
-
triggerId
|
|
45
|
-
]);
|
|
46
|
-
return /* @__PURE__ */ jsx(PopoverContext, {
|
|
47
|
-
value,
|
|
48
|
-
children
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Popover를 여닫는 버튼. 누르면(마우스, 터치, Enter, Space) 열림 상태를 뒤집는다.
|
|
53
|
-
* `aria-expanded`, 열렸을 때 `aria-controls`, 열렸을 때 `data-open`이 붙는다.
|
|
54
|
-
*/
|
|
55
|
-
function PopoverTrigger({ render, ref, id, className, ...props }) {
|
|
56
|
-
const { state, triggerRef, triggerProps, triggerId, setTriggerId } = usePopoverContext("PopoverTrigger");
|
|
57
|
-
const { onPress, ...ariaProps } = triggerProps;
|
|
58
|
-
const { pressProps } = usePress({
|
|
59
|
-
onPress,
|
|
60
|
-
ref: triggerRef
|
|
61
|
-
});
|
|
62
|
-
const mergedRef = useMemo(() => mergeRefs(ref, triggerRef), [ref, triggerRef]);
|
|
63
|
-
const resolvedId = id ?? triggerId;
|
|
64
|
-
useLayoutEffect(() => {
|
|
65
|
-
if (resolvedId !== triggerId) setTriggerId(resolvedId);
|
|
66
|
-
}, [
|
|
67
|
-
resolvedId,
|
|
68
|
-
triggerId,
|
|
69
|
-
setTriggerId
|
|
70
|
-
]);
|
|
71
|
-
const merged = {
|
|
72
|
-
...mergeProps(props, ariaProps, pressProps),
|
|
73
|
-
id: resolvedId,
|
|
74
|
-
ref: mergedRef,
|
|
75
|
-
"data-open": state.isOpen ? "" : void 0
|
|
76
|
-
};
|
|
77
|
-
if (!render) return createElement("button", {
|
|
78
|
-
type: "button",
|
|
79
|
-
...merged,
|
|
80
|
-
className
|
|
81
|
-
});
|
|
82
|
-
return renderElement({
|
|
83
|
-
defaultElement: "button",
|
|
84
|
-
render,
|
|
85
|
-
baseClassName: "",
|
|
86
|
-
props: {
|
|
87
|
-
...merged,
|
|
88
|
-
className
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
const contentClass = `isolate z-popover max-w-80 overflow-auto p-4 text-body-md outline-none ${overlaySurfaceClass} ${popoverMotionClass}`;
|
|
93
|
-
/**
|
|
94
|
-
* 트리거 옆에 뜨는 내용(`role="dialog"`). 열릴 때만 `document.body`에 portal로 렌더하고 `z-popover`로 쌓는다.
|
|
95
|
-
* 등장은 opacity + blur 4px + 4px 이동(`normal`), 퇴장은 그 절반(`fast`)이다. 움직임 줄이기에서는 opacity만 바뀐다.
|
|
96
|
-
* 열려 있으면 `data-open`이, 트리거 기준 방향이 `data-placement`(`top`/`bottom`/`left`/`right`)로 붙는다.
|
|
97
|
-
*/
|
|
98
|
-
function PopoverContent(props) {
|
|
99
|
-
const context = usePopoverContext("PopoverContent");
|
|
100
|
-
const popoverRef = useRef(null);
|
|
101
|
-
if (!useOverlayPresence(context.state.isOpen, popoverRef)) return null;
|
|
102
|
-
return /* @__PURE__ */ jsx(OverlayPortal, {
|
|
103
|
-
isExiting: !context.state.isOpen,
|
|
104
|
-
children: /* @__PURE__ */ jsx(PopoverContentInner, {
|
|
105
|
-
...props,
|
|
106
|
-
context,
|
|
107
|
-
popoverRef
|
|
108
|
-
})
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
/** DOM에 있는 동안만 portal 안에서 렌더한다. React Aria 오버레이 hook은 요소가 있다고 보고 동작한다. */
|
|
112
|
-
function PopoverContentInner({ context, popoverRef, placement = "bottom", offset = 8, ref, className, children, ...props }) {
|
|
113
|
-
const { state, triggerRef, contentId, triggerId } = context;
|
|
114
|
-
useOverlayTheme(triggerRef, popoverRef);
|
|
115
|
-
const { overlayProps } = usePopoverOverlay({
|
|
116
|
-
triggerRef,
|
|
117
|
-
popoverRef,
|
|
118
|
-
placement,
|
|
119
|
-
offset
|
|
120
|
-
}, state);
|
|
121
|
-
const { dialogProps } = useDialog({
|
|
122
|
-
"aria-label": props["aria-label"],
|
|
123
|
-
"aria-labelledby": props["aria-labelledby"]
|
|
124
|
-
}, popoverRef);
|
|
125
|
-
const labelledBy = dialogProps["aria-labelledby"] ?? (props["aria-label"] ? void 0 : triggerId);
|
|
126
|
-
const mergedRef = useMemo(() => mergeRefs(ref, popoverRef), [ref, popoverRef]);
|
|
127
|
-
const { style: _style, ...rest } = mergeProps(props, overlayProps, dialogProps);
|
|
128
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
129
|
-
...rest,
|
|
130
|
-
id: contentId,
|
|
131
|
-
ref: mergedRef,
|
|
132
|
-
"aria-labelledby": labelledBy,
|
|
133
|
-
"data-open": state.isOpen ? "" : void 0,
|
|
134
|
-
className: cn(contentClass, className),
|
|
135
|
-
style: {
|
|
136
|
-
...overlayProps.style,
|
|
137
|
-
...props.style
|
|
138
|
-
},
|
|
139
|
-
children: [
|
|
140
|
-
/* @__PURE__ */ jsx(DismissButton, { onDismiss: state.close }),
|
|
141
|
-
children,
|
|
142
|
-
/* @__PURE__ */ jsx(DismissButton, { onDismiss: state.close })
|
|
143
|
-
]
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export { Popover, PopoverContent, PopoverTrigger };
|