@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/Combobox.js
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "./libs/cn.js";
|
|
4
|
-
import { FieldContext, useFieldControl } from "./hooks/useFieldControl.js";
|
|
5
|
-
import { inputBaseClass, inputSizeClass } from "./constants/inputClass.js";
|
|
6
|
-
import { asCollectionComponent, resolveCollectionChildren, sectionCollectionNode, valueItemCollectionNode } from "./libs/listCollection.js";
|
|
7
|
-
import { listPopupClass } from "./constants/listClass.js";
|
|
8
|
-
import { ListBoxNodes } from "./components/ListBoxNodes.js";
|
|
9
|
-
import { OverlayPortal } from "./components/OverlayPortal.js";
|
|
10
|
-
import { useOverlayPresence } from "./hooks/useOverlayPresence.js";
|
|
11
|
-
import { useOverlayTheme } from "./hooks/useOverlayTheme.js";
|
|
12
|
-
import { usePopoverOverlay } from "./hooks/usePopoverOverlay.js";
|
|
13
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
-
import { use, useLayoutEffect, useMemo, useRef } from "react";
|
|
15
|
-
import { ChevronDownIcon } from "@tide-design/icons";
|
|
16
|
-
import { mergeProps, mergeRefs, useButton, useComboBox, useFilter, useListBox } from "react-aria";
|
|
17
|
-
import { useComboBoxState } from "react-stately";
|
|
18
|
-
|
|
19
|
-
// src/Combobox.tsx
|
|
20
|
-
const wrapperClass = "flex w-full";
|
|
21
|
-
const inputEndClass = {
|
|
22
|
-
sm: "pe-[34px]",
|
|
23
|
-
md: "pe-9",
|
|
24
|
-
lg: "pe-10"
|
|
25
|
-
};
|
|
26
|
-
const buttonSizeClass = {
|
|
27
|
-
sm: "-ms-[35px] w-[35px] pe-[11px]",
|
|
28
|
-
md: "-ms-[37px] w-[37px] pe-[13px]",
|
|
29
|
-
lg: "-ms-[41px] w-[41px] pe-[17px]"
|
|
30
|
-
};
|
|
31
|
-
const buttonClass = "inline-flex shrink-0 cursor-pointer items-center justify-end text-muted outline-none disabled:cursor-not-allowed disabled:text-disabled";
|
|
32
|
-
/**
|
|
33
|
-
* 거른 결과가 없을 때의 글자. 옵션과 같은 여백·글자 크기라 목록 높이가 옵션 하나와 같다. `text-muted`.
|
|
34
|
-
* listbox 밖(같은 목록 표면 안)에 둔다. listbox 자식은 option·group만 될 수 있어서다. 결과 개수(0개)는 React Aria가
|
|
35
|
-
* live region으로 알린다.
|
|
36
|
-
*/
|
|
37
|
-
const emptyClass = "px-2 py-1.5 text-body-sm text-muted select-none";
|
|
38
|
-
/**
|
|
39
|
-
* 한글 IME 조합 중의 keydown인지. 조합 중 Enter·화살표·Esc는 IME가 쓰므로 목록 동작에 쓰지 않는다.
|
|
40
|
-
* Chromium·Firefox는 `isComposing`이 `true`다. Safari는 조합을 끝내는 Enter의 keydown이 compositionend 뒤에
|
|
41
|
-
* `isComposing: false`로 오지만 `keyCode`가 229다(조합 처리 중인 키). 그래서 둘 다 본다.
|
|
42
|
-
*/
|
|
43
|
-
const isComposingKey = (event) => event.nativeEvent.isComposing || event.keyCode === 229;
|
|
44
|
-
/**
|
|
45
|
-
* 글자를 쳐서 옵션을 거르고 하나를 고르는 입력. 치면 목록이 열리고 옵션 글자에 친 글자가 들어 있는 옵션만 남는다
|
|
46
|
-
* (대소문자·악센트 무시, 현재 locale 기준). ↓·↑로 목록을 열고 옵션을 옮겨 Enter로 고르며, chevron 버튼을 누르면 거르지
|
|
47
|
-
* 않은 전체 목록이 열린다. 고르면 닫히고 입력에 그 옵션의 글자가 들어간다. Esc는 닫고 입력을 고른 옵션의 글자로 되돌린다.
|
|
48
|
-
* 포커스가 나가면 고르지 않은 글자는 지워진다(자유 입력 없음). 거른 결과가 없으면 목록에 `emptyMessage`가 보인다.
|
|
49
|
-
* Field 안에 두면 label·설명·오류가 자동으로 연결되고, `name`을 주면 고른 옵션의 `value`가 폼에 제출된다.
|
|
50
|
-
* 상태는 `data-open`·`data-invalid`·네이티브 `:disabled`(입력), `data-open`(목록),
|
|
51
|
-
* `data-highlighted`·`data-selected`·`data-disabled`(옵션)로 노출한다.
|
|
52
|
-
*/
|
|
53
|
-
function Combobox({ value, defaultValue, onValueChange, onOpenChange, emptyMessage = "결과가 없습니다", name, form, size = "md", invalid, disabled, required, readOnly, id, ref, className, children, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }) {
|
|
54
|
-
const field = use(FieldContext);
|
|
55
|
-
const control = useFieldControl({
|
|
56
|
-
id,
|
|
57
|
-
invalid,
|
|
58
|
-
disabled,
|
|
59
|
-
required,
|
|
60
|
-
"aria-describedby": ariaDescribedBy,
|
|
61
|
-
"aria-invalid": ariaInvalid
|
|
62
|
-
});
|
|
63
|
-
const isDisabled = control.disabled ?? false;
|
|
64
|
-
const isRequired = control.required ?? false;
|
|
65
|
-
const items = useMemo(() => resolveCollectionChildren(children), [children]);
|
|
66
|
-
const { contains } = useFilter({ sensitivity: "base" });
|
|
67
|
-
const state = useComboBoxState({
|
|
68
|
-
children: items,
|
|
69
|
-
defaultFilter: contains,
|
|
70
|
-
value,
|
|
71
|
-
defaultValue,
|
|
72
|
-
onChange: (key) => onValueChange?.(key == null ? null : String(key)),
|
|
73
|
-
onOpenChange: (open) => onOpenChange?.(open),
|
|
74
|
-
allowsEmptyCollection: true,
|
|
75
|
-
isDisabled,
|
|
76
|
-
isReadOnly: readOnly,
|
|
77
|
-
isRequired,
|
|
78
|
-
validationBehavior: "native"
|
|
79
|
-
});
|
|
80
|
-
const inputRef = useRef(null);
|
|
81
|
-
const buttonRef = useRef(null);
|
|
82
|
-
const popoverRef = useRef(null);
|
|
83
|
-
const listBoxRef = useRef(null);
|
|
84
|
-
const { inputProps, buttonProps, listBoxProps, isInvalid } = useComboBox({
|
|
85
|
-
inputRef,
|
|
86
|
-
buttonRef,
|
|
87
|
-
popoverRef,
|
|
88
|
-
listBoxRef,
|
|
89
|
-
id: control.id,
|
|
90
|
-
"aria-label": ariaLabel,
|
|
91
|
-
"aria-labelledby": ariaLabelledBy ?? field?.labelId,
|
|
92
|
-
isDisabled,
|
|
93
|
-
isReadOnly: readOnly,
|
|
94
|
-
isRequired,
|
|
95
|
-
validationBehavior: "native"
|
|
96
|
-
}, state);
|
|
97
|
-
const { buttonProps: chevronProps } = useButton(buttonProps, buttonRef);
|
|
98
|
-
const mergedRef = useMemo(() => mergeRefs(ref, inputRef), [ref, inputRef]);
|
|
99
|
-
const showInvalid = control["data-invalid"] === "" || isInvalid;
|
|
100
|
-
const { onKeyDown: ariaKeyDown, ...ariaInputProps } = inputProps;
|
|
101
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
102
|
-
className: wrapperClass,
|
|
103
|
-
children: [
|
|
104
|
-
/* @__PURE__ */ jsx("input", {
|
|
105
|
-
...mergeProps(props, ariaInputProps),
|
|
106
|
-
ref: mergedRef,
|
|
107
|
-
onKeyDown: (event) => {
|
|
108
|
-
props.onKeyDown?.(event);
|
|
109
|
-
if (!isComposingKey(event)) ariaKeyDown?.(event);
|
|
110
|
-
},
|
|
111
|
-
"aria-describedby": control["aria-describedby"],
|
|
112
|
-
"aria-invalid": showInvalid ? true : control["aria-invalid"],
|
|
113
|
-
"data-invalid": showInvalid ? "" : void 0,
|
|
114
|
-
"data-open": state.isOpen ? "" : void 0,
|
|
115
|
-
className: cn(inputSizeClass[size], inputBaseClass, inputEndClass[size], className)
|
|
116
|
-
}),
|
|
117
|
-
/* @__PURE__ */ jsx("button", {
|
|
118
|
-
...chevronProps,
|
|
119
|
-
ref: buttonRef,
|
|
120
|
-
className: cn(buttonClass, buttonSizeClass[size]),
|
|
121
|
-
children: /* @__PURE__ */ jsx(ChevronDownIcon, { size: 16 })
|
|
122
|
-
}),
|
|
123
|
-
name !== void 0 && /* @__PURE__ */ jsx("input", {
|
|
124
|
-
type: "hidden",
|
|
125
|
-
name,
|
|
126
|
-
form,
|
|
127
|
-
value: state.selectedKey == null ? "" : String(state.selectedKey),
|
|
128
|
-
disabled: isDisabled
|
|
129
|
-
}),
|
|
130
|
-
/* @__PURE__ */ jsx(ComboboxPopover, {
|
|
131
|
-
state,
|
|
132
|
-
inputRef,
|
|
133
|
-
popoverRef,
|
|
134
|
-
listBoxRef,
|
|
135
|
-
listBoxProps,
|
|
136
|
-
emptyMessage
|
|
137
|
-
})
|
|
138
|
-
]
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* 목록을 DOM에 둘지 정하고 portal한다. 닫혀도 퇴장 전환이 끝날 때까지 남긴다(ADR 0018).
|
|
143
|
-
* 포커스는 입력에 머물므로 FocusScope로 감싸지 않는다(`focusManagement={false}`). 감싸면 바깥 빈 곳을 눌러 포커스가
|
|
144
|
-
* body로 간 뒤 목록이 빠질 때 FocusScope가 입력으로 포커스를 되돌린다(react-aria 3.53.1 FocusScope restoreFocus).
|
|
145
|
-
*/
|
|
146
|
-
function ComboboxPopover(props) {
|
|
147
|
-
if (!useOverlayPresence(props.state.isOpen, props.popoverRef)) return null;
|
|
148
|
-
return /* @__PURE__ */ jsx(OverlayPortal, {
|
|
149
|
-
isExiting: !props.state.isOpen,
|
|
150
|
-
focusManagement: false,
|
|
151
|
-
children: /* @__PURE__ */ jsx(ComboboxPopoverInner, { ...props })
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* 목록 표면(`listPopupClass`)과 그 안의 `role="listbox"`. 입력 아래 시작 끝에 4px 떨어져 붙고(Select와 같다),
|
|
156
|
-
* 폭은 입력보다 좁지 않다. 거른 결과가 없으면 listbox 뒤에 `emptyMessage`를 보인다.
|
|
157
|
-
*/
|
|
158
|
-
function ComboboxPopoverInner({ state, inputRef, popoverRef, listBoxRef, listBoxProps, emptyMessage }) {
|
|
159
|
-
useOverlayTheme(inputRef, popoverRef);
|
|
160
|
-
useLayoutEffect(() => {
|
|
161
|
-
const popover = popoverRef.current;
|
|
162
|
-
const width = inputRef.current?.offsetWidth;
|
|
163
|
-
if (popover && width) popover.style.minWidth = `min(${width}px, 100vw - 24px)`;
|
|
164
|
-
}, [inputRef, popoverRef]);
|
|
165
|
-
const { overlayProps } = usePopoverOverlay({
|
|
166
|
-
triggerRef: inputRef,
|
|
167
|
-
popoverRef,
|
|
168
|
-
placement: "bottom start",
|
|
169
|
-
offset: 4,
|
|
170
|
-
nonModal: true
|
|
171
|
-
}, state);
|
|
172
|
-
const { listBoxProps: listProps } = useListBox(listBoxProps, state, listBoxRef);
|
|
173
|
-
const empty = state.collection.size === 0;
|
|
174
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
175
|
-
...overlayProps,
|
|
176
|
-
ref: popoverRef,
|
|
177
|
-
"data-open": state.isOpen ? "" : void 0,
|
|
178
|
-
className: listPopupClass,
|
|
179
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
180
|
-
...listProps,
|
|
181
|
-
ref: listBoxRef,
|
|
182
|
-
className: "outline-none",
|
|
183
|
-
children: /* @__PURE__ */ jsx(ListBoxNodes, { state })
|
|
184
|
-
}), empty && /* @__PURE__ */ jsx("div", {
|
|
185
|
-
className: emptyClass,
|
|
186
|
-
children: emptyMessage
|
|
187
|
-
})]
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Combobox의 옵션(`role="option"`). `Combobox`나 `ComboboxSection` 바로 안에 둔다. `value`가 고른 값이고 폼에
|
|
192
|
-
* 제출된다. 거르기와 고른 뒤 입력에 들어가는 글자는 `textValue`(기본은 내용의 글자)다. 키보드 위치와 마우스를 올린
|
|
193
|
-
* 옵션은 highlight, 고른 옵션은 neutral subtle-active 배경과 끝의 체크 아이콘이다(Select 옵션과 같다).
|
|
194
|
-
* 상태는 `data-highlighted`, `data-selected`, `data-disabled`로 노출한다.
|
|
195
|
-
*/
|
|
196
|
-
function ComboboxItem(_props) {
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
asCollectionComponent(ComboboxItem, valueItemCollectionNode);
|
|
200
|
-
/**
|
|
201
|
-
* 옵션 묶음(`role="group"`). `heading`이 화면에 보이는 제목이자 묶음의 이름이고, 없으면 `aria-label`이 이름이다.
|
|
202
|
-
* 거른 결과 묶음 안에 남은 옵션이 없으면 묶음도 빠진다.
|
|
203
|
-
*/
|
|
204
|
-
function ComboboxSection(_props) {
|
|
205
|
-
return null;
|
|
206
|
-
}
|
|
207
|
-
asCollectionComponent(ComboboxSection, sectionCollectionNode);
|
|
208
|
-
|
|
209
|
-
export { Combobox, ComboboxItem, ComboboxSection };
|
package/dist/Dialog.d.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
2
|
-
export interface DialogProps {
|
|
3
|
-
/** 열림 상태(제어). 주면 `onOpenChange`로 바꾼다. */
|
|
4
|
-
open?: boolean;
|
|
5
|
-
/** 처음 열림 상태(비제어). 기본값은 `false`다. */
|
|
6
|
-
defaultOpen?: boolean;
|
|
7
|
-
/** 열림 상태가 바뀌려 할 때 새 값으로 부른다. */
|
|
8
|
-
onOpenChange?: (open: boolean) => void;
|
|
9
|
-
/** `DialogTrigger`와 `DialogContent` */
|
|
10
|
-
children: ReactNode;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* 트리거와 내용을 잇는 열림 상태. DOM 요소를 만들지 않는다.
|
|
14
|
-
* 안에 `DialogTrigger`(없어도 된다. `open`으로 제어해 Menu 항목 등에서 열 수 있다)와 `DialogContent`를 둔다.
|
|
15
|
-
*/
|
|
16
|
-
export declare function Dialog(props: DialogProps): ReactElement;
|
|
17
|
-
export interface DialogTriggerProps extends ComponentProps<"button"> {
|
|
18
|
-
/**
|
|
19
|
-
* 다른 요소로 렌더한다. 예: `render={<Button variant="outline" />}`, `render={<IconButton aria-label="삭제" />}`.
|
|
20
|
-
* props, ref, className, 이벤트 핸들러를 그 요소에 병합한다. 기본은 class 없는 `<button type="button">`이다.
|
|
21
|
-
*/
|
|
22
|
-
render?: ReactElement;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Dialog를 여는 버튼. 누르면(마우스, 터치, Enter, Space) 연다. 열린 동안은 바깥이 inert라 다시 누를 수 없다.
|
|
26
|
-
* `aria-haspopup="dialog"`, `aria-expanded`, 열렸을 때 `aria-controls`와 `data-open`이 붙는다.
|
|
27
|
-
*/
|
|
28
|
-
export declare function DialogTrigger({ render, ref, id, className, ...props }: DialogTriggerProps): ReactElement;
|
|
29
|
-
/** Dialog 최대 폭. `sm` 24rem(384px), `md` 32rem(512px), `lg` 40rem(640px)이다. */
|
|
30
|
-
export type DialogSize = "sm" | "md" | "lg";
|
|
31
|
-
export interface DialogContentProps extends Omit<ComponentProps<"div">, "id" | "role"> {
|
|
32
|
-
/** 최대 폭. 기본값은 `md`(32rem)다. 화면이 좁으면 화면 폭 − 32px까지 줄어든다. */
|
|
33
|
-
size?: DialogSize;
|
|
34
|
-
/** 닫기 버튼(IconButton)의 이름. 기본값은 `"닫기"`다. AlertDialog에는 닫기 버튼이 없어 쓰지 않는다. */
|
|
35
|
-
closeLabel?: string;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* 화면 가운데 뜨는 모달 내용(`role="dialog"`, AlertDialog 안에서는 `role="alertdialog"`).
|
|
39
|
-
* 열릴 때만 `document.body`에 portal하고, 반투명 막(`bg-overlay`)과 함께 `z-modal`로 쌓는다.
|
|
40
|
-
* 등장은 opacity + scale 0.96 → 1(`normal`), 퇴장은 opacity + scale 0.98(`fast`)이다. 움직임 줄이기에서는 opacity만 바뀐다.
|
|
41
|
-
* Dialog에는 끝 위쪽에 닫기 버튼(IconButton)이 있고 바깥 막을 누르면 닫힌다. AlertDialog는 둘 다 없다(Esc는 닫는다).
|
|
42
|
-
*/
|
|
43
|
-
export declare function DialogContent(props: DialogContentProps): ReactElement | null;
|
|
44
|
-
export type DialogTitleProps = ComponentProps<"h2">;
|
|
45
|
-
/**
|
|
46
|
-
* Dialog 제목(`<h2>`, `text-heading-sm`). 있으면 dialog의 `aria-labelledby`가 가리켜 이름이 된다.
|
|
47
|
-
* Dialog에서는 끝쪽 닫기 버튼과 겹치지 않게 끝 여백(36px)을 둔다.
|
|
48
|
-
*/
|
|
49
|
-
export declare function DialogTitle({ id, className, ...props }: DialogTitleProps): ReactElement;
|
|
50
|
-
export type DialogDescriptionProps = ComponentProps<"p">;
|
|
51
|
-
/**
|
|
52
|
-
* Dialog 설명(`<p>`, `text-muted`). 있으면 dialog의 `aria-describedby`가 가리킨다. AlertDialog에서는 알릴 내용을 여기에 쓴다.
|
|
53
|
-
* 목록·여러 문단처럼 구조가 있는 내용은 한 줄로 읽히므로 이 요소 밖에 둔다(APG Dialog).
|
|
54
|
-
*/
|
|
55
|
-
export declare function DialogDescription({ id, className, ...props }: DialogDescriptionProps): ReactElement;
|
|
56
|
-
export type DialogFooterProps = ComponentProps<"div">;
|
|
57
|
-
/** 동작 버튼 줄. 끝쪽에 맞추고 버튼 사이는 8px이다. 앞에 덜 위험한 동작(취소)을, 끝에 주 동작을 둔다. */
|
|
58
|
-
export declare function DialogFooter({ className, ...props }: DialogFooterProps): ReactElement;
|
|
59
|
-
export interface DialogCloseProps extends ComponentProps<"button"> {
|
|
60
|
-
/**
|
|
61
|
-
* 다른 요소로 렌더한다. 예: `render={<Button variant="ghost" color="neutral" />}`.
|
|
62
|
-
* 기본은 class 없는 `<button type="button">`이다.
|
|
63
|
-
*/
|
|
64
|
-
render?: ReactElement;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* 누르면 Dialog를 닫는 버튼. `onClick`을 먼저 부르고, 그 안에서 `event.preventDefault()`를 부르면 닫지 않는다.
|
|
68
|
-
* 닫히면 포커스는 열기 전 요소로 돌아간다.
|
|
69
|
-
*/
|
|
70
|
-
export declare function DialogClose({ render, onClick, className, ...props }: DialogCloseProps): ReactElement;
|
package/dist/Dialog.js
DELETED
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "./libs/cn.js";
|
|
4
|
-
import { IconButton } from "./IconButton.js";
|
|
5
|
-
import { OverlayPortal } from "./components/OverlayPortal.js";
|
|
6
|
-
import { useOverlayPresence } from "./hooks/useOverlayPresence.js";
|
|
7
|
-
import { useOverlayTheme } from "./hooks/useOverlayTheme.js";
|
|
8
|
-
import { backdropMotionClass, dialogMotionClass, dialogSurfaceClass } from "./constants/overlayClass.js";
|
|
9
|
-
import { renderElement } from "./libs/renderElement.js";
|
|
10
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { createContext, createElement, use, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
12
|
-
import { XIcon } from "@tide-design/icons";
|
|
13
|
-
import { mergeProps, mergeRefs, useDialog, useFocusManager, useModalOverlay, useOverlayTrigger, usePress } from "react-aria";
|
|
14
|
-
import { useOverlayTriggerState } from "react-stately";
|
|
15
|
-
|
|
16
|
-
// src/Dialog.tsx
|
|
17
|
-
const DialogContext = createContext(null);
|
|
18
|
-
function useDialogContext(part) {
|
|
19
|
-
const context = use(DialogContext);
|
|
20
|
-
if (!context) throw new Error(`${part}는 Dialog나 AlertDialog 안에 둔다.`);
|
|
21
|
-
return context;
|
|
22
|
-
}
|
|
23
|
-
const DialogPartsContext = createContext(null);
|
|
24
|
-
function useDialogPartsContext(part) {
|
|
25
|
-
const context = use(DialogPartsContext);
|
|
26
|
-
if (!context) throw new Error(`${part}는 DialogContent 안에 둔다.`);
|
|
27
|
-
return context;
|
|
28
|
-
}
|
|
29
|
-
/** Dialog·AlertDialog가 같이 쓰는 열림 상태. 공개 API가 아니다(AlertDialog.tsx가 쓴다). */
|
|
30
|
-
function DialogRoot({ open, defaultOpen, onOpenChange, alert, children }) {
|
|
31
|
-
const state = useOverlayTriggerState({
|
|
32
|
-
isOpen: open,
|
|
33
|
-
defaultOpen,
|
|
34
|
-
onOpenChange
|
|
35
|
-
});
|
|
36
|
-
const triggerRef = useRef(null);
|
|
37
|
-
const { triggerProps, overlayProps } = useOverlayTrigger({ type: "dialog" }, state, triggerRef);
|
|
38
|
-
const [triggerId, setTriggerId] = useState(null);
|
|
39
|
-
const value = useMemo(() => ({
|
|
40
|
-
state,
|
|
41
|
-
triggerRef,
|
|
42
|
-
triggerProps,
|
|
43
|
-
contentId: overlayProps.id,
|
|
44
|
-
triggerId,
|
|
45
|
-
setTriggerId,
|
|
46
|
-
alert
|
|
47
|
-
}), [
|
|
48
|
-
state,
|
|
49
|
-
triggerProps,
|
|
50
|
-
overlayProps.id,
|
|
51
|
-
triggerId,
|
|
52
|
-
alert
|
|
53
|
-
]);
|
|
54
|
-
return /* @__PURE__ */ jsx(DialogContext, {
|
|
55
|
-
value,
|
|
56
|
-
children
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* 트리거와 내용을 잇는 열림 상태. DOM 요소를 만들지 않는다.
|
|
61
|
-
* 안에 `DialogTrigger`(없어도 된다. `open`으로 제어해 Menu 항목 등에서 열 수 있다)와 `DialogContent`를 둔다.
|
|
62
|
-
*/
|
|
63
|
-
function Dialog(props) {
|
|
64
|
-
return /* @__PURE__ */ jsx(DialogRoot, {
|
|
65
|
-
...props,
|
|
66
|
-
alert: false
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Dialog를 여는 버튼. 누르면(마우스, 터치, Enter, Space) 연다. 열린 동안은 바깥이 inert라 다시 누를 수 없다.
|
|
71
|
-
* `aria-haspopup="dialog"`, `aria-expanded`, 열렸을 때 `aria-controls`와 `data-open`이 붙는다.
|
|
72
|
-
*/
|
|
73
|
-
function DialogTrigger({ render, ref, id, className, ...props }) {
|
|
74
|
-
const { state, triggerRef, triggerProps, setTriggerId } = useDialogContext("DialogTrigger");
|
|
75
|
-
const { onPress, ...ariaProps } = triggerProps;
|
|
76
|
-
const { pressProps } = usePress({
|
|
77
|
-
onPress,
|
|
78
|
-
ref: triggerRef
|
|
79
|
-
});
|
|
80
|
-
const mergedRef = useMemo(() => mergeRefs(ref, triggerRef), [ref, triggerRef]);
|
|
81
|
-
const generatedId = useId();
|
|
82
|
-
const resolvedId = id ?? generatedId;
|
|
83
|
-
useLayoutEffect(() => {
|
|
84
|
-
setTriggerId(resolvedId);
|
|
85
|
-
return () => setTriggerId(null);
|
|
86
|
-
}, [resolvedId, setTriggerId]);
|
|
87
|
-
const merged = {
|
|
88
|
-
...mergeProps(props, ariaProps, pressProps),
|
|
89
|
-
id: resolvedId,
|
|
90
|
-
ref: mergedRef,
|
|
91
|
-
"data-open": state.isOpen ? "" : void 0
|
|
92
|
-
};
|
|
93
|
-
if (!render) return createElement("button", {
|
|
94
|
-
type: "button",
|
|
95
|
-
...merged,
|
|
96
|
-
className
|
|
97
|
-
});
|
|
98
|
-
return renderElement({
|
|
99
|
-
defaultElement: "button",
|
|
100
|
-
render,
|
|
101
|
-
baseClassName: "",
|
|
102
|
-
props: {
|
|
103
|
-
...merged,
|
|
104
|
-
className
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
const backdropClass = `fixed inset-0 isolate z-modal flex items-center justify-center bg-overlay p-4 ${backdropMotionClass}`;
|
|
109
|
-
const contentClass = `relative flex max-h-full w-full flex-col gap-4 overflow-y-auto p-6 text-body-md outline-none ${dialogSurfaceClass} ${dialogMotionClass}`;
|
|
110
|
-
const sizeClass = {
|
|
111
|
-
sm: "max-w-96",
|
|
112
|
-
md: "max-w-128",
|
|
113
|
-
lg: "max-w-160"
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* 화면 가운데 뜨는 모달 내용(`role="dialog"`, AlertDialog 안에서는 `role="alertdialog"`).
|
|
117
|
-
* 열릴 때만 `document.body`에 portal하고, 반투명 막(`bg-overlay`)과 함께 `z-modal`로 쌓는다.
|
|
118
|
-
* 등장은 opacity + scale 0.96 → 1(`normal`), 퇴장은 opacity + scale 0.98(`fast`)이다. 움직임 줄이기에서는 opacity만 바뀐다.
|
|
119
|
-
* Dialog에는 끝 위쪽에 닫기 버튼(IconButton)이 있고 바깥 막을 누르면 닫힌다. AlertDialog는 둘 다 없다(Esc는 닫는다).
|
|
120
|
-
*/
|
|
121
|
-
function DialogContent(props) {
|
|
122
|
-
const context = useDialogContext("DialogContent");
|
|
123
|
-
const backdropRef = useRef(null);
|
|
124
|
-
if (!useOverlayPresence(context.state.isOpen, backdropRef)) return null;
|
|
125
|
-
return /* @__PURE__ */ jsx(OverlayPortal, {
|
|
126
|
-
isExiting: !context.state.isOpen,
|
|
127
|
-
children: /* @__PURE__ */ jsx(DialogContentInner, {
|
|
128
|
-
...props,
|
|
129
|
-
context,
|
|
130
|
-
backdropRef
|
|
131
|
-
})
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
/** DOM에 있는 동안만 portal 안에서 렌더한다. React Aria 오버레이 hook은 요소가 있다고 보고 동작한다. */
|
|
135
|
-
function DialogContentInner({ context, backdropRef, size = "md", closeLabel = "닫기", ref, className, children, ...props }) {
|
|
136
|
-
const { state, triggerRef, contentId, triggerId, alert } = context;
|
|
137
|
-
const dialogRef = useRef(null);
|
|
138
|
-
const [titleId, setTitleId] = useState(null);
|
|
139
|
-
const [descriptionId, setDescriptionId] = useState(null);
|
|
140
|
-
useOverlayTheme(triggerRef, backdropRef);
|
|
141
|
-
const { modalProps, underlayProps } = useModalOverlay({ isDismissable: !alert }, state, dialogRef);
|
|
142
|
-
const labelledBy = props["aria-labelledby"] ?? (props["aria-label"] ? void 0 : titleId ?? triggerId ?? void 0);
|
|
143
|
-
const describedBy = props["aria-describedby"] ?? descriptionId ?? void 0;
|
|
144
|
-
const { dialogProps } = useDialog({
|
|
145
|
-
role: alert ? "alertdialog" : "dialog",
|
|
146
|
-
"aria-label": props["aria-label"],
|
|
147
|
-
"aria-labelledby": labelledBy,
|
|
148
|
-
"aria-describedby": describedBy
|
|
149
|
-
}, dialogRef);
|
|
150
|
-
const focusManager = useFocusManager();
|
|
151
|
-
useEffect(() => {
|
|
152
|
-
if (alert && document.activeElement === dialogRef.current) focusManager?.focusFirst({ tabbable: true });
|
|
153
|
-
}, []);
|
|
154
|
-
const mergedRef = useMemo(() => mergeRefs(ref, dialogRef), [ref]);
|
|
155
|
-
const parts = useMemo(() => ({
|
|
156
|
-
alert,
|
|
157
|
-
setTitleId,
|
|
158
|
-
setDescriptionId
|
|
159
|
-
}), [alert]);
|
|
160
|
-
const open = state.isOpen ? "" : void 0;
|
|
161
|
-
return /* @__PURE__ */ jsx("div", {
|
|
162
|
-
...underlayProps,
|
|
163
|
-
ref: backdropRef,
|
|
164
|
-
"data-open": open,
|
|
165
|
-
className: backdropClass,
|
|
166
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
167
|
-
...mergeProps(props, modalProps, dialogProps),
|
|
168
|
-
id: contentId,
|
|
169
|
-
ref: mergedRef,
|
|
170
|
-
"data-open": open,
|
|
171
|
-
className: cn(contentClass, sizeClass[size], className),
|
|
172
|
-
children: [/* @__PURE__ */ jsx(DialogPartsContext, {
|
|
173
|
-
value: parts,
|
|
174
|
-
children
|
|
175
|
-
}), !alert && /* @__PURE__ */ jsx(IconButton, {
|
|
176
|
-
"aria-label": closeLabel,
|
|
177
|
-
variant: "ghost",
|
|
178
|
-
color: "neutral",
|
|
179
|
-
size: "sm",
|
|
180
|
-
onClick: state.close,
|
|
181
|
-
className: "absolute end-5 top-5",
|
|
182
|
-
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
183
|
-
})]
|
|
184
|
-
})
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
/** 부분 요소의 id를 정하고 열린 동안 dialog에 알린다. */
|
|
188
|
-
function usePartId(id, register) {
|
|
189
|
-
const generated = useId();
|
|
190
|
-
const resolved = id ?? generated;
|
|
191
|
-
useLayoutEffect(() => {
|
|
192
|
-
register(resolved);
|
|
193
|
-
return () => register(null);
|
|
194
|
-
}, [resolved, register]);
|
|
195
|
-
return resolved;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Dialog 제목(`<h2>`, `text-heading-sm`). 있으면 dialog의 `aria-labelledby`가 가리켜 이름이 된다.
|
|
199
|
-
* Dialog에서는 끝쪽 닫기 버튼과 겹치지 않게 끝 여백(36px)을 둔다.
|
|
200
|
-
*/
|
|
201
|
-
function DialogTitle({ id, className, ...props }) {
|
|
202
|
-
const { alert, setTitleId } = useDialogPartsContext("DialogTitle");
|
|
203
|
-
const resolvedId = usePartId(id, setTitleId);
|
|
204
|
-
return /* @__PURE__ */ jsx("h2", {
|
|
205
|
-
...props,
|
|
206
|
-
id: resolvedId,
|
|
207
|
-
className: cn("text-heading-sm text-default", !alert && "pe-9", className)
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Dialog 설명(`<p>`, `text-muted`). 있으면 dialog의 `aria-describedby`가 가리킨다. AlertDialog에서는 알릴 내용을 여기에 쓴다.
|
|
212
|
-
* 목록·여러 문단처럼 구조가 있는 내용은 한 줄로 읽히므로 이 요소 밖에 둔다(APG Dialog).
|
|
213
|
-
*/
|
|
214
|
-
function DialogDescription({ id, className, ...props }) {
|
|
215
|
-
const { setDescriptionId } = useDialogPartsContext("DialogDescription");
|
|
216
|
-
const resolvedId = usePartId(id, setDescriptionId);
|
|
217
|
-
return /* @__PURE__ */ jsx("p", {
|
|
218
|
-
...props,
|
|
219
|
-
id: resolvedId,
|
|
220
|
-
className: cn("text-body-md text-muted", className)
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
/** 동작 버튼 줄. 끝쪽에 맞추고 버튼 사이는 8px이다. 앞에 덜 위험한 동작(취소)을, 끝에 주 동작을 둔다. */
|
|
224
|
-
function DialogFooter({ className, ...props }) {
|
|
225
|
-
return /* @__PURE__ */ jsx("div", {
|
|
226
|
-
...props,
|
|
227
|
-
className: cn("mt-2 flex flex-wrap justify-end gap-2", className)
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* 누르면 Dialog를 닫는 버튼. `onClick`을 먼저 부르고, 그 안에서 `event.preventDefault()`를 부르면 닫지 않는다.
|
|
232
|
-
* 닫히면 포커스는 열기 전 요소로 돌아간다.
|
|
233
|
-
*/
|
|
234
|
-
function DialogClose({ render, onClick, className, ...props }) {
|
|
235
|
-
const { state } = useDialogContext("DialogClose");
|
|
236
|
-
const handleClick = (event) => {
|
|
237
|
-
onClick?.(event);
|
|
238
|
-
if (!event.defaultPrevented) state.close();
|
|
239
|
-
};
|
|
240
|
-
const merged = {
|
|
241
|
-
...props,
|
|
242
|
-
onClick: handleClick,
|
|
243
|
-
className
|
|
244
|
-
};
|
|
245
|
-
if (!render) return createElement("button", {
|
|
246
|
-
type: "button",
|
|
247
|
-
...merged
|
|
248
|
-
});
|
|
249
|
-
return renderElement({
|
|
250
|
-
defaultElement: "button",
|
|
251
|
-
render,
|
|
252
|
-
baseClassName: "",
|
|
253
|
-
props: merged
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogRoot, DialogTitle, DialogTrigger };
|
package/dist/IconButton.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { FillVariant, Role, Size } from "./types.js";
|
|
2
|
-
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
3
|
-
/** IconButton의 채움 방식. Button과 같은 4개를 받는다. */
|
|
4
|
-
type IconButtonVariant = Extract<FillVariant, "solid" | "subtle" | "outline" | "ghost">;
|
|
5
|
-
/** IconButton의 size. 공통 size 4개를 모두 받는다. 가장 작은 `xs`도 24×24px다. */
|
|
6
|
-
type IconButtonSize = Extract<Size, "xs" | "sm" | "md" | "lg">;
|
|
7
|
-
export interface IconButtonProps extends Omit<ComponentProps<"button">, "color" | "aria-label" | "children"> {
|
|
8
|
-
/** 버튼 이름. 아이콘만 보이므로 반드시 적는다(예: `"설정"`). 스크린 리더가 읽는다. */
|
|
9
|
-
"aria-label": string;
|
|
10
|
-
/** 아이콘. 장식용으로 숨겨지고 size에 맞는 크기가 된다. 다른 라이브러리의 아이콘도 받는다. */
|
|
11
|
-
children: ReactNode;
|
|
12
|
-
/** 채움 방식. 기본값은 Button과 같은 `solid`다. 툴바·닫기 버튼처럼 약한 동작은 `ghost`를 쓴다. */
|
|
13
|
-
variant?: IconButtonVariant;
|
|
14
|
-
/**
|
|
15
|
-
* Role. Tide Role 6개와 앱이 `RoleRegistry`에 더한 Role을 받는다. 기본값은 `primary`다.
|
|
16
|
-
* 색 계열 이름(`blue` 등)은 받지 않는다. 행동의 뜻을 색으로 전하기 때문이다(ADR 0016).
|
|
17
|
-
* 루트에 `data-color`로 붙어 accent 색을 정한다. 바깥 요소의 색을 물려받지 않는다.
|
|
18
|
-
*/
|
|
19
|
-
color?: Role;
|
|
20
|
-
/** 정사각형 크기 `xs` 24px, `sm` 32px, `md` 40px, `lg` 48px. 아이콘은 16/16/20/24px다. 기본값은 `md`다. */
|
|
21
|
-
size?: IconButtonSize;
|
|
22
|
-
/**
|
|
23
|
-
* 로딩 중. 아이콘 자리에 Spinner를 보이고 클릭을 막는다.
|
|
24
|
-
* 포커스는 유지하고 `aria-disabled="true"`와 `data-loading`을 붙인다.
|
|
25
|
-
*/
|
|
26
|
-
loading?: boolean;
|
|
27
|
-
/** 로딩 중에 `aria-label` 뒤에 붙는 텍스트. 기본값은 `"로딩 중"`이다. */
|
|
28
|
-
loadingLabel?: string;
|
|
29
|
-
/** 누를 때 줄어드는 반응(scale 0.96)을 끈다. 움직임 줄이기 설정에서는 이 값과 관계없이 줄어들지 않는다. */
|
|
30
|
-
noPressScale?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* 다른 요소로 렌더한다. 예: `render={<Link href="/x" />}`.
|
|
33
|
-
* props, ref, className을 그 요소에 병합한다. `button`이 아닌 요소의 `disabled`는 `aria-disabled`로 바뀐다.
|
|
34
|
-
*/
|
|
35
|
-
render?: ReactElement;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* 아이콘만 있는 버튼. `aria-label`이 필수라 이름이 빠지지 않는다.
|
|
39
|
-
* Button과 같은 채움 방식(`variant`) × Role(`color`) × `size` 축을 쓴다.
|
|
40
|
-
*/
|
|
41
|
-
export declare function IconButton({ variant, color, size, loading, loadingLabel, noPressScale, render, disabled, type, children, onClick, "aria-label": ariaLabel, ...props }: IconButtonProps): ReactElement;
|
|
42
|
-
export {};
|
package/dist/Link.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Role } from "./types.js";
|
|
2
|
-
import { ComponentProps, ReactElement } from "react";
|
|
3
|
-
export interface LinkProps extends Omit<ComponentProps<"a">, "color"> {
|
|
4
|
-
/**
|
|
5
|
-
* Role. Tide Role 6개와 앱이 `RoleRegistry`에 더한 Role을 받는다. 기본값은 `primary`다.
|
|
6
|
-
* 색 계열 이름(`blue` 등)은 받지 않는다. 행동의 뜻을 색으로 전하기 때문이다(ADR 0016).
|
|
7
|
-
* 루트에 `data-color`로 붙어 글자색(`text-accent`)을 정한다. 바깥 요소의 색을 물려받지 않는다.
|
|
8
|
-
*/
|
|
9
|
-
color?: Role;
|
|
10
|
-
/**
|
|
11
|
-
* 다른 요소로 렌더한다. 예: `render={<NextLink href="/x" />}`.
|
|
12
|
-
* props, ref, className을 그 요소에 병합한다.
|
|
13
|
-
*/
|
|
14
|
-
render?: ReactElement;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* 문장 안에서 다른 페이지나 위치로 이동하는 텍스트 링크.
|
|
18
|
-
* Next.js에서는 `render={<NextLink href="/x" />}`로 클라이언트 이동을 쓴다.
|
|
19
|
-
*/
|
|
20
|
-
export declare function Link({ color, render, ...props }: LinkProps): ReactElement;
|
package/dist/Menu.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { CollectionItemProps, CollectionSectionProps } from "./libs/listCollection.js";
|
|
2
|
-
import { OverlayPlacement } from "./libs/overlayPosition.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;
|