@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,66 @@
|
|
|
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
|
+
function MenuContentInner({ context, popoverRef, placement = "bottom start", offset = 4, ref, className, children, ...props }) {
|
|
18
|
+
const { state, triggerRef, menuProps, triggerId } = context;
|
|
19
|
+
useOverlayTheme(triggerRef, popoverRef);
|
|
20
|
+
const { overlayProps } = usePopoverOverlay({
|
|
21
|
+
triggerRef,
|
|
22
|
+
popoverRef,
|
|
23
|
+
placement,
|
|
24
|
+
offset
|
|
25
|
+
}, state);
|
|
26
|
+
const items = useMemo(() => resolveCollectionChildren(children), [children]);
|
|
27
|
+
const tree = useTreeState({ children: items });
|
|
28
|
+
const labelledBy = props["aria-labelledby"] ?? (props["aria-label"] ? void 0 : triggerId);
|
|
29
|
+
const { menuProps: ariaMenuProps } = useMenu({
|
|
30
|
+
...menuProps,
|
|
31
|
+
"aria-label": props["aria-label"],
|
|
32
|
+
"aria-labelledby": labelledBy
|
|
33
|
+
}, tree, popoverRef);
|
|
34
|
+
const mergedRef = useMemo(() => mergeRefs(ref, popoverRef), [ref, popoverRef]);
|
|
35
|
+
useCloseOnTab(popoverRef, state.close);
|
|
36
|
+
const { style: _style, ...rest } = mergeProps(props, overlayProps, ariaMenuProps);
|
|
37
|
+
const nodes = [...tree.collection];
|
|
38
|
+
return /* @__PURE__ */ jsx("div", {
|
|
39
|
+
...rest,
|
|
40
|
+
ref: mergedRef,
|
|
41
|
+
"data-open": state.isOpen ? "" : void 0,
|
|
42
|
+
className: cn(listPopupClass, className),
|
|
43
|
+
style: {
|
|
44
|
+
...overlayProps.style,
|
|
45
|
+
...props.style
|
|
46
|
+
},
|
|
47
|
+
children: nodes.map((node, index) => {
|
|
48
|
+
const previous = nodes[index - 1];
|
|
49
|
+
const separator = previous !== void 0 && (node.type === "section" || previous.type === "section");
|
|
50
|
+
const element = node.type === "section" ? /* @__PURE__ */ jsx(MenuSectionView, {
|
|
51
|
+
node,
|
|
52
|
+
tree
|
|
53
|
+
}, node.key) : /* @__PURE__ */ jsx(MenuItemView, {
|
|
54
|
+
node,
|
|
55
|
+
tree
|
|
56
|
+
}, node.key);
|
|
57
|
+
if (!separator) return element;
|
|
58
|
+
return [/* @__PURE__ */ jsx("div", {
|
|
59
|
+
role: "separator",
|
|
60
|
+
className: listSeparatorClass
|
|
61
|
+
}, `${String(node.key)}-separator`), element];
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { MenuContentInner };
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
/** 항목을 실행할 때 부른다(누름·Enter·Space). 실행하면 메뉴가 닫힌다. `disabled`면 부르지 않는다. */
|
|
7
|
+
onClick?: ComponentProps<"div">["onClick"];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Menu의 동작 항목(`role="menuitem"`). `MenuContent`나 `MenuSection` 바로 안에 둔다.
|
|
11
|
+
* 상태는 `data-highlighted`(키보드 위치·hover), `data-disabled`(비활성)로 노출한다.
|
|
12
|
+
*/
|
|
13
|
+
export declare function MenuItem(_props: MenuItemProps): null;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
* 상태는 `data-highlighted`(키보드 위치·hover), `data-disabled`(비활성)로 노출한다.
|
|
9
|
+
*/
|
|
10
|
+
function MenuItem(_props) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
asCollectionComponent(MenuItem, itemCollectionNode);
|
|
14
|
+
|
|
15
|
+
export { MenuItem };
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
function MenuItemView({ node, tree }) {
|
|
11
|
+
const itemRef = useRef(null);
|
|
12
|
+
const { ref, className, onClick, disabled: _disabled, textValue: _textValue, isDisabled: _isDisabled, children: _children, id, ...props } = node.props;
|
|
13
|
+
const { menuItemProps, isFocused, isDisabled } = useMenuItem({
|
|
14
|
+
key: node.key,
|
|
15
|
+
id,
|
|
16
|
+
onClick,
|
|
17
|
+
"aria-label": props["aria-label"]
|
|
18
|
+
}, tree, itemRef);
|
|
19
|
+
const mergedRef = useMemo(() => mergeRefs(ref, itemRef), [ref, itemRef]);
|
|
20
|
+
const merged = mergeProps(props, menuItemProps);
|
|
21
|
+
return /* @__PURE__ */ jsx("div", {
|
|
22
|
+
...merged,
|
|
23
|
+
ref: mergedRef,
|
|
24
|
+
"aria-labelledby": props["aria-labelledby"],
|
|
25
|
+
"aria-describedby": props["aria-describedby"],
|
|
26
|
+
"data-highlighted": isFocused ? "" : void 0,
|
|
27
|
+
"data-disabled": isDisabled ? "" : void 0,
|
|
28
|
+
className: cn(listItemClass, className),
|
|
29
|
+
children: node.rendered
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
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,32 @@
|
|
|
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
|
+
function MenuSectionView({ node, tree }) {
|
|
10
|
+
const { className } = node.props;
|
|
11
|
+
const { itemProps, headingProps, groupProps } = useMenuSection({
|
|
12
|
+
heading: node.rendered,
|
|
13
|
+
"aria-label": node["aria-label"]
|
|
14
|
+
});
|
|
15
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
16
|
+
...itemProps,
|
|
17
|
+
className,
|
|
18
|
+
children: [node.rendered != null && /* @__PURE__ */ jsx("div", {
|
|
19
|
+
...headingProps,
|
|
20
|
+
className: "px-2 pt-1.5 pb-1 text-label-sm text-muted select-none",
|
|
21
|
+
children: node.rendered
|
|
22
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
23
|
+
...groupProps,
|
|
24
|
+
children: [...node.childNodes].map((child) => /* @__PURE__ */ jsx(MenuItemView, {
|
|
25
|
+
node: child,
|
|
26
|
+
tree
|
|
27
|
+
}, child.key))
|
|
28
|
+
})]
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
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" />}`. props·ref·className·핸들러를 병합한다.
|
|
5
|
+
* 기본은 class 없는 `<button type="button">`이다.
|
|
6
|
+
*/
|
|
7
|
+
render?: ReactElement;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Menu를 여는 버튼. 마우스는 누르는 순간 열고, 키보드는 Enter·Space·↓로 첫 항목, ↑로 마지막 항목에서 연다.
|
|
11
|
+
* 열렸을 때 `data-open`이 붙는다.
|
|
12
|
+
*/
|
|
13
|
+
export declare function MenuTrigger({ render, ref, id, className, ...props }: MenuTriggerProps): ReactElement;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { renderElement } from "../../_internal/libs/renderElement.js";
|
|
4
|
+
import { useMenuContext } from "../hooks/useMenuContext.js";
|
|
5
|
+
import { createElement, useLayoutEffect, useMemo } from "react";
|
|
6
|
+
import { mergeProps, mergeRefs, usePress } from "react-aria";
|
|
7
|
+
|
|
8
|
+
// src/Menu/components/MenuTrigger.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Menu를 여는 버튼. 마우스는 누르는 순간 열고, 키보드는 Enter·Space·↓로 첫 항목, ↑로 마지막 항목에서 연다.
|
|
11
|
+
* 열렸을 때 `data-open`이 붙는다.
|
|
12
|
+
*/
|
|
13
|
+
function MenuTrigger({ render, ref, id, className, ...props }) {
|
|
14
|
+
const { state, triggerRef, menuTriggerProps, triggerId, setTriggerId } = useMenuContext("MenuTrigger");
|
|
15
|
+
const { onPressStart, onPress, preventFocusOnPress, id: _ariaId, isDisabled: _isDisabled, ...ariaProps } = menuTriggerProps;
|
|
16
|
+
const { pressProps } = usePress({
|
|
17
|
+
onPressStart,
|
|
18
|
+
onPress,
|
|
19
|
+
preventFocusOnPress,
|
|
20
|
+
ref: triggerRef
|
|
21
|
+
});
|
|
22
|
+
const mergedRef = useMemo(() => mergeRefs(ref, triggerRef), [ref, triggerRef]);
|
|
23
|
+
const resolvedId = id ?? triggerId;
|
|
24
|
+
useLayoutEffect(() => {
|
|
25
|
+
if (resolvedId !== triggerId) setTriggerId(resolvedId);
|
|
26
|
+
}, [
|
|
27
|
+
resolvedId,
|
|
28
|
+
triggerId,
|
|
29
|
+
setTriggerId
|
|
30
|
+
]);
|
|
31
|
+
const merged = {
|
|
32
|
+
...mergeProps(props, ariaProps, pressProps),
|
|
33
|
+
id: resolvedId,
|
|
34
|
+
ref: mergedRef,
|
|
35
|
+
"data-open": state.isOpen ? "" : void 0
|
|
36
|
+
};
|
|
37
|
+
if (!render) return createElement("button", {
|
|
38
|
+
type: "button",
|
|
39
|
+
...merged,
|
|
40
|
+
className
|
|
41
|
+
});
|
|
42
|
+
return renderElement({
|
|
43
|
+
defaultElement: "button",
|
|
44
|
+
render,
|
|
45
|
+
baseClassName: "",
|
|
46
|
+
props: {
|
|
47
|
+
...merged,
|
|
48
|
+
className
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { MenuTrigger };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, use } from "react";
|
|
4
|
+
|
|
5
|
+
// src/Menu/hooks/useMenuContext.ts
|
|
6
|
+
const MenuContext = createContext(null);
|
|
7
|
+
function useMenuContext(part) {
|
|
8
|
+
const context = use(MenuContext);
|
|
9
|
+
if (!context) throw new Error(`${part}는 Menu 안에 둔다.`);
|
|
10
|
+
return context;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { MenuContext, useMenuContext };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Menu, MenuProps } from "./Menu.js";
|
|
2
|
+
import { MenuTrigger, MenuTriggerProps } from "./components/MenuTrigger.js";
|
|
3
|
+
import { MenuContent, MenuContentProps } from "./components/MenuContent.js";
|
|
4
|
+
import { MenuItem, MenuItemProps } from "./components/MenuItem.js";
|
|
5
|
+
import { MenuSection, MenuSectionProps } from "./components/MenuSection.js";
|
|
6
|
+
import { MenuPlacement } from "./types.js";
|
|
7
|
+
export { Menu, MenuContent, type MenuContentProps, MenuItem, type MenuItemProps, type MenuPlacement, type MenuProps, MenuSection, type MenuSectionProps, MenuTrigger, type MenuTriggerProps };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ComponentProps, ReactElement } from "react";
|
|
2
|
+
export interface PaginationProps extends ComponentProps<"nav"> {
|
|
3
|
+
/** 탐색 영역 이름. 기본값 `"페이지 이동"`. 한 화면에 여럿이면 `"댓글 페이지"`처럼 구분한다. */
|
|
4
|
+
"aria-label"?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 페이지 이동 탐색 영역(`<nav>` 안의 `<ul>`). 자식은 `PaginationItem`이다.
|
|
8
|
+
* 보일 번호 범위는 앱이 정한다. `ref`·`className`은 `<nav>`에 붙는다.
|
|
9
|
+
*/
|
|
10
|
+
export declare function Pagination({ "aria-label": ariaLabel, children, ...props }: PaginationProps): ReactElement;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { listClass } from "./constants/paginationClass.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
// src/Pagination/Pagination.tsx
|
|
5
|
+
/**
|
|
6
|
+
* 페이지 이동 탐색 영역(`<nav>` 안의 `<ul>`). 자식은 `PaginationItem`이다.
|
|
7
|
+
* 보일 번호 범위는 앱이 정한다. `ref`·`className`은 `<nav>`에 붙는다.
|
|
8
|
+
*/
|
|
9
|
+
function Pagination({ "aria-label": ariaLabel = "페이지 이동", children, ...props }) {
|
|
10
|
+
return /* @__PURE__ */ jsx("nav", {
|
|
11
|
+
...props,
|
|
12
|
+
"aria-label": ariaLabel,
|
|
13
|
+
children: /* @__PURE__ */ jsx("ul", {
|
|
14
|
+
className: listClass,
|
|
15
|
+
children
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { Pagination };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
2
|
+
export interface PaginationEllipsisProps extends Omit<ComponentProps<"span">, "children"> {
|
|
3
|
+
/** 스크린리더가 읽는 텍스트(화면에는 「…」만 보인다). 기본값 `"페이지 생략"`. */
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
/** 생략된 번호 자리. 화면에는 「…」 아이콘, 스크린리더에는 텍스트를 보인다. */
|
|
7
|
+
export declare function PaginationEllipsis({ className, children, ...props }: PaginationEllipsisProps): ReactElement;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { cn } from "../../_internal/libs/cn.js";
|
|
2
|
+
import { VisuallyHidden } from "../../VisuallyHidden/VisuallyHidden.js";
|
|
3
|
+
import { ellipsisClass } from "../constants/paginationClass.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { EllipsisIcon } from "@tide-design/icons";
|
|
6
|
+
|
|
7
|
+
// src/Pagination/components/PaginationEllipsis.tsx
|
|
8
|
+
/** 생략된 번호 자리. 화면에는 「…」 아이콘, 스크린리더에는 텍스트를 보인다. */
|
|
9
|
+
function PaginationEllipsis({ className, children = "페이지 생략", ...props }) {
|
|
10
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
11
|
+
...props,
|
|
12
|
+
className: cn(ellipsisClass, className),
|
|
13
|
+
children: [/* @__PURE__ */ jsx(EllipsisIcon, {}), /* @__PURE__ */ jsx(VisuallyHidden, { children })]
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { PaginationEllipsis };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComponentProps, ReactElement } from "react";
|
|
2
|
+
export interface PaginationLinkProps extends Omit<ComponentProps<"a">, "color"> {
|
|
3
|
+
/** 현재 페이지인지. `aria-current="page"`를 붙이고 subtle 채움으로 보인다. 기본값은 `false`다. */
|
|
4
|
+
current?: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* 다른 요소로 렌더한다. 예: `render={<NextLink href="?page=2" />}`.
|
|
7
|
+
* 상태로 페이지를 바꾸면 `render={<button type="button" onClick={...} />}`를 쓴다.
|
|
8
|
+
*/
|
|
9
|
+
render?: ReactElement;
|
|
10
|
+
}
|
|
11
|
+
/** 페이지 번호 링크. 기본은 `<a>`이고 Button(ghost, 32px) 모양이다. 현재 페이지는 `current`를 준다. */
|
|
12
|
+
export declare function PaginationLink({ current, render, className, ...props }: PaginationLinkProps): ReactElement;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Button } from "../../Button/Button.js";
|
|
2
|
+
import { cn } from "../../_internal/libs/cn.js";
|
|
3
|
+
import { linkClass } from "../constants/paginationClass.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
// src/Pagination/components/PaginationLink.tsx
|
|
7
|
+
/** 페이지 번호 링크. 기본은 `<a>`이고 Button(ghost, 32px) 모양이다. 현재 페이지는 `current`를 준다. */
|
|
8
|
+
function PaginationLink({ current = false, render, className, ...props }) {
|
|
9
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
10
|
+
...props,
|
|
11
|
+
render: render ?? /* @__PURE__ */ jsx("a", {}),
|
|
12
|
+
variant: current ? "subtle" : "ghost",
|
|
13
|
+
color: current ? "primary" : "neutral",
|
|
14
|
+
size: "sm",
|
|
15
|
+
"aria-current": current ? "page" : props["aria-current"],
|
|
16
|
+
className: cn(linkClass, className)
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { PaginationLink };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PaginationArrowProps } from "../types.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
export interface PaginationNextProps extends PaginationArrowProps {}
|
|
4
|
+
/** 다음 페이지로 가는 IconButton(ghost, 32px, ›). 마지막 페이지에서는 `disabled`를 준다. */
|
|
5
|
+
export declare function PaginationNext({ "aria-label": ariaLabel, ...props }: PaginationNextProps): ReactElement;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IconButton } from "../../IconButton/IconButton.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { ChevronRightIcon } from "@tide-design/icons";
|
|
4
|
+
|
|
5
|
+
// src/Pagination/components/PaginationNext.tsx
|
|
6
|
+
/** 다음 페이지로 가는 IconButton(ghost, 32px, ›). 마지막 페이지에서는 `disabled`를 준다. */
|
|
7
|
+
function PaginationNext({ "aria-label": ariaLabel = "다음 페이지", ...props }) {
|
|
8
|
+
return /* @__PURE__ */ jsx(IconButton, {
|
|
9
|
+
...props,
|
|
10
|
+
"aria-label": ariaLabel,
|
|
11
|
+
variant: "ghost",
|
|
12
|
+
color: "neutral",
|
|
13
|
+
size: "sm",
|
|
14
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, {})
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { PaginationNext };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PaginationArrowProps } from "../types.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
export interface PaginationPreviousProps extends PaginationArrowProps {}
|
|
4
|
+
/** 이전 페이지로 가는 IconButton(ghost, 32px, ‹). 첫 페이지에서는 `disabled`를 준다. */
|
|
5
|
+
export declare function PaginationPrevious({ "aria-label": ariaLabel, ...props }: PaginationPreviousProps): ReactElement;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IconButton } from "../../IconButton/IconButton.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { ChevronLeftIcon } from "@tide-design/icons";
|
|
4
|
+
|
|
5
|
+
// src/Pagination/components/PaginationPrevious.tsx
|
|
6
|
+
/** 이전 페이지로 가는 IconButton(ghost, 32px, ‹). 첫 페이지에서는 `disabled`를 준다. */
|
|
7
|
+
function PaginationPrevious({ "aria-label": ariaLabel = "이전 페이지", ...props }) {
|
|
8
|
+
return /* @__PURE__ */ jsx(IconButton, {
|
|
9
|
+
...props,
|
|
10
|
+
"aria-label": ariaLabel,
|
|
11
|
+
variant: "ghost",
|
|
12
|
+
color: "neutral",
|
|
13
|
+
size: "sm",
|
|
14
|
+
children: /* @__PURE__ */ jsx(ChevronLeftIcon, {})
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { PaginationPrevious };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// src/Pagination/constants/paginationClass.ts
|
|
2
|
+
const listClass = "flex flex-wrap items-center gap-1";
|
|
3
|
+
const linkClass = "min-w-8 px-2 tabular-nums";
|
|
4
|
+
const ellipsisClass = "inline-flex size-8 items-center justify-center text-muted";
|
|
5
|
+
|
|
6
|
+
export { ellipsisClass, linkClass, listClass };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Pagination, PaginationProps } from "./Pagination.js";
|
|
2
|
+
import { PaginationItem, PaginationItemProps } from "./components/PaginationItem.js";
|
|
3
|
+
import { PaginationLink, PaginationLinkProps } from "./components/PaginationLink.js";
|
|
4
|
+
import { PaginationPrevious, PaginationPreviousProps } from "./components/PaginationPrevious.js";
|
|
5
|
+
import { PaginationNext, PaginationNextProps } from "./components/PaginationNext.js";
|
|
6
|
+
import { PaginationEllipsis, PaginationEllipsisProps } from "./components/PaginationEllipsis.js";
|
|
7
|
+
export { Pagination, PaginationEllipsis, type PaginationEllipsisProps, PaginationItem, type PaginationItemProps, PaginationLink, type PaginationLinkProps, PaginationNext, type PaginationNextProps, PaginationPrevious, type PaginationPreviousProps, type PaginationProps };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IconButtonProps } from "../IconButton/IconButton.js";
|
|
2
|
+
/** 이전/다음 항목 props. IconButton에서 모양·아이콘·로딩을 고정했다. */
|
|
3
|
+
export interface PaginationArrowProps extends Omit<IconButtonProps, "aria-label" | "children" | "variant" | "color" | "size" | "loading" | "loadingLabel"> {
|
|
4
|
+
/** 버튼 이름. 기본값은 이전 `"이전 페이지"`, 다음 `"다음 페이지"`다. */
|
|
5
|
+
"aria-label"?: string;
|
|
6
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
|
+
export interface PopoverProps {
|
|
3
|
+
/** 열림 상태(제어). 주면 `onOpenChange`로 바꾼다. */
|
|
4
|
+
open?: boolean;
|
|
5
|
+
/** 처음 열림 상태(비제어). 기본값은 `false`다. */
|
|
6
|
+
defaultOpen?: boolean;
|
|
7
|
+
/** 열림 상태가 바뀌려 할 때 새 값으로 부른다. */
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
/** `PopoverTrigger`와 `PopoverContent` */
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 트리거와 내용을 잇는 열림 상태. DOM 요소를 만들지 않는다.
|
|
14
|
+
* 안에 `PopoverTrigger` 하나와 `PopoverContent` 하나를 둔다.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Popover({ open, defaultOpen, onOpenChange, children }: PopoverProps): ReactElement;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { PopoverContext } from "./hooks/usePopoverContext.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { useId, useMemo, useRef, useState } from "react";
|
|
6
|
+
import { useOverlayTrigger } from "react-aria";
|
|
7
|
+
import { useOverlayTriggerState } from "react-stately";
|
|
8
|
+
|
|
9
|
+
// src/Popover/Popover.tsx
|
|
10
|
+
/**
|
|
11
|
+
* 트리거와 내용을 잇는 열림 상태. DOM 요소를 만들지 않는다.
|
|
12
|
+
* 안에 `PopoverTrigger` 하나와 `PopoverContent` 하나를 둔다.
|
|
13
|
+
*/
|
|
14
|
+
function Popover({ open, defaultOpen, onOpenChange, children }) {
|
|
15
|
+
const state = useOverlayTriggerState({
|
|
16
|
+
isOpen: open,
|
|
17
|
+
defaultOpen,
|
|
18
|
+
onOpenChange
|
|
19
|
+
});
|
|
20
|
+
const triggerRef = useRef(null);
|
|
21
|
+
const { triggerProps, overlayProps } = useOverlayTrigger({ type: "dialog" }, state, triggerRef);
|
|
22
|
+
const generatedTriggerId = useId();
|
|
23
|
+
const [triggerId, setTriggerId] = useState(generatedTriggerId);
|
|
24
|
+
const value = useMemo(() => ({
|
|
25
|
+
state,
|
|
26
|
+
triggerRef,
|
|
27
|
+
triggerProps,
|
|
28
|
+
contentId: overlayProps.id,
|
|
29
|
+
triggerId,
|
|
30
|
+
setTriggerId
|
|
31
|
+
}), [
|
|
32
|
+
state,
|
|
33
|
+
triggerProps,
|
|
34
|
+
overlayProps.id,
|
|
35
|
+
triggerId
|
|
36
|
+
]);
|
|
37
|
+
return /* @__PURE__ */ jsx(PopoverContext, {
|
|
38
|
+
value,
|
|
39
|
+
children
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { Popover };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PopoverPlacement } from "../types.js";
|
|
2
|
+
import { ComponentProps, ReactElement } from "react";
|
|
3
|
+
export interface PopoverContentProps extends Omit<ComponentProps<"div">, "id" | "role"> {
|
|
4
|
+
/** 트리거 기준 위치. 기본값은 `bottom`(아래, 가운데 맞춤)이다. 공간이 모자라면 반대쪽으로 뒤집힌다. */
|
|
5
|
+
placement?: PopoverPlacement;
|
|
6
|
+
/** 트리거와의 간격(px). 기본값은 `8`이다. */
|
|
7
|
+
offset?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 트리거 옆에 뜨는 내용(`role="dialog"`). 열릴 때만 `document.body`에 portal로 렌더한다.
|
|
11
|
+
* 열려 있으면 `data-open`이, 트리거 기준 방향이 `data-placement`(`top`/`bottom`/`left`/`right`)로 붙는다.
|
|
12
|
+
*/
|
|
13
|
+
export declare function PopoverContent(props: PopoverContentProps): ReactElement | null;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { OverlayPortal } from "../../_internal/components/OverlayPortal.js";
|
|
4
|
+
import { useOverlayPresence } from "../../_internal/hooks/useOverlayPresence.js";
|
|
5
|
+
import { usePopoverContext } from "../hooks/usePopoverContext.js";
|
|
6
|
+
import { PopoverContentInner } from "./PopoverContentInner.js";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { useRef } from "react";
|
|
9
|
+
|
|
10
|
+
// src/Popover/components/PopoverContent.tsx
|
|
11
|
+
/**
|
|
12
|
+
* 트리거 옆에 뜨는 내용(`role="dialog"`). 열릴 때만 `document.body`에 portal로 렌더한다.
|
|
13
|
+
* 열려 있으면 `data-open`이, 트리거 기준 방향이 `data-placement`(`top`/`bottom`/`left`/`right`)로 붙는다.
|
|
14
|
+
*/
|
|
15
|
+
function PopoverContent(props) {
|
|
16
|
+
const context = usePopoverContext("PopoverContent");
|
|
17
|
+
const popoverRef = useRef(null);
|
|
18
|
+
if (!useOverlayPresence(context.state.isOpen, popoverRef)) return null;
|
|
19
|
+
return /* @__PURE__ */ jsx(OverlayPortal, {
|
|
20
|
+
isExiting: !context.state.isOpen,
|
|
21
|
+
children: /* @__PURE__ */ jsx(PopoverContentInner, {
|
|
22
|
+
...props,
|
|
23
|
+
context,
|
|
24
|
+
popoverRef
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { PopoverContent };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useOverlayTheme } from "../../_internal/hooks/useOverlayTheme.js";
|
|
4
|
+
import { usePopoverOverlay } from "../../_internal/hooks/usePopoverOverlay.js";
|
|
5
|
+
import { cn } from "../../_internal/libs/cn.js";
|
|
6
|
+
import { contentClass } from "../constants/popoverClass.js";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { useMemo } from "react";
|
|
9
|
+
import { DismissButton, mergeProps, mergeRefs, useDialog } from "react-aria";
|
|
10
|
+
|
|
11
|
+
// src/Popover/components/PopoverContentInner.tsx
|
|
12
|
+
/** DOM에 있는 동안만 portal 안에서 렌더한다. React Aria 오버레이 hook은 요소가 있다고 보고 동작한다. */
|
|
13
|
+
function PopoverContentInner({ context, popoverRef, placement = "bottom", offset = 8, ref, className, children, ...props }) {
|
|
14
|
+
const { state, triggerRef, contentId, triggerId } = context;
|
|
15
|
+
useOverlayTheme(triggerRef, popoverRef);
|
|
16
|
+
const { overlayProps } = usePopoverOverlay({
|
|
17
|
+
triggerRef,
|
|
18
|
+
popoverRef,
|
|
19
|
+
placement,
|
|
20
|
+
offset
|
|
21
|
+
}, state);
|
|
22
|
+
const { dialogProps } = useDialog({
|
|
23
|
+
"aria-label": props["aria-label"],
|
|
24
|
+
"aria-labelledby": props["aria-labelledby"]
|
|
25
|
+
}, popoverRef);
|
|
26
|
+
const labelledBy = dialogProps["aria-labelledby"] ?? (props["aria-label"] ? void 0 : triggerId);
|
|
27
|
+
const mergedRef = useMemo(() => mergeRefs(ref, popoverRef), [ref, popoverRef]);
|
|
28
|
+
const { style: _style, ...rest } = mergeProps(props, overlayProps, dialogProps);
|
|
29
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
30
|
+
...rest,
|
|
31
|
+
id: contentId,
|
|
32
|
+
ref: mergedRef,
|
|
33
|
+
"aria-labelledby": labelledBy,
|
|
34
|
+
"data-open": state.isOpen ? "" : void 0,
|
|
35
|
+
className: cn(contentClass, className),
|
|
36
|
+
style: {
|
|
37
|
+
...overlayProps.style,
|
|
38
|
+
...props.style
|
|
39
|
+
},
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ jsx(DismissButton, { onDismiss: state.close }),
|
|
42
|
+
children,
|
|
43
|
+
/* @__PURE__ */ jsx(DismissButton, { onDismiss: state.close })
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { PopoverContentInner };
|