@tide-design/components 0.11.2 → 0.11.4
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 +3 -12
- package/dist/Accordion/Accordion.js +1 -4
- package/dist/Accordion/components/AccordionPanel.d.ts +1 -4
- package/dist/Accordion/components/AccordionTrigger.d.ts +3 -7
- package/dist/Accordion/components/AccordionTrigger.js +2 -3
- package/dist/Alert/Alert.d.ts +8 -16
- package/dist/Alert/Alert.js +1 -4
- package/dist/Avatar/Avatar.d.ts +2 -4
- package/dist/Avatar/Avatar.js +1 -5
- package/dist/Badge/Badge.d.ts +5 -20
- package/dist/Badge/Badge.js +1 -5
- package/dist/Breadcrumb/Breadcrumb.d.ts +3 -4
- package/dist/Breadcrumb/Breadcrumb.js +2 -3
- package/dist/Breadcrumb/components/BreadcrumbCurrent.d.ts +1 -1
- package/dist/Breadcrumb/components/BreadcrumbCurrent.js +1 -1
- package/dist/Breadcrumb/components/BreadcrumbLink.d.ts +2 -5
- package/dist/Breadcrumb/components/BreadcrumbLink.js +1 -1
- package/dist/Button/Button.d.ts +7 -20
- package/dist/Button/Button.js +1 -4
- package/dist/Button/constants/buttonClass.js +2 -2
- package/dist/Checkbox/Checkbox.d.ts +6 -15
- package/dist/Checkbox/Checkbox.js +1 -6
- package/dist/CheckboxGroup/CheckboxGroup.d.ts +3 -6
- package/dist/CheckboxGroup/CheckboxGroup.js +2 -2
- package/dist/Combobox/Combobox.d.ts +6 -16
- package/dist/Combobox/Combobox.js +2 -12
- package/dist/Combobox/components/ComboboxItem.d.ts +2 -4
- package/dist/Combobox/components/ComboboxItem.js +2 -4
- package/dist/Combobox/components/ComboboxPopover.js +0 -5
- package/dist/Combobox/components/ComboboxPopoverInner.js +0 -4
- package/dist/Combobox/components/ComboboxSection.d.ts +1 -1
- package/dist/Combobox/components/ComboboxSection.js +1 -1
- package/dist/Combobox/constants/comboboxClass.js +0 -5
- package/dist/Dialog/Dialog.d.ts +1 -1
- package/dist/Dialog/Dialog.js +1 -1
- package/dist/Dialog/components/DialogClose.d.ts +1 -4
- package/dist/Dialog/components/DialogContent.d.ts +2 -4
- package/dist/Dialog/components/DialogContent.js +2 -4
- package/dist/Dialog/components/DialogTrigger.d.ts +1 -1
- package/dist/Dialog/components/DialogTrigger.js +1 -1
- package/dist/Field/Field.d.ts +4 -11
- package/dist/Field/Field.js +2 -4
- package/dist/IconButton/IconButton.d.ts +10 -25
- package/dist/IconButton/IconButton.js +1 -6
- package/dist/Link/Link.d.ts +3 -13
- package/dist/Link/Link.js +1 -4
- package/dist/Menu/Menu.d.ts +1 -4
- package/dist/Menu/Menu.js +1 -4
- package/dist/Menu/components/MenuContent.d.ts +2 -3
- package/dist/Menu/components/MenuContent.js +2 -3
- package/dist/Menu/components/MenuContentInner.js +0 -1
- package/dist/Menu/components/MenuItem.d.ts +1 -5
- package/dist/Menu/components/MenuItem.js +0 -1
- package/dist/Menu/components/MenuItemView.js +0 -1
- package/dist/Menu/components/MenuSection.d.ts +1 -1
- package/dist/Menu/components/MenuSection.js +1 -1
- package/dist/Menu/components/MenuSectionView.js +0 -1
- package/dist/Menu/components/MenuTrigger.d.ts +4 -4
- package/dist/Menu/components/MenuTrigger.js +2 -2
- package/dist/Pagination/Pagination.d.ts +3 -4
- package/dist/Pagination/Pagination.js +2 -3
- package/dist/Pagination/components/PaginationEllipsis.d.ts +2 -2
- package/dist/Pagination/components/PaginationEllipsis.js +1 -1
- package/dist/Pagination/components/PaginationLink.d.ts +2 -5
- package/dist/Pagination/components/PaginationLink.js +1 -4
- package/dist/Pagination/types.d.ts +1 -1
- package/dist/Popover/components/PopoverContent.d.ts +1 -2
- package/dist/Popover/components/PopoverContent.js +1 -2
- package/dist/Progress/Progress.d.ts +5 -13
- package/dist/Progress/Progress.js +1 -5
- package/dist/Radio/Radio.d.ts +6 -12
- package/dist/Radio/Radio.js +1 -5
- package/dist/Select/Select.d.ts +5 -15
- package/dist/Select/Select.js +1 -5
- package/dist/Select/components/SelectItem.d.ts +1 -3
- package/dist/Select/components/SelectItem.js +1 -3
- package/dist/Select/components/SelectPopoverInner.js +1 -4
- package/dist/Separator/Separator.d.ts +2 -9
- package/dist/Separator/Separator.js +1 -4
- package/dist/Skeleton/Skeleton.d.ts +4 -8
- package/dist/Skeleton/Skeleton.js +1 -1
- package/dist/Spinner/Spinner.d.ts +2 -8
- package/dist/Spinner/Spinner.js +1 -3
- package/dist/Switch/Switch.d.ts +4 -10
- package/dist/Switch/Switch.js +1 -4
- package/dist/Tabs/Tabs.d.ts +2 -8
- package/dist/Tabs/components/Tab.d.ts +1 -2
- package/dist/Tabs/components/Tab.js +1 -2
- package/dist/Tabs/components/TabPanel.d.ts +1 -1
- package/dist/Tabs/components/TabPanel.js +1 -1
- package/dist/Tag/Tag.d.ts +1 -5
- package/dist/Tag/components/TagGroup.d.ts +5 -8
- package/dist/Tag/components/TagGroup.js +2 -3
- package/dist/Tag/components/TagView.js +0 -1
- package/dist/Textarea/Textarea.d.ts +1 -4
- package/dist/Textarea/Textarea.js +0 -1
- package/dist/Toast/Toast.d.ts +2 -4
- package/dist/Toast/Toast.js +1 -1
- package/dist/Toast/libs/toastQueue.d.ts +1 -8
- package/dist/Toast/libs/toastQueue.js +1 -8
- package/dist/Toast/types.d.ts +5 -9
- package/dist/Tooltip/components/TooltipContent.d.ts +1 -2
- package/dist/Tooltip/components/TooltipContent.js +1 -2
- package/dist/Tooltip/components/TooltipTrigger.d.ts +2 -3
- package/dist/Typography/Typography.d.ts +4 -10
- package/dist/Typography/Typography.js +2 -2
- package/dist/_internal/components/ListBoxNodes/ListBoxNodes.js +1 -3
- package/dist/_internal/components/ListBoxNodes/components/ListBoxOptionView.js +1 -4
- package/dist/_internal/components/OverlayPortal.js +2 -4
- package/dist/_internal/constants/alertClass.js +7 -20
- package/dist/_internal/constants/choiceClass.js +2 -2
- package/dist/_internal/constants/choiceGroupClass.d.ts +0 -1
- package/dist/_internal/constants/choiceGroupClass.js +0 -1
- package/dist/_internal/constants/inputClass.d.ts +1 -1
- package/dist/_internal/constants/inputClass.js +1 -2
- package/dist/_internal/constants/listClass.js +4 -29
- package/dist/_internal/constants/overlayClass.js +9 -53
- package/dist/_internal/constants/pressableClass.js +3 -6
- package/dist/_internal/hooks/useChoiceGroup.js +1 -4
- package/dist/_internal/hooks/useCloseOnTab.js +2 -8
- package/dist/_internal/hooks/useFieldControl.js +1 -4
- package/dist/_internal/hooks/useOverlayPresence.js +1 -7
- package/dist/_internal/hooks/useOverlayTheme.js +1 -5
- package/dist/_internal/hooks/usePopoverOverlay.js +1 -7
- package/dist/_internal/libs/listCollection.js +5 -23
- package/dist/_internal/libs/overlayPosition.d.ts +1 -4
- package/dist/_internal/libs/overlayPosition.js +2 -5
- package/dist/_internal/libs/pressableState.js +2 -5
- package/dist/_internal/libs/renderElement.js +1 -1
- package/dist/types.d.ts +2 -5
- package/package.json +14 -3
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ComponentProps, ReactElement } from "react";
|
|
2
2
|
export interface TooltipTriggerProps extends ComponentProps<"button"> {
|
|
3
3
|
/**
|
|
4
|
-
* 다른 요소로
|
|
5
|
-
*
|
|
6
|
-
* 포커스를 받을 수 있는 요소여야 키보드 사용자도 설명을 본다.
|
|
4
|
+
* 다른 요소로 렌더하고 props·ref·이벤트 핸들러를 병합한다(예: `render={<IconButton aria-label="복사" />}`).
|
|
5
|
+
* 기본은 class 없는 `<button type="button">`. 포커스를 받을 수 있는 요소여야 키보드 사용자도 설명을 본다.
|
|
7
6
|
*/
|
|
8
7
|
render?: ReactElement;
|
|
9
8
|
}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import { HTMLAttributes, ReactElement, Ref } from "react";
|
|
2
2
|
import { TextStyleName } from "@tide-design/foundation";
|
|
3
|
-
/** heading·display 텍스트 스타일. 항상 `<h*>`로 렌더되고 `level`을 받는다. */
|
|
4
3
|
type HeadingVariant = Extract<TextStyleName, `display-${string}` | `heading-${string}`>;
|
|
5
|
-
/** heading·display가 아닌 텍스트 스타일 */
|
|
6
4
|
type TextVariant = Exclude<TextStyleName, HeadingVariant>;
|
|
7
|
-
/** 제목 단계 */
|
|
8
5
|
type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
9
6
|
interface TypographyBaseProps extends HTMLAttributes<HTMLElement> {
|
|
10
7
|
/** 루트 DOM 요소에 연결한다. */
|
|
11
8
|
ref?: Ref<HTMLElement>;
|
|
12
|
-
/**
|
|
13
|
-
* 다른 요소로 렌더한다. 예: `render={<label htmlFor="name" />}`.
|
|
14
|
-
* props, ref, className을 그 요소에 병합하고 `level`과 기본 요소는 무시한다.
|
|
15
|
-
*/
|
|
9
|
+
/** 다른 요소로 렌더한다. 예: `render={<label htmlFor="name" />}`. 이때 `level`은 무시한다. */
|
|
16
10
|
render?: ReactElement;
|
|
17
11
|
}
|
|
18
12
|
interface TypographyHeadingProps extends TypographyBaseProps {
|
|
@@ -22,15 +16,15 @@ interface TypographyHeadingProps extends TypographyBaseProps {
|
|
|
22
16
|
level?: HeadingLevel;
|
|
23
17
|
}
|
|
24
18
|
interface TypographyTextProps extends TypographyBaseProps {
|
|
25
|
-
/** 텍스트 스타일 이름.
|
|
19
|
+
/** 텍스트 스타일 이름. 기본값 `body-md`. */
|
|
26
20
|
variant?: TextVariant;
|
|
27
21
|
/** heading·display 텍스트 스타일에만 있다. */
|
|
28
22
|
level?: never;
|
|
29
23
|
}
|
|
30
24
|
export type TypographyProps = TypographyHeadingProps | TypographyTextProps;
|
|
31
25
|
/**
|
|
32
|
-
* 텍스트 스타일 하나로
|
|
33
|
-
* heading·display는 항상 `<h*>`다. 다른
|
|
26
|
+
* 텍스트 스타일 하나로 크기·행간·굵기를 정하고 알맞은 시맨틱 요소로 렌더한다.
|
|
27
|
+
* heading·display는 항상 `<h*>`다. 다른 요소는 `render`로. 서버 컴포넌트로 쓸 수 있다.
|
|
34
28
|
*/
|
|
35
29
|
export declare function Typography({ variant, level, render, ...props }: TypographyProps): ReactElement;
|
|
36
30
|
export {};
|
|
@@ -34,8 +34,8 @@ const elementByVariant = {
|
|
|
34
34
|
caption: "p"
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
|
-
* 텍스트 스타일 하나로
|
|
38
|
-
* heading·display는 항상 `<h*>`다. 다른
|
|
37
|
+
* 텍스트 스타일 하나로 크기·행간·굵기를 정하고 알맞은 시맨틱 요소로 렌더한다.
|
|
38
|
+
* heading·display는 항상 `<h*>`다. 다른 요소는 `render`로. 서버 컴포넌트로 쓸 수 있다.
|
|
39
39
|
*/
|
|
40
40
|
function Typography({ variant = "body-md", level, render, ...props }) {
|
|
41
41
|
const element = elementByVariant[variant];
|
|
@@ -7,9 +7,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
7
7
|
|
|
8
8
|
// src/_internal/components/ListBoxNodes/ListBoxNodes.tsx
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* 구분선은 그리지 않는다(Menu와 같다). listbox의 자식은 option·group만 될 수 있어(WAI-ARIA, axe
|
|
12
|
-
* aria-required-children) Menu와 달리 구분선은 `separator` 역할 없이 보조기술에서 숨긴다. 묶음 경계는 group이 알린다.
|
|
10
|
+
* 구분선은 `separator` 역할 없이 보조기술에서 숨긴다. listbox의 자식은 option·group만 될 수 있다(axe aria-required-children).
|
|
13
11
|
*/
|
|
14
12
|
function ListBoxNodes({ state }) {
|
|
15
13
|
const nodes = [...state.collection];
|
|
@@ -8,10 +8,7 @@ import { CheckIcon } from "@tide-design/icons";
|
|
|
8
8
|
import { mergeProps, mergeRefs, useOption } from "react-aria";
|
|
9
9
|
|
|
10
10
|
// src/_internal/components/ListBoxNodes/components/ListBoxOptionView.tsx
|
|
11
|
-
/**
|
|
12
|
-
* 고른 옵션 끝의 체크 아이콘. 장식용이다(선택은 `aria-selected`가 알린다). 배경(subtle-active)이 지워지는 고대비
|
|
13
|
-
* 모드에서도 고른 옵션이 보이게 한다. 글자와의 간격은 항목의 gap(8px)이고 `ms-auto`로 오른쪽 끝에 붙는다.
|
|
14
|
-
*/
|
|
11
|
+
/** 체크 아이콘은 장식용이지만, 배경이 지워지는 고대비 모드에서 고른 옵션을 보이게 한다. */
|
|
15
12
|
const checkClass = "ms-auto";
|
|
16
13
|
/** 옵션 하나를 그린다. node.props는 앱이 옵션에 준 props(와 컬렉션이 더한 isDisabled)다. */
|
|
17
14
|
function ListBoxOptionView({ node, state }) {
|
|
@@ -5,10 +5,8 @@ import { Overlay } from "react-aria";
|
|
|
5
5
|
|
|
6
6
|
// src/_internal/components/OverlayPortal.tsx
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* 역할 hook이 포커스 가두기를 요청하면(`useDialog` 등) Tab이 안에서 돈다. 서버 렌더에서는 아무것도 그리지 않는다.
|
|
11
|
-
* `focusManagement={false}`면 FocusScope 없이 portal만 한다(Tooltip).
|
|
8
|
+
* `document.body`에 portal하고 `FocusScope`(`restoreFocus`)로 감싸 닫힐 때 포커스를 트리거로 돌린다.
|
|
9
|
+
* top-layer(`<dialog>`, popover API)는 쓰지 않는다.
|
|
12
10
|
*/
|
|
13
11
|
function OverlayPortal({ isExiting, focusManagement = true, children }) {
|
|
14
12
|
return /* @__PURE__ */ jsx(Overlay, {
|
|
@@ -1,31 +1,18 @@
|
|
|
1
1
|
// src/_internal/constants/alertClass.ts
|
|
2
|
-
/**
|
|
3
|
-
* 배치. 아이콘·내용·닫기 버튼을 한 줄로 놓고 위에 맞춘다. 여백은 16px, radius는 담는 요소의 lg다(spec radius 「쓰는 곳」).
|
|
4
|
-
* border 1px는 항상 둔다. forced-colors에서 브라우저가 경계를 CanvasText로 덮어 배경 없이도 영역이 남는다.
|
|
5
|
-
*/
|
|
2
|
+
/** border는 항상 둔다. forced-colors에서 배경 없이도 영역이 남는다. */
|
|
6
3
|
const alertLayoutClass = "flex items-start gap-3 rounded-lg border p-4";
|
|
7
|
-
/**
|
|
8
|
-
* Alert의 subtle 표면(ADR 0022 §1).
|
|
9
|
-
* - 글자·아이콘: text-accent-on-subtle × bg-accent-subtle 4.5:1(Role `text-<role>-on-subtle` × `bg-<role>-subtle`, neutral은
|
|
10
|
-
* text-default × bg-neutral-subtle, 앱 Role은 색 이름 규칙 on-subtle × subtle)
|
|
11
|
-
* - 경계: 파스텔 테두리 border-accent-subtle. 바탕과 글자만으로 알아볼 수 있어 꾸밈이고 대비 검사에서 뺐다.
|
|
12
|
-
*/
|
|
4
|
+
/** subtle 표면(ADR 0022). 파스텔 테두리는 꾸밈이라 대비 검사에서 뺐다. */
|
|
13
5
|
const alertSurfaceClass = "border-accent-subtle bg-accent-subtle text-accent-on-subtle";
|
|
14
|
-
/**
|
|
6
|
+
/** 글자 첫 줄 높이(20px)와 같아 첫 줄 가운데에 맞는다. */
|
|
15
7
|
const alertIconClass = "size-5 shrink-0";
|
|
16
|
-
/**
|
|
8
|
+
/** 긴 단어가 닫기 버튼을 밀어내지 않게 min-w-0을 둔다. */
|
|
17
9
|
const alertContentClass = "flex min-w-0 flex-1 flex-col gap-1";
|
|
18
|
-
/**
|
|
10
|
+
/** 제목 수준은 화면마다 달라 heading 요소를 쓰지 않는다. */
|
|
19
11
|
const alertTitleClass = "text-body-sm font-semibold";
|
|
20
|
-
/** 본문 */
|
|
21
12
|
const alertDescriptionClass = "text-body-sm";
|
|
22
|
-
/** 닫기 버튼(
|
|
13
|
+
/** 닫기 버튼(24px)을 음수 margin으로 겹쳐 첫 줄 높이(20px)를 늘리지 않는다. */
|
|
23
14
|
const alertCloseClass = "-my-0.5 -me-1";
|
|
24
|
-
/**
|
|
25
|
-
* Alert(subtle 표면) 안 닫기 버튼의 색. ghost의 기본(text-accent, bg-hover·bg-active)을 덮어쓴다.
|
|
26
|
-
* subtle 바탕 위라 글자는 on-subtle이고, hover·누름은 같은 색의 subtle-hover·subtle-active다
|
|
27
|
-
* (on-subtle × subtle 4.5:1, × subtle-hover·subtle-active 4:1 등록, ADR 0022·0023).
|
|
28
|
-
*/
|
|
15
|
+
/** subtle 바탕 위 닫기 버튼. ghost 기본 색을 on-subtle·subtle-hover·subtle-active로 덮어쓴다(ADR 0022·0023). */
|
|
29
16
|
const alertSubtleCloseClass = "text-accent-on-subtle hover:bg-accent-subtle-hover active:bg-accent-subtle-active";
|
|
30
17
|
|
|
31
18
|
export { alertCloseClass, alertContentClass, alertDescriptionClass, alertIconClass, alertLayoutClass, alertSubtleCloseClass, alertSurfaceClass, alertTitleClass };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// src/_internal/constants/choiceClass.ts
|
|
2
2
|
/** 루트 label. 글자 크기 class와 사용자 className은 뒤에 붙인다. */
|
|
3
3
|
const choiceRootClass = "group/choice inline-flex items-start gap-2 align-top text-default cursor-pointer has-disabled:cursor-not-allowed has-disabled:text-disabled";
|
|
4
|
-
/**
|
|
4
|
+
/** 상자보다 큰 24×24 조작 영역(WCAG 2.5.8). */
|
|
5
5
|
const choiceAreaClass = "grid size-6 shrink-0 place-items-center";
|
|
6
|
-
/** 네이티브 input을 상자로 그린다.
|
|
6
|
+
/** 네이티브 input을 상자로 그린다. group-hover가 checked:보다 우선순위가 높아 체크 전 규칙에 not-checked를 붙인다. */
|
|
7
7
|
const choiceInputClass = "peer col-start-1 row-start-1 m-0 appearance-none border border-strong bg-canvas cursor-pointer transition-colors checked:border-accent checked:bg-accent-solid enabled:not-checked:not-indeterminate:group-hover/choice:bg-accent-subtle enabled:checked:group-hover/choice:bg-accent-solid-hover indeterminate:border-accent indeterminate:bg-accent-solid enabled:indeterminate:group-hover/choice:bg-accent-solid-hover enabled:not-checked:not-indeterminate:group-active/choice:bg-accent-subtle-active enabled:checked:group-active/choice:bg-accent-solid-active enabled:indeterminate:group-active/choice:bg-accent-solid-active aria-invalid:border-danger focus-visible:focus-ring disabled:cursor-not-allowed disabled:border-default disabled:bg-disabled forced-colors:forced-color-adjust-none forced-colors:[--tide-bg-canvas:Canvas] forced-colors:[--tide-border-strong:CanvasText] forced-colors:[--tide-border-danger:CanvasText] forced-colors:[--tide-accent-border:Highlight] forced-colors:[--tide-accent-solid:Highlight] forced-colors:[--tide-accent-solid-hover:Highlight] forced-colors:[--tide-accent-solid-active:Highlight] forced-colors:[--tide-accent-subtle:Canvas] forced-colors:[--tide-accent-subtle-active:Canvas] forced-colors:[--tide-border-default:GrayText] forced-colors:[--tide-bg-disabled:Canvas] forced-colors:[--tide-outline-focus:Highlight]";
|
|
8
8
|
/** 상자 위에 겹치는 표시 아이콘. 누름은 input이 받는다. 보이는 조건 class는 Component가 붙인다. */
|
|
9
9
|
const choiceMarkClass = "pointer-events-none col-start-1 row-start-1 hidden text-accent-on-solid peer-disabled:text-disabled forced-colors:forced-color-adjust-none forced-colors:[--tide-accent-on-solid:HighlightText] forced-colors:[--tide-text-disabled:GrayText]";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// src/_internal/constants/inputClass.ts
|
|
2
|
-
/**
|
|
2
|
+
/** size class 뒤에 넣는다. */
|
|
3
3
|
const inputBaseClass = "w-full min-w-0 rounded-md border border-strong bg-canvas font-normal text-default transition-colors placeholder:text-muted aria-invalid:border-danger focus:focus-field disabled:cursor-not-allowed disabled:border-default disabled:bg-disabled disabled:text-disabled disabled:placeholder:text-disabled";
|
|
4
|
-
/** 높이, 좌우 padding, 텍스트 스타일(spec size 표). radius는 모든 size에서 `md`다. */
|
|
5
4
|
const inputSizeClass = {
|
|
6
5
|
sm: "h-8 px-2.5 text-label-md",
|
|
7
6
|
md: "h-10 px-3 text-label-md",
|
|
@@ -1,35 +1,11 @@
|
|
|
1
1
|
import { frequentMotionClass, overlaySurfaceClass } from "./overlayClass.js";
|
|
2
2
|
|
|
3
3
|
// src/_internal/constants/listClass.ts
|
|
4
|
-
/**
|
|
5
|
-
* 목록 오버레이(Menu 목록, Select·Combobox 목록)의 루트. 요소에 `data-open`이 있어야 한다(`frequentMotionClass`).
|
|
6
|
-
*
|
|
7
|
-
* - 표면: raised + `shadow-md` + radius `lg` + `border-raised`(overlaySurfaceClass).
|
|
8
|
-
* - 여백: 3px. 바깥 radius 8px = 항목 radius 4px + 여백 3px + border 1px(spec 중첩 규칙).
|
|
9
|
-
* - 크기: 폭은 내용에 맞추되 10rem(`min-w-40`)~20rem(`max-w-80`). 높이는 React Aria가 `max-height`로 화면 안에
|
|
10
|
-
* 맞추고 넘치면 스크롤한다(`overflow-auto`).
|
|
11
|
-
* - 쌓임: `z-popover`(300)라 Dialog(`z-modal`) 위에 보인다. 루트 `isolate`.
|
|
12
|
-
* - 포커스: 목록 자신이 포커스를 받을 때(마우스로 연 직후)는 표시가 없다. 위치 표시는 항목의 highlight가 맡는다.
|
|
13
|
-
* - motion: 「자주 씀」. 바로 나타나고 사라질 때만 opacity `fast`.
|
|
14
|
-
*/
|
|
4
|
+
/** 요소에 `data-open`이 있어야 한다. padding 3px는 radius 중첩 규칙(8 = 4 + 3 + 1)이다. */
|
|
15
5
|
const listPopupClass = `isolate z-popover min-w-40 max-w-80 overflow-auto p-[3px] outline-none ${overlaySurfaceClass} ${frequentMotionClass}`;
|
|
16
6
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* - `data-highlighted`: 키보드 위치(React Aria가 옮긴 포커스 위치)이고, 마우스를 올리면 React Aria가 그 항목으로
|
|
20
|
-
* 위치를 옮기므로 hover도 같은 모양이다. highlight = primary subtle 배경 + primary text 글자 + 투명 outline 2px.
|
|
21
|
-
* 투명 outline은 평소에는 보이지 않고 forced-colors에서 시스템 색으로 그려져 위치가 남는다(그 모드는 배경을 덮는다).
|
|
22
|
-
* 기본 `outline-none`이 outline 모양 변수를 none으로 두므로 `outline-solid`를 함께 쓴다.
|
|
23
|
-
* 항목 안쪽(`-outline-offset-2`)에 그려 이웃 항목·목록 경계와 겹치지 않는다.
|
|
24
|
-
* - `hover`(highlight가 아닐 때): 색 없이 덮는 `bg-hover`(ADR 0022 §3). 키보드로 옮긴 위치가 따로 있을 때
|
|
25
|
-
* 마우스가 다른 항목 위에 있는 경우다. text-default × bg-hover(bg-raised 위 합성)가 4:1(일시 상태, ADR 0023)로 등록되어 있다.
|
|
26
|
-
* - `data-selected`(highlight가 아닐 때): 선택 유지 `subtle-active`(neutral). 상태를 나타내는 바탕이라 덮기로 바꾸지 않는다.
|
|
27
|
-
* Select·Combobox의 고른 옵션이 쓴다.
|
|
28
|
-
* - `data-disabled`: `text-disabled`, `cursor-not-allowed`. hover 배경이 없다.
|
|
29
|
-
* - 상태끼리 겹칠 때 순서에 기대지 않도록 `not-data-highlighted:`로 서로 뺀다.
|
|
30
|
-
* - transition이 없다. 반복되는 목록 항목은 바로 바뀐다(spec 「motion 적용」).
|
|
31
|
-
* - 크기: 세로 6px·가로 8px 여백, `text-body-sm`(14/20)이라 높이 32px. 글자 크기가 트리거(Button·Select `md`, 14px)와 같다. 바로 안의 아이콘(svg, 장식용)은 16px이고
|
|
32
|
-
* 아이콘과 글자 사이는 8px다(Button md와 같은 아이콘 크기).
|
|
7
|
+
* 상태는 boolean `data-*`로 받고 `not-data-highlighted:`로 서로 빼 CSS 순서에 기대지 않는다.
|
|
8
|
+
* highlight의 투명 outline은 forced-colors에서 위치를 남긴다. `outline-none`이 모양을 none으로 두어 `outline-solid`를 함께 쓴다.
|
|
33
9
|
*/
|
|
34
10
|
const listItemClass = [
|
|
35
11
|
"flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-body-sm text-default outline-none select-none [&>svg]:size-4 [&>svg]:shrink-0",
|
|
@@ -38,9 +14,8 @@ const listItemClass = [
|
|
|
38
14
|
"data-highlighted:bg-primary-subtle data-highlighted:text-primary data-highlighted:outline-2 data-highlighted:outline-solid data-highlighted:-outline-offset-2 data-highlighted:outline-transparent",
|
|
39
15
|
"data-disabled:cursor-not-allowed data-disabled:text-disabled"
|
|
40
16
|
].join(" ");
|
|
41
|
-
/**
|
|
17
|
+
/** 항목과 같은 가로 여백이라 글자 시작이 맞는다. */
|
|
42
18
|
const listHeadingClass = "px-2 pt-1.5 pb-1 text-label-sm text-muted select-none";
|
|
43
|
-
/** 묶음 사이 구분선. 장식용 `border-default` 1px, 위아래 4px. */
|
|
44
19
|
const listSeparatorClass = "my-1 h-0 border-t border-default";
|
|
45
20
|
|
|
46
21
|
export { listHeadingClass, listItemClass, listPopupClass, listSeparatorClass };
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
// src/_internal/constants/overlayClass.ts
|
|
2
|
-
/**
|
|
3
|
-
* 오버레이 표면. raised 표면(`bg-raised`), `shadow-md`, radius `lg`, 경계 `border-raised`(light 투명 / dark gray-800).
|
|
4
|
-
* - 글자는 `text-default`다. `text-default × bg-raised` 4.5:1이 등록되어 있다.
|
|
5
|
-
* - `border-raised`는 장식용 경계라 대비 검사에서 빠진다. light의 투명 border는 forced-colors에서 CanvasText로 칠해져
|
|
6
|
-
* 그림자 없이도 경계가 남는다(spec Elevation, 사용자 이야기 37). forced-colors에서는 브라우저가 box-shadow를 지운다.
|
|
7
|
-
*/
|
|
2
|
+
/** light의 투명 border는 forced-colors에서 CanvasText로 칠해져 그림자 없이도 경계가 남는다. */
|
|
8
3
|
const overlaySurfaceClass = "rounded-lg border border-raised bg-raised text-default shadow-md";
|
|
9
4
|
/**
|
|
10
|
-
* 「가끔 씀」
|
|
11
|
-
* `
|
|
12
|
-
*
|
|
13
|
-
* - 등장: `@starting-style`(`starting:`)에서 opacity 0 + blur 4px(`blur-xs`) + 트리거 쪽으로 4px(`*-translate-*-1`)
|
|
14
|
-
* 떨어진 곳에서 시작해 `normal`(300ms)로 제자리에 온다.
|
|
15
|
-
* - 퇴장: `data-open`이 빠지면 같은 조합의 절반(blur 2px, 2px 이동)으로 `fast`(150ms)에 사라진다.
|
|
16
|
-
* duration은 도착 상태의 값을 쓰므로 기본 `duration-fast`에 열림만 `data-open:duration-normal`이다. easing은 둘 다 out이다.
|
|
17
|
-
* - 닫힌 상태는 `display: none`(`hidden`)이고 `transition-discrete`(`transition-behavior: allow-discrete`)로 display도
|
|
18
|
-
* 전환 대상에 넣어, 퇴장 전환이 끝날 때 사라진다. 이 둘을 지원하지 않는 브라우저에서는 바로 나타나고 사라진다.
|
|
19
|
-
* 요소를 DOM에서 빼는 시점은 `useOverlayPresence`가 전환이 끝나기를 기다려 정한다.
|
|
20
|
-
* - 퇴장 중에는 `pointer-events-none`으로 눌리지 않는다.
|
|
21
|
-
* - reduced-motion: 이동·blur와 그 전환 대상(filter, translate)은 `motion-safe:`일 때만 둔다. 움직임 줄이기에서는
|
|
22
|
-
* opacity(와 display)만 같은 시간으로 바뀐다.
|
|
23
|
-
* - `transition-all`은 쓰지 않는다. 전환 대상을 적는다.
|
|
5
|
+
* 「가끔 씀」 오버레이 motion. 요소에 `data-open`과 `data-placement`가 있어야 한다.
|
|
6
|
+
* duration은 도착 상태의 값을 쓰므로 열림만 `data-open:duration-normal`이다. DOM에서 빼는 시점은 `useOverlayPresence`가 정한다.
|
|
24
7
|
*/
|
|
25
8
|
const popoverMotionClass = [
|
|
26
9
|
"transition-[opacity,display] transition-discrete duration-fast ease-out data-open:duration-normal motion-safe:transition-[opacity,filter,translate,display]",
|
|
@@ -32,49 +15,22 @@ const popoverMotionClass = [
|
|
|
32
15
|
"motion-safe:data-[placement=right]:starting:-translate-x-1 motion-safe:data-[placement=left]:starting:translate-x-1"
|
|
33
16
|
].join(" ");
|
|
34
17
|
/**
|
|
35
|
-
* 「자주 씀」 오버레이
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* - 등장: 바로 나타난다. 열린 동안은 `transition-none`이라 퇴장 중에 다시 열려도 바로 불투명해진다.
|
|
39
|
-
* 새로 넣은 요소는 이전 스타일이 없어 전환이 생기지 않으므로 `starting:`도 두지 않는다.
|
|
40
|
-
* - 퇴장: `data-open`이 빠지면 opacity만 `fast`(150ms), out으로 사라진다. 전환 대상은 opacity와 display다.
|
|
41
|
-
* duration·전환 대상은 도착 상태의 값을 쓰므로 닫힌 상태에서만 전환이 있다.
|
|
42
|
-
* - 닫힌 상태는 `display: none`(`hidden`)이고 `transition-discrete`로 퇴장이 끝날 때 사라진다(popoverMotionClass와 같다).
|
|
43
|
-
* DOM에서 빼는 시점은 `useOverlayPresence`가 정한다. 퇴장 중에는 `pointer-events-none`이다.
|
|
44
|
-
* - reduced-motion: 이동·blur·확대가 없으므로 바꿀 것이 없다. opacity 전환은 그대로 둔다.
|
|
18
|
+
* 「자주 씀」 오버레이 motion. 요소에 `data-open`이 있어야 한다.
|
|
19
|
+
* 열린 동안 `transition-none`이라 퇴장 중에 다시 열려도 바로 불투명해진다.
|
|
45
20
|
*/
|
|
46
21
|
const frequentMotionClass = ["transition-[opacity,display] transition-discrete duration-fast ease-out data-open:transition-none", "not-data-open:pointer-events-none not-data-open:hidden not-data-open:opacity-0"].join(" ");
|
|
47
|
-
/**
|
|
48
|
-
* Dialog류(Dialog, AlertDialog) 표면(spec radius·Elevation, 티켓 30). 가운데에 뜨는 모달이라 트리거에 붙는
|
|
49
|
-
* 오버레이보다 한 단계 높다. raised 표면(`bg-raised`), `shadow-lg`, radius `xl`, 경계 `border-raised`.
|
|
50
|
-
* 글자·경계·forced-colors 처리는 `overlaySurfaceClass`와 같다(`text-default × bg-raised` 4.5:1 등록, `border-raised`는 장식용).
|
|
51
|
-
*/
|
|
22
|
+
/** Dialog류 표면. forced-colors 처리는 `overlaySurfaceClass`와 같다. */
|
|
52
23
|
const dialogSurfaceClass = "rounded-xl border border-raised bg-raised text-default shadow-lg";
|
|
53
24
|
/**
|
|
54
|
-
* 모달
|
|
55
|
-
*
|
|
56
|
-
* - 등장: `starting:`에서 opacity 0으로 시작해 `normal`(300ms)로 나타난다. 퇴장: `data-open`이 빠지면 `fast`(150ms)로 사라진다.
|
|
57
|
-
* - 닫힌 상태는 `display: none`(`hidden`) + `transition-discrete`로 퇴장이 끝날 때 사라지고, 퇴장 중에는
|
|
58
|
-
* `pointer-events-none`이다(popoverMotionClass와 같은 구조). 안의 Dialog도 이 값을 물려받아 눌리지 않는다.
|
|
59
|
-
* - opacity만 바뀌므로 움직임 줄이기에서도 같다.
|
|
60
|
-
* - `useOverlayPresence`는 이 요소(막)의 전환이 끝나기를 기다린다. 안의 Dialog 전환(`dialogMotionClass`)도 같은
|
|
61
|
-
* duration이라 함께 끝난다.
|
|
25
|
+
* 모달 backdrop motion. 요소에 `data-open`이 있어야 한다.
|
|
26
|
+
* `useOverlayPresence`는 이 요소의 전환을 기다린다. 안의 Dialog도 같은 duration이라 함께 끝난다.
|
|
62
27
|
*/
|
|
63
28
|
const backdropMotionClass = [
|
|
64
29
|
"transition-[opacity,display] transition-discrete duration-fast ease-out data-open:duration-normal",
|
|
65
30
|
"not-data-open:pointer-events-none not-data-open:hidden not-data-open:opacity-0",
|
|
66
31
|
"starting:opacity-0"
|
|
67
32
|
].join(" ");
|
|
68
|
-
/**
|
|
69
|
-
* Dialog류의 등장·퇴장(spec 「motion 적용」 「가끔 씀」 Dialog류, 티켓 30). 요소에 `data-open`이 있어야 한다.
|
|
70
|
-
*
|
|
71
|
-
* - 등장: `starting:`에서 opacity 0 + scale 0.96(`scale-96`)으로 시작해 `normal`(300ms), out으로 제자리에 온다.
|
|
72
|
-
* - 퇴장: `data-open`이 빠지면 같은 조합을 약하게(scale 0.98, `scale-98`) `fast`(150ms)로 사라진다.
|
|
73
|
-
* duration은 도착 상태의 값을 쓰므로 기본 `duration-fast`에 열림만 `data-open:duration-normal`이다.
|
|
74
|
-
* - 화면에서 빼는 일(display)은 바깥 막(`backdropMotionClass`)이 한다. 이 요소는 opacity·scale만 전환한다.
|
|
75
|
-
* - reduced-motion: 확대(scale)와 그 전환 대상은 `motion-safe:`일 때만 둔다. 움직임 줄이기에서는 opacity만 바뀐다.
|
|
76
|
-
* - `transition-all`은 쓰지 않는다.
|
|
77
|
-
*/
|
|
33
|
+
/** Dialog류 motion. display 전환은 바깥 막(`backdropMotionClass`)이 맡고, 이 요소는 opacity·scale만 바꾼다. */
|
|
78
34
|
const dialogMotionClass = [
|
|
79
35
|
"transition-[opacity] duration-fast ease-out data-open:duration-normal motion-safe:transition-[opacity,scale]",
|
|
80
36
|
"not-data-open:opacity-0 motion-safe:not-data-open:scale-98",
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
// src/_internal/constants/pressableClass.ts
|
|
2
|
-
/**
|
|
3
|
-
* 기본 색(배경, 글자, 경계). 색 이름마다 Foundation이 같은 대비 규칙으로 검사한다.
|
|
4
|
-
* subtle 바탕 위 글자는 파스텔 글자 on-subtle이고(ADR 0022 §1), outline·ghost 글자는 바탕 없는 색 글자 text다.
|
|
5
|
-
*/
|
|
2
|
+
/** 기본 색. 색이 없는 variant는 투명 border라 forced-colors에서 경계로 보인다. */
|
|
6
3
|
const pressableColorClass = {
|
|
7
4
|
solid: "border-transparent bg-accent-solid text-accent-on-solid",
|
|
8
5
|
subtle: "border-transparent bg-accent-subtle text-accent-on-subtle",
|
|
9
6
|
outline: "border-accent text-accent",
|
|
10
7
|
ghost: "border-transparent text-accent"
|
|
11
8
|
};
|
|
12
|
-
/** outline·ghost
|
|
9
|
+
/** outline·ghost hover·누름. 색을 변수로 골라 Component의 `hover:`·`active:` 덮어쓰기를 tailwind-merge가 바꿀 수 있다(ADR 0025). */
|
|
13
10
|
const pressableTintClass = "[--pressable-hover:var(--tide-accent-faint)] [--pressable-active:var(--tide-accent-subtle)] data-[color=neutral]:[--pressable-hover:var(--tide-bg-hover)] data-[color=neutral]:[--pressable-active:var(--tide-bg-active)] hover:bg-(--pressable-hover) active:bg-(--pressable-active)";
|
|
14
11
|
/** hover·누름 색. 활성 상태일 때만 붙인다(비활성·로딩에는 붙이지 않아 CSS 순서에 기대지 않는다). */
|
|
15
12
|
const pressableInteractionClass = {
|
|
@@ -27,7 +24,7 @@ const pressableDisabledClass = {
|
|
|
27
24
|
};
|
|
28
25
|
/** 모양의 공통 부분. radius는 모든 size에서 `md`다. 높이·폭·padding은 Component가 정한다. */
|
|
29
26
|
const pressableBaseClass = "inline-flex shrink-0 items-center justify-center rounded-md border whitespace-nowrap select-none transition-colors focus-visible:focus-ring";
|
|
30
|
-
/** 누름 축소. motion-safe:일 때만
|
|
27
|
+
/** 누름 축소. motion-safe:일 때만 줄이고 scale도 그때만 전환 대상에 넣는다(ADR 0010). */
|
|
31
28
|
const pressableScaleClass = "motion-safe:transition-[color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,scale] motion-safe:active:scale-96";
|
|
32
29
|
|
|
33
30
|
export { pressableBaseClass, pressableColorClass, pressableDisabledClass, pressableInteractionClass, pressableScaleClass };
|
|
@@ -8,10 +8,7 @@ import { createContext, use } from "react";
|
|
|
8
8
|
const CheckboxGroupContext = createContext(null);
|
|
9
9
|
/** RadioGroup 안에서만 값이 있다. */
|
|
10
10
|
const RadioGroupContext = createContext(null);
|
|
11
|
-
/**
|
|
12
|
-
* Field 연결 정보와 묶음 자신의 props를 합친다. 묶음에 직접 준 값이 Field 값을 이긴다(useFieldControl과 같은 규칙).
|
|
13
|
-
* `aria-labelledby`를 직접 주면 Field label 대신 그것을 쓴다. `aria-describedby`는 Field 것 뒤에 이어 붙인다.
|
|
14
|
-
*/
|
|
11
|
+
/** 묶음에 직접 준 값이 Field 값을 이긴다. `aria-describedby`는 Field 것 뒤에 이어 붙인다. */
|
|
15
12
|
function useChoiceGroup(props) {
|
|
16
13
|
const field = use(FieldContext);
|
|
17
14
|
const invalid = props.invalid ?? field?.invalid ?? false;
|
|
@@ -4,14 +4,8 @@ import { useEffect } from "react";
|
|
|
4
4
|
|
|
5
5
|
// src/_internal/hooks/useCloseOnTab.ts
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* React Aria 목록 hook(useMenu·useListBox)은 Tab으로 닫지 않고, 항목의 keydown 처리가 전파를 멈추며 FocusScope가
|
|
11
|
-
* document capture에서 Tab을 먼저 다룬다. 열린 동안 바깥은 inert라 브라우저 기본 Tab은 갈 곳이 없다. 그래서 그보다
|
|
12
|
-
* 앞인 window capture에서 받는다.
|
|
13
|
-
* 전파도 멈춘다. listbox(useListBox 안의 useSelectableCollection)는 Tab에서 포커스를 목록 안 요소로 옮기는데, 그러면
|
|
14
|
-
* 닫힌 뒤 포커스가 트리거로 돌아오지 않았다(Select 테스트로 확인).
|
|
7
|
+
* Tab을 누르면 기본 동작을 막고 닫는다. FocusScope가 document capture에서 Tab을 먼저 다뤄 window capture에서 받는다.
|
|
8
|
+
* 전파도 멈춘다. listbox가 Tab에 포커스를 옮기면 닫힌 뒤 트리거로 돌아오지 않는다(ADR 0018).
|
|
15
9
|
*/
|
|
16
10
|
function useCloseOnTab(overlayRef, close) {
|
|
17
11
|
useEffect(() => {
|
|
@@ -5,10 +5,7 @@ import { createContext, use } from "react";
|
|
|
5
5
|
// src/_internal/hooks/useFieldControl.ts
|
|
6
6
|
/** Field 밖에서는 `null`이다. */
|
|
7
7
|
const FieldContext = createContext(null);
|
|
8
|
-
/**
|
|
9
|
-
* Field 연결 정보와 입력 Component 자신의 props를 합친다.
|
|
10
|
-
* 입력 Component에 직접 준 값(id, disabled 등)이 Field 값보다 이긴다. `aria-describedby`는 Field 것 뒤에 이어 붙인다.
|
|
11
|
-
*/
|
|
8
|
+
/** 직접 준 값(id, disabled 등)이 Field 값을 이긴다. `aria-describedby`는 Field 것 뒤에 이어 붙인다. */
|
|
12
9
|
function useFieldControl(props) {
|
|
13
10
|
const field = use(FieldContext);
|
|
14
11
|
const invalid = props.invalid ?? field?.invalid ?? false;
|
|
@@ -3,13 +3,7 @@
|
|
|
3
3
|
import { useLayoutEffect, useState } from "react";
|
|
4
4
|
|
|
5
5
|
// src/_internal/hooks/useOverlayPresence.ts
|
|
6
|
-
/**
|
|
7
|
-
* 열림 상태가 꺼져도 퇴장 전환이 끝날 때까지 오버레이를 DOM에 남긴다. DOM에 둘지(`true`)를 돌려준다.
|
|
8
|
-
*
|
|
9
|
-
* 닫힌 뒤 요소의 `getAnimations()`(CSS transition 포함)가 모두 끝나면 뺀다. 전환이 없으면(지원하지 않는 브라우저,
|
|
10
|
-
* 전환이 없는 오버레이) 바로 뺀다. 퇴장 중에 다시 열리면 빼지 않는다. React Aria hooks에는 퇴장을 기다리는 hook이
|
|
11
|
-
* 없어서(react-aria-components의 `isExiting`은 Component 층에만 있다) 이 hook이 그 일을 한다.
|
|
12
|
-
*/
|
|
6
|
+
/** 닫혀도 퇴장 전환(`getAnimations()`)이 끝날 때까지 DOM에 남긴다. DOM에 둘지를 돌려준다(ADR 0018). */
|
|
13
7
|
function useOverlayPresence(isOpen, ref) {
|
|
14
8
|
const [present, setPresent] = useState(isOpen);
|
|
15
9
|
if (isOpen && !present) setPresent(true);
|
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
import { useLayoutEffect } from "react";
|
|
4
4
|
|
|
5
5
|
// src/_internal/hooks/useOverlayTheme.ts
|
|
6
|
-
/**
|
|
7
|
-
* 트리거가 놓인 Theme(`data-theme`)을 portal로 나간 오버레이에 옮긴다. Theme을 `<html>`이 아닌 일부 영역에
|
|
8
|
-
* 붙인 앱에서도 오버레이가 같은 색이 된다. 오버레이에 이미 `data-theme`이 있으면 두고, 트리거 위에 Theme이 없으면
|
|
9
|
-
* 붙이지 않는다(`:root` 기본값을 따른다). 위치를 계산하기 전(첫 스타일 계산 전)에 붙도록 위치 hook보다 먼저 부른다.
|
|
10
|
-
*/
|
|
6
|
+
/** 트리거의 `data-theme`을 portal로 나간 오버레이에 옮긴다. 첫 스타일 계산 전에 붙도록 위치 hook보다 먼저 부른다. */
|
|
11
7
|
function useOverlayTheme(triggerRef, overlayRef) {
|
|
12
8
|
useLayoutEffect(() => {
|
|
13
9
|
const overlay = overlayRef.current;
|
|
@@ -4,13 +4,7 @@ import { overlayPositionProps } from "../libs/overlayPosition.js";
|
|
|
4
4
|
import { usePopover } from "react-aria";
|
|
5
5
|
|
|
6
6
|
// src/_internal/hooks/usePopoverOverlay.ts
|
|
7
|
-
/**
|
|
8
|
-
* 트리거에 붙는 오버레이(Popover, Menu, Select·Combobox 목록)의 위치·닫기 동작. React Aria `usePopover`를 감싼다.
|
|
9
|
-
* - 닫기: Esc, 바깥 누름, 포커스가 바깥으로 나감(`usePopover` 기본). 위에 쌓인 오버레이부터 닫힌다.
|
|
10
|
-
* - 모달: 기본은 바깥을 `inert`로 막고 스크롤을 잠근다. `nonModal`이면 둘 다 하지 않는다.
|
|
11
|
-
* - 위치: 공간이 모자라면 반대쪽으로 뒤집고, 주축 길이는 `max-height`로 줄여 트리거를 덮지 않는다(WCAG 2.4.11, Comments 참고).
|
|
12
|
-
* 돌려받은 `overlayProps`(style 포함)를 오버레이 요소에 펼친다. 쌓임 단계 class는 부르는 쪽이 붙인다.
|
|
13
|
-
*/
|
|
7
|
+
/** React Aria `usePopover`를 감싼다. 돌려받은 `overlayProps`(style 포함)를 오버레이 요소에 펼친다. */
|
|
14
8
|
function usePopoverOverlay({ triggerRef, popoverRef, placement, offset, nonModal = false }, state) {
|
|
15
9
|
const { popoverProps, placement: actual } = usePopover({
|
|
16
10
|
triggerRef,
|
|
@@ -3,9 +3,7 @@ import { Children, Fragment, createElement, isValidElement } from "react";
|
|
|
3
3
|
// src/_internal/libs/listCollection.ts
|
|
4
4
|
const lazyType = Symbol.for("react.lazy");
|
|
5
5
|
const isLazy = (type) => typeof type === "object" && type !== null && type.$$typeof === lazyType;
|
|
6
|
-
/**
|
|
7
|
-
* children 안의 React node에서 글자만 모은다. 항목의 기본 타입어헤드 글자다. 아이콘(글자 없는 요소)은 빠진다.
|
|
8
|
-
*/
|
|
6
|
+
/** children에서 글자만 모은다. 항목의 기본 타입어헤드 글자다. */
|
|
9
7
|
function textOf(node) {
|
|
10
8
|
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
11
9
|
if (Array.isArray(node)) return node.map((child) => textOf(child)).join("");
|
|
@@ -13,13 +11,7 @@ function textOf(node) {
|
|
|
13
11
|
return "";
|
|
14
12
|
}
|
|
15
13
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* - 서버 컴포넌트가 만든 요소는 client Component type이 React lazy 참조(RSC payload의 `$L`)로 온다. 컬렉션 빌더는
|
|
19
|
-
* type의 `getCollectionNode`를 직접 보므로 lazy를 풀어 실제 Component로 바꾼다. 목록 Component와 항목 Component는
|
|
20
|
-
* 같은 모듈이라 목록이 렌더되는 시점에는 이미 불러와져 있다(풀 때 기다리지 않는다).
|
|
21
|
-
* - Fragment는 펼친다. 배열·Fragment 안의 lazy도 같이 푼다.
|
|
22
|
-
* - 묶음 안의 항목은 묶음의 `getCollectionNode`(`sectionCollectionNode`)가 같은 함수로 푼다.
|
|
14
|
+
* 서버 컴포넌트가 만든 항목은 type이 React lazy 참조로 오므로 풀어 실제 Component로 바꾼다(ADR 0019). Fragment는 펼친다.
|
|
23
15
|
*/
|
|
24
16
|
function resolveCollectionChildren(children) {
|
|
25
17
|
const resolved = [];
|
|
@@ -44,10 +36,7 @@ function resolveCollectionChildren(children) {
|
|
|
44
36
|
});
|
|
45
37
|
return resolved;
|
|
46
38
|
}
|
|
47
|
-
/**
|
|
48
|
-
* 항목 Component의 `getCollectionNode`. node의 props에 `isDisabled`를 더한다(React Stately `SelectionManager`·
|
|
49
|
-
* 키보드 이동이 `props.isDisabled`를 읽는다). 렌더는 목록 Component가 node.props(항목에 준 props 그대로)로 한다.
|
|
50
|
-
*/
|
|
39
|
+
/** node props에 `isDisabled`를 더한다. React Stately 선택·키보드 이동이 그 이름을 읽는다. */
|
|
51
40
|
function* itemCollectionNode(props) {
|
|
52
41
|
yield {
|
|
53
42
|
type: "item",
|
|
@@ -61,12 +50,7 @@ function* itemCollectionNode(props) {
|
|
|
61
50
|
hasChildNodes: false
|
|
62
51
|
};
|
|
63
52
|
}
|
|
64
|
-
/**
|
|
65
|
-
* 옵션 Component의 `getCollectionNode`. `itemCollectionNode`와 같고, `value`를 node의 key로 yield한다.
|
|
66
|
-
* 컬렉션 빌더는 yield한 node에 key가 있으면 요소 key·자리 번호 대신 그 값을 쓴다(react-stately 3.51.0
|
|
67
|
-
* `CollectionBuilder.getFullNode`). 그래서 목록 상태의 선택 key가 곧 앱의 값이고, 묶음 안에 있어도 앞에 묶음 key가
|
|
68
|
-
* 붙지 않는다(묶음은 key 없는 부분 node로 항목을 넘긴다).
|
|
69
|
-
*/
|
|
53
|
+
/** `value`를 node key로 yield해, 묶음 안에서도 목록의 선택 key가 곧 앱의 값이 된다. */
|
|
70
54
|
function* valueItemCollectionNode(props) {
|
|
71
55
|
for (const node of itemCollectionNode(props)) yield {
|
|
72
56
|
...node,
|
|
@@ -89,9 +73,7 @@ function* sectionCollectionNode(props) {
|
|
|
89
73
|
}
|
|
90
74
|
};
|
|
91
75
|
}
|
|
92
|
-
/**
|
|
93
|
-
* 렌더하지 않는 표시 Component에 컬렉션 node 생성 함수를 붙인다. 공개 타입에는 드러나지 않는다.
|
|
94
|
-
*/
|
|
76
|
+
/** 렌더하지 않는 표시 Component에 컬렉션 node 생성 함수를 붙인다. 공개 타입에는 드러나지 않는다. */
|
|
95
77
|
function asCollectionComponent(component, getCollectionNode) {
|
|
96
78
|
component.getCollectionNode = getCollectionNode;
|
|
97
79
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import "react";
|
|
2
|
-
/**
|
|
3
|
-
* 트리거 기준 위치. 앞은 트리거의 어느 쪽에 놓을지(주축), 뒤는 그 변에서 어디에 맞출지(교차축)다.
|
|
4
|
-
* 공간이 모자라면 반대쪽으로 뒤집는다(React Aria `shouldFlip` 기본값).
|
|
5
|
-
*/
|
|
2
|
+
/** 앞은 트리거의 어느 쪽(주축), 뒤는 그 변의 어디에 맞출지(교차축)다. 공간이 모자라면 뒤집는다. */
|
|
6
3
|
export type OverlayPlacement = "top" | "top start" | "top end" | "bottom" | "bottom start" | "bottom end" | "left" | "left top" | "left bottom" | "right" | "right top" | "right bottom";
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
// src/_internal/libs/overlayPosition.ts
|
|
2
2
|
const isAxis = (value) => value === "top" || value === "bottom" || value === "left" || value === "right";
|
|
3
3
|
/**
|
|
4
|
-
* React Aria가
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `placement`가 아직 없으면(처음 렌더) 요청한 placement의 주축을 쓴다. 등장 전환의 시작 방향이 첫 스타일 계산에서
|
|
8
|
-
* 정해지기 때문이다. 공간이 없어 뒤집힌 경우에만 첫 프레임의 시작 방향이 요청한 쪽이 된다(4px).
|
|
4
|
+
* React Aria가 넣는 `zIndex: 100000`을 빼고(쌓임은 z-* class로만 정한다) 주축을 `data-placement`로 붙인다.
|
|
5
|
+
* 첫 렌더에도 요청한 주축을 붙인다. 등장 전환의 시작 방향이 첫 스타일 계산에서 정해지기 때문이다.
|
|
9
6
|
*/
|
|
10
7
|
function overlayPositionProps(props, placement, requested) {
|
|
11
8
|
const { zIndex: _zIndex, ...style } = props.style ?? {};
|
|
@@ -4,11 +4,8 @@ import { pressableColorClass, pressableDisabledClass, pressableInteractionClass,
|
|
|
4
4
|
/** `disabled`를 네이티브로 지원하는 요소인지. Button류가 렌더할 만한 요소 중에서는 `button`뿐이다. */
|
|
5
5
|
const supportsNativeDisabled = (render) => render === void 0 || render.type === "button";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* - loading: 포커스를 남긴 채 `aria-disabled`·`data-loading`과 클릭 차단. disabled와 함께 오면 disabled가 이긴다
|
|
10
|
-
* - 커서: 활성 pointer, 로딩 wait, 비활성 not-allowed
|
|
11
|
-
* - hover·누름 색과 누름 축소는 활성 상태에서만 붙인다
|
|
7
|
+
* 네이티브 disabled가 안 되는 요소의 disabled와 loading은 포커스를 남긴 채 `aria-disabled`와 클릭 차단으로 막는다.
|
|
8
|
+
* hover·누름 색과 누름 축소는 활성 상태에서만 붙인다.
|
|
12
9
|
*/
|
|
13
10
|
function pressableState({ variant, color, disabled, loading, noPressScale, render, type, onClick, ariaDisabled }) {
|
|
14
11
|
const native = supportsNativeDisabled(render);
|
|
@@ -20,7 +20,7 @@ function mergeRefs(...refs) {
|
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
/** render 요소의 props와 Component props를
|
|
23
|
+
/** render 요소의 props와 Component props를 합친다. */
|
|
24
24
|
function mergeProps(elementProps, props) {
|
|
25
25
|
const merged = { ...elementProps };
|
|
26
26
|
for (const [name, value] of Object.entries(props)) {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { Color, ColorFamilyName, ColorFamilyRegistry, Role, RoleRegistry } from "@tide-design/foundation";
|
|
2
|
-
/** Component size.
|
|
2
|
+
/** Component size. 높이 `xs` 24px, `sm` 32px, `md` 40px, `lg` 48px. */
|
|
3
3
|
export type Size = "xs" | "sm" | "md" | "lg";
|
|
4
|
-
/**
|
|
5
|
-
* Button류의 채움 방식. `solid`·`subtle`은 Token의 강도와 이름이 같고, `outline`·`ghost`는 Component에만 있다.
|
|
6
|
-
* 스타일 축 이름이 `variant`라도 값 집합은 채움 방식이라 `Variant`가 아닌 이 이름을 쓴다(GLOSSARY 「채움 방식」).
|
|
7
|
-
*/
|
|
4
|
+
/** Button류의 채움 방식(`variant` 값). `outline`·`ghost`는 Token에 없고 Component에만 있다. */
|
|
8
5
|
export type FillVariant = "solid" | "subtle" | "outline" | "ghost";
|
|
9
6
|
export type { Color, ColorFamilyName, ColorFamilyRegistry, Role, RoleRegistry };
|
package/package.json
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tide-design/components",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4",
|
|
4
4
|
"description": "Tide 디자인 시스템의 React Component",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"accessibility",
|
|
7
|
+
"design-system",
|
|
8
|
+
"react",
|
|
9
|
+
"react-aria",
|
|
10
|
+
"react-components",
|
|
11
|
+
"tailwindcss",
|
|
12
|
+
"tide",
|
|
13
|
+
"tide-design",
|
|
14
|
+
"ui"
|
|
15
|
+
],
|
|
5
16
|
"license": "MIT",
|
|
6
17
|
"repository": {
|
|
7
18
|
"type": "git",
|
|
@@ -23,8 +34,8 @@
|
|
|
23
34
|
"./styles.css": "./dist/styles.css"
|
|
24
35
|
},
|
|
25
36
|
"dependencies": {
|
|
26
|
-
"@tide-design/foundation": "0.11.
|
|
27
|
-
"@tide-design/icons": "0.11.
|
|
37
|
+
"@tide-design/foundation": "0.11.4",
|
|
38
|
+
"@tide-design/icons": "0.11.4",
|
|
28
39
|
"clsx": "^2.1.1",
|
|
29
40
|
"react-aria": "^3.53.1",
|
|
30
41
|
"react-stately": "^3.51.0",
|