@watcha-authentic/react-slider 0.0.1 → 0.1.1

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.
@@ -0,0 +1,85 @@
1
+ import type { CSSProperties } from "react";
2
+ import type { SlideTriggerEvent } from "../../script/type/slider-types";
3
+ type SliderProps<ItemType> = {
4
+ itemProps?: React.HTMLAttributes<HTMLLIElement>;
5
+ wrapProps?: React.HTMLAttributes<HTMLUListElement>;
6
+ contentProps?: React.HTMLAttributes<HTMLDivElement>;
7
+ items: Array<ItemType>;
8
+ onCreateItemView: (item: ItemType, index: number) => React.ReactNode;
9
+ onItemKey: (item: ItemType) => React.Key;
10
+ /**
11
+ * - 높이, 드래그 임계값 등의 사이즈 관련 값을 추정하는 방식을 선택 합니다. 기본값은 false 입니다.
12
+ * - true: 모든 자식요소로부터 추정합니다. 가장 큰 사이즈값이 선택 됩니다.
13
+ * - false: 첫번째 자식요소의 사이즈를 사용합니다.
14
+ */
15
+ estimateSizeFromEveryElements?: boolean;
16
+ /**
17
+ * - item 간 거리입니다.
18
+ * - 기본값은 0 입니다.
19
+ */
20
+ gap?: number;
21
+ /**
22
+ * - 슬라이드 애니메이션 지속 시간(milliseconds)입니다.
23
+ * - 기본값은 500 입니다.
24
+ */
25
+ animationDuration?: number;
26
+ /**
27
+ * - 슬라이드 애니메이션 타이밍 함수입니다.
28
+ * - 기본값은 "ease" 입니다.
29
+ */
30
+ animationTimingFunction?: CSSProperties["transitionTimingFunction"];
31
+ /**
32
+ * - 초기 인덱스입니다.
33
+ * - 기본값은 0 입니다.
34
+ */
35
+ defaultIndex?: number;
36
+ /**
37
+ * - currentIndex 입니다. 이 값이 변경되면 애니메이션이 동작 될 수 있습니다.
38
+ * - 기본값은 defaultIndex 입니다.
39
+ */
40
+ index?: number;
41
+ /**
42
+ * - 중앙 기준 좌우로 보여줄 요소 개수입니다.
43
+ * - 예: 1이면 좌1 + 중앙1 + 우1 = 3개, 2이면 좌2 + 중앙1 + 우2 = 5개
44
+ * - 기본값은 1 입니다.
45
+ */
46
+ visibleCount?: number;
47
+ /**
48
+ * - 인덱스 변경 시 호출되는 콜백입니다.
49
+ * - cause: 슬라이드 원인 ('swipe': 키보드 네비게이션, 'drag': 드래그/스와이프, undefined: 외부 prop 변경)
50
+ */
51
+ onIndexChange?: (newIndex: number, cause: SlideTriggerEvent) => void;
52
+ /**
53
+ * - 드래그 기능 활성화 여부입니다.
54
+ * - 기본값은 true 입니다.
55
+ */
56
+ enableDrag?: boolean;
57
+ onDraggingNow?: (isDragging: boolean) => void;
58
+ };
59
+ /**
60
+ * # 루프 슬라이더 컴포넌트
61
+ *
62
+ * ## Element 구조
63
+ * - wrap: 슬라이더를 감싸는 요소
64
+ * - item: 슬라이더 하위의 아이템 요소
65
+ * - content: 슬라이더 아이템 내부의 컨텐츠 요소 (높이영향)
66
+ *
67
+ * ## 아이템 복제 로직
68
+ * 아이템 개수가 부족하면 자동으로 복제하여 자연스러운 루프를 구현합니다.
69
+ *
70
+ * ### 최소 필요 개수 (visibleCount=1 기준): 5개
71
+ * - 좌측 (visibleCount + 1) = 2개 (보이는 1개 + 대기 1개)
72
+ * - 중앙 = 1개
73
+ * - 우측 (visibleCount + 1) = 2개 (보이는 1개 + 대기 1개)
74
+ *
75
+ * ### 아이템 갯수에 따른 복제 동작
76
+ * - 5개 이상: 복제 없음, 원본 그대로(x1)
77
+ * - 4개: 8개로 복제(x2)
78
+ * - 3개: 6개로 복제(x2)
79
+ * - 2개: 6개로 복제(x3)
80
+ * - 1개: 5개로 복제(x5)
81
+ */
82
+ export declare const Slider: <ItemType = unknown>(props: SliderProps<ItemType> & {
83
+ ref?: React.ForwardedRef<HTMLUListElement>;
84
+ }) => React.ReactElement;
85
+ export {};
@@ -0,0 +1,5 @@
1
+ export * from "./component/context/slider-context";
2
+ export * from "./component/context/slider-context-provider";
3
+ export * from "./component/hook/use-slider-context";
4
+ export * from "./component/view/slider";
5
+ export * from "./script/type/slider-types";
@@ -0,0 +1,4 @@
1
+ /**
2
+ * - 슬라이드시 이벤트 트리거 종류
3
+ */
4
+ export type SlideTriggerEvent = "drag" | "swipe";
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "@watcha-authentic/react-slider",
3
- "keywords": [],
4
- "version": "0.0.1",
5
- "homepage": "https://github.com/frograms/bistro-house#readme",
3
+ "description": "리액트기반 슬라이더 컴포넌트",
4
+ "keywords": [
5
+ "react",
6
+ "slider",
7
+ "swiper"
8
+ ],
9
+ "version": "0.1.1",
10
+ "homepage": "https://github.com/frograms/bistro-house/tree/master/packages/react-slider#readme",
6
11
  "author": {
7
12
  "name": "@watcha-authentic#web-dev-group",
8
13
  "email": "web-dev-group@watcha.com",
@@ -20,7 +25,63 @@
20
25
  "access": "public"
21
26
  },
