@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,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { pressableBaseClass } from "../_internal/constants/pressableClass.js";
|
|
4
|
+
import { pressableState } from "../_internal/libs/pressableState.js";
|
|
5
|
+
import { renderElement } from "../_internal/libs/renderElement.js";
|
|
6
|
+
import { Spinner } from "../Spinner/Spinner.js";
|
|
7
|
+
import { VisuallyHidden } from "../VisuallyHidden/VisuallyHidden.js";
|
|
8
|
+
import { Icon } from "./components/Icon.js";
|
|
9
|
+
import { sizeClass } from "./constants/buttonClass.js";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
|
|
12
|
+
// src/Button/Button.tsx
|
|
13
|
+
/** 누르면 동작을 실행하는 버튼. 링크로 렌더하려면 `render={<Link href="/x" />}`를 쓴다. */
|
|
14
|
+
function Button({ variant = "solid", color = "primary", size = "md", startIcon, endIcon, loading = false, loadingLabel = "로딩 중", noPressScale = false, render, disabled = false, type, children, onClick, ...props }) {
|
|
15
|
+
const state = pressableState({
|
|
16
|
+
variant,
|
|
17
|
+
color,
|
|
18
|
+
disabled,
|
|
19
|
+
loading,
|
|
20
|
+
noPressScale,
|
|
21
|
+
render,
|
|
22
|
+
type,
|
|
23
|
+
onClick,
|
|
24
|
+
ariaDisabled: props["aria-disabled"]
|
|
25
|
+
});
|
|
26
|
+
const { showSpinner } = state;
|
|
27
|
+
const label = children ?? (render?.props)?.children;
|
|
28
|
+
const rootProps = {
|
|
29
|
+
...props,
|
|
30
|
+
...state.rootProps,
|
|
31
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
32
|
+
showSpinner ? /* @__PURE__ */ jsx(Spinner, {
|
|
33
|
+
size,
|
|
34
|
+
"aria-hidden": "true"
|
|
35
|
+
}) : startIcon != null ? /* @__PURE__ */ jsx(Icon, {
|
|
36
|
+
size,
|
|
37
|
+
children: startIcon
|
|
38
|
+
}) : null,
|
|
39
|
+
label,
|
|
40
|
+
endIcon != null ? /* @__PURE__ */ jsx(Icon, {
|
|
41
|
+
size,
|
|
42
|
+
children: endIcon
|
|
43
|
+
}) : null,
|
|
44
|
+
showSpinner ? /* @__PURE__ */ jsx(VisuallyHidden, { children: loadingLabel }) : null
|
|
45
|
+
] })
|
|
46
|
+
};
|
|
47
|
+
return renderElement({
|
|
48
|
+
defaultElement: "button",
|
|
49
|
+
render,
|
|
50
|
+
baseClassName: `${pressableBaseClass} ${sizeClass[size]} ${state.className}`,
|
|
51
|
+
props: rootProps
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { Button };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { iconSizeClass } from "../constants/buttonClass.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
// src/Button/components/Icon.tsx
|
|
5
|
+
function Icon({ size, children }) {
|
|
6
|
+
return /* @__PURE__ */ jsx("span", {
|
|
7
|
+
"aria-hidden": "true",
|
|
8
|
+
className: `inline-flex shrink-0 items-center justify-center *:size-full ${iconSizeClass[size]}`,
|
|
9
|
+
children
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { Icon };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/Button/constants/buttonClass.ts
|
|
2
|
+
/** size별 높이·padding·간격·텍스트 스타일. */
|
|
3
|
+
const sizeClass = {
|
|
4
|
+
xs: "h-6 gap-1 px-2 text-label-sm",
|
|
5
|
+
sm: "h-8 gap-1.5 px-3 text-label-md",
|
|
6
|
+
md: "h-10 gap-2 px-4 text-label-md",
|
|
7
|
+
lg: "h-12 gap-2 px-5 text-label-lg"
|
|
8
|
+
};
|
|
9
|
+
/** 텍스트 옆 아이콘을 감싼 span 크기. 안의 요소가 꽉 채운다. */
|
|
10
|
+
const iconSizeClass = {
|
|
11
|
+
xs: "size-3.5",
|
|
12
|
+
sm: "size-3.5",
|
|
13
|
+
md: "size-4",
|
|
14
|
+
lg: "size-5"
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { iconSizeClass, sizeClass };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FillVariant, Size } from "../types.js";
|
|
2
|
+
/** Button의 채움 방식. 4개를 모두 받는다. */
|
|
3
|
+
export type ButtonVariant = Extract<FillVariant, "solid" | "subtle" | "outline" | "ghost">;
|
|
4
|
+
/** Button의 size. 공통 size 4개를 모두 받는다. */
|
|
5
|
+
export type ButtonSize = Extract<Size, "xs" | "sm" | "md" | "lg">;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { renderElement } from "
|
|
1
|
+
import { renderElement } from "../_internal/libs/renderElement.js";
|
|
2
2
|
|
|
3
|
-
// src/Card.tsx
|
|
3
|
+
// src/Card/Card.tsx
|
|
4
4
|
const baseClass = "rounded-lg border border-default bg-surface p-4 text-default";
|
|
5
5
|
/**
|
|
6
6
|
* 관련 내용을 한 덩어리로 묶는 surface 표면 컨테이너. 경계만 있고 그림자는 없다.
|
|
@@ -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 CheckboxProps extends Omit<ComponentProps<"input">, "type" | "size" | "color" | "children" | "className" | "style"> {
|
|
5
|
+
/** 상자 옆에 보이는 label. 체크박스의 이름이 된다. 없으면 `aria-label`을 준다. */
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
/** 상자 16px(`sm`) 또는 20px(`md`). 누르는 영역은 둘 다 24×24px. 기본값 `md`. */
|
|
8
|
+
size?: ChoiceSize;
|
|
9
|
+
/** 체크했을 때 상자 색(Role). 기본값 `primary`. */
|
|
10
|
+
color?: Role;
|
|
11
|
+
/** 일부만 선택된 상태(가로줄). 누르면 브라우저가 지우므로 앱이 다시 계산해 넘긴다. */
|
|
12
|
+
indeterminate?: boolean;
|
|
13
|
+
/** 오류 상태(`aria-invalid="true"`). Field·CheckboxGroup 값보다 여기에 준 값이 이긴다. */
|
|
14
|
+
invalid?: boolean;
|
|
15
|
+
/** 루트 label의 class. 기본 class를 이긴다. 상자 모양은 `size`·`color`가 맡는다. */
|
|
16
|
+
className?: string;
|
|
17
|
+
/** 루트 label의 style */
|
|
18
|
+
style?: CSSProperties;
|
|
19
|
+
}
|
|
20
|
+
/** 네이티브 체크박스. 여러 개를 묶어 이름·설명·오류를 붙이려면 `Field group` 안의 `CheckboxGroup`에 둔다. */
|
|
21
|
+
export declare function Checkbox({ children, size, color, indeterminate, invalid, id, disabled, required, className, style, ref, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...props }: CheckboxProps): ReactElement;
|
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { CheckboxGroupContext } from "
|
|
4
|
-
import { choiceAreaClass, choiceInputClass, choiceMarkClass, choiceRootClass, choiceTextClass } from "
|
|
5
|
-
import { cn } from "
|
|
6
|
-
import { useFieldControl } from "
|
|
3
|
+
import { CheckboxGroupContext } 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, useImperativeHandle, useLayoutEffect, useRef } from "react";
|
|
9
9
|
import { CheckIcon, MinusIcon } from "@tide-design/icons";
|
|
10
10
|
|
|
11
|
-
// src/Checkbox.tsx
|
|
12
|
-
/** 상자 크기와 모서리. 체크박스는 radius `sm`(4px)이다. */
|
|
11
|
+
// src/Checkbox/Checkbox.tsx
|
|
13
12
|
const boxClass = {
|
|
14
13
|
sm: "size-4 rounded-sm",
|
|
15
14
|
md: "size-5 rounded-sm"
|
|
16
15
|
};
|
|
17
|
-
/** 상자 안 아이콘 크기(px) */
|
|
18
16
|
const iconSize = {
|
|
19
17
|
sm: 12,
|
|
20
18
|
md: 16
|
|
21
19
|
};
|
|
22
|
-
/**
|
|
23
|
-
* 네이티브 체크박스. `checked`/`defaultChecked`/`onChange`를 그대로 받고 form에 그대로 제출된다.
|
|
24
|
-
* 여러 개를 묶어 이름·설명·오류를 붙이려면 `Field group` 안의 `CheckboxGroup`에 둔다.
|
|
25
|
-
*/
|
|
20
|
+
/** 네이티브 체크박스. 여러 개를 묶어 이름·설명·오류를 붙이려면 `Field group` 안의 `CheckboxGroup`에 둔다. */
|
|
26
21
|
function Checkbox({ children, size = "md", color = "primary", indeterminate = false, invalid, id, disabled, required, className, style, ref, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...props }) {
|
|
27
22
|
const group = use(CheckboxGroupContext);
|
|
28
23
|
const control = useFieldControl({
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
+
import { ChoiceOrientation } from "../_internal/constants/choiceGroupClass.js";
|
|
1
2
|
import { ComponentProps, ReactElement } from "react";
|
|
2
|
-
/** 항목을 쌓는 방향 */
|
|
3
|
-
export type ChoiceOrientation = "vertical" | "horizontal";
|
|
4
3
|
export interface CheckboxGroupProps extends ComponentProps<"div"> {
|
|
5
4
|
/** 항목을 세로(`vertical`)로 쌓거나 가로(`horizontal`)로 늘어놓는다. 기본값은 `vertical`이다. */
|
|
6
5
|
orientation?: ChoiceOrientation;
|
|
7
|
-
/**
|
|
8
|
-
* 오류 상태. 안의 Checkbox마다 `aria-invalid="true"`가 붙고, 묶음에 `data-invalid`가 붙는다.
|
|
9
|
-
* Field 안에서는 Field의 값을 따르고, 여기에 준 값이 이긴다.
|
|
10
|
-
*/
|
|
6
|
+
/** 오류 상태. 안의 Checkbox마다 `aria-invalid="true"`, 묶음에 `data-invalid`. Field 안에서는 여기 준 값이 이긴다. */
|
|
11
7
|
invalid?: boolean;
|
|
12
8
|
/** 안의 Checkbox를 모두 비활성으로 만든다. Field 안에서는 Field의 값을 따른다. */
|
|
13
9
|
disabled?: boolean;
|
|
14
10
|
}
|
|
15
11
|
/**
|
|
16
|
-
* Checkbox 여러 개를 하나의 이름으로 묶는다.
|
|
17
|
-
*
|
|
12
|
+
* Checkbox 여러 개를 하나의 이름으로 묶는다. 값은 각 Checkbox가 가진다(묶음은 값을 모으지 않는다).
|
|
13
|
+
* `<Field label group>` 안에서는 Field label·설명이 이름·설명이 되고, 밖에서는 `aria-label`·`aria-labelledby`를 준다.
|
|
18
14
|
*/
|
|
19
|
-
export declare function CheckboxGroup({ orientation, invalid, disabled, id, className, children, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...props }: CheckboxGroupProps): ReactElement;
|
|
15
|
+
export declare function CheckboxGroup({ orientation, invalid, disabled, id, className, children, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...props }: CheckboxGroupProps): ReactElement;
|
|
16
|
+
export type { ChoiceOrientation };
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { CheckboxGroupContext, useChoiceGroup } from "
|
|
4
|
-
import { cn } from "
|
|
5
|
-
import { FieldContext } from "
|
|
3
|
+
import { CheckboxGroupContext, useChoiceGroup } from "../_internal/hooks/useChoiceGroup.js";
|
|
4
|
+
import { cn } from "../_internal/libs/cn.js";
|
|
5
|
+
import { FieldContext } from "../_internal/hooks/useFieldControl.js";
|
|
6
|
+
import { orientationClass } from "../_internal/constants/choiceGroupClass.js";
|
|
6
7
|
import { jsx } from "react/jsx-runtime";
|
|
7
8
|
|
|
8
|
-
// src/CheckboxGroup.tsx
|
|
9
|
-
/** 방향별 배치. 가로는 줄이 넘치면 다음 줄로 간다. */
|
|
10
|
-
const orientationClass = {
|
|
11
|
-
vertical: "flex flex-col gap-2",
|
|
12
|
-
horizontal: "flex flex-row flex-wrap gap-x-6 gap-y-2"
|
|
13
|
-
};
|
|
9
|
+
// src/CheckboxGroup/CheckboxGroup.tsx
|
|
14
10
|
/**
|
|
15
|
-
* Checkbox 여러 개를 하나의 이름으로 묶는다.
|
|
16
|
-
*
|
|
11
|
+
* Checkbox 여러 개를 하나의 이름으로 묶는다. 값은 각 Checkbox가 가진다(묶음은 값을 모으지 않는다).
|
|
12
|
+
* `<Field label group>` 안에서는 Field label·설명이 이름·설명이 되고, 밖에서는 `aria-label`·`aria-labelledby`를 준다.
|
|
17
13
|
*/
|
|
18
14
|
function CheckboxGroup({ orientation = "vertical", invalid, disabled, id, className, children, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...props }) {
|
|
19
15
|
const connection = useChoiceGroup({
|
|
@@ -42,4 +38,4 @@ function CheckboxGroup({ orientation = "vertical", invalid, disabled, id, classN
|
|
|
42
38
|
});
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
export { CheckboxGroup
|
|
41
|
+
export { CheckboxGroup };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { InputSize } from "../_internal/constants/inputClass.js";
|
|
2
|
+
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
3
|
+
export interface ComboboxProps extends Omit<ComponentProps<"input">, "value" | "defaultValue" | "onChange" | "type" | "size" | "children" | "name" | "form" | "list"> {
|
|
4
|
+
/** 고른 값(제어). 고른 옵션의 `value`다. `null`이면 아무것도 고르지 않은 상태다. 주면 `onValueChange`로 바꾼다. */
|
|
5
|
+
value?: string | null;
|
|
6
|
+
/** 처음 고른 값(비제어). 입력에 그 옵션의 글자가 보인다. 폼을 reset하면 이 값으로 돌아간다. */
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
/** 고른 값이 바뀌면 부른다. 옵션을 고르면 그 `value`로, 사용자가 입력을 모두 지우면 `null`로 부른다. */
|
|
9
|
+
onValueChange?: (value: string | null) => void;
|
|
10
|
+
/** 목록이 열리거나 닫힐 때 새 상태로 부른다. 열림 상태는 입력이 정하므로 제어할 수 없다. */
|
|
11
|
+
onOpenChange?: (open: boolean) => void;
|
|
12
|
+
/** 거른 결과가 없을 때 목록에 보이는 글자. 기본값은 `"결과가 없습니다"`다. */
|
|
13
|
+
emptyMessage?: ReactNode;
|
|
14
|
+
/** 폼 제출 이름. 숨은 input에 붙어 고른 옵션의 `value`가 이 이름으로 제출된다(입력한 글자는 제출되지 않는다). */
|
|
15
|
+
name?: string;
|
|
16
|
+
/** 숨은 input이 속할 `<form>`의 id. 폼 밖에 둘 때 쓴다. */
|
|
17
|
+
form?: string;
|
|
18
|
+
/** 높이 `sm` 32px, `md` 40px, `lg` 48px. 같은 size의 Input·Select·Button과 높이가 같다. 기본값은 `md`다. */
|
|
19
|
+
size?: InputSize;
|
|
20
|
+
/** 오류 상태. 입력에 `aria-invalid="true"`와 `data-invalid`가 붙는다. Field 안에서는 여기 준 값이 이긴다. */
|
|
21
|
+
invalid?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* 필수. 비어 있으면 제출이 막히고 입력으로 포커스가 오며 오류 상태가 된다(브라우저 말풍선 없음).
|
|
24
|
+
* 메시지는 Field `error`로 보여 준다. Field 안에서는 Field의 값을 따른다.
|
|
25
|
+
*/
|
|
26
|
+
required?: boolean;
|
|
27
|
+
/** `ComboboxItem`과 `ComboboxSection`. 이 요소들을 바로 아래(또는 Fragment·배열 안)에 둔다. */
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 글자를 쳐서 옵션을 거르고 하나를 고르는 입력. 포커스가 나가면 고르지 않은 글자는 지워진다(자유 입력 없음).
|
|
32
|
+
* Field 안에 두면 label·설명·오류가 연결되고, `name`을 주면 고른 옵션의 `value`가 제출된다.
|
|
33
|
+
*/
|
|
34
|
+
export declare function Combobox({ value, defaultValue, onValueChange, onOpenChange, emptyMessage, name, form, size, invalid, disabled, required, readOnly, id, ref, className, children, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }: ComboboxProps): ReactElement;
|
|
@@ -0,0 +1,110 @@
|
|
|
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 { ComboboxPopover } from "./components/ComboboxPopover.js";
|
|
8
|
+
import { buttonClass, buttonSizeClass, inputEndClass, wrapperClass } from "./constants/comboboxClass.js";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { use, useMemo, useRef } from "react";
|
|
11
|
+
import { ChevronDownIcon } from "@tide-design/icons";
|
|
12
|
+
import { mergeProps, mergeRefs, useButton, useComboBox, useFilter } from "react-aria";
|
|
13
|
+
import { useComboBoxState } from "react-stately";
|
|
14
|
+
|
|
15
|
+
// src/Combobox/Combobox.tsx
|
|
16
|
+
const isComposingKey = (event) => event.nativeEvent.isComposing || event.keyCode === 229;
|
|
17
|
+
/**
|
|
18
|
+
* 글자를 쳐서 옵션을 거르고 하나를 고르는 입력. 포커스가 나가면 고르지 않은 글자는 지워진다(자유 입력 없음).
|
|
19
|
+
* Field 안에 두면 label·설명·오류가 연결되고, `name`을 주면 고른 옵션의 `value`가 제출된다.
|
|
20
|
+
*/
|
|
21
|
+
function Combobox({ value, defaultValue, onValueChange, onOpenChange, emptyMessage = "결과가 없습니다", name, form, size = "md", invalid, disabled, required, readOnly, id, ref, className, children, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }) {
|
|
22
|
+
const field = use(FieldContext);
|
|
23
|
+
const control = useFieldControl({
|
|
24
|
+
id,
|
|
25
|
+
invalid,
|
|
26
|
+
disabled,
|
|
27
|
+
required,
|
|
28
|
+
"aria-describedby": ariaDescribedBy,
|
|
29
|
+
"aria-invalid": ariaInvalid
|
|
30
|
+
});
|
|
31
|
+
const isDisabled = control.disabled ?? false;
|
|
32
|
+
const isRequired = control.required ?? false;
|
|
33
|
+
const items = useMemo(() => resolveCollectionChildren(children), [children]);
|
|
34
|
+
const { contains } = useFilter({ sensitivity: "base" });
|
|
35
|
+
const state = useComboBoxState({
|
|
36
|
+
children: items,
|
|
37
|
+
defaultFilter: contains,
|
|
38
|
+
value,
|
|
39
|
+
defaultValue,
|
|
40
|
+
onChange: (key) => onValueChange?.(key == null ? null : String(key)),
|
|
41
|
+
onOpenChange: (open) => onOpenChange?.(open),
|
|
42
|
+
allowsEmptyCollection: true,
|
|
43
|
+
isDisabled,
|
|
44
|
+
isReadOnly: readOnly,
|
|
45
|
+
isRequired,
|
|
46
|
+
validationBehavior: "native"
|
|
47
|
+
});
|
|
48
|
+
const inputRef = useRef(null);
|
|
49
|
+
const buttonRef = useRef(null);
|
|
50
|
+
const popoverRef = useRef(null);
|
|
51
|
+
const listBoxRef = useRef(null);
|
|
52
|
+
const { inputProps, buttonProps, listBoxProps, isInvalid } = useComboBox({
|
|
53
|
+
inputRef,
|
|
54
|
+
buttonRef,
|
|
55
|
+
popoverRef,
|
|
56
|
+
listBoxRef,
|
|
57
|
+
id: control.id,
|
|
58
|
+
"aria-label": ariaLabel,
|
|
59
|
+
"aria-labelledby": ariaLabelledBy ?? field?.labelId,
|
|
60
|
+
isDisabled,
|
|
61
|
+
isReadOnly: readOnly,
|
|
62
|
+
isRequired,
|
|
63
|
+
validationBehavior: "native"
|
|
64
|
+
}, state);
|
|
65
|
+
const { buttonProps: chevronProps } = useButton(buttonProps, buttonRef);
|
|
66
|
+
const mergedRef = useMemo(() => mergeRefs(ref, inputRef), [ref, inputRef]);
|
|
67
|
+
const showInvalid = control["data-invalid"] === "" || isInvalid;
|
|
68
|
+
const { onKeyDown: ariaKeyDown, ...ariaInputProps } = inputProps;
|
|
69
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
70
|
+
className: wrapperClass,
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsx("input", {
|
|
73
|
+
...mergeProps(props, ariaInputProps),
|
|
74
|
+
ref: mergedRef,
|
|
75
|
+
onKeyDown: (event) => {
|
|
76
|
+
props.onKeyDown?.(event);
|
|
77
|
+
if (!isComposingKey(event)) ariaKeyDown?.(event);
|
|
78
|
+
},
|
|
79
|
+
"aria-describedby": control["aria-describedby"],
|
|
80
|
+
"aria-invalid": showInvalid ? true : control["aria-invalid"],
|
|
81
|
+
"data-invalid": showInvalid ? "" : void 0,
|
|
82
|
+
"data-open": state.isOpen ? "" : void 0,
|
|
83
|
+
className: cn(inputSizeClass[size], inputBaseClass, inputEndClass[size], className)
|
|
84
|
+
}),
|
|
85
|
+
/* @__PURE__ */ jsx("button", {
|
|
86
|
+
...chevronProps,
|
|
87
|
+
ref: buttonRef,
|
|
88
|
+
className: cn(buttonClass, buttonSizeClass[size]),
|
|
89
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, { size: 16 })
|
|
90
|
+
}),
|
|
91
|
+
name !== void 0 && /* @__PURE__ */ jsx("input", {
|
|
92
|
+
type: "hidden",
|
|
93
|
+
name,
|
|
94
|
+
form,
|
|
95
|
+
value: state.selectedKey == null ? "" : String(state.selectedKey),
|
|
96
|
+
disabled: isDisabled
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ jsx(ComboboxPopover, {
|
|
99
|
+
state,
|
|
100
|
+
inputRef,
|
|
101
|
+
popoverRef,
|
|
102
|
+
listBoxRef,
|
|
103
|
+
listBoxProps,
|
|
104
|
+
emptyMessage
|
|
105
|
+
})
|
|
106
|
+
]
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { Combobox };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ListBoxOptionProps } from "../../_internal/components/ListBoxNodes/types.js";
|
|
2
|
+
export interface ComboboxItemProps extends ListBoxOptionProps {}
|
|
3
|
+
/**
|
|
4
|
+
* Combobox의 옵션(`role="option"`). `Combobox`나 `ComboboxSection` 바로 안에 둔다. `value`가 고른 값이고 제출된다.
|
|
5
|
+
* 거르기와 고른 뒤 입력에 들어가는 글자는 `textValue`(기본은 내용의 글자)다.
|
|
6
|
+
*/
|
|
7
|
+
export declare function ComboboxItem(_props: ComboboxItemProps): null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { asCollectionComponent, valueItemCollectionNode } from "../../_internal/libs/listCollection.js";
|
|
4
|
+
|
|
5
|
+
// src/Combobox/components/ComboboxItem.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Combobox의 옵션(`role="option"`). `Combobox`나 `ComboboxSection` 바로 안에 둔다. `value`가 고른 값이고 제출된다.
|
|
8
|
+
* 거르기와 고른 뒤 입력에 들어가는 글자는 `textValue`(기본은 내용의 글자)다.
|
|
9
|
+
*/
|
|
10
|
+
function ComboboxItem(_props) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
asCollectionComponent(ComboboxItem, valueItemCollectionNode);
|
|
14
|
+
|
|
15
|
+
export { ComboboxItem };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { OverlayPortal } from "../../_internal/components/OverlayPortal.js";
|
|
4
|
+
import { useOverlayPresence } from "../../_internal/hooks/useOverlayPresence.js";
|
|
5
|
+
import { ComboboxPopoverInner } from "./ComboboxPopoverInner.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
// src/Combobox/components/ComboboxPopover.tsx
|
|
9
|
+
function ComboboxPopover(props) {
|
|
10
|
+
if (!useOverlayPresence(props.state.isOpen, props.popoverRef)) return null;
|
|
11
|
+
return /* @__PURE__ */ jsx(OverlayPortal, {
|
|
12
|
+
isExiting: !props.state.isOpen,
|
|
13
|
+
focusManagement: false,
|
|
14
|
+
children: /* @__PURE__ */ jsx(ComboboxPopoverInner, { ...props })
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { ComboboxPopover };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { ListBoxNodes } from "../../_internal/components/ListBoxNodes/ListBoxNodes.js";
|
|
4
|
+
import { listPopupClass } from "../../_internal/constants/listClass.js";
|
|
5
|
+
import { useOverlayTheme } from "../../_internal/hooks/useOverlayTheme.js";
|
|
6
|
+
import { usePopoverOverlay } from "../../_internal/hooks/usePopoverOverlay.js";
|
|
7
|
+
import { emptyClass } from "../constants/comboboxClass.js";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { useLayoutEffect } from "react";
|
|
10
|
+
import { useListBox } from "react-aria";
|
|
11
|
+
|
|
12
|
+
// src/Combobox/components/ComboboxPopoverInner.tsx
|
|
13
|
+
function ComboboxPopoverInner({ state, inputRef, popoverRef, listBoxRef, listBoxProps, emptyMessage }) {
|
|
14
|
+
useOverlayTheme(inputRef, popoverRef);
|
|
15
|
+
useLayoutEffect(() => {
|
|
16
|
+
const popover = popoverRef.current;
|
|
17
|
+
const width = inputRef.current?.offsetWidth;
|
|
18
|
+
if (popover && width) popover.style.minWidth = `min(${width}px, 100vw - 24px)`;
|
|
19
|
+
}, [inputRef, popoverRef]);
|
|
20
|
+
const { overlayProps } = usePopoverOverlay({
|
|
21
|
+
triggerRef: inputRef,
|
|
22
|
+
popoverRef,
|
|
23
|
+
placement: "bottom start",
|
|
24
|
+
offset: 4,
|
|
25
|
+
nonModal: true
|
|
26
|
+
}, state);
|
|
27
|
+
const { listBoxProps: listProps } = useListBox(listBoxProps, state, listBoxRef);
|
|
28
|
+
const empty = state.collection.size === 0;
|
|
29
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
30
|
+
...overlayProps,
|
|
31
|
+
ref: popoverRef,
|
|
32
|
+
"data-open": state.isOpen ? "" : void 0,
|
|
33
|
+
className: listPopupClass,
|
|
34
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
35
|
+
...listProps,
|
|
36
|
+
ref: listBoxRef,
|
|
37
|
+
className: "outline-none",
|
|
38
|
+
children: /* @__PURE__ */ jsx(ListBoxNodes, { state })
|
|
39
|
+
}), empty && /* @__PURE__ */ jsx("div", {
|
|
40
|
+
className: "px-2 py-1.5 text-body-sm text-muted select-none",
|
|
41
|
+
children: emptyMessage
|
|
42
|
+
})]
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { ComboboxPopoverInner };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ListBoxSectionProps } from "../../_internal/components/ListBoxNodes/types.js";
|
|
2
|
+
export interface ComboboxSectionProps extends ListBoxSectionProps {}
|
|
3
|
+
/**
|
|
4
|
+
* 옵션 묶음(`role="group"`). `heading`이 보이는 제목이자 이름이고, 없으면 `aria-label`이 이름이다.
|
|
5
|
+
* 거른 결과 묶음 안에 남은 옵션이 없으면 묶음도 빠진다.
|
|
6
|
+
*/
|
|
7
|
+
export declare function ComboboxSection(_props: ComboboxSectionProps): null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { asCollectionComponent, sectionCollectionNode } from "../../_internal/libs/listCollection.js";
|
|
4
|
+
|
|
5
|
+
// src/Combobox/components/ComboboxSection.tsx
|
|
6
|
+
/**
|
|
7
|
+
* 옵션 묶음(`role="group"`). `heading`이 보이는 제목이자 이름이고, 없으면 `aria-label`이 이름이다.
|
|
8
|
+
* 거른 결과 묶음 안에 남은 옵션이 없으면 묶음도 빠진다.
|
|
9
|
+
*/
|
|
10
|
+
function ComboboxSection(_props) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
asCollectionComponent(ComboboxSection, sectionCollectionNode);
|
|
14
|
+
|
|
15
|
+
export { ComboboxSection };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/Combobox/constants/comboboxClass.ts
|
|
2
|
+
const wrapperClass = "flex w-full";
|
|
3
|
+
const inputEndClass = {
|
|
4
|
+
sm: "pe-[34px]",
|
|
5
|
+
md: "pe-9",
|
|
6
|
+
lg: "pe-10"
|
|
7
|
+
};
|
|
8
|
+
const buttonSizeClass = {
|
|
9
|
+
sm: "-ms-[35px] w-[35px] pe-[11px]",
|
|
10
|
+
md: "-ms-[37px] w-[37px] pe-[13px]",
|
|
11
|
+
lg: "-ms-[41px] w-[41px] pe-[17px]"
|
|
12
|
+
};
|
|
13
|
+
const buttonClass = "inline-flex shrink-0 cursor-pointer items-center justify-end text-muted outline-none disabled:cursor-not-allowed disabled:text-disabled";
|
|
14
|
+
const emptyClass = "px-2 py-1.5 text-body-sm text-muted select-none";
|
|
15
|
+
|
|
16
|
+
export { buttonClass, buttonSizeClass, emptyClass, inputEndClass, wrapperClass };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Combobox, ComboboxProps } from "./Combobox.js";
|
|
2
|
+
import { ComboboxItem, ComboboxItemProps } from "./components/ComboboxItem.js";
|
|
3
|
+
import { ComboboxSection, ComboboxSectionProps } from "./components/ComboboxSection.js";
|
|
4
|
+
export { Combobox, ComboboxItem, type ComboboxItemProps, type ComboboxProps, ComboboxSection, type ComboboxSectionProps };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DialogProps } from "../_internal/components/DialogRoot.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* 트리거와 내용을 잇는 열림 상태. DOM 요소를 만들지 않는다.
|
|
5
|
+
* 안에 `DialogTrigger`와 `DialogContent`를 둔다. 트리거 없이 `open`으로 제어해 열어도 된다.
|
|
6
|
+
*/
|
|
7
|
+
export declare function Dialog(props: DialogProps): ReactElement;
|
|
8
|
+
export type { DialogProps };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { DialogRoot } from "../_internal/components/DialogRoot.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
// src/Dialog/Dialog.tsx
|
|
7
|
+
/**
|
|
8
|
+
* 트리거와 내용을 잇는 열림 상태. DOM 요소를 만들지 않는다.
|
|
9
|
+
* 안에 `DialogTrigger`와 `DialogContent`를 둔다. 트리거 없이 `open`으로 제어해 열어도 된다.
|
|
10
|
+
*/
|
|
11
|
+
function Dialog(props) {
|
|
12
|
+
return /* @__PURE__ */ jsx(DialogRoot, {
|
|
13
|
+
...props,
|
|
14
|
+
alert: false
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { Dialog };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ComponentProps, ReactElement } from "react";
|
|
2
|
+
export interface DialogCloseProps extends ComponentProps<"button"> {
|
|
3
|
+
/** 다른 요소로 렌더한다(예: `render={<Button variant="ghost" color="neutral" />}`). 기본은 class 없는 `<button type="button">`. */
|
|
4
|
+
render?: ReactElement;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 누르면 Dialog를 닫는 버튼. `onClick`을 먼저 부르고, 그 안에서 `event.preventDefault()`를 부르면 닫지 않는다.
|
|
8
|
+
* 닫히면 포커스는 열기 전 요소로 돌아간다.
|
|
9
|
+
*/
|
|
10
|
+
export declare function DialogClose({ render, onClick, className, ...props }: DialogCloseProps): ReactElement;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useDialogContext } from "../../_internal/hooks/useDialogContext.js";
|
|
4
|
+
import { renderElement } from "../../_internal/libs/renderElement.js";
|
|
5
|
+
import { createElement } from "react";
|
|
6
|
+
|
|
7
|
+
// src/Dialog/components/DialogClose.tsx
|
|
8
|
+
/**
|
|
9
|
+
* 누르면 Dialog를 닫는 버튼. `onClick`을 먼저 부르고, 그 안에서 `event.preventDefault()`를 부르면 닫지 않는다.
|
|
10
|
+
* 닫히면 포커스는 열기 전 요소로 돌아간다.
|
|
11
|
+
*/
|
|
12
|
+
function DialogClose({ render, onClick, className, ...props }) {
|
|
13
|
+
const { state } = useDialogContext("DialogClose");
|
|
14
|
+
const handleClick = (event) => {
|
|
15
|
+
onClick?.(event);
|
|
16
|
+
if (!event.defaultPrevented) state.close();
|
|
17
|
+
};
|
|
18
|
+
const merged = {
|
|
19
|
+
...props,
|
|
20
|
+
onClick: handleClick,
|
|
21
|
+
className
|
|
22
|
+
};
|
|
23
|
+
if (!render) return createElement("button", {
|
|
24
|
+
type: "button",
|
|
25
|
+
...merged
|
|
26
|
+
});
|
|
27
|
+
return renderElement({
|
|
28
|
+
defaultElement: "button",
|
|
29
|
+
render,
|
|
30
|
+
baseClassName: "",
|
|
31
|
+
props: merged
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { DialogClose };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DialogSize } from "../types.js";
|
|
2
|
+
import { ComponentProps, ReactElement } from "react";
|
|
3
|
+
export interface DialogContentProps extends Omit<ComponentProps<"div">, "id" | "role"> {
|
|
4
|
+
/** 최대 폭. 기본값은 `md`(32rem)다. 화면이 좁으면 화면 폭 − 32px까지 줄어든다. */
|
|
5
|
+
size?: DialogSize;
|
|
6
|
+
/** 닫기 버튼(IconButton)의 이름. 기본값은 `"닫기"`다. AlertDialog에는 닫기 버튼이 없어 쓰지 않는다. */
|
|
7
|
+
closeLabel?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 화면 가운데 뜨는 모달 내용(`role="dialog"`, AlertDialog 안에서는 `alertdialog`). 열릴 때만 `document.body`에 portal한다.
|
|
11
|
+
* Dialog는 끝 위쪽 닫기 버튼과 바깥 막 누름으로 닫히고, AlertDialog는 둘 다 없다(Esc는 닫는다).
|
|
12
|
+
*/
|
|
13
|
+
export declare function DialogContent(props: DialogContentProps): ReactElement | null;
|