@tide-design/components 0.11.1 → 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 -5
- 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 -27
- 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 -99
- 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 -5
- 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/{components/ListBoxNodes.d.ts → _internal/components/ListBoxNodes/types.d.ts} +1 -1
- package/dist/{components → _internal/components}/OverlayPortal.js +1 -1
- package/dist/{constants → _internal/constants}/alertClass.js +1 -1
- package/dist/{constants → _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/{constants → _internal/constants}/inputClass.d.ts +1 -1
- package/dist/{constants → _internal/constants}/inputClass.js +1 -1
- package/dist/{constants → _internal/constants}/listClass.js +1 -1
- package/dist/{constants → _internal/constants}/overlayClass.js +1 -1
- package/dist/{constants → _internal/constants}/pressableClass.js +1 -1
- package/dist/{hooks → _internal/hooks}/useChoiceGroup.js +1 -1
- package/dist/{hooks → _internal/hooks}/useCloseOnTab.js +1 -1
- package/dist/_internal/hooks/useDialogContext.js +14 -0
- package/dist/{hooks → _internal/hooks}/useFieldControl.js +1 -1
- package/dist/{hooks → _internal/hooks}/useOverlayPresence.js +1 -1
- package/dist/{hooks → _internal/hooks}/useOverlayTheme.js +1 -1
- package/dist/{hooks → _internal/hooks}/usePopoverOverlay.js +1 -1
- 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 +1 -1
- package/dist/{libs → _internal/libs}/overlayPosition.js +1 -1
- package/dist/{libs → _internal/libs}/pressableState.js +1 -1
- package/dist/{libs → _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 -257
- 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/Select.js +0 -173
- 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 -193
- package/dist/Tooltip.d.ts +0 -53
- package/dist/Tooltip.js +0 -132
- package/dist/components/ListBoxNodes.js +0 -90
- /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/{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/{libs → _internal/libs}/overlayPosition.d.ts +0 -0
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/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.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { cn } from "./libs/cn.js";
|
|
4
|
-
import { IconButton } from "./IconButton.js";
|
|
5
|
-
import { asCollectionComponent, resolveCollectionChildren, valueItemCollectionNode } from "./libs/listCollection.js";
|
|
6
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { createContext, use, useMemo, useRef } from "react";
|
|
8
|
-
import { XIcon } from "@tide-design/icons";
|
|
9
|
-
import { mergeProps, mergeRefs, useTag, useTagGroup } from "react-aria";
|
|
10
|
-
import { useListState } from "react-stately";
|
|
11
|
-
|
|
12
|
-
// src/Tag.tsx
|
|
13
|
-
const TagGroupContext = createContext(null);
|
|
14
|
-
const tagGroupClass = "flex flex-wrap items-center gap-2 outline-none";
|
|
15
|
-
const tagClass = [
|
|
16
|
-
"inline-flex h-8 max-w-full min-w-0 shrink-0 items-center rounded-sm border border-accent-subtle bg-accent-subtle ps-2.5 align-middle text-label-md whitespace-nowrap text-accent-on-subtle outline-none select-none",
|
|
17
|
-
"[--tag-remove-hover:var(--tide-accent-subtle-hover)] [--tag-remove-active:var(--tide-accent-subtle-active)]",
|
|
18
|
-
"aria-disabled:bg-disabled aria-disabled:text-disabled focus-visible:focus-ring"
|
|
19
|
-
].join(" ");
|
|
20
|
-
const tagCellClass = "flex min-w-0 items-center gap-1";
|
|
21
|
-
const tagLabelClass = "inline-flex min-w-0 items-center gap-1 [&>svg]:size-4 [&>svg]:shrink-0";
|
|
22
|
-
const removeClass = "rounded-sm text-current";
|
|
23
|
-
const removeInteractionClass = "hover:bg-(--tag-remove-hover) active:bg-(--tag-remove-active)";
|
|
24
|
-
/**
|
|
25
|
-
* 고르거나 입력한 값을 보여 주는 태그 묶음(`role="grid"`). ←→로 태그를 옮기고(끝에서 처음으로 돈다) Home·End로
|
|
26
|
-
* 처음·마지막 태그에 간다. `onRemove`를 주면 Delete·Backspace와 지우기 버튼으로 태그를 지운다.
|
|
27
|
-
* 지운 뒤 포커스는 옆 태그로 옮겨 간다. 이름은 `aria-label`이나 `aria-labelledby`로 꼭 준다.
|
|
28
|
-
*/
|
|
29
|
-
function TagGroup({ onRemove, removeLabel = "제거", ref, className, children, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, ...props }) {
|
|
30
|
-
const groupRef = useRef(null);
|
|
31
|
-
const items = useMemo(() => resolveCollectionChildren(children), [children]);
|
|
32
|
-
const state = useListState({ children: items });
|
|
33
|
-
const { gridProps } = useTagGroup({
|
|
34
|
-
id,
|
|
35
|
-
"aria-label": ariaLabel,
|
|
36
|
-
"aria-labelledby": ariaLabelledby,
|
|
37
|
-
"aria-describedby": ariaDescribedby,
|
|
38
|
-
onRemove: onRemove ? (keys) => keys.forEach((key) => onRemove(String(key))) : void 0
|
|
39
|
-
}, state, groupRef);
|
|
40
|
-
const mergedRef = useMemo(() => mergeRefs(ref, groupRef), [ref, groupRef]);
|
|
41
|
-
const context = useMemo(() => ({
|
|
42
|
-
onRemove,
|
|
43
|
-
removeLabel
|
|
44
|
-
}), [onRemove, removeLabel]);
|
|
45
|
-
return /* @__PURE__ */ jsx("div", {
|
|
46
|
-
...mergeProps(props, gridProps),
|
|
47
|
-
ref: mergedRef,
|
|
48
|
-
className: cn(tagGroupClass, className),
|
|
49
|
-
children: /* @__PURE__ */ jsx(TagGroupContext, {
|
|
50
|
-
value: context,
|
|
51
|
-
children: [...state.collection].map((node) => /* @__PURE__ */ jsx(TagView, {
|
|
52
|
-
node,
|
|
53
|
-
state
|
|
54
|
-
}, node.key))
|
|
55
|
-
})
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* 태그 하나(`role="row"`). `TagGroup` 바로 안에 둔다. `value`가 묶음 안의 key이고 `onRemove`에 넘어오는 값이다.
|
|
60
|
-
* `disabled`면 지울 수 없고 키보드 이동도 건너뛴다(`aria-disabled`).
|
|
61
|
-
*/
|
|
62
|
-
function Tag(_props) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
asCollectionComponent(Tag, valueItemCollectionNode);
|
|
66
|
-
/** 태그 하나를 그린다. node.props는 앱이 Tag에 준 props(와 컬렉션이 더한 isDisabled)다. */
|
|
67
|
-
function TagView({ node, state }) {
|
|
68
|
-
const context = use(TagGroupContext);
|
|
69
|
-
const rowRef = useRef(null);
|
|
70
|
-
const { ref, className, color = "gray", value: _value, disabled: _disabled, isDisabled: _isDisabled, textValue: _textValue, children: _children, "aria-label": _ariaLabel, onFocus: _onFocus, onBlur: _onBlur, onKeyDown: _onKeyDown, onKeyUp: _onKeyUp, autoFocus: _autoFocus, ...props } = node.props;
|
|
71
|
-
const { rowProps, gridCellProps, removeButtonProps, allowsRemoving, isDisabled } = useTag({ item: node }, state, rowRef);
|
|
72
|
-
const mergedRef = useMemo(() => mergeRefs(ref, rowRef), [ref, rowRef]);
|
|
73
|
-
const onRemove = context?.onRemove;
|
|
74
|
-
return /* @__PURE__ */ jsx("div", {
|
|
75
|
-
...mergeProps(props, rowProps),
|
|
76
|
-
ref: mergedRef,
|
|
77
|
-
"data-color": color,
|
|
78
|
-
className: cn(tagClass, allowsRemoving ? "pe-0.75" : "pe-2.5", className),
|
|
79
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
80
|
-
...gridCellProps,
|
|
81
|
-
className: tagCellClass,
|
|
82
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
83
|
-
className: tagLabelClass,
|
|
84
|
-
children: node.rendered
|
|
85
|
-
}), allowsRemoving && onRemove ? /* @__PURE__ */ jsx(IconButton, {
|
|
86
|
-
"aria-label": context.removeLabel,
|
|
87
|
-
"aria-labelledby": removeButtonProps["aria-labelledby"],
|
|
88
|
-
id: removeButtonProps.id,
|
|
89
|
-
variant: "ghost",
|
|
90
|
-
color: "neutral",
|
|
91
|
-
size: "xs",
|
|
92
|
-
disabled: isDisabled,
|
|
93
|
-
tabIndex: -1,
|
|
94
|
-
onClick: () => onRemove(String(node.key)),
|
|
95
|
-
className: cn(removeClass, isDisabled ? void 0 : removeInteractionClass),
|
|
96
|
-
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
97
|
-
}) : null]
|
|
98
|
-
})
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export { Tag, TagGroup };
|