22
27
  "scripts": {
23
- "test": "echo \"Error: no test specified\" && exit 1"
28
+ "test": "echo Test skipped...",
29
+ "validate": "tsc && npm run lint && npm run build",
30
+ "lint": "eslint .",
31
+ "build:cjs": "swc src --out-dir ./dist/cjs --config-file swc-cjs.json --ignore '**/*.d.ts' --strip-leading-paths",
32
+ "build:esm": "swc src --out-dir ./dist/esm --config-file swc-esm.json --ignore '**/*.d.ts' --strip-leading-paths",
33
+ "build:type": "tsc --outDir ./dist/type --project ./tsconfig.type.json",
34
+ "build": "rm -rf ./dist && concurrently -n CJS,ESM,TYPE 'pnpm build:cjs' 'pnpm build:esm' 'pnpm build:type' && pnpm post-build",
35
+ "post-build": "bash ./project-attachment/post-build.sh"
36
+ },
37
+ "main": "./dist/cjs/index.js",
38
+ "module": "./dist/esm/index.js",
39
+ "types": "./dist/type/index.d.ts",
40
+ "exports": {
41
+ ".": {
42
+ "import": "./dist/esm/index.js",
43
+ "require": "./dist/cjs/index.js",
44
+ "types": "./dist/type/index.d.ts"
45
+ },
46
+ "./style.css": "./dist/style.css"
47
+ },
48
+ "files": [
49
+ "dist"
50
+ ],
51
+ "dependencies": {
52
+ "@watcha-authentic/react-a11y": "^0.1.0",
53
+ "@watcha-authentic/react-event-callback": "^0.1.0",
54
+ "@watcha-authentic/react-motion": "^0.1.0"
55
+ },
56
+ "devDependencies": {
57
+ "@swc/cli": "^0.7.9",
58
+ "@swc/core": "^1.15.7",
59
+ "@types/react": "^19.0.0",
60
+ "@types/react-dom": "^19.0.0",
61
+ "@typescript-eslint/eslint-plugin": "^8.50.0",
62
+ "@typescript-eslint/parser": "^8.50.0",
63
+ "@watcha-authentic/eslint-config": "^0.1.0",
64
+ "chokidar": "^4.0.1",
65
+ "chokidar-cli": "^3.0.0",
66
+ "concurrently": "^9.2.1",
67
+ "eslint": "^9.39.2",
68
+ "eslint-import-resolver-typescript": "^3.6.0",
69
+ "eslint-plugin-import": "^2.31.0",
70
+ "eslint-plugin-react": "^7.37.5",
71
+ "eslint-plugin-react-hooks": "^7.0.0",
72
+ "eslint-plugin-simple-import-sort": "^12.1.1",
73
+ "jiti": "^2.6.1",
74
+ "postcss": "^8.4.0",
75
+ "postcss-cli": "^11.0.0",
76
+ "postcss-load-config": "^6.0.0",
77
+ "cssnano": "^7.0.0",
78
+ "react": "^19.0.0",
79
+ "react-dom": "^19.0.0",
80
+ "typescript": "~5.9.3"
81
+ },
82
+ "peerDependencies": {
83
+ "react": ">=18.0.0",
84
+ "react-dom": ">=18.0.0"
24
85
  },
25
86
  "license": "MIT"
26
- }
87
+ }