@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/Select.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { InputSize } from "./constants/inputClass.js";
|
|
2
|
-
import { ListBoxOptionProps, ListBoxSectionProps } from "./components/ListBoxNodes.js";
|
|
3
|
-
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
4
|
-
export interface SelectProps extends Omit<ComponentProps<"button">, "value" | "defaultValue" | "onChange" | "type" | "size" | "children" | "name" | "form"> {
|
|
5
|
-
/** 고른 값(제어). 고른 옵션의 `value`다. `null`이면 아무것도 고르지 않은 상태다. 주면 `onValueChange`로 바꾼다. */
|
|
6
|
-
value?: string | null;
|
|
7
|
-
/** 처음 고른 값(비제어). 주지 않으면 아무것도 고르지 않은 상태로 시작한다. 폼을 reset하면 이 값으로 돌아간다. */
|
|
8
|
-
defaultValue?: string;
|
|
9
|
-
/** 사용자가 다른 옵션을 고르면 그 옵션의 `value`로 부른다. */
|
|
10
|
-
onValueChange?: (value: string) => void;
|
|
11
|
-
/** 목록 열림 상태(제어). 주면 `onOpenChange`로 바꾼다. */
|
|
12
|
-
open?: boolean;
|
|
13
|
-
/** 처음 목록 열림 상태(비제어). 기본값은 `false`다. */
|
|
14
|
-
defaultOpen?: boolean;
|
|
15
|
-
/** 목록 열림 상태가 바뀌려 할 때 새 값으로 부른다. 옵션을 골라 닫힐 때도 부른다. */
|
|
16
|
-
onOpenChange?: (open: boolean) => void;
|
|
17
|
-
/** 폼 제출 이름. 숨은 `<select>`에 붙어 고른 값이 이 이름으로 제출된다(트리거 버튼에는 붙지 않는다). */
|
|
18
|
-
name?: string;
|
|
19
|
-
/** 숨은 `<select>`가 속할 `<form>`의 id. 폼 밖에 둘 때 쓴다. */
|
|
20
|
-
form?: string;
|
|
21
|
-
/** 브라우저 자동 완성 힌트. 숨은 `<select>`에 붙는다. */
|
|
22
|
-
autoComplete?: string;
|
|
23
|
-
/** 아무것도 고르지 않았을 때 트리거에 보이는 글자. 기본값은 `"선택하세요"`다. */
|
|
24
|
-
placeholder?: string;
|
|
25
|
-
/** 높이 `sm` 32px, `md` 40px, `lg` 48px. 같은 size의 Input·Button과 높이가 같다. 기본값은 `md`다. */
|
|
26
|
-
size?: InputSize;
|
|
27
|
-
/**
|
|
28
|
-
* 오류 상태. 트리거에 `aria-invalid="true"`와 `data-invalid`가 붙고 경계가 danger 색이 된다.
|
|
29
|
-
* Field 안에서는 Field의 값을 따르고, 여기에 준 값이 이긴다.
|
|
30
|
-
*/
|
|
31
|
-
invalid?: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* 필수. 고르지 않고 폼을 제출하면 제출이 막히고 트리거로 포커스가 오며 오류 상태가 된다(브라우저 오류 말풍선은
|
|
34
|
-
* 없다). 메시지는 Field의 `error`로 앱이 보여 준다. Field 안에서는 Field의 값을 따른다.
|
|
35
|
-
*/
|
|
36
|
-
required?: boolean;
|
|
37
|
-
/** `SelectItem`과 `SelectSection`. 이 요소들을 바로 아래(또는 Fragment·배열 안)에 둔다. */
|
|
38
|
-
children?: ReactNode;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* 값 하나를 고르는 입력. 트리거를 누르거나(마우스는 누르는 순간) Enter·Space·↓·↑로 목록을 열고, 화살표·Home/End·
|
|
42
|
-
* 영문 글자로 옵션을 옮겨 Enter·Space·누름으로 고른다. 닫힌 채로 글자를 치면 바로 그 옵션을 고른다.
|
|
43
|
-
* 고르면 닫히고 포커스는 트리거로 돌아온다. Esc·바깥 누름·Tab으로도 닫힌다.
|
|
44
|
-
* Field 안에 두면 label·설명·오류가 자동으로 연결되고, `name`을 주면 고른 값이 폼에 제출된다.
|
|
45
|
-
* 상태는 `data-open`(트리거·목록), `data-invalid`(트리거), 네이티브 `:disabled`(트리거),
|
|
46
|
-
* `data-highlighted`·`data-selected`·`data-disabled`(옵션)로 노출한다.
|
|
47
|
-
*/
|
|
48
|
-
export declare function Select({ value, defaultValue, onValueChange, open, defaultOpen, onOpenChange, name, form, autoComplete, placeholder, size, invalid, disabled, required, id, ref, className, children, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }: SelectProps): ReactElement;
|
|
49
|
-
export interface SelectItemProps extends ListBoxOptionProps {}
|
|
50
|
-
/**
|
|
51
|
-
* Select의 옵션(`role="option"`). `Select`나 `SelectSection` 바로 안에 둔다. `value`가 고른 값이고 폼에 제출된다.
|
|
52
|
-
* 내용(아이콘과 글자)은 고르면 트리거에도 보인다. 키보드 위치와 마우스를 올린 옵션은 highlight(primary subtle 배경,
|
|
53
|
-
* primary 글자), 고른 옵션은 neutral subtle-active 배경과 끝의 체크 아이콘이다.
|
|
54
|
-
* 상태는 `data-highlighted`, `data-selected`, `data-disabled`로 노출한다.
|
|
55
|
-
*/
|
|
56
|
-
export declare function SelectItem(_props: SelectItemProps): null;
|
|
57
|
-
export interface SelectSectionProps extends ListBoxSectionProps {}
|
|
58
|
-
/**
|
|
59
|
-
* 옵션 묶음(`role="group"`). `heading`이 화면에 보이는 제목이자 묶음의 이름이고, 없으면 `aria-label`이 이름이다.
|
|
60
|
-
* 앞뒤 다른 옵션·묶음과의 사이에 구분선이 그려진다.
|
|
61
|
-
*/
|
|
62
|
-
export declare function SelectSection(_props: SelectSectionProps): null;
|
package/dist/Select.js
DELETED
|
@@ -1,173 +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 { useCloseOnTab } from "./hooks/useCloseOnTab.js";
|
|
11
|
-
import { useOverlayPresence } from "./hooks/useOverlayPresence.js";
|
|
12
|
-
import { useOverlayTheme } from "./hooks/useOverlayTheme.js";
|
|
13
|
-
import { usePopoverOverlay } from "./hooks/usePopoverOverlay.js";
|
|
14
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
import { use, useLayoutEffect, useMemo, useRef } from "react";
|
|
16
|
-
import { ChevronDownIcon } from "@tide-design/icons";
|
|
17
|
-
import { DismissButton, HiddenSelect, mergeProps, mergeRefs, useButton, useListBox, useSelect } from "react-aria";
|
|
18
|
-
import { useSelectState } from "react-stately";
|
|
19
|
-
|
|
20
|
-
// src/Select.tsx
|
|
21
|
-
const triggerClass = "group inline-flex items-center justify-between gap-2 text-start";
|
|
22
|
-
const valueClass = "min-w-0 flex-1 truncate [&>svg]:me-2 [&>svg]:inline-block [&>svg]:size-4 [&>svg]:align-[-0.125em]";
|
|
23
|
-
const placeholderClass = "text-muted group-disabled:text-disabled";
|
|
24
|
-
const chevronClass = "shrink-0 text-muted group-disabled:text-disabled";
|
|
25
|
-
/**
|
|
26
|
-
* 값 하나를 고르는 입력. 트리거를 누르거나(마우스는 누르는 순간) Enter·Space·↓·↑로 목록을 열고, 화살표·Home/End·
|
|
27
|
-
* 영문 글자로 옵션을 옮겨 Enter·Space·누름으로 고른다. 닫힌 채로 글자를 치면 바로 그 옵션을 고른다.
|
|
28
|
-
* 고르면 닫히고 포커스는 트리거로 돌아온다. Esc·바깥 누름·Tab으로도 닫힌다.
|
|
29
|
-
* Field 안에 두면 label·설명·오류가 자동으로 연결되고, `name`을 주면 고른 값이 폼에 제출된다.
|
|
30
|
-
* 상태는 `data-open`(트리거·목록), `data-invalid`(트리거), 네이티브 `:disabled`(트리거),
|
|
31
|
-
* `data-highlighted`·`data-selected`·`data-disabled`(옵션)로 노출한다.
|
|
32
|
-
*/
|
|
33
|
-
function Select({ value, defaultValue, onValueChange, open, defaultOpen, onOpenChange, name, form, autoComplete, placeholder = "선택하세요", size = "md", invalid, disabled, required, id, ref, className, children, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }) {
|
|
34
|
-
const field = use(FieldContext);
|
|
35
|
-
const control = useFieldControl({
|
|
36
|
-
id,
|
|
37
|
-
invalid,
|
|
38
|
-
disabled,
|
|
39
|
-
required,
|
|
40
|
-
"aria-describedby": ariaDescribedBy,
|
|
41
|
-
"aria-invalid": ariaInvalid
|
|
42
|
-
});
|
|
43
|
-
const isDisabled = control.disabled ?? false;
|
|
44
|
-
const isRequired = control.required ?? false;
|
|
45
|
-
const items = useMemo(() => resolveCollectionChildren(children), [children]);
|
|
46
|
-
const state = useSelectState({
|
|
47
|
-
children: items,
|
|
48
|
-
value,
|
|
49
|
-
defaultValue,
|
|
50
|
-
onChange: (key) => {
|
|
51
|
-
if (key != null) onValueChange?.(String(key));
|
|
52
|
-
},
|
|
53
|
-
isOpen: open,
|
|
54
|
-
defaultOpen,
|
|
55
|
-
onOpenChange,
|
|
56
|
-
isDisabled,
|
|
57
|
-
isRequired,
|
|
58
|
-
validationBehavior: "native"
|
|
59
|
-
});
|
|
60
|
-
const triggerRef = useRef(null);
|
|
61
|
-
const { triggerProps, valueProps, menuProps, hiddenSelectProps, isInvalid } = useSelect({
|
|
62
|
-
id: control.id,
|
|
63
|
-
"aria-label": ariaLabel,
|
|
64
|
-
"aria-labelledby": ariaLabelledBy ?? field?.labelId,
|
|
65
|
-
isDisabled,
|
|
66
|
-
isRequired,
|
|
67
|
-
validationBehavior: "native",
|
|
68
|
-
name,
|
|
69
|
-
form,
|
|
70
|
-
autoComplete
|
|
71
|
-
}, state, triggerRef);
|
|
72
|
-
const { buttonProps } = useButton(triggerProps, triggerRef);
|
|
73
|
-
const mergedRef = useMemo(() => mergeRefs(ref, triggerRef), [ref, triggerRef]);
|
|
74
|
-
const showInvalid = control["data-invalid"] === "" || isInvalid;
|
|
75
|
-
const selected = state.selectedItem;
|
|
76
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
77
|
-
/* @__PURE__ */ jsxs("button", {
|
|
78
|
-
...mergeProps(props, buttonProps),
|
|
79
|
-
ref: mergedRef,
|
|
80
|
-
"aria-describedby": control["aria-describedby"],
|
|
81
|
-
"aria-invalid": showInvalid ? true : control["aria-invalid"],
|
|
82
|
-
"data-invalid": showInvalid ? "" : void 0,
|
|
83
|
-
"data-open": state.isOpen ? "" : void 0,
|
|
84
|
-
className: cn(inputSizeClass[size], inputBaseClass, triggerClass, className),
|
|
85
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
86
|
-
...valueProps,
|
|
87
|
-
className: cn(valueClass, !selected && placeholderClass),
|
|
88
|
-
children: selected ? selected.rendered : placeholder
|
|
89
|
-
}), /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
90
|
-
size: 16,
|
|
91
|
-
className: chevronClass
|
|
92
|
-
})]
|
|
93
|
-
}),
|
|
94
|
-
/* @__PURE__ */ jsx(HiddenSelect, {
|
|
95
|
-
...hiddenSelectProps,
|
|
96
|
-
autoComplete
|
|
97
|
-
}),
|
|
98
|
-
/* @__PURE__ */ jsx(SelectPopover, {
|
|
99
|
-
state,
|
|
100
|
-
triggerRef,
|
|
101
|
-
menuProps
|
|
102
|
-
})
|
|
103
|
-
] });
|
|
104
|
-
}
|
|
105
|
-
/** 목록을 DOM에 둘지 정하고 portal한다. 닫혀도 퇴장 전환이 끝날 때까지 남긴다(ADR 0018). */
|
|
106
|
-
function SelectPopover(props) {
|
|
107
|
-
const popoverRef = useRef(null);
|
|
108
|
-
if (!useOverlayPresence(props.state.isOpen, popoverRef)) return null;
|
|
109
|
-
return /* @__PURE__ */ jsx(OverlayPortal, {
|
|
110
|
-
isExiting: !props.state.isOpen,
|
|
111
|
-
children: /* @__PURE__ */ jsx(SelectPopoverInner, {
|
|
112
|
-
...props,
|
|
113
|
-
popoverRef
|
|
114
|
-
})
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* 목록 표면(`listPopupClass`)과 그 안의 `role="listbox"`. 트리거 아래 시작 끝에 4px 떨어져 붙고(Menu와 같다),
|
|
119
|
-
* 폭은 트리거보다 좁지 않다.
|
|
120
|
-
*/
|
|
121
|
-
function SelectPopoverInner({ state, triggerRef, menuProps, popoverRef }) {
|
|
122
|
-
const listRef = useRef(null);
|
|
123
|
-
useOverlayTheme(triggerRef, popoverRef);
|
|
124
|
-
useLayoutEffect(() => {
|
|
125
|
-
const popover = popoverRef.current;
|
|
126
|
-
const width = triggerRef.current?.offsetWidth;
|
|
127
|
-
if (popover && width) popover.style.minWidth = `${width}px`;
|
|
128
|
-
}, [triggerRef, popoverRef]);
|
|
129
|
-
const { overlayProps } = usePopoverOverlay({
|
|
130
|
-
triggerRef,
|
|
131
|
-
popoverRef,
|
|
132
|
-
placement: "bottom start",
|
|
133
|
-
offset: 4
|
|
134
|
-
}, state);
|
|
135
|
-
const { listBoxProps } = useListBox(menuProps, state, listRef);
|
|
136
|
-
useCloseOnTab(popoverRef, state.close);
|
|
137
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
138
|
-
...overlayProps,
|
|
139
|
-
ref: popoverRef,
|
|
140
|
-
"data-open": state.isOpen ? "" : void 0,
|
|
141
|
-
className: listPopupClass,
|
|
142
|
-
children: [
|
|
143
|
-
/* @__PURE__ */ jsx(DismissButton, { onDismiss: state.close }),
|
|
144
|
-
/* @__PURE__ */ jsx("div", {
|
|
145
|
-
...listBoxProps,
|
|
146
|
-
ref: listRef,
|
|
147
|
-
className: "outline-none",
|
|
148
|
-
children: /* @__PURE__ */ jsx(ListBoxNodes, { state })
|
|
149
|
-
}),
|
|
150
|
-
/* @__PURE__ */ jsx(DismissButton, { onDismiss: state.close })
|
|
151
|
-
]
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Select의 옵션(`role="option"`). `Select`나 `SelectSection` 바로 안에 둔다. `value`가 고른 값이고 폼에 제출된다.
|
|
156
|
-
* 내용(아이콘과 글자)은 고르면 트리거에도 보인다. 키보드 위치와 마우스를 올린 옵션은 highlight(primary subtle 배경,
|
|
157
|
-
* primary 글자), 고른 옵션은 neutral subtle-active 배경과 끝의 체크 아이콘이다.
|
|
158
|
-
* 상태는 `data-highlighted`, `data-selected`, `data-disabled`로 노출한다.
|
|
159
|
-
*/
|
|
160
|
-
function SelectItem(_props) {
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
asCollectionComponent(SelectItem, valueItemCollectionNode);
|
|
164
|
-
/**
|
|
165
|
-
* 옵션 묶음(`role="group"`). `heading`이 화면에 보이는 제목이자 묶음의 이름이고, 없으면 `aria-label`이 이름이다.
|
|
166
|
-
* 앞뒤 다른 옵션·묶음과의 사이에 구분선이 그려진다.
|
|
167
|
-
*/
|
|
168
|
-
function SelectSection(_props) {
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
asCollectionComponent(SelectSection, sectionCollectionNode);
|
|
172
|
-
|
|
173
|
-
export { Select, SelectItem, SelectSection };
|
package/dist/Spinner.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Size } from "./types.js";
|
|
2
|
-
import { ComponentProps, ReactElement } from "react";
|
|
3
|
-
/** Spinner의 size. 공통 size 4개를 모두 받는다. */
|
|
4
|
-
type SpinnerSize = Extract<Size, "xs" | "sm" | "md" | "lg">;
|
|
5
|
-
export interface SpinnerProps extends Omit<ComponentProps<"svg">, "children"> {
|
|
6
|
-
/**
|
|
7
|
-
* 같은 size의 Component(Button 등) 안 텍스트 옆 아이콘과 같은 크기다.
|
|
8
|
-
* `xs`·`sm` 14px, `md` 16px, `lg` 20px. 기본값은 `md`다.
|
|
9
|
-
*/
|
|
10
|
-
size?: SpinnerSize;
|
|
11
|
-
/** 접근 가능한 이름. 기본값은 `"로딩 중"`이다. 무엇을 불러오는지 적으면 더 좋다. */
|
|
12
|
-
"aria-label"?: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* 로딩 중임을 알리는 회전 표시. 역할은 `status`이고 접근 가능한 이름이 기본으로 붙는다.
|
|
16
|
-
* 회전은 keyframe(`animate-spin`)이고 움직임 줄이기에서도 멈추지 않는다(로딩 여부 자체가 정보다).
|
|
17
|
-
* 색은 `currentColor`라 주변 글자색을 따른다. 서버 컴포넌트로 쓸 수 있다.
|
|
18
|
-
*/
|
|
19
|
-
export declare function Spinner({ size, className, "aria-label": ariaLabel, ...props }: SpinnerProps): ReactElement;
|
|
20
|
-
export {};
|
package/dist/Table.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ComponentProps, ReactElement } from "react";
|
|
2
|
-
export interface TableProps extends ComponentProps<"table"> {}
|
|
3
|
-
export interface TableHeadProps extends ComponentProps<"thead"> {}
|
|
4
|
-
export interface TableBodyProps extends ComponentProps<"tbody"> {}
|
|
5
|
-
export interface TableRowProps extends ComponentProps<"tr"> {}
|
|
6
|
-
export interface TableHeaderCellProps extends ComponentProps<"th"> {
|
|
7
|
-
/**
|
|
8
|
-
* 이 머리 칸이 맡는 범위. 기본값은 `"col"`(아래 열)이다. 본문 행의 첫 칸처럼 행을 맡으면 `"row"`를 준다.
|
|
9
|
-
* 열 그룹·행 그룹 머리는 `"colgroup"`·`"rowgroup"`이다.
|
|
10
|
-
*/
|
|
11
|
-
scope?: "col" | "row" | "colgroup" | "rowgroup";
|
|
12
|
-
}
|
|
13
|
-
export interface TableCellProps extends ComponentProps<"td"> {}
|
|
14
|
-
/**
|
|
15
|
-
* 시맨틱 `<table>`. 행·열로 된 데이터를 보여 준다. 정렬·행 선택·가상화는 없다. 서버 컴포넌트로 쓸 수 있다.
|
|
16
|
-
* 표의 이름은 `<caption>`이나 `aria-label`·`aria-labelledby`로 준다.
|
|
17
|
-
*/
|
|
18
|
-
export declare function Table({ className, ...props }: TableProps): ReactElement;
|
|
19
|
-
/** 머리 행 묶음 `<thead>`. 안의 행은 hover로 바뀌지 않는다. */
|
|
20
|
-
export declare function TableHead(props: TableHeadProps): ReactElement;
|
|
21
|
-
/** 본문 행 묶음 `<tbody>`. 바로 아래 `TableRow`에 마우스를 올리면 배경이 바로 바뀐다. */
|
|
22
|
-
export declare function TableBody(props: TableBodyProps): ReactElement;
|
|
23
|
-
/** 행 `<tr>`. 아래 경계가 있고, `TableBody` 안에서는 hover 배경이 transition 없이 바로 바뀐다. */
|
|
24
|
-
export declare function TableRow({ className, ...props }: TableRowProps): ReactElement;
|
|
25
|
-
/**
|
|
26
|
-
* 머리 칸 `<th>`. 기본은 `scope="col"`(열 머리, columnheader)이다. 본문 행의 행 머리는 `scope="row"`(rowheader)를 준다.
|
|
27
|
-
* 복잡한 표(여러 줄 머리)는 `id`와 칸의 `headers`로 직접 잇는다.
|
|
28
|
-
*/
|
|
29
|
-
export declare function TableHeaderCell({ scope, className, ...props }: TableHeaderCellProps): ReactElement;
|
|
30
|
-
/** 데이터 칸 `<td>`. 숫자 열은 `className="tabular-nums text-end"`로 자릿수를 맞춘다. */
|
|
31
|
-
export declare function TableCell({ className, ...props }: TableCellProps): ReactElement;
|
package/dist/Table.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { cn } from "./libs/cn.js";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
// src/Table.tsx
|
|
5
|
-
const tableClass = "w-full border-collapse text-body-sm text-default";
|
|
6
|
-
const rowClass = "border-b border-default [:where(tbody>&)]:hover:bg-hover";
|
|
7
|
-
const headerCellClass = "px-3 py-2.5 text-start align-middle text-label-md";
|
|
8
|
-
const cellClass = "px-3 py-2.5 text-start align-middle";
|
|
9
|
-
/**
|
|
10
|
-
* 시맨틱 `<table>`. 행·열로 된 데이터를 보여 준다. 정렬·행 선택·가상화는 없다. 서버 컴포넌트로 쓸 수 있다.
|
|
11
|
-
* 표의 이름은 `<caption>`이나 `aria-label`·`aria-labelledby`로 준다.
|
|
12
|
-
*/
|
|
13
|
-
function Table({ className, ...props }) {
|
|
14
|
-
return /* @__PURE__ */ jsx("table", {
|
|
15
|
-
...props,
|
|
16
|
-
className: cn(tableClass, className)
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
/** 머리 행 묶음 `<thead>`. 안의 행은 hover로 바뀌지 않는다. */
|
|
20
|
-
function TableHead(props) {
|
|
21
|
-
return /* @__PURE__ */ jsx("thead", { ...props });
|
|
22
|
-
}
|
|
23
|
-
/** 본문 행 묶음 `<tbody>`. 바로 아래 `TableRow`에 마우스를 올리면 배경이 바로 바뀐다. */
|
|
24
|
-
function TableBody(props) {
|
|
25
|
-
return /* @__PURE__ */ jsx("tbody", { ...props });
|
|
26
|
-
}
|
|
27
|
-
/** 행 `<tr>`. 아래 경계가 있고, `TableBody` 안에서는 hover 배경이 transition 없이 바로 바뀐다. */
|
|
28
|
-
function TableRow({ className, ...props }) {
|
|
29
|
-
return /* @__PURE__ */ jsx("tr", {
|
|
30
|
-
...props,
|
|
31
|
-
className: cn(rowClass, className)
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* 머리 칸 `<th>`. 기본은 `scope="col"`(열 머리, columnheader)이다. 본문 행의 행 머리는 `scope="row"`(rowheader)를 준다.
|
|
36
|
-
* 복잡한 표(여러 줄 머리)는 `id`와 칸의 `headers`로 직접 잇는다.
|
|
37
|
-
*/
|
|
38
|
-
function TableHeaderCell({ scope = "col", className, ...props }) {
|
|
39
|
-
return /* @__PURE__ */ jsx("th", {
|
|
40
|
-
...props,
|
|
41
|
-
scope,
|
|
42
|
-
className: cn(headerCellClass, className)
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
/** 데이터 칸 `<td>`. 숫자 열은 `className="tabular-nums text-end"`로 자릿수를 맞춘다. */
|
|
46
|
-
function TableCell({ className, ...props }) {
|
|
47
|
-
return /* @__PURE__ */ jsx("td", {
|
|
48
|
-
...props,
|
|
49
|
-
className: cn(cellClass, className)
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export { Table, TableBody, TableCell, TableHead, TableHeaderCell, TableRow };
|
package/dist/Tabs.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { CollectionValueItemProps } from "./libs/listCollection.js";
|
|
2
|
-
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
3
|
-
/** 탭 목록의 방향. 세로면 ↓↑로 옮기고 탭 목록이 패널의 시작쪽에 선다. */
|
|
4
|
-
export type TabsOrientation = "horizontal" | "vertical";
|
|
5
|
-
/** 키보드로 탭을 옮겼을 때 바로 고를지(`automatic`), Enter·Space로 고를지(`manual`). */
|
|
6
|
-
export type TabsActivationMode = "automatic" | "manual";
|
|
7
|
-
type TabsValueProps = {
|
|
8
|
-
/** 고른 탭의 값(제어). 주면 `onValueChange`로 바꾼다. */
|
|
9
|
-
value: string;
|
|
10
|
-
defaultValue?: undefined;
|
|
11
|
-
} | {
|
|
12
|
-
value?: undefined;
|
|
13
|
-
/** 처음 고른 탭의 값(비제어). 서버 렌더에서도 그 패널이 바로 보이도록 `value`나 `defaultValue` 하나는 꼭 준다. */
|
|
14
|
-
defaultValue: string;
|
|
15
|
-
};
|
|
16
|
-
interface TabsBaseProps extends Omit<ComponentProps<"div">, "defaultValue" | "onChange"> {
|
|
17
|
-
/**
|
|
18
|
-
* 고른 탭이 바뀌려 할 때 새 값으로 부른다. 이미 고른 탭을 다시 눌러도 부르지 않는다.
|
|
19
|
-
* 준 값과 같은 탭이 없으면 첫 활성 탭을 고르며 부른다.
|
|
20
|
-
*/
|
|
21
|
-
onValueChange?: (value: string) => void;
|
|
22
|
-
/** 탭 목록의 방향. 기본값은 `horizontal`이다. 세로면 ↓↑로 옮기고 탭 목록이 패널의 시작쪽에 선다. */
|
|
23
|
-
orientation?: TabsOrientation;
|
|
24
|
-
/**
|
|
25
|
-
* 키보드로 탭을 옮겼을 때 바로 고를지(`automatic`, 기본값), Enter·Space로 고를지(`manual`)다.
|
|
26
|
-
* 패널을 그리는 데 시간이 걸리면(데이터를 불러오는 패널) `manual`을 쓴다(WAI-ARIA APG).
|
|
27
|
-
*/
|
|
28
|
-
activationMode?: TabsActivationMode;
|
|
29
|
-
/** `TabList` 하나와 `TabPanel`들 */
|
|
30
|
-
children?: ReactNode;
|
|
31
|
-
}
|
|
32
|
-
export type TabsProps = TabsBaseProps & TabsValueProps;
|
|
33
|
-
/**
|
|
34
|
-
* 같은 영역의 여러 패널 중 하나를 고르는 탭 묶음. 루트는 `<div>`이고 방향이 `data-orientation`으로 붙는다.
|
|
35
|
-
* 안에 `TabList` 하나와 탭마다 `TabPanel`을 둔다.
|
|
36
|
-
*/
|
|
37
|
-
export declare function Tabs({ value: valueProp, defaultValue, onValueChange, orientation, activationMode, ref, className, children, ...props }: TabsProps): ReactElement;
|
|
38
|
-
export interface TabListProps extends Omit<ComponentProps<"div">, "role" | "children"> {
|
|
39
|
-
/** `Tab`. 바로 아래(또는 Fragment·배열 안)에 둔다. */
|
|
40
|
-
children?: ReactNode;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 탭 목록(`role="tablist"`). 화살표로 탭을 옮기고(끝에서 처음으로 돈다) Home·End로 처음·마지막 탭에 간다.
|
|
44
|
-
* 비활성 탭은 건너뛴다. 이름은 `aria-label`이나 `aria-labelledby`로 준다.
|
|
45
|
-
*/
|
|
46
|
-
export declare function TabList({ ref, className, children, ...props }: TabListProps): ReactElement;
|
|
47
|
-
export interface TabProps extends Omit<ComponentProps<"button">, "value" | "type" | "role" | "id" | "disabled" | "children">, Omit<CollectionValueItemProps, "textValue"> {
|
|
48
|
-
/** 탭 글자. 아이콘(장식용)과 글자를 함께 둘 수 있다. */
|
|
49
|
-
children?: ReactNode;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* 탭 하나(`role="tab"`). `TabList` 바로 안에 두고, 같은 `value`의 `TabPanel`과 이어진다.
|
|
53
|
-
* 고른 탭은 `data-selected`와 `aria-selected="true"`이고 primary 글자와 아래(세로면 끝쪽) 막대로 보인다.
|
|
54
|
-
* `disabled`면 네이티브 `disabled`라 고를 수 없고 키보드 이동도 건너뛴다.
|
|
55
|
-
*/
|
|
56
|
-
export declare function Tab(_props: TabProps): null;
|
|
57
|
-
export interface TabPanelProps extends Omit<ComponentProps<"div">, "id" | "role"> {
|
|
58
|
-
/** 이어지는 `Tab`의 값. 그 탭을 고른 동안만 렌더한다. */
|
|
59
|
-
value: string;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* 탭 하나의 내용(`role="tabpanel"`). 같은 `value`의 탭을 고른 동안만 렌더하고, 그 탭이 이름이 된다(`aria-labelledby`).
|
|
63
|
-
* 탭 다음 Tab 순서에 들어간다(`tabIndex` 기본 `0`). 첫 내용이 조작 요소면 `tabIndex={-1}`로 뺄 수 있다.
|
|
64
|
-
*/
|
|
65
|
-
export declare function TabPanel({ value, ref, className, tabIndex, ...props }: TabPanelProps): ReactElement | null;
|
|
66
|
-
export {};
|
package/dist/Tabs.js
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "./libs/cn.js";
|
|
4
|
-
import { asCollectionComponent, resolveCollectionChildren, valueItemCollectionNode } from "./libs/listCollection.js";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import { createContext, isValidElement, use, useCallback, useId, useMemo, useRef, useState } from "react";
|
|
7
|
-
import { mergeProps, mergeRefs, useTab, useTabList } from "react-aria";
|
|
8
|
-
import { useTabListState } from "react-stately";
|
|
9
|
-
|
|
10
|
-
// src/Tabs.tsx
|
|
11
|
-
const TabsContext = createContext(null);
|
|
12
|
-
function useTabsContext(part) {
|
|
13
|
-
const context = use(TabsContext);
|
|
14
|
-
if (!context) throw new Error(`${part}는 Tabs 안에 둔다.`);
|
|
15
|
-
return context;
|
|
16
|
-
}
|
|
17
|
-
const tabsOrientationClass = {
|
|
18
|
-
horizontal: "flex flex-col gap-4",
|
|
19
|
-
vertical: "flex flex-row gap-6"
|
|
20
|
-
};
|
|
21
|
-
const tabListOrientationClass = {
|
|
22
|
-
horizontal: "flex shrink-0 gap-1 border-b border-default",
|
|
23
|
-
vertical: "flex shrink-0 flex-col gap-1 border-e border-default"
|
|
24
|
-
};
|
|
25
|
-
const tabBaseClass = [
|
|
26
|
-
"relative flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-label-md whitespace-nowrap text-muted outline-none select-none [&>svg]:size-4 [&>svg]:shrink-0",
|
|
27
|
-
"hover:not-data-selected:enabled:text-default data-selected:text-primary focus-visible:focus-ring",
|
|
28
|
-
"disabled:cursor-not-allowed disabled:text-disabled",
|
|
29
|
-
"after:pointer-events-none after:absolute after:border-primary after:opacity-0 after:transition-opacity data-selected:after:opacity-100",
|
|
30
|
-
"forced-colors:after:forced-color-adjust-none forced-colors:after:border-[Highlight]"
|
|
31
|
-
].join(" ");
|
|
32
|
-
const tabOrientationClass = {
|
|
33
|
-
horizontal: "after:inset-x-0 after:-bottom-px after:border-b-2 motion-safe:after:scale-x-0 motion-safe:after:transition-[opacity,scale] motion-safe:data-selected:after:scale-x-100",
|
|
34
|
-
vertical: "after:inset-y-0 after:-end-px after:border-e-2 motion-safe:after:scale-y-0 motion-safe:after:transition-[opacity,scale] motion-safe:data-selected:after:scale-y-100"
|
|
35
|
-
};
|
|
36
|
-
const tabPanelClass = "min-w-0 flex-1 rounded-md outline-none focus-visible:focus-ring";
|
|
37
|
-
/** id에 쓸 수 없는 공백을 뺀다(React Aria 탭 id와 같은 규칙). */
|
|
38
|
-
const idPart = (value) => value.replace(/\s+/g, "");
|
|
39
|
-
/**
|
|
40
|
-
* 같은 영역의 여러 패널 중 하나를 고르는 탭 묶음. 루트는 `<div>`이고 방향이 `data-orientation`으로 붙는다.
|
|
41
|
-
* 안에 `TabList` 하나와 탭마다 `TabPanel`을 둔다.
|
|
42
|
-
*/
|
|
43
|
-
function Tabs({ value: valueProp, defaultValue, onValueChange, orientation = "horizontal", activationMode = "automatic", ref, className, children, ...props }) {
|
|
44
|
-
const [internal, setInternal] = useState(defaultValue ?? "");
|
|
45
|
-
const controlled = valueProp !== void 0;
|
|
46
|
-
const value = controlled ? valueProp : internal;
|
|
47
|
-
const setValue = useCallback((next) => {
|
|
48
|
-
if (next === value) return;
|
|
49
|
-
if (!controlled) setInternal(next);
|
|
50
|
-
onValueChange?.(next);
|
|
51
|
-
}, [
|
|
52
|
-
controlled,
|
|
53
|
-
onValueChange,
|
|
54
|
-
value
|
|
55
|
-
]);
|
|
56
|
-
const baseId = useId();
|
|
57
|
-
const context = useMemo(() => ({
|
|
58
|
-
value,
|
|
59
|
-
setValue,
|
|
60
|
-
orientation,
|
|
61
|
-
activationMode,
|
|
62
|
-
tabId: (tab) => `${baseId}-tab-${idPart(tab)}`,
|
|
63
|
-
panelId: (tab) => `${baseId}-tabpanel-${idPart(tab)}`
|
|
64
|
-
}), [
|
|
65
|
-
value,
|
|
66
|
-
setValue,
|
|
67
|
-
orientation,
|
|
68
|
-
activationMode,
|
|
69
|
-
baseId
|
|
70
|
-
]);
|
|
71
|
-
return /* @__PURE__ */ jsx("div", {
|
|
72
|
-
...props,
|
|
73
|
-
ref,
|
|
74
|
-
"data-orientation": orientation,
|
|
75
|
-
className: cn(tabsOrientationClass[orientation], className),
|
|
76
|
-
children: /* @__PURE__ */ jsx(TabsContext, {
|
|
77
|
-
value: context,
|
|
78
|
-
children
|
|
79
|
-
})
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* 탭 목록(`role="tablist"`). 화살표로 탭을 옮기고(끝에서 처음으로 돈다) Home·End로 처음·마지막 탭에 간다.
|
|
84
|
-
* 비활성 탭은 건너뛴다. 이름은 `aria-label`이나 `aria-labelledby`로 준다.
|
|
85
|
-
*/
|
|
86
|
-
function TabList({ ref, className, children, ...props }) {
|
|
87
|
-
const context = useTabsContext("TabList");
|
|
88
|
-
const listRef = useRef(null);
|
|
89
|
-
const items = useMemo(() => resolveCollectionChildren(children), [children]);
|
|
90
|
-
const known = items.some((item) => isValidElement(item) && item.props.value === context.value);
|
|
91
|
-
const state = useTabListState({
|
|
92
|
-
children: items,
|
|
93
|
-
selectedKey: known ? context.value : null,
|
|
94
|
-
onSelectionChange: (key) => context.setValue(String(key))
|
|
95
|
-
});
|
|
96
|
-
const { tabListProps } = useTabList({
|
|
97
|
-
orientation: context.orientation,
|
|
98
|
-
keyboardActivation: context.activationMode,
|
|
99
|
-
"aria-label": props["aria-label"],
|
|
100
|
-
"aria-labelledby": props["aria-labelledby"]
|
|
101
|
-
}, state, listRef);
|
|
102
|
-
const mergedRef = useMemo(() => mergeRefs(ref, listRef), [ref, listRef]);
|
|
103
|
-
return /* @__PURE__ */ jsx("div", {
|
|
104
|
-
...mergeProps(props, tabListProps),
|
|
105
|
-
ref: mergedRef,
|
|
106
|
-
className: cn(tabListOrientationClass[context.orientation], className),
|
|
107
|
-
children: [...state.collection].map((node) => /* @__PURE__ */ jsx(TabView, {
|
|
108
|
-
node,
|
|
109
|
-
state,
|
|
110
|
-
context
|
|
111
|
-
}, node.key))
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* 탭 하나(`role="tab"`). `TabList` 바로 안에 두고, 같은 `value`의 `TabPanel`과 이어진다.
|
|
116
|
-
* 고른 탭은 `data-selected`와 `aria-selected="true"`이고 primary 글자와 아래(세로면 끝쪽) 막대로 보인다.
|
|
117
|
-
* `disabled`면 네이티브 `disabled`라 고를 수 없고 키보드 이동도 건너뛴다.
|
|
118
|
-
*/
|
|
119
|
-
function Tab(_props) {
|
|
120
|
-
return null;
|
|
121
|
-
}
|
|
122
|
-
asCollectionComponent(Tab, valueItemCollectionNode);
|
|
123
|
-
/** 탭 하나를 그린다. node.props는 앱이 Tab에 준 props(와 컬렉션이 더한 isDisabled)다. */
|
|
124
|
-
function TabView({ node, state, context }) {
|
|
125
|
-
const tabRef = useRef(null);
|
|
126
|
-
const { ref, className, value, disabled: _disabled, isDisabled: _isDisabled, children: _children, onFocus: _onFocus, onBlur: _onBlur, onKeyDown: _onKeyDown, onKeyUp: _onKeyUp, autoFocus: _autoFocus, ...props } = node.props;
|
|
127
|
-
const { tabProps, isSelected, isDisabled } = useTab({ key: node.key }, state, tabRef);
|
|
128
|
-
const mergedRef = useMemo(() => mergeRefs(ref, tabRef), [ref, tabRef]);
|
|
129
|
-
return /* @__PURE__ */ jsx("button", {
|
|
130
|
-
...mergeProps(props, tabProps),
|
|
131
|
-
ref: mergedRef,
|
|
132
|
-
type: "button",
|
|
133
|
-
id: context.tabId(value),
|
|
134
|
-
"aria-controls": isSelected ? context.panelId(value) : void 0,
|
|
135
|
-
disabled: isDisabled || void 0,
|
|
136
|
-
"data-selected": isSelected ? "" : void 0,
|
|
137
|
-
className: cn(tabBaseClass, tabOrientationClass[context.orientation], className),
|
|
138
|
-
children: node.rendered
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* 탭 하나의 내용(`role="tabpanel"`). 같은 `value`의 탭을 고른 동안만 렌더하고, 그 탭이 이름이 된다(`aria-labelledby`).
|
|
143
|
-
* 탭 다음 Tab 순서에 들어간다(`tabIndex` 기본 `0`). 첫 내용이 조작 요소면 `tabIndex={-1}`로 뺄 수 있다.
|
|
144
|
-
*/
|
|
145
|
-
function TabPanel({ value, ref, className, tabIndex = 0, ...props }) {
|
|
146
|
-
const context = useTabsContext("TabPanel");
|
|
147
|
-
if (context.value !== value) return null;
|
|
148
|
-
return /* @__PURE__ */ jsx("div", {
|
|
149
|
-
...props,
|
|
150
|
-
ref,
|
|
151
|
-
role: "tabpanel",
|
|
152
|
-
id: context.panelId(value),
|
|
153
|
-
"aria-labelledby": context.tabId(value),
|
|
154
|
-
tabIndex,
|
|
155
|
-
className: cn(tabPanelClass, className)
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export { Tab, TabList, TabPanel, Tabs };
|
package/dist/Tag.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { CollectionValueItemProps } from "./libs/listCollection.js";
|
|
2
|
-
import { ColorFamilyName } from "./types.js";
|
|
3
|
-
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
4
|
-
type TagGroupNameProps = {
|
|
5
|
-
/** 묶음 이름(예: `"고른 필터"`). 화면에 보이는 제목이 있으면 `aria-labelledby`를 쓴다. */
|
|
6
|
-
"aria-label": string;
|
|
7
|
-
"aria-labelledby"?: string;
|
|
8
|
-
} | {
|
|
9
|
-
"aria-label"?: string;
|
|
10
|
-
/** 묶음 이름이 되는 요소의 id. 이름(`aria-label`이나 `aria-labelledby`) 하나는 꼭 준다. */
|
|
11
|
-
"aria-labelledby": string;
|
|
12
|
-
};
|
|
13
|
-
interface TagGroupBaseProps extends Omit<ComponentProps<"div">, "role" | "children" | "aria-label" | "aria-labelledby"> {
|
|
14
|
-
/**
|
|
15
|
-
* 태그를 지우려 할 때 지울 태그의 `value`로 부른다. 지우기 버튼을 누르거나 태그에서 Delete·Backspace를 누르면 불린다.
|
|
16
|
-
* 주면 태그마다 지우기 버튼이 생긴다. 태그를 목록에서 빼는 일은 앱이 한다.
|
|
17
|
-
*/
|
|
18
|
-
onRemove?: (value: string) => void;
|
|
19
|
-
/**
|
|
20
|
-
* 지우기 버튼 이름의 앞부분. 기본값은 `"제거"`다. 버튼 이름은 이 글자와 태그 글자를 이어 읽는다(예: 「제거 디자인」).
|
|
21
|
-
*/
|
|
22
|
-
removeLabel?: string;
|
|
23
|
-
/** `Tag`. 바로 아래(또는 Fragment·배열 안)에 둔다. */
|
|
24
|
-
children?: ReactNode;
|
|
25
|
-
}
|
|
26
|
-
export type TagGroupProps = TagGroupBaseProps & TagGroupNameProps;
|
|
27
|
-
/**
|
|
28
|
-
* 고르거나 입력한 값을 보여 주는 태그 묶음(`role="grid"`). ←→로 태그를 옮기고(끝에서 처음으로 돈다) Home·End로
|
|
29
|
-
* 처음·마지막 태그에 간다. `onRemove`를 주면 Delete·Backspace와 지우기 버튼으로 태그를 지운다.
|
|
30
|
-
* 지운 뒤 포커스는 옆 태그로 옮겨 간다. 이름은 `aria-label`이나 `aria-labelledby`로 꼭 준다.
|
|
31
|
-
*/
|
|
32
|
-
export declare function TagGroup({ onRemove, removeLabel, ref, className, children, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, ...props }: TagGroupProps): ReactElement;
|
|
33
|
-
export interface TagProps extends Omit<ComponentProps<"div">, "color" | "role" | "id" | "tabIndex" | "children">, CollectionValueItemProps {
|
|
34
|
-
/** 태그 글자. 필수다. 아이콘(장식용)을 앞에 함께 둘 수 있다. */
|
|
35
|
-
children: ReactNode;
|
|
36
|
-
/**
|
|
37
|
-
* 색 계열 이름. Tide 색 계열 8개(장식 계열 purple·mint 포함)와 앱이 `ColorFamilyRegistry`에 더한 계열을 받는다. 기본값은 `gray`다.
|
|
38
|
-
* 분류를 구분하는 뜻 없는 색이라 Role(`primary`·`danger` 등)은 받지 않는다(ADR 0016·0017 후속).
|
|
39
|
-
* 루트에 `data-color`로 붙고 바깥 요소의 색을 물려받지 않는다.
|
|
40
|
-
*/
|
|
41
|
-
color?: ColorFamilyName;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* 태그 하나(`role="row"`). `TagGroup` 바로 안에 둔다. `value`가 묶음 안의 key이고 `onRemove`에 넘어오는 값이다.
|
|
45
|
-
* `disabled`면 지울 수 없고 키보드 이동도 건너뛴다(`aria-disabled`).
|
|
46
|
-
*/
|
|
47
|
-
export declare function Tag(_props: TagProps): null;
|
|
48
|
-
export {};
|