@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
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentProps, ReactElement } from "react";
|
|
2
|
+
export interface PopoverTriggerProps extends ComponentProps<"button"> {
|
|
3
|
+
/**
|
|
4
|
+
* 다른 요소로 렌더한다. 예: `render={<Button variant="outline" />}`, `render={<IconButton aria-label="설정" />}`.
|
|
5
|
+
* props, ref, className, 이벤트 핸들러를 그 요소에 병합한다. 기본은 class 없는 `<button type="button">`이다.
|
|
6
|
+
*/
|
|
7
|
+
render?: ReactElement;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Popover를 여닫는 버튼. 누르면(마우스, 터치, Enter, Space) 열림 상태를 뒤집는다.
|
|
11
|
+
* `aria-expanded`, 열렸을 때 `aria-controls`, 열렸을 때 `data-open`이 붙는다.
|
|
12
|
+
*/
|
|
13
|
+
export declare function PopoverTrigger({ render, ref, id, className, ...props }: PopoverTriggerProps): ReactElement;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { renderElement } from "../../_internal/libs/renderElement.js";
|
|
4
|
+
import { usePopoverContext } from "../hooks/usePopoverContext.js";
|
|
5
|
+
import { createElement, useLayoutEffect, useMemo } from "react";
|
|
6
|
+
import { mergeProps, mergeRefs, usePress } from "react-aria";
|
|
7
|
+
|
|
8
|
+
// src/Popover/components/PopoverTrigger.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Popover를 여닫는 버튼. 누르면(마우스, 터치, Enter, Space) 열림 상태를 뒤집는다.
|
|
11
|
+
* `aria-expanded`, 열렸을 때 `aria-controls`, 열렸을 때 `data-open`이 붙는다.
|
|
12
|
+
*/
|
|
13
|
+
function PopoverTrigger({ render, ref, id, className, ...props }) {
|
|
14
|
+
const { state, triggerRef, triggerProps, triggerId, setTriggerId } = usePopoverContext("PopoverTrigger");
|
|
15
|
+
const { onPress, ...ariaProps } = triggerProps;
|
|
16
|
+
const { pressProps } = usePress({
|
|
17
|
+
onPress,
|
|
18
|
+
ref: triggerRef
|
|
19
|
+
});
|
|
20
|
+
const mergedRef = useMemo(() => mergeRefs(ref, triggerRef), [ref, triggerRef]);
|
|
21
|
+
const resolvedId = id ?? triggerId;
|
|
22
|
+
useLayoutEffect(() => {
|
|
23
|
+
if (resolvedId !== triggerId) setTriggerId(resolvedId);
|
|
24
|
+
}, [
|
|
25
|
+
resolvedId,
|
|
26
|
+
triggerId,
|
|
27
|
+
setTriggerId
|
|
28
|
+
]);
|
|
29
|
+
const merged = {
|
|
30
|
+
...mergeProps(props, ariaProps, pressProps),
|
|
31
|
+
id: resolvedId,
|
|
32
|
+
ref: mergedRef,
|
|
33
|
+
"data-open": state.isOpen ? "" : void 0
|
|
34
|
+
};
|
|
35
|
+
if (!render) return createElement("button", {
|
|
36
|
+
type: "button",
|
|
37
|
+
...merged,
|
|
38
|
+
className
|
|
39
|
+
});
|
|
40
|
+
return renderElement({
|
|
41
|
+
defaultElement: "button",
|
|
42
|
+
render,
|
|
43
|
+
baseClassName: "",
|
|
44
|
+
props: {
|
|
45
|
+
...merged,
|
|
46
|
+
className
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { PopoverTrigger };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { overlaySurfaceClass, popoverMotionClass } from "../../_internal/constants/overlayClass.js";
|
|
2
|
+
|
|
3
|
+
// src/Popover/constants/popoverClass.ts
|
|
4
|
+
const contentClass = `isolate z-popover max-w-80 overflow-auto p-4 text-body-md outline-none ${overlaySurfaceClass} ${popoverMotionClass}`;
|
|
5
|
+
|
|
6
|
+
export { contentClass };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, use } from "react";
|
|
4
|
+
|
|
5
|
+
// src/Popover/hooks/usePopoverContext.ts
|
|
6
|
+
const PopoverContext = createContext(null);
|
|
7
|
+
function usePopoverContext(part) {
|
|
8
|
+
const context = use(PopoverContext);
|
|
9
|
+
if (!context) throw new Error(`${part}는 Popover 안에 둔다.`);
|
|
10
|
+
return context;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { PopoverContext, usePopoverContext };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Popover, PopoverProps } from "./Popover.js";
|
|
2
|
+
import { PopoverTrigger, PopoverTriggerProps } from "./components/PopoverTrigger.js";
|
|
3
|
+
import { PopoverContent, PopoverContentProps } from "./components/PopoverContent.js";
|
|
4
|
+
import { PopoverPlacement } from "./types.js";
|
|
5
|
+
export { Popover, PopoverContent, type PopoverContentProps, type PopoverPlacement, type PopoverProps, PopoverTrigger, type PopoverTriggerProps };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Role, Size } from "../types.js";
|
|
2
|
+
import { ComponentProps, ReactElement } from "react";
|
|
3
|
+
type ProgressSize = Extract<Size, "sm" | "md">;
|
|
4
|
+
type ProgressName = {
|
|
5
|
+
"aria-label": string;
|
|
6
|
+
"aria-labelledby"?: string;
|
|
7
|
+
} | {
|
|
8
|
+
"aria-label"?: string;
|
|
9
|
+
"aria-labelledby": string;
|
|
10
|
+
};
|
|
11
|
+
interface ProgressOwnProps extends Omit<ComponentProps<"div">, "color" | "children" | "role" | "aria-label" | "aria-labelledby" | "aria-valuenow" | "aria-valuemin" | "aria-valuemax"> {
|
|
12
|
+
/** 현재 값. 0~`max`로 잘라 쓴다. 값을 모르는 진행은 Spinner를 쓴다. */
|
|
13
|
+
value: number;
|
|
14
|
+
/** 끝 값. 기본값 `100`. 시작 값은 항상 0이다. */
|
|
15
|
+
max?: number;
|
|
16
|
+
/** 막대 굵기. `sm` 4px, `md` 8px. 기본값 `md`. */
|
|
17
|
+
size?: ProgressSize;
|
|
18
|
+
/** 막대 색. Role(Tide Role + 앱 Role)만 받는다. 기본값 `primary`. */
|
|
19
|
+
color?: Role;
|
|
20
|
+
}
|
|
21
|
+
export type ProgressProps = ProgressOwnProps & ProgressName;
|
|
22
|
+
/** 작업이 얼마나 진행됐는지 막대로 보여 준다(`role="progressbar"`). 서버 컴포넌트로 쓸 수 있다. */
|
|
23
|
+
export declare function Progress({ value, max, size, color, className, ...props }: ProgressProps): ReactElement;
|
|
24
|
+
export {};
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import { cn } from "
|
|
1
|
+
import { cn } from "../_internal/libs/cn.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
|
|
4
|
-
// src/Progress.tsx
|
|
4
|
+
// src/Progress/Progress.tsx
|
|
5
5
|
const sizeClass = {
|
|
6
6
|
sm: "h-1",
|
|
7
7
|
md: "h-2"
|
|
8
8
|
};
|
|
9
9
|
const trackClass = "relative block w-full overflow-hidden rounded-full bg-accent-subtle forced-colors:forced-color-adjust-none forced-colors:border forced-colors:border-[CanvasText] forced-colors:bg-[Canvas]";
|
|
10
10
|
const barClass = "block h-full rounded-full bg-current text-accent motion-safe:transition-[width] forced-colors:text-[Highlight]";
|
|
11
|
-
/** 0 이상 max 이하로 자른다. max가 0 이하이거나 숫자가 아니면 0으로 본다. */
|
|
12
11
|
function clamp(value, max) {
|
|
13
12
|
if (!Number.isFinite(value) || !Number.isFinite(max) || max <= 0) return 0;
|
|
14
13
|
return Math.min(Math.max(value, 0), max);
|
|
15
14
|
}
|
|
16
|
-
/**
|
|
17
|
-
* 작업이 얼마나 진행됐는지 막대로 보여 준다. 역할은 `progressbar`이고 값은 `aria-valuenow`로 나간다.
|
|
18
|
-
* 움직임 줄이기에서도 진행 표시는 그대로다. 서버 컴포넌트로 쓸 수 있다.
|
|
19
|
-
*/
|
|
15
|
+
/** 작업이 얼마나 진행됐는지 막대로 보여 준다(`role="progressbar"`). 서버 컴포넌트로 쓸 수 있다. */
|
|
20
16
|
function Progress({ value, max = 100, size = "md", color = "primary", className, ...props }) {
|
|
21
17
|
const safeMax = Number.isFinite(max) && max > 0 ? max : 100;
|
|
22
18
|
const now = clamp(value, safeMax);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ChoiceSize } from "../_internal/constants/choiceClass.js";
|
|
2
|
+
import { Role } from "../types.js";
|
|
3
|
+
import { CSSProperties, ComponentProps, ReactElement, ReactNode } from "react";
|
|
4
|
+
export interface RadioProps extends Omit<ComponentProps<"input">, "type" | "size" | "color" | "children" | "className" | "style" | "value"> {
|
|
5
|
+
/** 이 라디오의 값. RadioGroup의 `value`·`onValueChange`가 쓰고 form에 제출된다. */
|
|
6
|
+
value: string;
|
|
7
|
+
/** 원 옆에 보이는 label. 라디오의 이름이 된다. 없으면 `aria-label`을 준다. */
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
/** 원 16px(`sm`) 또는 20px(`md`). 누르는 영역은 둘 다 24×24px. 기본값 `md`. */
|
|
10
|
+
size?: ChoiceSize;
|
|
11
|
+
/** 선택했을 때 원 색(Role). 기본값 `primary`. */
|
|
12
|
+
color?: Role;
|
|
13
|
+
/** 오류 상태(`aria-invalid="true"`). Field·RadioGroup 값보다 여기에 준 값이 이긴다. */
|
|
14
|
+
invalid?: boolean;
|
|
15
|
+
/** 루트 label의 class. 기본 class를 이긴다. 원 모양은 `size`·`color`가 맡는다. */
|
|
16
|
+
className?: string;
|
|
17
|
+
/** 루트 label의 style */
|
|
18
|
+
style?: CSSProperties;
|
|
19
|
+
}
|
|
20
|
+
/** 네이티브 라디오 버튼. 보통 `RadioGroup` 안에 둔다. 묶음 밖에서는 `name`·`checked`·`onChange`를 직접 준다. */
|
|
21
|
+
export declare function Radio({ value, children, size, color, invalid, id, disabled, required, name, checked, defaultChecked, onChange, className, style, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...props }: RadioProps): ReactElement;
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { RadioGroupContext } from "
|
|
4
|
-
import { choiceAreaClass, choiceInputClass, choiceMarkClass, choiceRootClass, choiceTextClass } from "
|
|
5
|
-
import { cn } from "
|
|
6
|
-
import { useFieldControl } from "
|
|
3
|
+
import { RadioGroupContext } from "../_internal/hooks/useChoiceGroup.js";
|
|
4
|
+
import { choiceAreaClass, choiceInputClass, choiceMarkClass, choiceRootClass, choiceTextClass } from "../_internal/constants/choiceClass.js";
|
|
5
|
+
import { cn } from "../_internal/libs/cn.js";
|
|
6
|
+
import { useFieldControl } from "../_internal/hooks/useFieldControl.js";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { use } from "react";
|
|
9
9
|
import { CircleIcon } from "@tide-design/icons";
|
|
10
10
|
|
|
11
|
-
// src/Radio.tsx
|
|
11
|
+
// src/Radio/Radio.tsx
|
|
12
12
|
const boxClass = {
|
|
13
13
|
sm: "size-4 rounded-full",
|
|
14
14
|
md: "size-5 rounded-full"
|
|
15
15
|
};
|
|
16
|
-
/** 가운데 점 크기(px). 원 아이콘을 채워 그리고 선 두께 2px이 더해진다. */
|
|
17
16
|
const dotSize = {
|
|
18
17
|
sm: 6,
|
|
19
18
|
md: 8
|
|
20
19
|
};
|
|
21
|
-
/**
|
|
22
|
-
* 네이티브 라디오 버튼. 보통 `RadioGroup` 안에 두고, 묶음이 `name`과 선택 값을 정한다.
|
|
23
|
-
* 묶음 밖에서는 `name`·`checked`/`defaultChecked`·`onChange`를 직접 준다.
|
|
24
|
-
*/
|
|
20
|
+
/** 네이티브 라디오 버튼. 보통 `RadioGroup` 안에 둔다. 묶음 밖에서는 `name`·`checked`·`onChange`를 직접 준다. */
|
|
25
21
|
function Radio({ value, children, size = "md", color = "primary", invalid, id, disabled, required, name, checked, defaultChecked, onChange, className, style, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...props }) {
|
|
26
22
|
const group = use(RadioGroupContext);
|
|
27
23
|
const control = useFieldControl({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChoiceOrientation } from "
|
|
1
|
+
import { ChoiceOrientation } from "../_internal/constants/choiceGroupClass.js";
|
|
2
2
|
import { ComponentProps, ReactElement } from "react";
|
|
3
3
|
export interface RadioGroupProps extends Omit<ComponentProps<"div">, "defaultValue"> {
|
|
4
4
|
/** 안의 Radio가 함께 쓰는 `name`. form에 이 이름으로 제출된다. 주지 않으면 자동으로 만든다. */
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { orientationClass } from "
|
|
4
|
-
import { RadioGroupContext, useChoiceGroup } from "
|
|
5
|
-
import { cn } from "
|
|
6
|
-
import { FieldContext } from "
|
|
3
|
+
import { orientationClass } from "../_internal/constants/choiceGroupClass.js";
|
|
4
|
+
import { RadioGroupContext, useChoiceGroup } from "../_internal/hooks/useChoiceGroup.js";
|
|
5
|
+
import { cn } from "../_internal/libs/cn.js";
|
|
6
|
+
import { FieldContext } from "../_internal/hooks/useFieldControl.js";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
import { useId } from "react";
|
|
9
9
|
|
|
10
|
-
// src/RadioGroup.tsx
|
|
10
|
+
// src/RadioGroup/RadioGroup.tsx
|
|
11
11
|
/**
|
|
12
12
|
* Radio 여러 개를 하나의 이름과 선택 값으로 묶는다. `<Field label group>` 안에 두면 label이 묶음의 이름,
|
|
13
13
|
* 설명·오류가 묶음의 설명이 된다. Field 밖에서는 `aria-label`이나 `aria-labelledby`를 준다.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { InputSize } from "../_internal/constants/inputClass.js";
|
|
2
|
+
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
3
|
+
export interface SelectProps extends Omit<ComponentProps<"button">, "value" | "defaultValue" | "onChange" | "type" | "size" | "children" | "name" | "form"> {
|
|
4
|
+
/** 고른 옵션의 `value`(제어). `null`이면 아무것도 고르지 않은 상태다. */
|
|
5
|
+
value?: string | null;
|
|
6
|
+
/** 처음 고른 값(비제어). 폼을 reset하면 이 값으로 돌아간다. */
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
/** 사용자가 다른 옵션을 고르면 그 옵션의 `value`로 부른다. */
|
|
9
|
+
onValueChange?: (value: string) => void;
|
|
10
|
+
/** 목록 열림 상태(제어). 주면 `onOpenChange`로 바꾼다. */
|
|
11
|
+
open?: boolean;
|
|
12
|
+
/** 처음 목록 열림 상태(비제어). 기본값은 `false`다. */
|
|
13
|
+
defaultOpen?: boolean;
|
|
14
|
+
/** 목록 열림 상태가 바뀌려 할 때 새 값으로 부른다. 옵션을 골라 닫힐 때도 부른다. */
|
|
15
|
+
onOpenChange?: (open: boolean) => void;
|
|
16
|
+
/** 폼 제출 이름. 숨은 `<select>`에 붙어 고른 값이 이 이름으로 제출된다(트리거 버튼에는 붙지 않는다). */
|
|
17
|
+
name?: string;
|
|
18
|
+
/** 숨은 `<select>`가 속할 `<form>`의 id. 폼 밖에 둘 때 쓴다. */
|
|
19
|
+
form?: string;
|
|
20
|
+
/** 브라우저 자동 완성 힌트. 숨은 `<select>`에 붙는다. */
|
|
21
|
+
autoComplete?: string;
|
|
22
|
+
/** 아무것도 고르지 않았을 때 트리거에 보이는 글자. 기본값은 `"선택하세요"`다. */
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
/** 높이 `sm` 32px, `md` 40px, `lg` 48px. 같은 size의 Input·Button과 높이가 같다. 기본값은 `md`다. */
|
|
25
|
+
size?: InputSize;
|
|
26
|
+
/** 오류 상태. 트리거에 `aria-invalid="true"`와 `data-invalid`가 붙는다. Field 값보다 여기 준 값이 이긴다. */
|
|
27
|
+
invalid?: boolean;
|
|
28
|
+
/** 필수. 비운 채 제출하면 막고 트리거로 포커스를 옮긴다(브라우저 말풍선 없음, 메시지는 Field `error`). */
|
|
29
|
+
required?: boolean;
|
|
30
|
+
/** `SelectItem`과 `SelectSection`. 이 요소들을 바로 아래(또는 Fragment·배열 안)에 둔다. */
|
|
31
|
+
children?: ReactNode;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 값 하나를 고르는 입력. 루트 DOM은 트리거 `<button>`이고 목록은 `document.body`에 portal한다.
|
|
35
|
+
* Field 안에 두면 label·설명·오류가 자동으로 연결되고, `name`을 주면 고른 값이 폼에 제출된다.
|
|
36
|
+
*/
|
|
37
|
+
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;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { inputBaseClass, inputSizeClass } from "../_internal/constants/inputClass.js";
|
|
4
|
+
import { FieldContext, useFieldControl } from "../_internal/hooks/useFieldControl.js";
|
|
5
|
+
import { cn } from "../_internal/libs/cn.js";
|
|
6
|
+
import { resolveCollectionChildren } from "../_internal/libs/listCollection.js";
|
|
7
|
+
import { SelectPopover } from "./components/SelectPopover.js";
|
|
8
|
+
import { chevronClass, placeholderClass, triggerClass, valueClass } from "./constants/selectClass.js";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { use, useMemo, useRef } from "react";
|
|
11
|
+
import { ChevronDownIcon } from "@tide-design/icons";
|
|
12
|
+
import { HiddenSelect, mergeProps, mergeRefs, useButton, useSelect } from "react-aria";
|
|
13
|
+
import { useSelectState } from "react-stately";
|
|
14
|
+
|
|
15
|
+
// src/Select/Select.tsx
|
|
16
|
+
/**
|
|
17
|
+
* 값 하나를 고르는 입력. 루트 DOM은 트리거 `<button>`이고 목록은 `document.body`에 portal한다.
|
|
18
|
+
* Field 안에 두면 label·설명·오류가 자동으로 연결되고, `name`을 주면 고른 값이 폼에 제출된다.
|
|
19
|
+
*/
|
|
20
|
+
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 }) {
|
|
21
|
+
const field = use(FieldContext);
|
|
22
|
+
const control = useFieldControl({
|
|
23
|
+
id,
|
|
24
|
+
invalid,
|
|
25
|
+
disabled,
|
|
26
|
+
required,
|
|
27
|
+
"aria-describedby": ariaDescribedBy,
|
|
28
|
+
"aria-invalid": ariaInvalid
|
|
29
|
+
});
|
|
30
|
+
const isDisabled = control.disabled ?? false;
|
|
31
|
+
const isRequired = control.required ?? false;
|
|
32
|
+
const items = useMemo(() => resolveCollectionChildren(children), [children]);
|
|
33
|
+
const state = useSelectState({
|
|
34
|
+
children: items,
|
|
35
|
+
value,
|
|
36
|
+
defaultValue,
|
|
37
|
+
onChange: (key) => {
|
|
38
|
+
if (key != null) onValueChange?.(String(key));
|
|
39
|
+
},
|
|
40
|
+
isOpen: open,
|
|
41
|
+
defaultOpen,
|
|
42
|
+
onOpenChange,
|
|
43
|
+
isDisabled,
|
|
44
|
+
isRequired,
|
|
45
|
+
validationBehavior: "native"
|
|
46
|
+
});
|
|
47
|
+
const triggerRef = useRef(null);
|
|
48
|
+
const { triggerProps, valueProps, menuProps, hiddenSelectProps, isInvalid } = useSelect({
|
|
49
|
+
id: control.id,
|
|
50
|
+
"aria-label": ariaLabel,
|
|
51
|
+
"aria-labelledby": ariaLabelledBy ?? field?.labelId,
|
|
52
|
+
isDisabled,
|
|
53
|
+
isRequired,
|
|
54
|
+
validationBehavior: "native",
|
|
55
|
+
name,
|
|
56
|
+
form,
|
|
57
|
+
autoComplete
|
|
58
|
+
}, state, triggerRef);
|
|
59
|
+
const { buttonProps } = useButton(triggerProps, triggerRef);
|
|
60
|
+
const mergedRef = useMemo(() => mergeRefs(ref, triggerRef), [ref, triggerRef]);
|
|
61
|
+
const showInvalid = control["data-invalid"] === "" || isInvalid;
|
|
62
|
+
const selected = state.selectedItem;
|
|
63
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
64
|
+
/* @__PURE__ */ jsxs("button", {
|
|
65
|
+
...mergeProps(props, buttonProps),
|
|
66
|
+
ref: mergedRef,
|
|
67
|
+
"aria-describedby": control["aria-describedby"],
|
|
68
|
+
"aria-invalid": showInvalid ? true : control["aria-invalid"],
|
|
69
|
+
"data-invalid": showInvalid ? "" : void 0,
|
|
70
|
+
"data-open": state.isOpen ? "" : void 0,
|
|
71
|
+
className: cn(inputSizeClass[size], inputBaseClass, triggerClass, className),
|
|
72
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
73
|
+
...valueProps,
|
|
74
|
+
className: cn(valueClass, !selected && "text-muted group-disabled:text-disabled"),
|
|
75
|
+
children: selected ? selected.rendered : placeholder
|
|
76
|
+
}), /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
77
|
+
size: 16,
|
|
78
|
+
className: chevronClass
|
|
79
|
+
})]
|
|
80
|
+
}),
|
|
81
|
+
/* @__PURE__ */ jsx(HiddenSelect, {
|
|
82
|
+
...hiddenSelectProps,
|
|
83
|
+
autoComplete
|
|
84
|
+
}),
|
|
85
|
+
/* @__PURE__ */ jsx(SelectPopover, {
|
|
86
|
+
state,
|
|
87
|
+
triggerRef,
|
|
88
|
+
menuProps
|
|
89
|
+
})
|
|
90
|
+
] });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export { Select };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ListBoxOptionProps } from "../../_internal/components/ListBoxNodes/types.js";
|
|
2
|
+
export interface SelectItemProps extends ListBoxOptionProps {}
|
|
3
|
+
/**
|
|
4
|
+
* Select의 옵션(`role="option"`). `Select`나 `SelectSection` 바로 안에 둔다. `value`가 고른 값이고 폼에 제출된다.
|
|
5
|
+
* 내용(아이콘과 글자)은 고르면 트리거에도 보인다. 상태는 `data-highlighted`·`data-selected`·`data-disabled`다.
|
|
6
|
+
*/
|
|
7
|
+
export declare function SelectItem(_props: SelectItemProps): null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { asCollectionComponent, valueItemCollectionNode } from "../../_internal/libs/listCollection.js";
|
|
4
|
+
|
|
5
|
+
// src/Select/components/SelectItem.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Select의 옵션(`role="option"`). `Select`나 `SelectSection` 바로 안에 둔다. `value`가 고른 값이고 폼에 제출된다.
|
|
8
|
+
* 내용(아이콘과 글자)은 고르면 트리거에도 보인다. 상태는 `data-highlighted`·`data-selected`·`data-disabled`다.
|
|
9
|
+
*/
|
|
10
|
+
function SelectItem(_props) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
asCollectionComponent(SelectItem, valueItemCollectionNode);
|
|
14
|
+
|
|
15
|
+
export { SelectItem };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { OverlayPortal } from "../../_internal/components/OverlayPortal.js";
|
|
4
|
+
import { useOverlayPresence } from "../../_internal/hooks/useOverlayPresence.js";
|
|
5
|
+
import { SelectPopoverInner } from "./SelectPopoverInner.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { useRef } from "react";
|
|
8
|
+
|
|
9
|
+
// src/Select/components/SelectPopover.tsx
|
|
10
|
+
/** 목록을 DOM에 둘지 정하고 portal한다. 닫혀도 퇴장 전환이 끝날 때까지 남긴다(ADR 0018). */
|
|
11
|
+
function SelectPopover(props) {
|
|
12
|
+
const popoverRef = useRef(null);
|
|
13
|
+
if (!useOverlayPresence(props.state.isOpen, popoverRef)) return null;
|
|
14
|
+
return /* @__PURE__ */ jsx(OverlayPortal, {
|
|
15
|
+
isExiting: !props.state.isOpen,
|
|
16
|
+
children: /* @__PURE__ */ jsx(SelectPopoverInner, {
|
|
17
|
+
...props,
|
|
18
|
+
popoverRef
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { SelectPopover };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { ListBoxNodes } from "../../_internal/components/ListBoxNodes/ListBoxNodes.js";
|
|
4
|
+
import { listPopupClass } from "../../_internal/constants/listClass.js";
|
|
5
|
+
import { useCloseOnTab } from "../../_internal/hooks/useCloseOnTab.js";
|
|
6
|
+
import { useOverlayTheme } from "../../_internal/hooks/useOverlayTheme.js";
|
|
7
|
+
import { usePopoverOverlay } from "../../_internal/hooks/usePopoverOverlay.js";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { useLayoutEffect, useRef } from "react";
|
|
10
|
+
import { DismissButton, useListBox } from "react-aria";
|
|
11
|
+
|
|
12
|
+
// src/Select/components/SelectPopoverInner.tsx
|
|
13
|
+
/** 목록 표면과 그 안의 `role="listbox"`. listbox 자식은 option·group만 되므로 닫기 버튼은 표면에 둔다. */
|
|
14
|
+
function SelectPopoverInner({ state, triggerRef, menuProps, popoverRef }) {
|
|
15
|
+
const listRef = useRef(null);
|
|
16
|
+
useOverlayTheme(triggerRef, popoverRef);
|
|
17
|
+
useLayoutEffect(() => {
|
|
18
|
+
const popover = popoverRef.current;
|
|
19
|
+
const width = triggerRef.current?.offsetWidth;
|
|
20
|
+
if (popover && width) popover.style.minWidth = `${width}px`;
|
|
21
|
+
}, [triggerRef, popoverRef]);
|
|
22
|
+
const { overlayProps } = usePopoverOverlay({
|
|
23
|
+
triggerRef,
|
|
24
|
+
popoverRef,
|
|
25
|
+
placement: "bottom start",
|
|
26
|
+
offset: 4
|
|
27
|
+
}, state);
|
|
28
|
+
const { listBoxProps } = useListBox(menuProps, state, listRef);
|
|
29
|
+
useCloseOnTab(popoverRef, state.close);
|
|
30
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
31
|
+
...overlayProps,
|
|
32
|
+
ref: popoverRef,
|
|
33
|
+
"data-open": state.isOpen ? "" : void 0,
|
|
34
|
+
className: listPopupClass,
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ jsx(DismissButton, { onDismiss: state.close }),
|
|
37
|
+
/* @__PURE__ */ jsx("div", {
|
|
38
|
+
...listBoxProps,
|
|
39
|
+
ref: listRef,
|
|
40
|
+
className: "outline-none",
|
|
41
|
+
children: /* @__PURE__ */ jsx(ListBoxNodes, { state })
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ jsx(DismissButton, { onDismiss: state.close })
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { SelectPopoverInner };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ListBoxSectionProps } from "../../_internal/components/ListBoxNodes/types.js";
|
|
2
|
+
export interface SelectSectionProps extends ListBoxSectionProps {}
|
|
3
|
+
/**
|
|
4
|
+
* 옵션 묶음(`role="group"`). `heading`이 화면에 보이는 제목이자 묶음의 이름이고, 없으면 `aria-label`이 이름이다.
|
|
5
|
+
* 앞뒤 다른 옵션·묶음과의 사이에 구분선이 그려진다.
|
|
6
|
+
*/
|
|
7
|
+
export declare function SelectSection(_props: SelectSectionProps): null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { asCollectionComponent, sectionCollectionNode } from "../../_internal/libs/listCollection.js";
|
|
4
|
+
|
|
5
|
+
// src/Select/components/SelectSection.tsx
|
|
6
|
+
/**
|
|
7
|
+
* 옵션 묶음(`role="group"`). `heading`이 화면에 보이는 제목이자 묶음의 이름이고, 없으면 `aria-label`이 이름이다.
|
|
8
|
+
* 앞뒤 다른 옵션·묶음과의 사이에 구분선이 그려진다.
|
|
9
|
+
*/
|
|
10
|
+
function SelectSection(_props) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
asCollectionComponent(SelectSection, sectionCollectionNode);
|
|
14
|
+
|
|
15
|
+
export { SelectSection };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// src/Select/constants/selectClass.ts
|
|
2
|
+
const triggerClass = "group inline-flex items-center justify-between gap-2 text-start";
|
|
3
|
+
const valueClass = "min-w-0 flex-1 truncate [&>svg]:me-2 [&>svg]:inline-block [&>svg]:size-4 [&>svg]:align-[-0.125em]";
|
|
4
|
+
const placeholderClass = "text-muted group-disabled:text-disabled";
|
|
5
|
+
const chevronClass = "shrink-0 text-muted group-disabled:text-disabled";
|
|
6
|
+
|
|
7
|
+
export { chevronClass, placeholderClass, triggerClass, valueClass };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Select, SelectProps } from "./Select.js";
|
|
2
|
+
import { SelectItem, SelectItemProps } from "./components/SelectItem.js";
|
|
3
|
+
import { SelectSection, SelectSectionProps } from "./components/SelectSection.js";
|
|
4
|
+
export { Select, SelectItem, type SelectItemProps, type SelectProps, SelectSection, type SelectSectionProps };
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import { ComponentProps, ReactElement } from "react";
|
|
2
|
-
/** Separator의 방향 */
|
|
3
2
|
type SeparatorOrientation = "horizontal" | "vertical";
|
|
4
3
|
export interface SeparatorProps extends Omit<ComponentProps<"hr">, "children" | "role"> {
|
|
5
4
|
/** `horizontal`(기본값)은 위아래 내용을, `vertical`은 한 줄 안의 양옆 내용을 나눈다. */
|
|
6
5
|
orientation?: SeparatorOrientation;
|
|
7
|
-
/**
|
|
8
|
-
* 보기만 나누는 선이면 `true`. `role="none"`이 붙어 보조 기술에서 빠진다. 기본값은 `false`(separator 역할)다.
|
|
9
|
-
* 내용의 주제가 바뀌는 곳이면 `false`로 둔다.
|
|
10
|
-
*/
|
|
6
|
+
/** 보기만 나누는 선이면 `true`(`role="none"`, 보조 기술에서 빠진다). 기본값 `false`. 주제가 바뀌는 곳이면 `false`로 둔다. */
|
|
11
7
|
decorative?: boolean;
|
|
12
8
|
}
|
|
13
|
-
/**
|
|
14
|
-
* 내용 묶음 사이를 선으로 나눈다. 기본은 의미 구분(separator 역할)이고, `decorative`면 보조 기술에서 빠진다.
|
|
15
|
-
* 서버 컴포넌트로 쓸 수 있다.
|
|
16
|
-
*/
|
|
9
|
+
/** 내용 묶음 사이를 선(`<hr>`)으로 나눈다. `decorative`면 보조 기술에서 빠진다. 서버 컴포넌트로 쓸 수 있다. */
|
|
17
10
|
export declare function Separator({ orientation, decorative, className, ...props }: SeparatorProps): ReactElement;
|
|
18
11
|
export {};
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { cn } from "
|
|
1
|
+
import { cn } from "../_internal/libs/cn.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
|
|
4
|
-
// src/Separator.tsx
|
|
4
|
+
// src/Separator/Separator.tsx
|
|
5
5
|
const orientationClass = {
|
|
6
6
|
horizontal: "h-0 w-full border-t",
|
|
7
7
|
vertical: "h-auto w-0 self-stretch border-s"
|
|
8
8
|
};
|
|
9
9
|
const baseClass = "m-0 shrink-0 border-0 border-default";
|
|
10
|
-
/**
|
|
11
|
-
* 내용 묶음 사이를 선으로 나눈다. 기본은 의미 구분(separator 역할)이고, `decorative`면 보조 기술에서 빠진다.
|
|
12
|
-
* 서버 컴포넌트로 쓸 수 있다.
|
|
13
|
-
*/
|
|
10
|
+
/** 내용 묶음 사이를 선(`<hr>`)으로 나눈다. `decorative`면 보조 기술에서 빠진다. 서버 컴포넌트로 쓸 수 있다. */
|
|
14
11
|
function Separator({ orientation = "horizontal", decorative = false, className, ...props }) {
|
|
15
12
|
return /* @__PURE__ */ jsx("hr", {
|
|
16
13
|
...props,
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import { Size } from "
|
|
1
|
+
import { Size } from "../types.js";
|
|
2
2
|
import { ComponentProps, ReactElement } from "react";
|
|
3
|
-
/** 원의 size. Avatar size와 같은 24·32·40·48px다(Avatar 자리를 그대로 채운다). */
|
|
4
3
|
type SkeletonCircleSize = Extract<Size, "xs" | "sm" | "md" | "lg">;
|
|
5
4
|
interface SkeletonBaseProps extends Omit<ComponentProps<"div">, "children" | "aria-hidden"> {}
|
|
6
|
-
/** `
|
|
5
|
+
/** `size`는 원(`circle`)에만 있다. */
|
|
7
6
|
export type SkeletonProps = SkeletonBaseProps & ({
|
|
8
|
-
/**
|
|
9
|
-
* 모양. `text`는 글 한 줄(높이 1em, 너비 100%), `rect`는 사각형 영역(너비 100%, 높이는 `className`으로 준다),
|
|
10
|
-
* `circle`은 원(크기는 `size`). 기본값은 `text`다.
|
|
11
|
-
*/
|
|
7
|
+
/** 모양. `text`는 글 한 줄, `rect`는 사각형(높이는 `className`으로), `circle`은 원. 기본값 `text`. */
|
|
12
8
|
variant?: "text" | "rect";
|
|
13
9
|
size?: never;
|
|
14
10
|
} | {
|
|
15
11
|
variant: "circle";
|
|
16
|
-
/** 원 크기. `xs` 24px, `sm` 32px, `md` 40px, `lg` 48px(Avatar와 같다).
|
|
12
|
+
/** 원 크기. `xs` 24px, `sm` 32px, `md` 40px, `lg` 48px(Avatar와 같다). 기본값 `md`. */
|
|
17
13
|
size?: SkeletonCircleSize;
|
|
18
14
|
});
|
|
19
15
|
/**
|
|
20
16
|
* 내용이 오기 전 자리를 표시한다. 스크린 리더에는 읽히지 않는다(`aria-hidden`).
|
|
21
|
-
* 불러오는 중이라는 사실은 앱이
|
|
17
|
+
* 불러오는 중이라는 사실은 앱이 `aria-busy`나 보이는 문구로 알린다. 서버 컴포넌트로 쓸 수 있다.
|
|
22
18
|
*/
|
|
23
19
|
export declare function Skeleton({ variant, size, className, ...props }: SkeletonProps): ReactElement;
|
|
24
20
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { cn } from "
|
|
1
|
+
import { cn } from "../_internal/libs/cn.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
|
|
4
|
-
// src/Skeleton.tsx
|
|
4
|
+
// src/Skeleton/Skeleton.tsx
|
|
5
5
|
const variantClass = {
|
|
6
6
|
text: "h-[1em] w-full rounded-sm",
|
|
7
7
|
rect: "w-full rounded-md",
|
|
@@ -16,7 +16,7 @@ const circleSizeClass = {
|
|
|
16
16
|
const baseClass = "block border border-transparent bg-neutral-subtle-active motion-safe:animate-pulse";
|
|
17
17
|
/**
|
|
18
18
|
* 내용이 오기 전 자리를 표시한다. 스크린 리더에는 읽히지 않는다(`aria-hidden`).
|
|
19
|
-
* 불러오는 중이라는 사실은 앱이
|
|
19
|
+
* 불러오는 중이라는 사실은 앱이 `aria-busy`나 보이는 문구로 알린다. 서버 컴포넌트로 쓸 수 있다.
|
|
20
20
|
*/
|
|
21
21
|
function Skeleton({ variant = "text", size, className, ...props }) {
|
|
22
22
|
return /* @__PURE__ */ jsx("div", {
|