@tide-tds/components 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/dist/Spinner.d.ts +20 -0
- package/dist/Spinner.js +35 -0
- package/dist/Typography.d.ts +36 -0
- package/dist/Typography.js +50 -0
- package/dist/VisuallyHidden.d.ts +4 -0
- package/dist/VisuallyHidden.js +13 -0
- package/dist/cn.d.ts +6 -0
- package/dist/cn.js +15 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/render.js +55 -0
- package/dist/styles.css +5 -0
- package/dist/types.d.ts +2 -0
- package/package.json +56 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 chane81
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Size } from "./types.js";
|
|
2
|
+
import { ComponentProps, ReactElement } from "react";
|
|
3
|
+
/** Spinner의 size. 공통 size 4개를 모두 받는다. */
|
|
4
|
+
type SpinnerSize = Extract<Size, "xs" | "sm" | "md" | "lg">;
|
|
5
|
+
export interface SpinnerProps extends Omit<ComponentProps<"svg">, "children"> {
|
|
6
|
+
/**
|
|
7
|
+
* 같은 size의 Component(Button 등) 안 텍스트 옆 아이콘과 같은 크기다.
|
|
8
|
+
* `xs`·`sm` 14px, `md` 16px, `lg` 20px. 기본값은 `md`다.
|
|
9
|
+
*/
|
|
10
|
+
size?: SpinnerSize;
|
|
11
|
+
/** 접근 가능한 이름. 기본값은 `"로딩 중"`이다. 무엇을 불러오는지 적으면 더 좋다. */
|
|
12
|
+
"aria-label"?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 로딩 중임을 알리는 회전 표시. 역할은 `status`이고 접근 가능한 이름이 기본으로 붙는다.
|
|
16
|
+
* 회전은 keyframe(`animate-spin`)이고 움직임 줄이기에서도 멈추지 않는다(로딩 여부 자체가 정보다).
|
|
17
|
+
* 색은 `currentColor`라 주변 글자색을 따른다. 서버 컴포넌트로 쓸 수 있다.
|
|
18
|
+
*/
|
|
19
|
+
export declare function Spinner({ size, className, "aria-label": ariaLabel, ...props }: SpinnerProps): ReactElement;
|
|
20
|
+
export {};
|
package/dist/Spinner.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { cn } from "./cn.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
// src/Spinner.tsx
|
|
5
|
+
const sizeClass = {
|
|
6
|
+
xs: "size-3.5",
|
|
7
|
+
sm: "size-3.5",
|
|
8
|
+
md: "size-4",
|
|
9
|
+
lg: "size-5"
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* 로딩 중임을 알리는 회전 표시. 역할은 `status`이고 접근 가능한 이름이 기본으로 붙는다.
|
|
13
|
+
* 회전은 keyframe(`animate-spin`)이고 움직임 줄이기에서도 멈추지 않는다(로딩 여부 자체가 정보다).
|
|
14
|
+
* 색은 `currentColor`라 주변 글자색을 따른다. 서버 컴포넌트로 쓸 수 있다.
|
|
15
|
+
*/
|
|
16
|
+
function Spinner({ size = "md", className, "aria-label": ariaLabel = "로딩 중", ...props }) {
|
|
17
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
18
|
+
role: "status",
|
|
19
|
+
"aria-label": ariaLabel,
|
|
20
|
+
viewBox: "0 0 24 24",
|
|
21
|
+
fill: "none",
|
|
22
|
+
focusable: "false",
|
|
23
|
+
...props,
|
|
24
|
+
className: cn("shrink-0 animate-spin", sizeClass[size], className),
|
|
25
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
26
|
+
d: "M12 3a9 9 0 1 1-9 9",
|
|
27
|
+
stroke: "currentColor",
|
|
28
|
+
strokeWidth: 2,
|
|
29
|
+
strokeLinecap: "round",
|
|
30
|
+
vectorEffect: "non-scaling-stroke"
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { Spinner };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactElement, Ref } from "react";
|
|
2
|
+
import { TextStyleName } from "@tide-tds/foundation";
|
|
3
|
+
/** heading·display 텍스트 스타일. 항상 `<h*>`로 렌더되고 `level`을 받는다. */
|
|
4
|
+
type HeadingVariant = Extract<TextStyleName, `display-${string}` | `heading-${string}`>;
|
|
5
|
+
/** heading·display가 아닌 텍스트 스타일 */
|
|
6
|
+
type TextVariant = Exclude<TextStyleName, HeadingVariant>;
|
|
7
|
+
/** 제목 단계 */
|
|
8
|
+
type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
9
|
+
interface TypographyBaseProps extends HTMLAttributes<HTMLElement> {
|
|
10
|
+
/** 루트 DOM 요소에 연결한다. */
|
|
11
|
+
ref?: Ref<HTMLElement>;
|
|
12
|
+
/**
|
|
13
|
+
* 다른 요소로 렌더한다. 예: `render={<label htmlFor="name" />}`.
|
|
14
|
+
* props, ref, className을 그 요소에 병합하고 `level`과 기본 요소는 무시한다.
|
|
15
|
+
*/
|
|
16
|
+
render?: ReactElement;
|
|
17
|
+
}
|
|
18
|
+
interface TypographyHeadingProps extends TypographyBaseProps {
|
|
19
|
+
/** 텍스트 스타일 이름 */
|
|
20
|
+
variant: HeadingVariant;
|
|
21
|
+
/** 제목 단계. 주지 않으면 텍스트 스타일의 기본 단계를 쓴다. */
|
|
22
|
+
level?: HeadingLevel;
|
|
23
|
+
}
|
|
24
|
+
interface TypographyTextProps extends TypographyBaseProps {
|
|
25
|
+
/** 텍스트 스타일 이름. 기본값은 `body-md`다. */
|
|
26
|
+
variant?: TextVariant;
|
|
27
|
+
/** heading·display 텍스트 스타일에만 있다. */
|
|
28
|
+
level?: never;
|
|
29
|
+
}
|
|
30
|
+
export type TypographyProps = TypographyHeadingProps | TypographyTextProps;
|
|
31
|
+
/**
|
|
32
|
+
* 텍스트 스타일 하나로 크기, 행간, 굵기를 정하고 알맞은 시맨틱 요소로 렌더한다.
|
|
33
|
+
* heading·display는 항상 `<h*>`다. 다른 요소가 필요하면 `render`를 쓴다. 서버 컴포넌트로 쓸 수 있다.
|
|
34
|
+
*/
|
|
35
|
+
export declare function Typography({ variant, level, render, ...props }: TypographyProps): ReactElement;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { renderElement } from "./render.js";
|
|
2
|
+
|
|
3
|
+
// src/Typography.tsx
|
|
4
|
+
const variantClass = {
|
|
5
|
+
"display-lg": "text-display-lg",
|
|
6
|
+
"display-md": "text-display-md",
|
|
7
|
+
"heading-xl": "text-heading-xl",
|
|
8
|
+
"heading-lg": "text-heading-lg",
|
|
9
|
+
"heading-md": "text-heading-md",
|
|
10
|
+
"heading-sm": "text-heading-sm",
|
|
11
|
+
"heading-xs": "text-heading-xs",
|
|
12
|
+
"body-lg": "text-body-lg",
|
|
13
|
+
"body-md": "text-body-md",
|
|
14
|
+
"body-sm": "text-body-sm",
|
|
15
|
+
"label-lg": "text-label-lg",
|
|
16
|
+
"label-md": "text-label-md",
|
|
17
|
+
"label-sm": "text-label-sm",
|
|
18
|
+
caption: "text-caption"
|
|
19
|
+
};
|
|
20
|
+
const elementByVariant = {
|
|
21
|
+
"display-lg": 1,
|
|
22
|
+
"display-md": 1,
|
|
23
|
+
"heading-xl": 1,
|
|
24
|
+
"heading-lg": 2,
|
|
25
|
+
"heading-md": 3,
|
|
26
|
+
"heading-sm": 4,
|
|
27
|
+
"heading-xs": 5,
|
|
28
|
+
"body-lg": "p",
|
|
29
|
+
"body-md": "p",
|
|
30
|
+
"body-sm": "p",
|
|
31
|
+
"label-lg": "span",
|
|
32
|
+
"label-md": "span",
|
|
33
|
+
"label-sm": "span",
|
|
34
|
+
caption: "p"
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 텍스트 스타일 하나로 크기, 행간, 굵기를 정하고 알맞은 시맨틱 요소로 렌더한다.
|
|
38
|
+
* heading·display는 항상 `<h*>`다. 다른 요소가 필요하면 `render`를 쓴다. 서버 컴포넌트로 쓸 수 있다.
|
|
39
|
+
*/
|
|
40
|
+
function Typography({ variant = "body-md", level, render, ...props }) {
|
|
41
|
+
const element = elementByVariant[variant];
|
|
42
|
+
return renderElement({
|
|
43
|
+
defaultElement: typeof element === "number" ? `h${level ?? element}` : element,
|
|
44
|
+
render,
|
|
45
|
+
baseClassName: variantClass[variant],
|
|
46
|
+
props
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { Typography };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cn } from "./cn.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
// src/VisuallyHidden.tsx
|
|
5
|
+
/** 화면에는 보이지 않고 보조 기술에는 읽히는 텍스트. 서버 컴포넌트로 쓸 수 있다. */
|
|
6
|
+
function VisuallyHidden({ className, ...props }) {
|
|
7
|
+
return /* @__PURE__ */ jsx("span", {
|
|
8
|
+
...props,
|
|
9
|
+
className: cn("sr-only", className)
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { VisuallyHidden };
|
package/dist/cn.d.ts
ADDED
package/dist/cn.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { tailwindMergeConfig } from "@tide-tds/foundation/tailwind-merge";
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import { extendTailwindMerge } from "tailwind-merge";
|
|
4
|
+
|
|
5
|
+
// src/cn.ts
|
|
6
|
+
const twMerge = extendTailwindMerge(tailwindMergeConfig);
|
|
7
|
+
/**
|
|
8
|
+
* class를 합치고 충돌을 푼다. 뒤에 온 class가 이긴다.
|
|
9
|
+
* Component는 사용자 `className`을 항상 마지막 인자로 넘긴다.
|
|
10
|
+
*/
|
|
11
|
+
function cn(...inputs) {
|
|
12
|
+
return twMerge(clsx(inputs));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { cn };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { cn } from "./cn.js";
|
|
2
|
+
import { VisuallyHidden, VisuallyHiddenProps } from "./VisuallyHidden.js";
|
|
3
|
+
import { Typography, TypographyProps } from "./Typography.js";
|
|
4
|
+
import { Spinner, SpinnerProps } from "./Spinner.js";
|
|
5
|
+
import { Size } from "./types.js";
|
|
6
|
+
export { type Size, Spinner, type SpinnerProps, Typography, type TypographyProps, VisuallyHidden, type VisuallyHiddenProps, cn };
|
package/dist/index.js
ADDED
package/dist/render.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { cn } from "./cn.js";
|
|
2
|
+
import { cloneElement, createElement } from "react";
|
|
3
|
+
|
|
4
|
+
// src/render.ts
|
|
5
|
+
const isHandlerName = (name) => /^on[A-Z]/.test(name);
|
|
6
|
+
/** ref 여러 개를 하나로 합친다. React 19의 cleanup 함수 반환도 지원한다. */
|
|
7
|
+
function mergeRefs(...refs) {
|
|
8
|
+
return (node) => {
|
|
9
|
+
const cleanups = refs.map((ref) => {
|
|
10
|
+
if (typeof ref === "function") return ref(node);
|
|
11
|
+
if (ref) ref.current = node;
|
|
12
|
+
});
|
|
13
|
+
return () => {
|
|
14
|
+
refs.forEach((ref, index) => {
|
|
15
|
+
const cleanup = cleanups[index];
|
|
16
|
+
if (typeof cleanup === "function") cleanup();
|
|
17
|
+
else if (typeof ref === "function") ref(null);
|
|
18
|
+
else if (ref) ref.current = null;
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** render 요소의 props와 Component props를 위 규칙대로 합친다. */
|
|
24
|
+
function mergeProps(elementProps, props) {
|
|
25
|
+
const merged = { ...elementProps };
|
|
26
|
+
for (const [name, value] of Object.entries(props)) {
|
|
27
|
+
const existing = elementProps[name];
|
|
28
|
+
if (value === void 0) continue;
|
|
29
|
+
if (isHandlerName(name) && typeof existing === "function" && typeof value === "function") merged[name] = (...args) => {
|
|
30
|
+
existing(...args);
|
|
31
|
+
return value(...args);
|
|
32
|
+
};
|
|
33
|
+
else if (name === "style" && existing && typeof existing === "object") merged[name] = {
|
|
34
|
+
...existing,
|
|
35
|
+
...value
|
|
36
|
+
};
|
|
37
|
+
else if (name === "ref" && existing) merged[name] = mergeRefs(existing, value);
|
|
38
|
+
else merged[name] = value;
|
|
39
|
+
}
|
|
40
|
+
return merged;
|
|
41
|
+
}
|
|
42
|
+
/** `render`가 있으면 그 요소에 props를 병합하고, 없으면 기본 요소를 렌더한다. */
|
|
43
|
+
function renderElement({ defaultElement, render, baseClassName, props }) {
|
|
44
|
+
const { className, ...rest } = props;
|
|
45
|
+
if (!render) return createElement(defaultElement, {
|
|
46
|
+
...rest,
|
|
47
|
+
className: cn(baseClassName, className)
|
|
48
|
+
});
|
|
49
|
+
const elementProps = render.props;
|
|
50
|
+
const merged = mergeProps(elementProps, rest);
|
|
51
|
+
merged["className"] = cn(baseClassName, elementProps["className"], className);
|
|
52
|
+
return cloneElement(render, merged);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { renderElement };
|
package/dist/styles.css
ADDED
package/dist/types.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tide-tds/components",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Tide 디자인 시스템의 React Component",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/chane81/tide-design-system.git",
|
|
9
|
+
"directory": "packages/components"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": [
|
|
16
|
+
"**/*.css"
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./styles.css": "./dist/styles.css"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@tide-tds/foundation": "0.1.0",
|
|
27
|
+
"@tide-tds/icons": "0.1.0",
|
|
28
|
+
"clsx": "^2.1.1",
|
|
29
|
+
"react-aria": "^3.53.1",
|
|
30
|
+
"react-stately": "^3.51.0",
|
|
31
|
+
"tailwind-merge": "^3.7.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@tailwindcss/vite": "^4.3.5",
|
|
35
|
+
"@types/node": "^26.6.6",
|
|
36
|
+
"@types/react": "^19.3.0",
|
|
37
|
+
"@types/react-dom": "^19.3.0",
|
|
38
|
+
"@vitest/browser-playwright": "^5.1.0",
|
|
39
|
+
"playwright": "^1.65.0",
|
|
40
|
+
"react": "^19.3.1",
|
|
41
|
+
"react-dom": "^19.3.1",
|
|
42
|
+
"tailwindcss": "^4.3.5",
|
|
43
|
+
"tsdown": "0.23.7",
|
|
44
|
+
"typescript": "^7.0.2",
|
|
45
|
+
"vite": "^8.3.6",
|
|
46
|
+
"vitest": "^5.1.0",
|
|
47
|
+
"vitest-browser-react": "^2.3.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"react": "^19",
|
|
51
|
+
"react-dom": "^19",
|
|
52
|
+
"tailwindcss": "^4.3"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsdown && cp src/styles.css dist/styles.css",
|
|
56
|
+
"typecheck": "tsc --noEmit",
|
|
57
|
+
"test": "vitest run"
|
|
58
|
+
}
|
|
6
59
|
}
|
package/README.md
DELETED