@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
package/dist/Tag.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "./libs/cn.js";
|
|
4
|
-
import { IconButton } from "./IconButton.js";
|
|
5
|
-
import { asCollectionComponent, resolveCollectionChildren, valueItemCollectionNode } from "./libs/listCollection.js";
|
|
6
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { createContext, use, useMemo, useRef } from "react";
|
|
8
|
-
import { XIcon } from "@tide-design/icons";
|
|
9
|
-
import { mergeProps, mergeRefs, useTag, useTagGroup } from "react-aria";
|
|
10
|
-
import { useListState } from "react-stately";
|
|
11
|
-
|
|
12
|
-
// src/Tag.tsx
|
|
13
|
-
const TagGroupContext = createContext(null);
|
|
14
|
-
const tagGroupClass = "flex flex-wrap items-center gap-2 outline-none";
|
|
15
|
-
const tagClass = [
|
|
16
|
-
"inline-flex h-8 max-w-full min-w-0 shrink-0 items-center rounded-sm border border-accent-subtle bg-accent-subtle ps-2.5 align-middle text-label-md whitespace-nowrap text-accent-on-subtle outline-none select-none",
|
|
17
|
-
"[--tag-remove-hover:var(--tide-accent-subtle-hover)] [--tag-remove-active:var(--tide-accent-subtle-active)]",
|
|
18
|
-
"aria-disabled:bg-disabled aria-disabled:text-disabled focus-visible:focus-ring"
|
|
19
|
-
].join(" ");
|
|
20
|
-
const tagCellClass = "flex min-w-0 items-center gap-1";
|
|
21
|
-
const tagLabelClass = "inline-flex min-w-0 items-center gap-1 [&>svg]:size-4 [&>svg]:shrink-0";
|
|
22
|
-
const removeClass = "rounded-sm text-current";
|
|
23
|
-
const removeInteractionClass = "hover:bg-(--tag-remove-hover) active:bg-(--tag-remove-active)";
|
|
24
|
-
/**
|
|
25
|
-
* 고르거나 입력한 값을 보여 주는 태그 묶음(`role="grid"`). ←→로 태그를 옮기고(끝에서 처음으로 돈다) Home·End로
|
|
26
|
-
* 처음·마지막 태그에 간다. `onRemove`를 주면 Delete·Backspace와 지우기 버튼으로 태그를 지운다.
|
|
27
|
-
* 지운 뒤 포커스는 옆 태그로 옮겨 간다. 이름은 `aria-label`이나 `aria-labelledby`로 꼭 준다.
|
|
28
|
-
*/
|
|
29
|
-
function TagGroup({ onRemove, removeLabel = "제거", ref, className, children, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, ...props }) {
|
|
30
|
-
const groupRef = useRef(null);
|
|
31
|
-
const items = useMemo(() => resolveCollectionChildren(children), [children]);
|
|
32
|
-
const state = useListState({ children: items });
|
|
33
|
-
const { gridProps } = useTagGroup({
|
|
34
|
-
id,
|
|
35
|
-
"aria-label": ariaLabel,
|
|
36
|
-
"aria-labelledby": ariaLabelledby,
|
|
37
|
-
"aria-describedby": ariaDescribedby,
|
|
38
|
-
onRemove: onRemove ? (keys) => keys.forEach((key) => onRemove(String(key))) : void 0
|
|
39
|
-
}, state, groupRef);
|
|
40
|
-
const mergedRef = useMemo(() => mergeRefs(ref, groupRef), [ref, groupRef]);
|
|
41
|
-
const context = useMemo(() => ({
|
|
42
|
-
onRemove,
|
|
43
|
-
removeLabel
|
|
44
|
-
}), [onRemove, removeLabel]);
|
|
45
|
-
return /* @__PURE__ */ jsx("div", {
|
|
46
|
-
...mergeProps(props, gridProps),
|
|
47
|
-
ref: mergedRef,
|
|
48
|
-
className: cn(tagGroupClass, className),
|
|
49
|
-
children: /* @__PURE__ */ jsx(TagGroupContext, {
|
|
50
|
-
value: context,
|
|
51
|
-
children: [...state.collection].map((node) => /* @__PURE__ */ jsx(TagView, {
|
|
52
|
-
node,
|
|
53
|
-
state
|
|
54
|
-
}, node.key))
|
|
55
|
-
})
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* 태그 하나(`role="row"`). `TagGroup` 바로 안에 둔다. `value`가 묶음 안의 key이고 `onRemove`에 넘어오는 값이다.
|
|
60
|
-
* `disabled`면 지울 수 없고 키보드 이동도 건너뛴다(`aria-disabled`).
|
|
61
|
-
*/
|
|
62
|
-
function Tag(_props) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
asCollectionComponent(Tag, valueItemCollectionNode);
|
|
66
|
-
/** 태그 하나를 그린다. node.props는 앱이 Tag에 준 props(와 컬렉션이 더한 isDisabled)다. */
|
|
67
|
-
function TagView({ node, state }) {
|
|
68
|
-
const context = use(TagGroupContext);
|
|
69
|
-
const rowRef = useRef(null);
|
|
70
|
-
const { ref, className, color = "gray", value: _value, disabled: _disabled, isDisabled: _isDisabled, textValue: _textValue, children: _children, "aria-label": _ariaLabel, onFocus: _onFocus, onBlur: _onBlur, onKeyDown: _onKeyDown, onKeyUp: _onKeyUp, autoFocus: _autoFocus, ...props } = node.props;
|
|
71
|
-
const { rowProps, gridCellProps, removeButtonProps, allowsRemoving, isDisabled } = useTag({ item: node }, state, rowRef);
|
|
72
|
-
const mergedRef = useMemo(() => mergeRefs(ref, rowRef), [ref, rowRef]);
|
|
73
|
-
const onRemove = context?.onRemove;
|
|
74
|
-
return /* @__PURE__ */ jsx("div", {
|
|
75
|
-
...mergeProps(props, rowProps),
|
|
76
|
-
ref: mergedRef,
|
|
77
|
-
"data-color": color,
|
|
78
|
-
className: cn(tagClass, allowsRemoving ? "pe-0.75" : "pe-2.5", className),
|
|
79
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
80
|
-
...gridCellProps,
|
|
81
|
-
className: tagCellClass,
|
|
82
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
83
|
-
className: tagLabelClass,
|
|
84
|
-
children: node.rendered
|
|
85
|
-
}), allowsRemoving && onRemove ? /* @__PURE__ */ jsx(IconButton, {
|
|
86
|
-
"aria-label": context.removeLabel,
|
|
87
|
-
"aria-labelledby": removeButtonProps["aria-labelledby"],
|
|
88
|
-
id: removeButtonProps.id,
|
|
89
|
-
variant: "ghost",
|
|
90
|
-
color: "neutral",
|
|
91
|
-
size: "xs",
|
|
92
|
-
disabled: isDisabled,
|
|
93
|
-
tabIndex: -1,
|
|
94
|
-
onClick: () => onRemove(String(node.key)),
|
|
95
|
-
className: cn(removeClass, isDisabled ? void 0 : removeInteractionClass),
|
|
96
|
-
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
97
|
-
}) : null]
|
|
98
|
-
})
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export { Tag, TagGroup };
|
package/dist/Toast.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Role } from "./types.js";
|
|
2
|
-
import { ComponentProps, MouseEvent, ReactElement, ReactNode } from "react";
|
|
3
|
-
/** Toast의 액션 버튼 */
|
|
4
|
-
export interface ToastAction {
|
|
5
|
-
/** 버튼 글자. 예: 「되돌리기」, 「다시 시도」 */
|
|
6
|
-
label: ReactNode;
|
|
7
|
-
/**
|
|
8
|
-
* 누르면 부른다. 부른 뒤 Toast를 닫는다. `event.preventDefault()`를 부르면 닫지 않는다.
|
|
9
|
-
*/
|
|
10
|
-
onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
11
|
-
}
|
|
12
|
-
/** `queue.add`에 넘기는 Toast 하나 */
|
|
13
|
-
export interface ToastOptions {
|
|
14
|
-
/** 제목. Toast의 이름이 되고 굵은 글자로 보인다. */
|
|
15
|
-
title: ReactNode;
|
|
16
|
-
/** 본문. Toast의 설명이 된다. */
|
|
17
|
-
description?: ReactNode;
|
|
18
|
-
/**
|
|
19
|
-
* Role. Tide Role 6개와 앱이 `RoleRegistry`에 더한 Role을 받는다. 기본값은 `info`다(Alert와 같다).
|
|
20
|
-
* 상태 아이콘과 그 색을 정한다. 닫기·액션 버튼은 색과 관계없이 neutral이다. `danger`(오류)는 자동으로 닫지 않는다.
|
|
21
|
-
* 색 계열 이름(`blue` 등)은 받지 않는다(ADR 0016).
|
|
22
|
-
*/
|
|
23
|
-
color?: Role;
|
|
24
|
-
/** 액션 버튼. 있으면 자동으로 닫지 않는다. */
|
|
25
|
-
action?: ToastAction;
|
|
26
|
-
/**
|
|
27
|
-
* 자동으로 닫을 시간(ms). 기본값은 5000이고, 더 짧은 값은 5000으로 올린다. `null`이면 자동으로 닫지 않는다.
|
|
28
|
-
* 액션이 있거나 `color="danger"`면 이 값과 관계없이 자동으로 닫지 않는다.
|
|
29
|
-
* 시간은 영역에 마우스를 올리거나 포커스가 있는 동안 멈춘다.
|
|
30
|
-
*/
|
|
31
|
-
timeout?: number | null;
|
|
32
|
-
/** 닫힐 때(닫기 버튼, 액션, 자동 닫힘, `queue.close`) 부른다. */
|
|
33
|
-
onClose?: () => void;
|
|
34
|
-
/** 닫기 버튼 이름. 기본값은 `"닫기"`다. */
|
|
35
|
-
closeLabel?: string;
|
|
36
|
-
}
|
|
37
|
-
/** `new ToastQueue(options)`의 인자 */
|
|
38
|
-
export interface ToastQueueOptions {
|
|
39
|
-
/** 한 번에 보이는 Toast 수. 넘는 Toast는 앞의 것이 닫힐 때까지 기다린다. 기본값은 3이다. */
|
|
40
|
-
maxVisible?: number;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Toast 큐. React 밖(모듈)에서 만들어 `ToastRegion`에 넘기고, 어디서든 `add`로 띄운다.
|
|
44
|
-
*
|
|
45
|
-
* ```tsx
|
|
46
|
-
* export const toasts = new ToastQueue();
|
|
47
|
-
* toasts.add({ title: "저장했습니다" });
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export declare class ToastQueue {
|
|
51
|
-
constructor({ maxVisible }?: ToastQueueOptions);
|
|
52
|
-
/** Toast를 띄우고 key를 돌려준다. 새 Toast가 맨 앞(영역의 아래)에 온다. */
|
|
53
|
-
add(options: ToastOptions): string;
|
|
54
|
-
/** key의 Toast를 닫는다. */
|
|
55
|
-
close(key: string): void;
|
|
56
|
-
/** 모든 Toast를 닫는다. 기다리던 Toast도 빠진다. `onClose`는 부르지 않는다. */
|
|
57
|
-
clear(): void;
|
|
58
|
-
}
|
|
59
|
-
export interface ToastRegionProps extends Omit<ComponentProps<"div">, "children" | "role"> {
|
|
60
|
-
/** 그릴 큐(`new ToastQueue()`) */
|
|
61
|
-
queue: ToastQueue;
|
|
62
|
-
/**
|
|
63
|
-
* 영역(랜드마크) 이름. 기본값은 React Aria 번역 「N개 알림.」(locale을 따른다)이다.
|
|
64
|
-
*/
|
|
65
|
-
"aria-label"?: string;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* `ToastQueue`의 Toast를 그리는 영역. 앱에 하나 둔다(보통 레이아웃의 client Component 안).
|
|
69
|
-
* Toast가 있을 때만 `document.body`에 portal하고, 없으면 아무것도 그리지 않는다.
|
|
70
|
-
*/
|
|
71
|
-
export declare function ToastRegion({ queue, ...props }: ToastRegionProps): ReactElement | null;
|
package/dist/Toast.js
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { alertCloseClass, alertContentClass, alertDescriptionClass, alertIconClass, alertLayoutClass, alertTitleClass } from "./constants/alertClass.js";
|
|
4
|
-
import { alertStatusIcon } from "./libs/alertStatusIcon.js";
|
|
5
|
-
import { Button } from "./Button.js";
|
|
6
|
-
import { cn } from "./libs/cn.js";
|
|
7
|
-
import { IconButton } from "./IconButton.js";
|
|
8
|
-
import { OverlayPortal } from "./components/OverlayPortal.js";
|
|
9
|
-
import { useOverlayPresence } from "./hooks/useOverlayPresence.js";
|
|
10
|
-
import { overlaySurfaceClass, popoverMotionClass } from "./constants/overlayClass.js";
|
|
11
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
13
|
-
import { XIcon } from "@tide-design/icons";
|
|
14
|
-
import { mergeProps, mergeRefs, useToast, useToastRegion } from "react-aria";
|
|
15
|
-
import { ToastQueue, useToastQueue } from "react-stately";
|
|
16
|
-
|
|
17
|
-
// src/Toast.tsx
|
|
18
|
-
/** 자동으로 닫히는 Toast가 보이는 가장 짧은 시간(ms). React Aria 문서가 권하는 최소값과 같다. */
|
|
19
|
-
const minTimeout = 5e3;
|
|
20
|
-
const statelyQueues = /* @__PURE__ */ new WeakMap();
|
|
21
|
-
/** 자동 닫힘 시간. `undefined`면 자동으로 닫지 않는다. */
|
|
22
|
-
function resolveTimeout(options) {
|
|
23
|
-
if (options.action !== void 0 || options.color === "danger") return void 0;
|
|
24
|
-
const timeout = options.timeout === void 0 ? minTimeout : options.timeout;
|
|
25
|
-
if (timeout === null || !Number.isFinite(timeout)) return void 0;
|
|
26
|
-
return Math.max(timeout, minTimeout);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Toast 큐. React 밖(모듈)에서 만들어 `ToastRegion`에 넘기고, 어디서든 `add`로 띄운다.
|
|
30
|
-
*
|
|
31
|
-
* ```tsx
|
|
32
|
-
* export const toasts = new ToastQueue();
|
|
33
|
-
* toasts.add({ title: "저장했습니다" });
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
var ToastQueue$1 = class {
|
|
37
|
-
constructor({ maxVisible = 3 } = {}) {
|
|
38
|
-
statelyQueues.set(this, new ToastQueue({ maxVisibleToasts: maxVisible }));
|
|
39
|
-
}
|
|
40
|
-
/** Toast를 띄우고 key를 돌려준다. 새 Toast가 맨 앞(영역의 아래)에 온다. */
|
|
41
|
-
add(options) {
|
|
42
|
-
const { timeout: _timeout, onClose, ...content } = options;
|
|
43
|
-
return queueOf(this).add(content, {
|
|
44
|
-
timeout: resolveTimeout(options),
|
|
45
|
-
onClose
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/** key의 Toast를 닫는다. */
|
|
49
|
-
close(key) {
|
|
50
|
-
queueOf(this).close(key);
|
|
51
|
-
}
|
|
52
|
-
/** 모든 Toast를 닫는다. 기다리던 Toast도 빠진다. `onClose`는 부르지 않는다. */
|
|
53
|
-
clear() {
|
|
54
|
-
queueOf(this).clear();
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
function queueOf(queue) {
|
|
58
|
-
const stately = statelyQueues.get(queue);
|
|
59
|
-
if (!stately) throw new Error("ToastRegion의 queue에는 new ToastQueue()로 만든 큐를 넘긴다.");
|
|
60
|
-
return stately;
|
|
61
|
-
}
|
|
62
|
-
const regionClass = "fixed end-4 bottom-4 isolate z-toast flex w-[calc(100%-2rem)] max-w-96 flex-col-reverse gap-2 rounded-lg outline-none focus-visible:focus-ring";
|
|
63
|
-
const toastClass = `${alertLayoutClass} ${overlaySurfaceClass} ${popoverMotionClass} outline-none focus-visible:focus-ring`;
|
|
64
|
-
/** 보이는 Toast 목록에 퇴장 중인 Toast를 원래 자리에 끼워 넣는다. */
|
|
65
|
-
function mergeEntries(previous, visible) {
|
|
66
|
-
const visibleKeys = new Set(visible.map((toast) => toast.key));
|
|
67
|
-
const next = visible.map((toast) => ({
|
|
68
|
-
toast,
|
|
69
|
-
open: true
|
|
70
|
-
}));
|
|
71
|
-
previous.forEach((entry, index) => {
|
|
72
|
-
if (visibleKeys.has(entry.toast.key)) return;
|
|
73
|
-
next.splice(Math.min(index, next.length), 0, {
|
|
74
|
-
toast: entry.toast,
|
|
75
|
-
open: false
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
return next;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* `ToastQueue`의 Toast를 그리는 영역. 앱에 하나 둔다(보통 레이아웃의 client Component 안).
|
|
82
|
-
* Toast가 있을 때만 `document.body`에 portal하고, 없으면 아무것도 그리지 않는다.
|
|
83
|
-
*/
|
|
84
|
-
function ToastRegion({ queue, ...props }) {
|
|
85
|
-
const state = useToastQueue(queueOf(queue));
|
|
86
|
-
const [entries, setEntries] = useState(() => state.visibleToasts.map((toast) => ({
|
|
87
|
-
toast,
|
|
88
|
-
open: true
|
|
89
|
-
})));
|
|
90
|
-
const [visible, setVisible] = useState(state.visibleToasts);
|
|
91
|
-
if (visible !== state.visibleToasts) {
|
|
92
|
-
setVisible(state.visibleToasts);
|
|
93
|
-
setEntries(mergeEntries(entries, state.visibleToasts));
|
|
94
|
-
}
|
|
95
|
-
const onExited = useCallback((key) => {
|
|
96
|
-
setEntries((current) => current.filter((entry) => entry.open || entry.toast.key !== key));
|
|
97
|
-
}, []);
|
|
98
|
-
if (entries.length === 0) return null;
|
|
99
|
-
return /* @__PURE__ */ jsx(OverlayPortal, {
|
|
100
|
-
isExiting: false,
|
|
101
|
-
focusManagement: false,
|
|
102
|
-
children: /* @__PURE__ */ jsx(Region, {
|
|
103
|
-
...props,
|
|
104
|
-
state,
|
|
105
|
-
entries,
|
|
106
|
-
onExited
|
|
107
|
-
})
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
function Region({ state, entries, onExited, ref, className, "aria-label": ariaLabel, ...props }) {
|
|
111
|
-
const regionRef = useRef(null);
|
|
112
|
-
const mergedRef = useMemo(() => mergeRefs(ref, regionRef), [ref]);
|
|
113
|
-
const { regionProps } = useToastRegion({ "aria-label": ariaLabel }, state, regionRef);
|
|
114
|
-
return /* @__PURE__ */ jsx("div", {
|
|
115
|
-
...mergeProps(props, regionProps),
|
|
116
|
-
ref: mergedRef,
|
|
117
|
-
className: cn(regionClass, className),
|
|
118
|
-
children: entries.map((entry) => /* @__PURE__ */ jsx(ToastItem, {
|
|
119
|
-
toast: entry.toast,
|
|
120
|
-
open: entry.open,
|
|
121
|
-
state,
|
|
122
|
-
onExited
|
|
123
|
-
}, entry.toast.key))
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
function ToastItem({ toast, open, state, onExited }) {
|
|
127
|
-
const ref = useRef(null);
|
|
128
|
-
const present = useOverlayPresence(open, ref);
|
|
129
|
-
useEffect(() => {
|
|
130
|
-
if (!present) onExited(toast.key);
|
|
131
|
-
}, [
|
|
132
|
-
present,
|
|
133
|
-
onExited,
|
|
134
|
-
toast.key
|
|
135
|
-
]);
|
|
136
|
-
const { toastProps, contentProps, titleProps, descriptionProps } = useToast({ toast }, state, ref);
|
|
137
|
-
const { title, description, color = "info", action, closeLabel = "닫기" } = toast.content;
|
|
138
|
-
const StatusIcon = alertStatusIcon(color);
|
|
139
|
-
const close = () => state.close(toast.key);
|
|
140
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
141
|
-
...open ? toastProps : {},
|
|
142
|
-
ref,
|
|
143
|
-
"data-color": color,
|
|
144
|
-
"data-open": open ? "" : void 0,
|
|
145
|
-
inert: !open,
|
|
146
|
-
"data-placement": "top",
|
|
147
|
-
className: toastClass,
|
|
148
|
-
children: [
|
|
149
|
-
/* @__PURE__ */ jsx(StatusIcon, {
|
|
150
|
-
size: 20,
|
|
151
|
-
"aria-hidden": "true",
|
|
152
|
-
className: `${alertIconClass} text-accent`
|
|
153
|
-
}),
|
|
154
|
-
/* @__PURE__ */ jsxs("div", {
|
|
155
|
-
className: "flex min-w-0 flex-1 flex-col gap-3",
|
|
156
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
157
|
-
...open ? contentProps : {},
|
|
158
|
-
className: alertContentClass,
|
|
159
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
160
|
-
...titleProps,
|
|
161
|
-
className: alertTitleClass,
|
|
162
|
-
children: title
|
|
163
|
-
}), description !== void 0 && /* @__PURE__ */ jsx("div", {
|
|
164
|
-
...descriptionProps,
|
|
165
|
-
className: "text-body-sm",
|
|
166
|
-
children: description
|
|
167
|
-
})]
|
|
168
|
-
}), action !== void 0 && /* @__PURE__ */ jsx(Button, {
|
|
169
|
-
variant: "outline",
|
|
170
|
-
color: "neutral",
|
|
171
|
-
size: "sm",
|
|
172
|
-
className: "self-start",
|
|
173
|
-
onClick: (event) => {
|
|
174
|
-
action.onClick?.(event);
|
|
175
|
-
if (!event.defaultPrevented) close();
|
|
176
|
-
},
|
|
177
|
-
children: action.label
|
|
178
|
-
})]
|
|
179
|
-
}),
|
|
180
|
-
/* @__PURE__ */ jsx(IconButton, {
|
|
181
|
-
"aria-label": closeLabel,
|
|
182
|
-
variant: "ghost",
|
|
183
|
-
color: "neutral",
|
|
184
|
-
size: "xs",
|
|
185
|
-
onClick: close,
|
|
186
|
-
className: alertCloseClass,
|
|
187
|
-
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
188
|
-
})
|
|
189
|
-
]
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export { ToastQueue$1 as ToastQueue, ToastRegion };
|
package/dist/Tooltip.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { OverlayPlacement } from "./libs/overlayPosition.js";
|
|
2
|
-
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
3
|
-
/** Tooltip 설명의 위치. 앞은 트리거의 어느 쪽, 뒤는 그 변에서 맞출 끝이다. 공간이 모자라면 반대쪽으로 뒤집힌다. */
|
|
4
|
-
export type TooltipPlacement = OverlayPlacement;
|
|
5
|
-
export interface TooltipProps {
|
|
6
|
-
/** 열림 상태(제어). 주면 `onOpenChange`로 바꾼다. */
|
|
7
|
-
open?: boolean;
|
|
8
|
-
/** 처음 열림 상태(비제어). 기본값은 `false`다. */
|
|
9
|
-
defaultOpen?: boolean;
|
|
10
|
-
/** 열림 상태가 바뀌려 할 때 새 값으로 부른다. */
|
|
11
|
-
onOpenChange?: (open: boolean) => void;
|
|
12
|
-
/**
|
|
13
|
-
* 마우스를 올린 뒤 열릴 때까지 기다리는 시간(ms). 기본값은 `500`이다. 키보드 포커스는 기다리지 않는다.
|
|
14
|
-
* 한 Tooltip이 열린 뒤 잠깐(0.5초) 안에 다른 트리거로 옮기면 기다리지 않고 바로 연다.
|
|
15
|
-
*/
|
|
16
|
-
delay?: number;
|
|
17
|
-
/** 포인터가 트리거·설명을 떠난 뒤 닫힐 때까지 기다리는 시간(ms). 기본값은 `300`이다. 설명으로 옮겨 갈 틈이다. */
|
|
18
|
-
closeDelay?: number;
|
|
19
|
-
/** `true`면 열리지 않는다. 트리거는 그대로 동작한다. */
|
|
20
|
-
disabled?: boolean;
|
|
21
|
-
/** `TooltipTrigger`와 `TooltipContent` */
|
|
22
|
-
children: ReactNode;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* 트리거와 설명을 잇는 열림 상태. DOM 요소를 만들지 않는다.
|
|
26
|
-
* 안에 `TooltipTrigger` 하나와 `TooltipContent` 하나를 둔다.
|
|
27
|
-
*/
|
|
28
|
-
export declare function Tooltip({ open, defaultOpen, onOpenChange, delay, closeDelay, disabled, children }: TooltipProps): ReactElement;
|
|
29
|
-
export interface TooltipTriggerProps extends ComponentProps<"button"> {
|
|
30
|
-
/**
|
|
31
|
-
* 다른 요소로 렌더한다. 예: `render={<IconButton aria-label="복사" />}`, `render={<Button variant="ghost" />}`.
|
|
32
|
-
* props, ref, className, 이벤트 핸들러를 그 요소에 병합한다. 기본은 class 없는 `<button type="button">`이다.
|
|
33
|
-
* 포커스를 받을 수 있는 요소여야 키보드 사용자도 설명을 본다.
|
|
34
|
-
*/
|
|
35
|
-
render?: ReactElement;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Tooltip을 여는 요소. 마우스를 올리면 `delay` 뒤에, 키보드로 포커스하면 바로 열린다.
|
|
39
|
-
* 누르면(마우스, 터치, 키) 닫힌다. 열린 동안 `aria-describedby`에 설명 id가 더해진다.
|
|
40
|
-
*/
|
|
41
|
-
export declare function TooltipTrigger({ render, ref, className, "aria-describedby": describedBy, ...props }: TooltipTriggerProps): ReactElement;
|
|
42
|
-
export interface TooltipContentProps extends Omit<ComponentProps<"div">, "id" | "role"> {
|
|
43
|
-
/** 트리거 기준 위치. 기본값은 `top`(위, 가운데 맞춤)이다. 공간이 모자라면 반대쪽으로 뒤집힌다. */
|
|
44
|
-
placement?: TooltipPlacement;
|
|
45
|
-
/** 트리거와의 간격(px). 기본값은 `4`다. */
|
|
46
|
-
offset?: number;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* 트리거에 붙는 설명(`role="tooltip"`). 열릴 때만 `document.body`에 portal로 렌더하고 `z-tooltip`으로 쌓는다.
|
|
50
|
-
* 바로 나타나고, 닫히면 opacity만 `fast`(150ms)로 사라진다. 조작 요소(버튼, 링크)는 넣지 않는다.
|
|
51
|
-
* 열려 있으면 `data-open`이, 트리거 기준 방향이 `data-placement`(`top`/`bottom`/`left`/`right`)로 붙는다.
|
|
52
|
-
*/
|
|
53
|
-
export declare function TooltipContent(props: TooltipContentProps): ReactElement | null;
|
package/dist/Tooltip.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "./libs/cn.js";
|
|
4
|
-
import { OverlayPortal } from "./components/OverlayPortal.js";
|
|
5
|
-
import { overlayPositionProps } from "./libs/overlayPosition.js";
|
|
6
|
-
import { useOverlayPresence } from "./hooks/useOverlayPresence.js";
|
|
7
|
-
import { useOverlayTheme } from "./hooks/useOverlayTheme.js";
|
|
8
|
-
import { frequentMotionClass, overlaySurfaceClass } from "./constants/overlayClass.js";
|
|
9
|
-
import { renderElement } from "./libs/renderElement.js";
|
|
10
|
-
import { jsx } from "react/jsx-runtime";
|
|
11
|
-
import { createContext, createElement, use, useMemo, useRef } from "react";
|
|
12
|
-
import { mergeProps, mergeRefs, useOverlayPosition, useTooltip, useTooltipTrigger } from "react-aria";
|
|
13
|
-
import { useTooltipTriggerState } from "react-stately";
|
|
14
|
-
|
|
15
|
-
// src/Tooltip.tsx
|
|
16
|
-
const TooltipContext = createContext(null);
|
|
17
|
-
function useTooltipContext(part) {
|
|
18
|
-
const context = use(TooltipContext);
|
|
19
|
-
if (!context) throw new Error(`${part}는 Tooltip 안에 둔다.`);
|
|
20
|
-
return context;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* 트리거와 설명을 잇는 열림 상태. DOM 요소를 만들지 않는다.
|
|
24
|
-
* 안에 `TooltipTrigger` 하나와 `TooltipContent` 하나를 둔다.
|
|
25
|
-
*/
|
|
26
|
-
function Tooltip({ open, defaultOpen, onOpenChange, delay = 500, closeDelay = 300, disabled, children }) {
|
|
27
|
-
const options = {
|
|
28
|
-
isOpen: open,
|
|
29
|
-
defaultOpen,
|
|
30
|
-
onOpenChange,
|
|
31
|
-
delay,
|
|
32
|
-
closeDelay,
|
|
33
|
-
isDisabled: disabled
|
|
34
|
-
};
|
|
35
|
-
const state = useTooltipTriggerState(options);
|
|
36
|
-
const triggerRef = useRef(null);
|
|
37
|
-
const { triggerProps, tooltipProps } = useTooltipTrigger(options, state, triggerRef);
|
|
38
|
-
const value = useMemo(() => ({
|
|
39
|
-
state,
|
|
40
|
-
triggerRef,
|
|
41
|
-
triggerProps,
|
|
42
|
-
tooltipId: tooltipProps.id
|
|
43
|
-
}), [
|
|
44
|
-
state,
|
|
45
|
-
triggerProps,
|
|
46
|
-
tooltipProps.id
|
|
47
|
-
]);
|
|
48
|
-
return /* @__PURE__ */ jsx(TooltipContext, {
|
|
49
|
-
value,
|
|
50
|
-
children
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Tooltip을 여는 요소. 마우스를 올리면 `delay` 뒤에, 키보드로 포커스하면 바로 열린다.
|
|
55
|
-
* 누르면(마우스, 터치, 키) 닫힌다. 열린 동안 `aria-describedby`에 설명 id가 더해진다.
|
|
56
|
-
*/
|
|
57
|
-
function TooltipTrigger({ render, ref, className, "aria-describedby": describedBy, ...props }) {
|
|
58
|
-
const { triggerRef, triggerProps } = useTooltipContext("TooltipTrigger");
|
|
59
|
-
const { tabIndex: _tabIndex, "aria-describedby": tooltipDescribedBy, ...ariaProps } = triggerProps;
|
|
60
|
-
const mergedRef = useMemo(() => mergeRefs(ref, triggerRef), [ref, triggerRef]);
|
|
61
|
-
const merged = {
|
|
62
|
-
...mergeProps(props, ariaProps),
|
|
63
|
-
"aria-describedby": [describedBy, tooltipDescribedBy].filter(Boolean).join(" ") || void 0,
|
|
64
|
-
ref: mergedRef
|
|
65
|
-
};
|
|
66
|
-
if (!render) return createElement("button", {
|
|
67
|
-
type: "button",
|
|
68
|
-
...merged,
|
|
69
|
-
className
|
|
70
|
-
});
|
|
71
|
-
return renderElement({
|
|
72
|
-
defaultElement: "button",
|
|
73
|
-
render,
|
|
74
|
-
baseClassName: "",
|
|
75
|
-
props: {
|
|
76
|
-
...merged,
|
|
77
|
-
className
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
const contentClass = `isolate z-tooltip max-w-60 px-2 py-1 text-body-sm ${overlaySurfaceClass} ${frequentMotionClass}`;
|
|
82
|
-
/**
|
|
83
|
-
* 트리거에 붙는 설명(`role="tooltip"`). 열릴 때만 `document.body`에 portal로 렌더하고 `z-tooltip`으로 쌓는다.
|
|
84
|
-
* 바로 나타나고, 닫히면 opacity만 `fast`(150ms)로 사라진다. 조작 요소(버튼, 링크)는 넣지 않는다.
|
|
85
|
-
* 열려 있으면 `data-open`이, 트리거 기준 방향이 `data-placement`(`top`/`bottom`/`left`/`right`)로 붙는다.
|
|
86
|
-
*/
|
|
87
|
-
function TooltipContent(props) {
|
|
88
|
-
const context = useTooltipContext("TooltipContent");
|
|
89
|
-
const tooltipRef = useRef(null);
|
|
90
|
-
if (!useOverlayPresence(context.state.isOpen, tooltipRef)) return null;
|
|
91
|
-
return /* @__PURE__ */ jsx(OverlayPortal, {
|
|
92
|
-
isExiting: !context.state.isOpen,
|
|
93
|
-
focusManagement: false,
|
|
94
|
-
children: /* @__PURE__ */ jsx(TooltipContentInner, {
|
|
95
|
-
...props,
|
|
96
|
-
context,
|
|
97
|
-
tooltipRef
|
|
98
|
-
})
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
/** DOM에 있는 동안만 portal 안에서 렌더한다. 위치 hook은 요소가 있다고 보고 동작한다. */
|
|
102
|
-
function TooltipContentInner({ context, tooltipRef, placement = "top", offset = 4, ref, className, children, ...props }) {
|
|
103
|
-
const { state, triggerRef, tooltipId } = context;
|
|
104
|
-
useOverlayTheme(triggerRef, tooltipRef);
|
|
105
|
-
const position = useOverlayPosition({
|
|
106
|
-
targetRef: triggerRef,
|
|
107
|
-
overlayRef: tooltipRef,
|
|
108
|
-
placement,
|
|
109
|
-
offset,
|
|
110
|
-
isOpen: state.isOpen,
|
|
111
|
-
onClose: () => state.close(true)
|
|
112
|
-
});
|
|
113
|
-
const overlayProps = overlayPositionProps(position.overlayProps, position.placement, placement);
|
|
114
|
-
const { tooltipProps } = useTooltip({}, state);
|
|
115
|
-
const mergedRef = useMemo(() => mergeRefs(ref, tooltipRef), [ref, tooltipRef]);
|
|
116
|
-
const { style: _style, ...rest } = mergeProps(props, overlayProps, tooltipProps);
|
|
117
|
-
return /* @__PURE__ */ jsx("div", {
|
|
118
|
-
...rest,
|
|
119
|
-
id: tooltipId,
|
|
120
|
-
ref: mergedRef,
|
|
121
|
-
"data-open": state.isOpen ? "" : void 0,
|
|
122
|
-
"data-react-aria-top-layer": "",
|
|
123
|
-
className: cn(contentClass, !state.isOpen && state.shouldSkipAnimation && "transition-none", className),
|
|
124
|
-
style: {
|
|
125
|
-
...overlayProps.style,
|
|
126
|
-
...props.style
|
|
127
|
-
},
|
|
128
|
-
children
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export { Tooltip, TooltipContent, TooltipTrigger };
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "../libs/cn.js";
|
|
4
|
-
import { listHeadingClass, listItemClass, listSeparatorClass } from "../constants/listClass.js";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { useMemo, useRef } from "react";
|
|
7
|
-
import { CheckIcon } from "@tide-design/icons";
|
|
8
|
-
import { mergeProps, mergeRefs, useListBoxSection, useOption } from "react-aria";
|
|
9
|
-
|
|
10
|
-
// src/components/ListBoxNodes.tsx
|
|
11
|
-
/**
|
|
12
|
-
* 고른 옵션 끝의 체크 아이콘. 장식용이다(선택은 `aria-selected`가 알린다). 배경(subtle-active)이 지워지는 고대비
|
|
13
|
-
* 모드에서도 고른 옵션이 보이게 한다. 글자와의 간격은 항목의 gap(8px)이고 `ms-auto`로 오른쪽 끝에 붙는다.
|
|
14
|
-
*/
|
|
15
|
-
const checkClass = "ms-auto";
|
|
16
|
-
/**
|
|
17
|
-
* 목록 상태의 옵션·묶음을 그린다. 묶음과 이웃한 옵션·묶음 사이에 장식용 구분선을 둔다. 목록의 처음·끝과 이어진
|
|
18
|
-
* 구분선은 그리지 않는다(Menu와 같다). listbox의 자식은 option·group만 될 수 있어(WAI-ARIA, axe
|
|
19
|
-
* aria-required-children) Menu와 달리 구분선은 `separator` 역할 없이 보조기술에서 숨긴다. 묶음 경계는 group이 알린다.
|
|
20
|
-
*/
|
|
21
|
-
function ListBoxNodes({ state }) {
|
|
22
|
-
const nodes = [...state.collection];
|
|
23
|
-
return nodes.map((node, index) => {
|
|
24
|
-
const previous = nodes[index - 1];
|
|
25
|
-
const separator = previous !== void 0 && (node.type === "section" || previous.type === "section");
|
|
26
|
-
const element = node.type === "section" ? /* @__PURE__ */ jsx(ListBoxSectionView, {
|
|
27
|
-
node,
|
|
28
|
-
state
|
|
29
|
-
}, node.key) : /* @__PURE__ */ jsx(ListBoxOptionView, {
|
|
30
|
-
node,
|
|
31
|
-
state
|
|
32
|
-
}, node.key);
|
|
33
|
-
if (!separator) return element;
|
|
34
|
-
return [/* @__PURE__ */ jsx("div", {
|
|
35
|
-
role: "presentation",
|
|
36
|
-
"aria-hidden": "true",
|
|
37
|
-
className: listSeparatorClass
|
|
38
|
-
}, `${String(node.key)}-separator`), element];
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/** 옵션 하나를 그린다. node.props는 앱이 옵션에 준 props(와 컬렉션이 더한 isDisabled)다. */
|
|
42
|
-
function ListBoxOptionView({ node, state }) {
|
|
43
|
-
const optionRef = useRef(null);
|
|
44
|
-
const { ref, className, value: _value, disabled: _disabled, textValue: _textValue, isDisabled: _isDisabled, children: _children, id: _id, ...props } = node.props;
|
|
45
|
-
const { optionProps, isFocused, isSelected, isDisabled } = useOption({
|
|
46
|
-
key: node.key,
|
|
47
|
-
"aria-label": props["aria-label"]
|
|
48
|
-
}, state, optionRef);
|
|
49
|
-
const mergedRef = useMemo(() => mergeRefs(ref, optionRef), [ref, optionRef]);
|
|
50
|
-
const merged = mergeProps(props, optionProps);
|
|
51
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
52
|
-
...merged,
|
|
53
|
-
ref: mergedRef,
|
|
54
|
-
"aria-labelledby": props["aria-labelledby"],
|
|
55
|
-
"aria-describedby": props["aria-describedby"],
|
|
56
|
-
"data-highlighted": isFocused ? "" : void 0,
|
|
57
|
-
"data-selected": isSelected ? "" : void 0,
|
|
58
|
-
"data-disabled": isDisabled ? "" : void 0,
|
|
59
|
-
className: cn(listItemClass, className),
|
|
60
|
-
children: [node.rendered, isSelected ? /* @__PURE__ */ jsx(CheckIcon, {
|
|
61
|
-
size: 16,
|
|
62
|
-
className: checkClass
|
|
63
|
-
}) : null]
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
/** 묶음 하나를 그린다. 제목은 보조기술에서 숨기고(`presentation`) 묶음의 이름으로만 쓴다(useListBoxSection). */
|
|
67
|
-
function ListBoxSectionView({ node, state }) {
|
|
68
|
-
const { className } = node.props;
|
|
69
|
-
const { itemProps, headingProps, groupProps } = useListBoxSection({
|
|
70
|
-
heading: node.rendered,
|
|
71
|
-
"aria-label": node["aria-label"]
|
|
72
|
-
});
|
|
73
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
74
|
-
...itemProps,
|
|
75
|
-
className,
|
|
76
|
-
children: [node.rendered != null && /* @__PURE__ */ jsx("div", {
|
|
77
|
-
...headingProps,
|
|
78
|
-
className: "px-2 pt-1.5 pb-1 text-label-sm text-muted select-none",
|
|
79
|
-
children: node.rendered
|
|
80
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
81
|
-
...groupProps,
|
|
82
|
-
children: [...node.childNodes].map((child) => /* @__PURE__ */ jsx(ListBoxOptionView, {
|
|
83
|
-
node: child,
|
|
84
|
-
state
|
|
85
|
-
}, child.key))
|
|
86
|
-
})]
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export { ListBoxNodes };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import { Overlay } from "react-aria";
|
|
5
|
-
|
|
6
|
-
// src/components/OverlayPortal.tsx
|
|
7
|
-
/**
|
|
8
|
-
* 오버레이를 `document.body`에 portal한다(React Aria `Overlay`). top-layer(`<dialog>`, popover API)는 쓰지 않는다.
|
|
9
|
-
* 안을 `FocusScope`(`restoreFocus`)로 감싸서, DOM에서 빠질 때 포커스가 열기 전 요소(보통 트리거)로 돌아간다.
|
|
10
|
-
* 역할 hook이 포커스 가두기를 요청하면(`useDialog` 등) Tab이 안에서 돈다. 서버 렌더에서는 아무것도 그리지 않는다.
|
|
11
|
-
* `focusManagement={false}`면 FocusScope 없이 portal만 한다(Tooltip).
|
|
12
|
-
*/
|
|
13
|
-
function OverlayPortal({ isExiting, focusManagement = true, children }) {
|
|
14
|
-
return /* @__PURE__ */ jsx(Overlay, {
|
|
15
|
-
isExiting,
|
|
16
|
-
disableFocusManagement: !focusManagement,
|
|
17
|
-
children
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { OverlayPortal };
|