@tide-design/components 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Accordion/Accordion.d.ts +24 -0
- package/dist/Accordion/Accordion.js +32 -0
- package/dist/Accordion/components/AccordionItem.d.ts +14 -0
- package/dist/Accordion/components/AccordionItem.js +51 -0
- package/dist/Accordion/components/AccordionPanel.d.ts +13 -0
- package/dist/Accordion/components/AccordionPanel.js +27 -0
- package/dist/Accordion/components/AccordionTrigger.d.ts +17 -0
- package/dist/Accordion/components/AccordionTrigger.js +39 -0
- package/dist/Accordion/constants/accordionClass.js +12 -0
- package/dist/Accordion/hooks/useAccordionContext.js +8 -0
- package/dist/Accordion/hooks/useAccordionItemContext.js +13 -0
- package/dist/Accordion/index.d.ts +6 -0
- package/dist/Accordion/types.d.ts +2 -0
- package/dist/{Alert.d.ts → Alert/Alert.d.ts} +1 -1
- package/dist/{Alert.js → Alert/Alert.js} +5 -4
- package/dist/Alert/index.d.ts +2 -0
- package/dist/{AlertDialog.d.ts → AlertDialog/AlertDialog.d.ts} +1 -1
- package/dist/{AlertDialog.js → AlertDialog/AlertDialog.js} +2 -2
- package/dist/AlertDialog/index.d.ts +2 -0
- package/dist/{Avatar.d.ts → Avatar/Avatar.d.ts} +1 -1
- package/dist/{Avatar.js → Avatar/Avatar.js} +2 -2
- package/dist/Avatar/index.d.ts +2 -0
- package/dist/{Badge.d.ts → Badge/Badge.d.ts} +1 -1
- package/dist/{Badge.js → Badge/Badge.js} +2 -2
- package/dist/Badge/index.d.ts +2 -0
- package/dist/Breadcrumb/Breadcrumb.d.ts +11 -0
- package/dist/Breadcrumb/Breadcrumb.js +21 -0
- package/dist/Breadcrumb/components/BreadcrumbCurrent.d.ts +4 -0
- package/dist/Breadcrumb/components/BreadcrumbCurrent.js +15 -0
- package/dist/Breadcrumb/components/BreadcrumbItem.d.ts +4 -0
- package/dist/Breadcrumb/components/BreadcrumbItem.js +16 -0
- package/dist/Breadcrumb/components/BreadcrumbLink.d.ts +10 -0
- package/dist/Breadcrumb/components/BreadcrumbLink.js +15 -0
- package/dist/Breadcrumb/constants/breadcrumbClass.js +8 -0
- package/dist/Breadcrumb/index.d.ts +5 -0
- package/dist/{Button.d.ts → Button/Button.d.ts} +3 -7
- package/dist/{Button.js → Button/Button.js} +8 -26
- package/dist/Button/components/Icon.js +13 -0
- package/dist/Button/constants/buttonClass.js +17 -0
- package/dist/Button/index.d.ts +2 -0
- package/dist/Button/types.d.ts +5 -0
- package/dist/{Card.js → Card/Card.js} +2 -2
- package/dist/Card/index.d.ts +2 -0
- package/dist/{Checkbox.d.ts → Checkbox/Checkbox.d.ts} +2 -2
- package/dist/{Checkbox.js → Checkbox/Checkbox.js} +5 -5
- package/dist/Checkbox/index.d.ts +2 -0
- package/dist/{CheckboxGroup.d.ts → CheckboxGroup/CheckboxGroup.d.ts} +3 -3
- package/dist/{CheckboxGroup.js → CheckboxGroup/CheckboxGroup.js} +6 -10
- package/dist/CheckboxGroup/index.d.ts +3 -0
- package/dist/{Combobox.d.ts → Combobox/Combobox.d.ts} +2 -17
- package/dist/{Combobox.js → Combobox/Combobox.js} +10 -96
- package/dist/Combobox/components/ComboboxItem.d.ts +9 -0
- package/dist/Combobox/components/ComboboxItem.js +17 -0
- package/dist/Combobox/components/ComboboxPopover.js +23 -0
- package/dist/Combobox/components/ComboboxPopoverInner.js +50 -0
- package/dist/Combobox/components/ComboboxSection.d.ts +7 -0
- package/dist/Combobox/components/ComboboxSection.js +15 -0
- package/dist/Combobox/constants/comboboxClass.js +21 -0
- package/dist/Combobox/index.d.ts +4 -0
- package/dist/Dialog/Dialog.d.ts +8 -0
- package/dist/Dialog/Dialog.js +18 -0
- package/dist/Dialog/components/DialogClose.d.ts +13 -0
- package/dist/Dialog/components/DialogClose.js +35 -0
- package/dist/Dialog/components/DialogContent.d.ts +15 -0
- package/dist/Dialog/components/DialogContent.js +31 -0
- package/dist/Dialog/components/DialogContentInner.js +68 -0
- package/dist/Dialog/components/DialogDescription.d.ts +7 -0
- package/dist/Dialog/components/DialogDescription.js +23 -0
- package/dist/Dialog/components/DialogFooter.d.ts +4 -0
- package/dist/Dialog/components/DialogFooter.js +13 -0
- package/dist/Dialog/components/DialogTitle.d.ts +7 -0
- package/dist/Dialog/components/DialogTitle.js +23 -0
- package/dist/Dialog/components/DialogTrigger.d.ts +13 -0
- package/dist/Dialog/components/DialogTrigger.js +49 -0
- package/dist/Dialog/constants/dialogClass.js +12 -0
- package/dist/Dialog/hooks/useDialogPartsContext.js +13 -0
- package/dist/Dialog/hooks/usePartId.js +17 -0
- package/dist/Dialog/index.d.ts +10 -0
- package/dist/Dialog/types.d.ts +2 -0
- package/dist/{Field.js → Field/Field.js} +3 -3
- package/dist/Field/index.d.ts +2 -0
- package/dist/{IconButton.d.ts → IconButton/IconButton.d.ts} +1 -1
- package/dist/{IconButton.js → IconButton/IconButton.js} +5 -4
- package/dist/IconButton/index.d.ts +2 -0
- package/dist/{Input.d.ts → Input/Input.d.ts} +1 -1
- package/dist/{Input.js → Input/Input.js} +4 -4
- package/dist/Input/index.d.ts +2 -0
- package/dist/{Link.d.ts → Link/Link.d.ts} +1 -1
- package/dist/{Link.js → Link/Link.js} +2 -2
- package/dist/Link/index.d.ts +2 -0
- package/dist/Menu/Menu.d.ts +16 -0
- package/dist/Menu/Menu.js +43 -0
- package/dist/Menu/components/MenuContent.d.ts +16 -0
- package/dist/Menu/components/MenuContent.js +30 -0
- package/dist/Menu/components/MenuContentInner.js +67 -0
- package/dist/Menu/components/MenuItem.d.ts +17 -0
- package/dist/Menu/components/MenuItem.js +16 -0
- package/dist/Menu/components/MenuItemView.js +34 -0
- package/dist/Menu/components/MenuSection.d.ts +13 -0
- package/dist/Menu/components/MenuSection.js +15 -0
- package/dist/Menu/components/MenuSectionView.js +33 -0
- package/dist/Menu/components/MenuTrigger.d.ts +13 -0
- package/dist/Menu/components/MenuTrigger.js +53 -0
- package/dist/Menu/hooks/useMenuContext.js +13 -0
- package/dist/Menu/index.d.ts +7 -0
- package/dist/Menu/types.d.ts +4 -0
- package/dist/Pagination/Pagination.d.ts +11 -0
- package/dist/Pagination/Pagination.js +21 -0
- package/dist/Pagination/components/PaginationEllipsis.d.ts +7 -0
- package/dist/Pagination/components/PaginationEllipsis.js +17 -0
- package/dist/Pagination/components/PaginationItem.d.ts +4 -0
- package/dist/Pagination/components/PaginationItem.js +9 -0
- package/dist/Pagination/components/PaginationLink.d.ts +15 -0
- package/dist/Pagination/components/PaginationLink.js +23 -0
- package/dist/Pagination/components/PaginationNext.d.ts +5 -0
- package/dist/Pagination/components/PaginationNext.js +18 -0
- package/dist/Pagination/components/PaginationPrevious.d.ts +5 -0
- package/dist/Pagination/components/PaginationPrevious.js +18 -0
- package/dist/Pagination/constants/paginationClass.js +6 -0
- package/dist/Pagination/index.d.ts +7 -0
- package/dist/Pagination/types.d.ts +6 -0
- package/dist/Popover/Popover.d.ts +16 -0
- package/dist/Popover/Popover.js +43 -0
- package/dist/Popover/components/PopoverContent.d.ts +14 -0
- package/dist/Popover/components/PopoverContent.js +30 -0
- package/dist/Popover/components/PopoverContentInner.js +48 -0
- package/dist/Popover/components/PopoverTrigger.d.ts +13 -0
- package/dist/Popover/components/PopoverTrigger.js +51 -0
- package/dist/Popover/constants/popoverClass.js +6 -0
- package/dist/Popover/hooks/usePopoverContext.js +13 -0
- package/dist/Popover/index.d.ts +5 -0
- package/dist/Popover/types.d.ts +3 -0
- package/dist/{Progress.d.ts → Progress/Progress.d.ts} +1 -1
- package/dist/{Progress.js → Progress/Progress.js} +2 -2
- package/dist/Progress/index.d.ts +2 -0
- package/dist/{Radio.d.ts → Radio/Radio.d.ts} +2 -2
- package/dist/{Radio.js → Radio/Radio.js} +5 -5
- package/dist/Radio/index.d.ts +2 -0
- package/dist/{RadioGroup.d.ts → RadioGroup/RadioGroup.d.ts} +1 -1
- package/dist/{RadioGroup.js → RadioGroup/RadioGroup.js} +5 -5
- package/dist/RadioGroup/index.d.ts +2 -0
- package/dist/{Select.d.ts → Select/Select.d.ts} +2 -17
- package/dist/Select/Select.js +97 -0
- package/dist/Select/components/SelectItem.d.ts +9 -0
- package/dist/Select/components/SelectItem.js +17 -0
- package/dist/Select/components/SelectPopover.js +23 -0
- package/dist/Select/components/SelectPopoverInner.js +51 -0
- package/dist/Select/components/SelectSection.d.ts +7 -0
- package/dist/Select/components/SelectSection.js +15 -0
- package/dist/Select/constants/selectClass.js +7 -0
- package/dist/Select/index.d.ts +4 -0
- package/dist/{Separator.js → Separator/Separator.js} +2 -2
- package/dist/Separator/index.d.ts +2 -0
- package/dist/{Skeleton.d.ts → Skeleton/Skeleton.d.ts} +1 -1
- package/dist/{Skeleton.js → Skeleton/Skeleton.js} +2 -2
- package/dist/Skeleton/index.d.ts +2 -0
- package/dist/{Spinner.d.ts → Spinner/Spinner.d.ts} +1 -1
- package/dist/{Spinner.js → Spinner/Spinner.js} +2 -2
- package/dist/Spinner/index.d.ts +2 -0
- package/dist/{Switch.d.ts → Switch/Switch.d.ts} +1 -1
- package/dist/{Switch.js → Switch/Switch.js} +3 -3
- package/dist/Switch/index.d.ts +2 -0
- package/dist/Table/Table.d.ts +7 -0
- package/dist/Table/Table.js +17 -0
- package/dist/Table/components/TableBody.d.ts +4 -0
- package/dist/Table/components/TableBody.js +9 -0
- package/dist/Table/components/TableCell.d.ts +4 -0
- package/dist/Table/components/TableCell.js +14 -0
- package/dist/Table/components/TableHead.d.ts +4 -0
- package/dist/Table/components/TableHead.js +9 -0
- package/dist/Table/components/TableHeaderCell.d.ts +13 -0
- package/dist/Table/components/TableHeaderCell.js +18 -0
- package/dist/Table/components/TableRow.d.ts +4 -0
- package/dist/Table/components/TableRow.js +14 -0
- package/dist/Table/constants/tableClass.js +7 -0
- package/dist/Table/index.d.ts +7 -0
- package/dist/Tabs/Tabs.d.ts +34 -0
- package/dist/Tabs/Tabs.js +56 -0
- package/dist/Tabs/components/Tab.d.ts +12 -0
- package/dist/Tabs/components/Tab.js +16 -0
- package/dist/Tabs/components/TabList.d.ts +10 -0
- package/dist/Tabs/components/TabList.js +47 -0
- package/dist/Tabs/components/TabPanel.d.ts +10 -0
- package/dist/Tabs/components/TabPanel.js +27 -0
- package/dist/Tabs/components/TabView.js +29 -0
- package/dist/Tabs/constants/tabsClass.js +23 -0
- package/dist/Tabs/hooks/useTabsContext.js +13 -0
- package/dist/Tabs/index.d.ts +6 -0
- package/dist/Tabs/types.d.ts +5 -0
- package/dist/Tag/Tag.d.ts +18 -0
- package/dist/Tag/Tag.js +15 -0
- package/dist/{Tag.d.ts → Tag/components/TagGroup.d.ts} +0 -17
- package/dist/Tag/components/TagGroup.js +49 -0
- package/dist/Tag/components/TagView.js +49 -0
- package/dist/Tag/constants/tagClass.js +13 -0
- package/dist/Tag/hooks/useTagGroupContext.js +8 -0
- package/dist/Tag/index.d.ts +3 -0
- package/dist/{Textarea.d.ts → Textarea/Textarea.d.ts} +1 -1
- package/dist/{Textarea.js → Textarea/Textarea.js} +4 -4
- package/dist/Textarea/index.d.ts +2 -0
- package/dist/Toast/Toast.d.ts +15 -0
- package/dist/Toast/Toast.js +43 -0
- package/dist/Toast/components/Region.js +28 -0
- package/dist/Toast/components/ToastItem.js +82 -0
- package/dist/Toast/constants/toastClass.js +8 -0
- package/dist/Toast/index.d.ts +4 -0
- package/dist/Toast/libs/mergeEntries.js +19 -0
- package/dist/Toast/libs/toastQueue.d.ts +20 -0
- package/dist/Toast/libs/toastQueue.js +49 -0
- package/dist/{Toast.d.ts → Toast/types.d.ts} +4 -33
- package/dist/Tooltip/Tooltip.d.ts +25 -0
- package/dist/Tooltip/Tooltip.js +42 -0
- package/dist/Tooltip/components/TooltipContent.d.ts +14 -0
- package/dist/Tooltip/components/TooltipContent.js +31 -0
- package/dist/Tooltip/components/TooltipContentInner.js +43 -0
- package/dist/Tooltip/components/TooltipTrigger.d.ts +14 -0
- package/dist/Tooltip/components/TooltipTrigger.js +38 -0
- package/dist/Tooltip/constants/tooltipClass.js +6 -0
- package/dist/Tooltip/hooks/useTooltipContext.js +13 -0
- package/dist/Tooltip/index.d.ts +5 -0
- package/dist/Tooltip/types.d.ts +3 -0
- package/dist/{Typography.js → Typography/Typography.js} +2 -2
- package/dist/Typography/index.d.ts +2 -0
- package/dist/{VisuallyHidden.js → VisuallyHidden/VisuallyHidden.js} +2 -2
- package/dist/VisuallyHidden/index.d.ts +2 -0
- package/dist/_internal/components/DialogRoot.d.ts +11 -0
- package/dist/_internal/components/DialogRoot.js +41 -0
- package/dist/_internal/components/ListBoxNodes/ListBoxNodes.js +35 -0
- package/dist/_internal/components/ListBoxNodes/components/ListBoxOptionView.js +42 -0
- package/dist/_internal/components/ListBoxNodes/components/ListBoxSectionView.js +33 -0
- package/dist/{listbox.d.ts → _internal/components/ListBoxNodes/types.d.ts} +1 -1
- package/dist/_internal/components/OverlayPortal.js +21 -0
- package/dist/{alert-style.js → _internal/constants/alertClass.js} +2 -16
- package/dist/{choice-style.js → _internal/constants/choiceClass.js} +1 -1
- package/dist/_internal/constants/choiceGroupClass.d.ts +2 -0
- package/dist/_internal/constants/choiceGroupClass.js +8 -0
- package/dist/{input-style.d.ts → _internal/constants/inputClass.d.ts} +1 -1
- package/dist/{input-style.js → _internal/constants/inputClass.js} +1 -1
- package/dist/{list-style.js → _internal/constants/listClass.js} +2 -2
- package/dist/{overlay-style.js → _internal/constants/overlayClass.js} +1 -1
- package/dist/_internal/constants/pressableClass.js +33 -0
- package/dist/{choice-group.js → _internal/hooks/useChoiceGroup.js} +2 -2
- package/dist/_internal/hooks/useCloseOnTab.js +29 -0
- package/dist/_internal/hooks/useDialogContext.js +14 -0
- package/dist/{field-context.js → _internal/hooks/useFieldControl.js} +1 -1
- package/dist/_internal/hooks/useOverlayPresence.js +46 -0
- package/dist/_internal/hooks/useOverlayTheme.js +20 -0
- package/dist/_internal/hooks/usePopoverOverlay.js +25 -0
- package/dist/_internal/libs/alertStatusIcon.js +17 -0
- package/dist/{cn.js → _internal/libs/cn.js} +1 -1
- package/dist/{list-collection.js → _internal/libs/listCollection.js} +1 -1
- package/dist/{overlay.d.ts → _internal/libs/overlayPosition.d.ts} +0 -1
- package/dist/_internal/libs/overlayPosition.js +20 -0
- package/dist/_internal/libs/pressableState.js +43 -0
- package/dist/{render.js → _internal/libs/renderElement.js} +1 -1
- package/dist/index.d.ts +119 -36
- package/dist/index.js +75 -36
- package/package.json +3 -3
- package/dist/Accordion.d.ts +0 -66
- package/dist/Accordion.js +0 -127
- package/dist/Breadcrumb.d.ts +0 -26
- package/dist/Breadcrumb.js +0 -53
- package/dist/Dialog.d.ts +0 -70
- package/dist/Dialog.js +0 -255
- package/dist/Menu.d.ts +0 -72
- package/dist/Menu.js +0 -226
- package/dist/Pagination.d.ts +0 -46
- package/dist/Pagination.js +0 -79
- package/dist/Popover.d.ts +0 -43
- package/dist/Popover.js +0 -147
- package/dist/Select.js +0 -169
- package/dist/Table.d.ts +0 -31
- package/dist/Table.js +0 -53
- package/dist/Tabs.d.ts +0 -66
- package/dist/Tabs.js +0 -159
- package/dist/Tag.js +0 -102
- package/dist/Toast.js +0 -191
- package/dist/Tooltip.d.ts +0 -53
- package/dist/Tooltip.js +0 -129
- package/dist/listbox.js +0 -90
- package/dist/overlay.js +0 -130
- package/dist/pressable.js +0 -70
- /package/dist/{Card.d.ts → Card/Card.d.ts} +0 -0
- /package/dist/{Field.d.ts → Field/Field.d.ts} +0 -0
- /package/dist/{Separator.d.ts → Separator/Separator.d.ts} +0 -0
- /package/dist/{Typography.d.ts → Typography/Typography.d.ts} +0 -0
- /package/dist/{VisuallyHidden.d.ts → VisuallyHidden/VisuallyHidden.d.ts} +0 -0
- /package/dist/{choice-style.d.ts → _internal/constants/choiceClass.d.ts} +0 -0
- /package/dist/{cn.d.ts → _internal/libs/cn.d.ts} +0 -0
- /package/dist/{list-collection.d.ts → _internal/libs/listCollection.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tide-design/components",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"description": "Tide 디자인 시스템의 React Component",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"./styles.css": "./dist/styles.css"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@tide-design/foundation": "0.11.
|
|
27
|
-
"@tide-design/icons": "0.11.
|
|
26
|
+
"@tide-design/foundation": "0.11.2",
|
|
27
|
+
"@tide-design/icons": "0.11.2",
|
|
28
28
|
"clsx": "^2.1.1",
|
|
29
29
|
"react-aria": "^3.53.1",
|
|
30
30
|
"react-stately": "^3.51.0",
|
package/dist/Accordion.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
2
|
-
/** 트리거를 감싸는 제목 요소의 단계 */
|
|
3
|
-
export type AccordionHeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
4
|
-
export interface AccordionProps extends Omit<ComponentProps<"div">, "defaultValue" | "onChange"> {
|
|
5
|
-
/**
|
|
6
|
-
* 펼친 항목의 값 목록(제어). 주면 `onValueChange`로 바꾼다.
|
|
7
|
-
* `multiple`이 아닌데 값이 둘 이상이면 첫 값만 남기며 `onValueChange`를 부른다.
|
|
8
|
-
*/
|
|
9
|
-
value?: readonly string[];
|
|
10
|
-
/** 처음 펼친 항목의 값 목록(비제어). 기본값은 빈 목록(모두 접힘)이다. */
|
|
11
|
-
defaultValue?: readonly string[];
|
|
12
|
-
/** 펼친 항목이 바뀌려 할 때 새 값 목록으로 부른다. 목록 순서는 펼친 순서다. */
|
|
13
|
-
onValueChange?: (value: string[]) => void;
|
|
14
|
-
/**
|
|
15
|
-
* 여러 항목을 함께 펼칠지. 기본값은 `false`로, 한 항목을 펼치면 펼쳐 있던 항목이 접힌다.
|
|
16
|
-
* 어느 쪽이든 펼친 항목을 다시 누르면 접힌다(모두 접을 수 있다).
|
|
17
|
-
*/
|
|
18
|
-
multiple?: boolean;
|
|
19
|
-
/** `AccordionItem`들 */
|
|
20
|
-
children?: ReactNode;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* 접고 펴는 영역 묶음. 루트는 `<div>`(radius `lg`, 장식용 경계)이고 안에 `AccordionItem`을 둔다.
|
|
24
|
-
* 기본은 한 번에 한 항목만 펼친다(`multiple`이면 여럿).
|
|
25
|
-
*/
|
|
26
|
-
export declare function Accordion({ value, defaultValue, onValueChange, multiple, ref, className, children, ...props }: AccordionProps): ReactElement;
|
|
27
|
-
export interface AccordionItemProps extends Omit<ComponentProps<"div">, "value"> {
|
|
28
|
-
/** 항목을 가리키는 값. `Accordion`의 `value`·`defaultValue` 목록에 이 값을 넣으면 펼친다. */
|
|
29
|
-
value: string;
|
|
30
|
-
/** 펼치거나 접을 수 없게 한다. 트리거가 네이티브 `disabled`가 된다. 펼친 채 비활성이면 펼친 채로 남는다. */
|
|
31
|
-
disabled?: boolean;
|
|
32
|
-
/** `AccordionTrigger` 하나와 `AccordionPanel` 하나 */
|
|
33
|
-
children?: ReactNode;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* 항목 하나. 안에 `AccordionTrigger`와 `AccordionPanel`을 둔다.
|
|
37
|
-
* 펼쳐 있으면 `data-open`, 비활성이면 `data-disabled`가 붙는다.
|
|
38
|
-
*/
|
|
39
|
-
export declare function AccordionItem({ value, disabled, ref, className, children, ...props }: AccordionItemProps): ReactElement;
|
|
40
|
-
export interface AccordionTriggerProps extends Omit<ComponentProps<"button">, "type" | "id" | "disabled" | "aria-expanded" | "aria-controls"> {
|
|
41
|
-
/**
|
|
42
|
-
* 트리거를 감싸는 제목 요소의 단계(`<h1>`~`<h6>`). 기본값은 `3`이다.
|
|
43
|
-
* 페이지 제목 구조에 맞춘다(WAI-ARIA APG Accordion).
|
|
44
|
-
*/
|
|
45
|
-
level?: AccordionHeadingLevel;
|
|
46
|
-
/** 항목 제목. 제목 요소 안에는 버튼만 둔다(APG). */
|
|
47
|
-
children?: ReactNode;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* 항목 제목 버튼. 제목 요소(`level`, 기본 `<h3>`) 안의 `<button type="button">`이고 끝에 장식용 chevron이 있다.
|
|
51
|
-
* `ref`·`className`·나머지 props는 버튼에 간다. 펼침 상태는 `aria-expanded`와 `data-open`, 비활성은 `:disabled`다.
|
|
52
|
-
* Enter·Space·누름으로 펼치고 접는다.
|
|
53
|
-
*/
|
|
54
|
-
export declare function AccordionTrigger({ level, ref, className, children, ...props }: AccordionTriggerProps): ReactElement;
|
|
55
|
-
export interface AccordionPanelProps extends Omit<ComponentProps<"div">, "id" | "role" | "hidden" | "aria-labelledby"> {
|
|
56
|
-
/**
|
|
57
|
-
* 패널 역할. 기본값은 `region`(트리거 이름이 붙은 영역, APG 예시)이다.
|
|
58
|
-
* 함께 펼칠 수 있는 패널이 많으면(대략 6개 넘음) 영역 랜드마크가 너무 늘지 않게 `group`으로 둔다(APG).
|
|
59
|
-
*/
|
|
60
|
-
role?: "region" | "group";
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* 항목 내용. 트리거가 `aria-controls`로 가리키고 트리거 글자가 이름이 된다(`aria-labelledby`).
|
|
64
|
-
* 접혀 있으면 숨는다(`hidden`). 늘 렌더하므로 안의 입력 상태는 접어도 남는다.
|
|
65
|
-
*/
|
|
66
|
-
export declare function AccordionPanel({ role, ref, className, ...props }: AccordionPanelProps): ReactElement;
|
package/dist/Accordion.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "./cn.js";
|
|
4
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { createContext, use, useMemo, useRef } from "react";
|
|
6
|
-
import { ChevronDownIcon } from "@tide-design/icons";
|
|
7
|
-
import { mergeProps, mergeRefs, useButton, useDisclosure } from "react-aria";
|
|
8
|
-
import { useDisclosureGroupState, useDisclosureState } from "react-stately";
|
|
9
|
-
|
|
10
|
-
// src/Accordion.tsx
|
|
11
|
-
const AccordionContext = createContext(null);
|
|
12
|
-
const AccordionItemContext = createContext(null);
|
|
13
|
-
function useAccordionItemContext(part) {
|
|
14
|
-
const context = use(AccordionItemContext);
|
|
15
|
-
if (!context) throw new Error(`${part}는 AccordionItem 안에 둔다.`);
|
|
16
|
-
return context;
|
|
17
|
-
}
|
|
18
|
-
const accordionClass = "rounded-lg border border-default text-default";
|
|
19
|
-
const itemClass = "not-first:border-t not-first:border-default";
|
|
20
|
-
const triggerClass = [
|
|
21
|
-
"group flex flex-1 cursor-pointer items-center gap-3 rounded-md px-4 py-3 text-start text-label-lg outline-none select-none",
|
|
22
|
-
"enabled:hover:bg-hover focus-visible:focus-ring",
|
|
23
|
-
"disabled:cursor-not-allowed disabled:text-disabled"
|
|
24
|
-
].join(" ");
|
|
25
|
-
const chevronClass = "ms-auto shrink-0 text-muted group-hover:group-enabled:text-default group-disabled:text-disabled group-aria-expanded:rotate-180 motion-safe:transition-[rotate] forced-colors:text-current forced-colors:group-disabled:text-current";
|
|
26
|
-
const panelClass = "px-4 pb-4 text-body-md [&[hidden]]:p-0";
|
|
27
|
-
/**
|
|
28
|
-
* 접고 펴는 영역 묶음. 루트는 `<div>`(radius `lg`, 장식용 경계)이고 안에 `AccordionItem`을 둔다.
|
|
29
|
-
* 기본은 한 번에 한 항목만 펼친다(`multiple`이면 여럿).
|
|
30
|
-
*/
|
|
31
|
-
function Accordion({ value, defaultValue, onValueChange, multiple = false, ref, className, children, ...props }) {
|
|
32
|
-
const state = useDisclosureGroupState({
|
|
33
|
-
allowsMultipleExpanded: multiple,
|
|
34
|
-
expandedKeys: value,
|
|
35
|
-
defaultExpandedKeys: defaultValue,
|
|
36
|
-
onExpandedChange: onValueChange && ((keys) => onValueChange([...keys].map(String)))
|
|
37
|
-
});
|
|
38
|
-
return /* @__PURE__ */ jsx("div", {
|
|
39
|
-
...props,
|
|
40
|
-
ref,
|
|
41
|
-
className: cn(accordionClass, className),
|
|
42
|
-
children: /* @__PURE__ */ jsx(AccordionContext, {
|
|
43
|
-
value: state,
|
|
44
|
-
children
|
|
45
|
-
})
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* 항목 하나. 안에 `AccordionTrigger`와 `AccordionPanel`을 둔다.
|
|
50
|
-
* 펼쳐 있으면 `data-open`, 비활성이면 `data-disabled`가 붙는다.
|
|
51
|
-
*/
|
|
52
|
-
function AccordionItem({ value, disabled = false, ref, className, children, ...props }) {
|
|
53
|
-
const group = use(AccordionContext);
|
|
54
|
-
if (!group) throw new Error("AccordionItem는 Accordion 안에 둔다.");
|
|
55
|
-
const panelRef = useRef(null);
|
|
56
|
-
const state = useDisclosureState({
|
|
57
|
-
isExpanded: group.expandedKeys.has(value),
|
|
58
|
-
onExpandedChange: () => group.toggleKey(value)
|
|
59
|
-
});
|
|
60
|
-
const { buttonProps, panelProps } = useDisclosure({ isDisabled: disabled }, state, panelRef);
|
|
61
|
-
const context = useMemo(() => ({
|
|
62
|
-
expanded: state.isExpanded,
|
|
63
|
-
disabled,
|
|
64
|
-
buttonProps,
|
|
65
|
-
panelProps,
|
|
66
|
-
panelRef
|
|
67
|
-
}), [
|
|
68
|
-
state.isExpanded,
|
|
69
|
-
disabled,
|
|
70
|
-
buttonProps,
|
|
71
|
-
panelProps
|
|
72
|
-
]);
|
|
73
|
-
return /* @__PURE__ */ jsx("div", {
|
|
74
|
-
...props,
|
|
75
|
-
ref,
|
|
76
|
-
"data-open": state.isExpanded ? "" : void 0,
|
|
77
|
-
"data-disabled": disabled ? "" : void 0,
|
|
78
|
-
className: cn(itemClass, className),
|
|
79
|
-
children: /* @__PURE__ */ jsx(AccordionItemContext, {
|
|
80
|
-
value: context,
|
|
81
|
-
children
|
|
82
|
-
})
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* 항목 제목 버튼. 제목 요소(`level`, 기본 `<h3>`) 안의 `<button type="button">`이고 끝에 장식용 chevron이 있다.
|
|
87
|
-
* `ref`·`className`·나머지 props는 버튼에 간다. 펼침 상태는 `aria-expanded`와 `data-open`, 비활성은 `:disabled`다.
|
|
88
|
-
* Enter·Space·누름으로 펼치고 접는다.
|
|
89
|
-
*/
|
|
90
|
-
function AccordionTrigger({ level = 3, ref, className, children, ...props }) {
|
|
91
|
-
const item = useAccordionItemContext("AccordionTrigger");
|
|
92
|
-
const buttonRef = useRef(null);
|
|
93
|
-
const { buttonProps } = useButton(item.buttonProps, buttonRef);
|
|
94
|
-
const mergedRef = useMemo(() => mergeRefs(ref, buttonRef), [ref, buttonRef]);
|
|
95
|
-
const Heading = `h${level}`;
|
|
96
|
-
return /* @__PURE__ */ jsx(Heading, {
|
|
97
|
-
className: "flex",
|
|
98
|
-
children: /* @__PURE__ */ jsxs("button", {
|
|
99
|
-
...mergeProps(props, buttonProps),
|
|
100
|
-
ref: mergedRef,
|
|
101
|
-
type: "button",
|
|
102
|
-
"data-open": item.expanded ? "" : void 0,
|
|
103
|
-
className: cn(triggerClass, className),
|
|
104
|
-
children: [children, /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
105
|
-
size: 16,
|
|
106
|
-
className: chevronClass
|
|
107
|
-
})]
|
|
108
|
-
})
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* 항목 내용. 트리거가 `aria-controls`로 가리키고 트리거 글자가 이름이 된다(`aria-labelledby`).
|
|
113
|
-
* 접혀 있으면 숨는다(`hidden`). 늘 렌더하므로 안의 입력 상태는 접어도 남는다.
|
|
114
|
-
*/
|
|
115
|
-
function AccordionPanel({ role = "region", ref, className, ...props }) {
|
|
116
|
-
const item = useAccordionItemContext("AccordionPanel");
|
|
117
|
-
const mergedRef = useMemo(() => mergeRefs(ref, item.panelRef), [ref, item.panelRef]);
|
|
118
|
-
return /* @__PURE__ */ jsx("div", {
|
|
119
|
-
...mergeProps(props, item.panelProps),
|
|
120
|
-
ref: mergedRef,
|
|
121
|
-
role,
|
|
122
|
-
"data-open": item.expanded ? "" : void 0,
|
|
123
|
-
className: cn(panelClass, className)
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export { Accordion, AccordionItem, AccordionPanel, AccordionTrigger };
|
package/dist/Breadcrumb.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ComponentProps, ReactElement } from "react";
|
|
2
|
-
export interface BreadcrumbProps extends ComponentProps<"nav"> {
|
|
3
|
-
/** 탐색 영역 이름. 기본값은 `"이동 경로"`다. 한 화면에 같은 이름의 탐색 영역이 겹치지 않게 한다. */
|
|
4
|
-
"aria-label"?: string;
|
|
5
|
-
}
|
|
6
|
-
export interface BreadcrumbItemProps extends ComponentProps<"li"> {}
|
|
7
|
-
export interface BreadcrumbLinkProps extends Omit<ComponentProps<"a">, "color"> {
|
|
8
|
-
/**
|
|
9
|
-
* 다른 요소로 렌더한다. 예: `render={<NextLink href="/docs" />}`.
|
|
10
|
-
* props, ref, className을 그 요소에 병합한다.
|
|
11
|
-
*/
|
|
12
|
-
render?: ReactElement;
|
|
13
|
-
}
|
|
14
|
-
export interface BreadcrumbCurrentProps extends ComponentProps<"span"> {}
|
|
15
|
-
/**
|
|
16
|
-
* 현재 페이지까지의 경로를 보여 주는 탐색 영역. `<nav>` 안의 `<ol>`이다.
|
|
17
|
-
* 자식은 `BreadcrumbItem`이고, 그 안에 `BreadcrumbLink`(상위 페이지)나 `BreadcrumbCurrent`(현재 페이지)를 둔다.
|
|
18
|
-
* `ref`·`className`은 `<nav>`에 붙는다.
|
|
19
|
-
*/
|
|
20
|
-
export declare function Breadcrumb({ "aria-label": ariaLabel, children, ...props }: BreadcrumbProps): ReactElement;
|
|
21
|
-
/** 경로의 한 항목 `<li>`. 앞에 장식용 구분자(›)를 붙이고, 목록의 첫 항목에서는 숨긴다. */
|
|
22
|
-
export declare function BreadcrumbItem({ className, children, ...props }: BreadcrumbItemProps): ReactElement;
|
|
23
|
-
/** 상위 페이지 링크 `<a>`. 밑줄이 있고 hover에 짙어진다. Next.js에서는 `render={<NextLink href="/x" />}`를 쓴다. */
|
|
24
|
-
export declare function BreadcrumbLink({ render, ...props }: BreadcrumbLinkProps): ReactElement;
|
|
25
|
-
/** 현재 페이지 `<span aria-current="page">`. 링크가 아니다. 경로의 마지막 항목에 둔다. */
|
|
26
|
-
export declare function BreadcrumbCurrent({ className, ...props }: BreadcrumbCurrentProps): ReactElement;
|
package/dist/Breadcrumb.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { cn } from "./cn.js";
|
|
2
|
-
import { renderElement } from "./render.js";
|
|
3
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { ChevronRightIcon } from "@tide-design/icons";
|
|
5
|
-
|
|
6
|
-
// src/Breadcrumb.tsx
|
|
7
|
-
const listClass = "flex flex-wrap items-center gap-1.5 text-body-sm text-muted";
|
|
8
|
-
const itemClass = "inline-flex items-center gap-1.5";
|
|
9
|
-
const separatorClass = "size-4 shrink-0 [li:first-child>&]:hidden";
|
|
10
|
-
const linkClass = "cursor-pointer rounded-sm underline decoration-1 underline-offset-2 hover:text-default hover:decoration-2 focus-visible:focus-ring";
|
|
11
|
-
const currentClass = "text-label-md text-default";
|
|
12
|
-
/**
|
|
13
|
-
* 현재 페이지까지의 경로를 보여 주는 탐색 영역. `<nav>` 안의 `<ol>`이다.
|
|
14
|
-
* 자식은 `BreadcrumbItem`이고, 그 안에 `BreadcrumbLink`(상위 페이지)나 `BreadcrumbCurrent`(현재 페이지)를 둔다.
|
|
15
|
-
* `ref`·`className`은 `<nav>`에 붙는다.
|
|
16
|
-
*/
|
|
17
|
-
function Breadcrumb({ "aria-label": ariaLabel = "이동 경로", children, ...props }) {
|
|
18
|
-
return /* @__PURE__ */ jsx("nav", {
|
|
19
|
-
...props,
|
|
20
|
-
"aria-label": ariaLabel,
|
|
21
|
-
children: /* @__PURE__ */ jsx("ol", {
|
|
22
|
-
className: listClass,
|
|
23
|
-
children
|
|
24
|
-
})
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
/** 경로의 한 항목 `<li>`. 앞에 장식용 구분자(›)를 붙이고, 목록의 첫 항목에서는 숨긴다. */
|
|
28
|
-
function BreadcrumbItem({ className, children, ...props }) {
|
|
29
|
-
return /* @__PURE__ */ jsxs("li", {
|
|
30
|
-
...props,
|
|
31
|
-
className: cn(itemClass, className),
|
|
32
|
-
children: [/* @__PURE__ */ jsx(ChevronRightIcon, { className: separatorClass }), children]
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
/** 상위 페이지 링크 `<a>`. 밑줄이 있고 hover에 짙어진다. Next.js에서는 `render={<NextLink href="/x" />}`를 쓴다. */
|
|
36
|
-
function BreadcrumbLink({ render, ...props }) {
|
|
37
|
-
return renderElement({
|
|
38
|
-
defaultElement: "a",
|
|
39
|
-
render,
|
|
40
|
-
baseClassName: linkClass,
|
|
41
|
-
props
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
/** 현재 페이지 `<span aria-current="page">`. 링크가 아니다. 경로의 마지막 항목에 둔다. */
|
|
45
|
-
function BreadcrumbCurrent({ className, ...props }) {
|
|
46
|
-
return /* @__PURE__ */ jsx("span", {
|
|
47
|
-
"aria-current": "page",
|
|
48
|
-
...props,
|
|
49
|
-
className: cn(currentClass, className)
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export { Breadcrumb, BreadcrumbCurrent, BreadcrumbItem, BreadcrumbLink };
|
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,255 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "./cn.js";
|
|
4
|
-
import { IconButton } from "./IconButton.js";
|
|
5
|
-
import { OverlayPortal, useOverlayPresence, useOverlayTheme } from "./overlay.js";
|
|
6
|
-
import { backdropMotionClass, dialogMotionClass, dialogSurfaceClass } from "./overlay-style.js";
|
|
7
|
-
import { renderElement } from "./render.js";
|
|
8
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
import { createContext, createElement, use, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
10
|
-
import { XIcon } from "@tide-design/icons";
|
|
11
|
-
import { mergeProps, mergeRefs, useDialog, useFocusManager, useModalOverlay, useOverlayTrigger, usePress } from "react-aria";
|
|
12
|
-
import { useOverlayTriggerState } from "react-stately";
|
|
13
|
-
|
|
14
|
-
// src/Dialog.tsx
|
|
15
|
-
const DialogContext = createContext(null);
|
|
16
|
-
function useDialogContext(part) {
|
|
17
|
-
const context = use(DialogContext);
|
|
18
|
-
if (!context) throw new Error(`${part}는 Dialog나 AlertDialog 안에 둔다.`);
|
|
19
|
-
return context;
|
|
20
|
-
}
|
|
21
|
-
const DialogPartsContext = createContext(null);
|
|
22
|
-
function useDialogPartsContext(part) {
|
|
23
|
-
const context = use(DialogPartsContext);
|
|
24
|
-
if (!context) throw new Error(`${part}는 DialogContent 안에 둔다.`);
|
|
25
|
-
return context;
|
|
26
|
-
}
|
|
27
|
-
/** Dialog·AlertDialog가 같이 쓰는 열림 상태. 공개 API가 아니다(AlertDialog.tsx가 쓴다). */
|
|
28
|
-
function DialogRoot({ open, defaultOpen, onOpenChange, alert, children }) {
|
|
29
|
-
const state = useOverlayTriggerState({
|
|
30
|
-
isOpen: open,
|
|
31
|
-
defaultOpen,
|
|
32
|
-
onOpenChange
|
|
33
|
-
});
|
|
34
|
-
const triggerRef = useRef(null);
|
|
35
|
-
const { triggerProps, overlayProps } = useOverlayTrigger({ type: "dialog" }, state, triggerRef);
|
|
36
|
-
const [triggerId, setTriggerId] = useState(null);
|
|
37
|
-
const value = useMemo(() => ({
|
|
38
|
-
state,
|
|
39
|
-
triggerRef,
|
|
40
|
-
triggerProps,
|
|
41
|
-
contentId: overlayProps.id,
|
|
42
|
-
triggerId,
|
|
43
|
-
setTriggerId,
|
|
44
|
-
alert
|
|
45
|
-
}), [
|
|
46
|
-
state,
|
|
47
|
-
triggerProps,
|
|
48
|
-
overlayProps.id,
|
|
49
|
-
triggerId,
|
|
50
|
-
alert
|
|
51
|
-
]);
|
|
52
|
-
return /* @__PURE__ */ jsx(DialogContext, {
|
|
53
|
-
value,
|
|
54
|
-
children
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* 트리거와 내용을 잇는 열림 상태. DOM 요소를 만들지 않는다.
|
|
59
|
-
* 안에 `DialogTrigger`(없어도 된다. `open`으로 제어해 Menu 항목 등에서 열 수 있다)와 `DialogContent`를 둔다.
|
|
60
|
-
*/
|
|
61
|
-
function Dialog(props) {
|
|
62
|
-
return /* @__PURE__ */ jsx(DialogRoot, {
|
|
63
|
-
...props,
|
|
64
|
-
alert: false
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Dialog를 여는 버튼. 누르면(마우스, 터치, Enter, Space) 연다. 열린 동안은 바깥이 inert라 다시 누를 수 없다.
|
|
69
|
-
* `aria-haspopup="dialog"`, `aria-expanded`, 열렸을 때 `aria-controls`와 `data-open`이 붙는다.
|
|
70
|
-
*/
|
|
71
|
-
function DialogTrigger({ render, ref, id, className, ...props }) {
|
|
72
|
-
const { state, triggerRef, triggerProps, setTriggerId } = useDialogContext("DialogTrigger");
|
|
73
|
-
const { onPress, ...ariaProps } = triggerProps;
|
|
74
|
-
const { pressProps } = usePress({
|
|
75
|
-
onPress,
|
|
76
|
-
ref: triggerRef
|
|
77
|
-
});
|
|
78
|
-
const mergedRef = useMemo(() => mergeRefs(ref, triggerRef), [ref, triggerRef]);
|
|
79
|
-
const generatedId = useId();
|
|
80
|
-
const resolvedId = id ?? generatedId;
|
|
81
|
-
useLayoutEffect(() => {
|
|
82
|
-
setTriggerId(resolvedId);
|
|
83
|
-
return () => setTriggerId(null);
|
|
84
|
-
}, [resolvedId, setTriggerId]);
|
|
85
|
-
const merged = {
|
|
86
|
-
...mergeProps(props, ariaProps, pressProps),
|
|
87
|
-
id: resolvedId,
|
|
88
|
-
ref: mergedRef,
|
|
89
|
-
"data-open": state.isOpen ? "" : void 0
|
|
90
|
-
};
|
|
91
|
-
if (!render) return createElement("button", {
|
|
92
|
-
type: "button",
|
|
93
|
-
...merged,
|
|
94
|
-
className
|
|
95
|
-
});
|
|
96
|
-
return renderElement({
|
|
97
|
-
defaultElement: "button",
|
|
98
|
-
render,
|
|
99
|
-
baseClassName: "",
|
|
100
|
-
props: {
|
|
101
|
-
...merged,
|
|
102
|
-
className
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
const backdropClass = `fixed inset-0 isolate z-modal flex items-center justify-center bg-overlay p-4 ${backdropMotionClass}`;
|
|
107
|
-
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}`;
|
|
108
|
-
const sizeClass = {
|
|
109
|
-
sm: "max-w-96",
|
|
110
|
-
md: "max-w-128",
|
|
111
|
-
lg: "max-w-160"
|
|
112
|
-
};
|
|
113
|
-
/**
|
|
114
|
-
* 화면 가운데 뜨는 모달 내용(`role="dialog"`, AlertDialog 안에서는 `role="alertdialog"`).
|
|
115
|
-
* 열릴 때만 `document.body`에 portal하고, 반투명 막(`bg-overlay`)과 함께 `z-modal`로 쌓는다.
|
|
116
|
-
* 등장은 opacity + scale 0.96 → 1(`normal`), 퇴장은 opacity + scale 0.98(`fast`)이다. 움직임 줄이기에서는 opacity만 바뀐다.
|
|
117
|
-
* Dialog에는 끝 위쪽에 닫기 버튼(IconButton)이 있고 바깥 막을 누르면 닫힌다. AlertDialog는 둘 다 없다(Esc는 닫는다).
|
|
118
|
-
*/
|
|
119
|
-
function DialogContent(props) {
|
|
120
|
-
const context = useDialogContext("DialogContent");
|
|
121
|
-
const backdropRef = useRef(null);
|
|
122
|
-
if (!useOverlayPresence(context.state.isOpen, backdropRef)) return null;
|
|
123
|
-
return /* @__PURE__ */ jsx(OverlayPortal, {
|
|
124
|
-
isExiting: !context.state.isOpen,
|
|
125
|
-
children: /* @__PURE__ */ jsx(DialogContentInner, {
|
|
126
|
-
...props,
|
|
127
|
-
context,
|
|
128
|
-
backdropRef
|
|
129
|
-
})
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
/** DOM에 있는 동안만 portal 안에서 렌더한다. React Aria 오버레이 hook은 요소가 있다고 보고 동작한다. */
|
|
133
|
-
function DialogContentInner({ context, backdropRef, size = "md", closeLabel = "닫기", ref, className, children, ...props }) {
|
|
134
|
-
const { state, triggerRef, contentId, triggerId, alert } = context;
|
|
135
|
-
const dialogRef = useRef(null);
|
|
136
|
-
const [titleId, setTitleId] = useState(null);
|
|
137
|
-
const [descriptionId, setDescriptionId] = useState(null);
|
|
138
|
-
useOverlayTheme(triggerRef, backdropRef);
|
|
139
|
-
const { modalProps, underlayProps } = useModalOverlay({ isDismissable: !alert }, state, dialogRef);
|
|
140
|
-
const labelledBy = props["aria-labelledby"] ?? (props["aria-label"] ? void 0 : titleId ?? triggerId ?? void 0);
|
|
141
|
-
const describedBy = props["aria-describedby"] ?? descriptionId ?? void 0;
|
|
142
|
-
const { dialogProps } = useDialog({
|
|
143
|
-
role: alert ? "alertdialog" : "dialog",
|
|
144
|
-
"aria-label": props["aria-label"],
|
|
145
|
-
"aria-labelledby": labelledBy,
|
|
146
|
-
"aria-describedby": describedBy
|
|
147
|
-
}, dialogRef);
|
|
148
|
-
const focusManager = useFocusManager();
|
|
149
|
-
useEffect(() => {
|
|
150
|
-
if (alert && document.activeElement === dialogRef.current) focusManager?.focusFirst({ tabbable: true });
|
|
151
|
-
}, []);
|
|
152
|
-
const mergedRef = useMemo(() => mergeRefs(ref, dialogRef), [ref]);
|
|
153
|
-
const parts = useMemo(() => ({
|
|
154
|
-
alert,
|
|
155
|
-
setTitleId,
|
|
156
|
-
setDescriptionId
|
|
157
|
-
}), [alert]);
|
|
158
|
-
const open = state.isOpen ? "" : void 0;
|
|
159
|
-
return /* @__PURE__ */ jsx("div", {
|
|
160
|
-
...underlayProps,
|
|
161
|
-
ref: backdropRef,
|
|
162
|
-
"data-open": open,
|
|
163
|
-
className: backdropClass,
|
|
164
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
165
|
-
...mergeProps(props, modalProps, dialogProps),
|
|
166
|
-
id: contentId,
|
|
167
|
-
ref: mergedRef,
|
|
168
|
-
"data-open": open,
|
|
169
|
-
className: cn(contentClass, sizeClass[size], className),
|
|
170
|
-
children: [/* @__PURE__ */ jsx(DialogPartsContext, {
|
|
171
|
-
value: parts,
|
|
172
|
-
children
|
|
173
|
-
}), !alert && /* @__PURE__ */ jsx(IconButton, {
|
|
174
|
-
"aria-label": closeLabel,
|
|
175
|
-
variant: "ghost",
|
|
176
|
-
color: "neutral",
|
|
177
|
-
size: "sm",
|
|
178
|
-
onClick: state.close,
|
|
179
|
-
className: "absolute end-5 top-5",
|
|
180
|
-
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
181
|
-
})]
|
|
182
|
-
})
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
/** 부분 요소의 id를 정하고 열린 동안 dialog에 알린다. */
|
|
186
|
-
function usePartId(id, register) {
|
|
187
|
-
const generated = useId();
|
|
188
|
-
const resolved = id ?? generated;
|
|
189
|
-
useLayoutEffect(() => {
|
|
190
|
-
register(resolved);
|
|
191
|
-
return () => register(null);
|
|
192
|
-
}, [resolved, register]);
|
|
193
|
-
return resolved;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Dialog 제목(`<h2>`, `text-heading-sm`). 있으면 dialog의 `aria-labelledby`가 가리켜 이름이 된다.
|
|
197
|
-
* Dialog에서는 끝쪽 닫기 버튼과 겹치지 않게 끝 여백(36px)을 둔다.
|
|
198
|
-
*/
|
|
199
|
-
function DialogTitle({ id, className, ...props }) {
|
|
200
|
-
const { alert, setTitleId } = useDialogPartsContext("DialogTitle");
|
|
201
|
-
const resolvedId = usePartId(id, setTitleId);
|
|
202
|
-
return /* @__PURE__ */ jsx("h2", {
|
|
203
|
-
...props,
|
|
204
|
-
id: resolvedId,
|
|
205
|
-
className: cn("text-heading-sm text-default", !alert && "pe-9", className)
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Dialog 설명(`<p>`, `text-muted`). 있으면 dialog의 `aria-describedby`가 가리킨다. AlertDialog에서는 알릴 내용을 여기에 쓴다.
|
|
210
|
-
* 목록·여러 문단처럼 구조가 있는 내용은 한 줄로 읽히므로 이 요소 밖에 둔다(APG Dialog).
|
|
211
|
-
*/
|
|
212
|
-
function DialogDescription({ id, className, ...props }) {
|
|
213
|
-
const { setDescriptionId } = useDialogPartsContext("DialogDescription");
|
|
214
|
-
const resolvedId = usePartId(id, setDescriptionId);
|
|
215
|
-
return /* @__PURE__ */ jsx("p", {
|
|
216
|
-
...props,
|
|
217
|
-
id: resolvedId,
|
|
218
|
-
className: cn("text-body-md text-muted", className)
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
/** 동작 버튼 줄. 끝쪽에 맞추고 버튼 사이는 8px이다. 앞에 덜 위험한 동작(취소)을, 끝에 주 동작을 둔다. */
|
|
222
|
-
function DialogFooter({ className, ...props }) {
|
|
223
|
-
return /* @__PURE__ */ jsx("div", {
|
|
224
|
-
...props,
|
|
225
|
-
className: cn("mt-2 flex flex-wrap justify-end gap-2", className)
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* 누르면 Dialog를 닫는 버튼. `onClick`을 먼저 부르고, 그 안에서 `event.preventDefault()`를 부르면 닫지 않는다.
|
|
230
|
-
* 닫히면 포커스는 열기 전 요소로 돌아간다.
|
|
231
|
-
*/
|
|
232
|
-
function DialogClose({ render, onClick, className, ...props }) {
|
|
233
|
-
const { state } = useDialogContext("DialogClose");
|
|
234
|
-
const handleClick = (event) => {
|
|
235
|
-
onClick?.(event);
|
|
236
|
-
if (!event.defaultPrevented) state.close();
|
|
237
|
-
};
|
|
238
|
-
const merged = {
|
|
239
|
-
...props,
|
|
240
|
-
onClick: handleClick,
|
|
241
|
-
className
|
|
242
|
-
};
|
|
243
|
-
if (!render) return createElement("button", {
|
|
244
|
-
type: "button",
|
|
245
|
-
...merged
|
|
246
|
-
});
|
|
247
|
-
return renderElement({
|
|
248
|
-
defaultElement: "button",
|
|
249
|
-
render,
|
|
250
|
-
baseClassName: "",
|
|
251
|
-
props: merged
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogRoot, DialogTitle, DialogTrigger };
|