@jongh/cli 1.0.11 → 1.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/.lintstagedrc.json +4 -0
- package/CHANGELOG.md +7 -0
- package/dist/components/Accordion/Accordion.tsx +21 -14
- package/dist/components/Accordion/useAccordionHeight.ts +13 -16
- package/dist/components/Button/index.tsx +11 -45
- package/dist/components/Primitive/index.tsx +58 -0
- package/dist/components/RovingIndex/RovingItem.tsx +47 -0
- package/dist/components/RovingIndex/RovingTabIndexRoot.tsx +92 -0
- package/dist/components/RovingIndex/index.ts +3 -0
- package/dist/components/RovingIndex/useRovingTabIndex.tsx +76 -0
- package/dist/components/Select/index.tsx +231 -0
- package/dist/components/Slider/index.tsx +141 -0
- package/dist/components/Slider/style.ts +28 -41
- package/dist/components/{Tab → Tabs}/Tab.tsx +11 -7
- package/dist/components/{Tab → Tabs}/TabContent.tsx +4 -2
- package/dist/components/Tabs/TabIndicator.tsx +6 -0
- package/dist/components/{Tab → Tabs}/TabList.tsx +20 -21
- package/dist/components/Tabs/index.ts +43 -0
- package/dist/components/{Tab → Tabs}/useRovingTabIndex.tsx +0 -1
- package/dist/components/index.ts +3 -3
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/{fetchComponent.ts → copyComponent.ts} +0 -1
- package/src/getConfig.ts +7 -4
- package/src/index.ts +2 -2
- package/dist/components/Slider/Slider.tsx +0 -140
- package/dist/components/Tab/TabIndicator.tsx +0 -19
- package/dist/components/Tab/index.ts +0 -4
- package/dist/components/Tab/style.ts +0 -9
- package/park-ui.json +0 -3
- /package/dist/components/{Tab → Tabs}/useTabContext.ts +0 -0
package/package.json
CHANGED
|
@@ -3,7 +3,6 @@ import path from "node:path"
|
|
|
3
3
|
import fs from "fs-extra"
|
|
4
4
|
import { fileURLToPath } from "node:url"
|
|
5
5
|
|
|
6
|
-
// __dirname은 현재 실행되는 스크립트의 디렉토리 경로 (우리 패키지 내부)
|
|
7
6
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
8
7
|
|
|
9
8
|
const COMPONENTS_DIR = path.join(__dirname, "./components/Button/index.tsx")
|
package/src/getConfig.ts
CHANGED
|
@@ -3,9 +3,13 @@ import fs from "fs-extra"
|
|
|
3
3
|
import { packageDirectory } from "pkg-dir"
|
|
4
4
|
import * as p from "@clack/prompts"
|
|
5
5
|
//TODO: json schema 제공
|
|
6
|
+
|
|
7
|
+
const initialPath = "./src/components/ui"
|
|
8
|
+
const jsonFileName = "component.json"
|
|
9
|
+
|
|
6
10
|
export async function getConfig(): Promise<{ outputPath: string }> {
|
|
7
11
|
const packageDir = await packageDirectory()
|
|
8
|
-
const configPath = path.join(packageDir || process.cwd(),
|
|
12
|
+
const configPath = path.join(packageDir || process.cwd(), jsonFileName)
|
|
9
13
|
try {
|
|
10
14
|
// 1. 프로젝트 루트 디렉토리 찾기
|
|
11
15
|
|
|
@@ -13,11 +17,10 @@ export async function getConfig(): Promise<{ outputPath: string }> {
|
|
|
13
17
|
const config = await fs.readJSON(configPath)
|
|
14
18
|
return config
|
|
15
19
|
} catch {
|
|
16
|
-
// 4. 설정 파일이 없거나 잘못된 경우 사용자에게 입력받기
|
|
17
20
|
p.note("설정 파일이 존재하지 않습니다")
|
|
18
21
|
const config = await promptConfig() //3. 사용자에게 경로 관련 입력 받기
|
|
19
22
|
|
|
20
|
-
//
|
|
23
|
+
// 4. 새 설정 파일 저장
|
|
21
24
|
await fs.outputJSON(
|
|
22
25
|
configPath,
|
|
23
26
|
{
|
|
@@ -36,7 +39,7 @@ const promptConfig = async () =>
|
|
|
36
39
|
outputPath: () =>
|
|
37
40
|
p.text({
|
|
38
41
|
message: "컴포넌트 저장 경로를 설정해주세요",
|
|
39
|
-
initialValue:
|
|
42
|
+
initialValue: initialPath,
|
|
40
43
|
validate: (value) => {
|
|
41
44
|
if (!value) return "Please enter a path."
|
|
42
45
|
if (!value.startsWith("."))
|
package/src/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ import yargs from "yargs"
|
|
|
4
4
|
import { hideBin } from "yargs/helpers"
|
|
5
5
|
import { getConfig } from "./getConfig"
|
|
6
6
|
import * as p from "@clack/prompts"
|
|
7
|
-
import { copyComponent } from "./
|
|
7
|
+
import { copyComponent } from "./copyComponent"
|
|
8
8
|
|
|
9
9
|
const main = async () => {
|
|
10
10
|
await yargs(hideBin(process.argv))
|
|
@@ -28,7 +28,7 @@ const main = async () => {
|
|
|
28
28
|
async (argv) => {
|
|
29
29
|
// 컴포넌트가 없고 --all 플래그도 없으면 에러
|
|
30
30
|
if (argv.components.length === 0 && !argv.all) {
|
|
31
|
-
p.
|
|
31
|
+
p.cancel(
|
|
32
32
|
"Error: You need to specify at least one component or use the --all flag",
|
|
33
33
|
)
|
|
34
34
|
console.log('Run "cli --help" for more information')
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { useState } from "react"
|
|
2
|
-
import { useControlledState } from "../../hooks/useControllableState"
|
|
3
|
-
|
|
4
|
-
type Props = {
|
|
5
|
-
min: number
|
|
6
|
-
max: number
|
|
7
|
-
value: number
|
|
8
|
-
defaultValue?: number
|
|
9
|
-
onChange: (value: number) => void
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const getPercentage = (value: number, min: number, max: number) =>
|
|
13
|
-
((value - min) / (max - min)) * 100
|
|
14
|
-
|
|
15
|
-
const isTouchEvent = (e: TouchEvent | MouseEvent): e is TouchEvent => {
|
|
16
|
-
return e && "touches" in e
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const isMouseEvent = (e: TouchEvent | MouseEvent): e is MouseEvent => {
|
|
20
|
-
return e && "screenX" in e
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const getClientX = (
|
|
24
|
-
e: React.TouchEvent<HTMLElement> | React.MouseEvent<HTMLElement>,
|
|
25
|
-
) => {
|
|
26
|
-
let clientX = 0
|
|
27
|
-
if (isMouseEvent(e.nativeEvent)) {
|
|
28
|
-
clientX = e.nativeEvent.clientX
|
|
29
|
-
} else if (isTouchEvent(e.nativeEvent)) {
|
|
30
|
-
clientX =
|
|
31
|
-
e.nativeEvent.touches.length > 0
|
|
32
|
-
? e.nativeEvent.touches[0].clientX
|
|
33
|
-
: e.nativeEvent.changedTouches[0].clientX
|
|
34
|
-
}
|
|
35
|
-
return clientX
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const Slider = ({
|
|
39
|
-
min = 0,
|
|
40
|
-
max = 100,
|
|
41
|
-
value,
|
|
42
|
-
onChange,
|
|
43
|
-
defaultValue,
|
|
44
|
-
}: Props) => {
|
|
45
|
-
const [isDragging, setIsDragging] = useState(false)
|
|
46
|
-
|
|
47
|
-
const [innerValue = 0, setValue] = useControlledState({
|
|
48
|
-
prop: value,
|
|
49
|
-
defaultProp: defaultValue || min,
|
|
50
|
-
onChange,
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
const handlePointerDown = (e: React.PointerEvent) => {
|
|
54
|
-
e.preventDefault()
|
|
55
|
-
setIsDragging(true)
|
|
56
|
-
e.currentTarget.setPointerCapture(e.pointerId)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const handlePointerUp = (e: React.PointerEvent) => {
|
|
60
|
-
e.preventDefault()
|
|
61
|
-
setIsDragging(false)
|
|
62
|
-
e.currentTarget.releasePointerCapture(e.pointerId)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const percentage = getPercentage(innerValue, min, max)
|
|
66
|
-
|
|
67
|
-
const handleMouseMove = (e: React.PointerEvent<HTMLElement>) => {
|
|
68
|
-
e.preventDefault()
|
|
69
|
-
if (!isDragging) return
|
|
70
|
-
//width는 본인의 상위태그여야함..
|
|
71
|
-
const { left, width } = e.currentTarget.getBoundingClientRect()
|
|
72
|
-
let percentage = (getClientX(e) - left) / width
|
|
73
|
-
console.log(left, width)
|
|
74
|
-
percentage = Math.min(Math.max(percentage, 0), 1)
|
|
75
|
-
console.log(percentage)
|
|
76
|
-
const newValue = min + percentage * (max - min)
|
|
77
|
-
setValue(newValue)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<>
|
|
82
|
-
<span
|
|
83
|
-
className="slider-wrapper"
|
|
84
|
-
style={{
|
|
85
|
-
position: "relative",
|
|
86
|
-
display: "flex",
|
|
87
|
-
alignItems: "center",
|
|
88
|
-
width: "200px",
|
|
89
|
-
height: "50px",
|
|
90
|
-
}}
|
|
91
|
-
>
|
|
92
|
-
<span
|
|
93
|
-
className="slider-track"
|
|
94
|
-
onPointerDownCapture={handlePointerDown}
|
|
95
|
-
onPointerUpCapture={handlePointerUp}
|
|
96
|
-
onPointerMoveCapture={handleMouseMove}
|
|
97
|
-
onPointerCancelCapture={handlePointerUp}
|
|
98
|
-
style={{
|
|
99
|
-
position: "relative",
|
|
100
|
-
backgroundColor: "black",
|
|
101
|
-
flexGrow: 1,
|
|
102
|
-
borderRadius: "9999px",
|
|
103
|
-
height: "10px",
|
|
104
|
-
}}
|
|
105
|
-
>
|
|
106
|
-
<span
|
|
107
|
-
className="slider-value"
|
|
108
|
-
style={{
|
|
109
|
-
backgroundColor: "white",
|
|
110
|
-
borderRadius: "9999px",
|
|
111
|
-
height: "100%",
|
|
112
|
-
position: "absolute",
|
|
113
|
-
width: `${percentage}%`,
|
|
114
|
-
}}
|
|
115
|
-
></span>
|
|
116
|
-
<span
|
|
117
|
-
className="slider-thumb"
|
|
118
|
-
style={{
|
|
119
|
-
position: "absolute",
|
|
120
|
-
left: `${percentage}%`,
|
|
121
|
-
transform: "translateX(-50%)",
|
|
122
|
-
}}
|
|
123
|
-
>
|
|
124
|
-
<span
|
|
125
|
-
style={{
|
|
126
|
-
width: "10px",
|
|
127
|
-
height: "10px",
|
|
128
|
-
borderRadius: "100px",
|
|
129
|
-
backgroundColor: "pink",
|
|
130
|
-
opacity: "0.5",
|
|
131
|
-
display: "block",
|
|
132
|
-
}}
|
|
133
|
-
></span>
|
|
134
|
-
</span>
|
|
135
|
-
</span>
|
|
136
|
-
</span>
|
|
137
|
-
<div style={{ color: "pink" }}>{innerValue}</div>
|
|
138
|
-
</>
|
|
139
|
-
)
|
|
140
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { css } from "@styled-system/css"
|
|
2
|
-
import { motion } from "framer-motion"
|
|
3
|
-
|
|
4
|
-
export const TabIndicator = () => {
|
|
5
|
-
return (
|
|
6
|
-
<motion.div
|
|
7
|
-
className={css({
|
|
8
|
-
width: "var(--indicator-width)",
|
|
9
|
-
height: "2px",
|
|
10
|
-
transform: "translateZ(0px)",
|
|
11
|
-
position: "absolute",
|
|
12
|
-
bottom: 0,
|
|
13
|
-
left: `var(--indicator-left)`,
|
|
14
|
-
background: "red_300",
|
|
15
|
-
borderRadius: "rounded",
|
|
16
|
-
})}
|
|
17
|
-
></motion.div>
|
|
18
|
-
)
|
|
19
|
-
}
|
package/park-ui.json
DELETED
|
File without changes
|