Skip to content

Commit 9434971

Browse files
authored
Merge pull request #79 from kmsbernard/feat/migrate-daum-to-kakao
feat: migrate daum interfaces to kakao
2 parents ebd42b1 + 47f7e72 commit 9434971

6 files changed

Lines changed: 65 additions & 45 deletions

File tree

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# react-daum-postcode
22

3-
Daum 우편번호 검색 서비스를 React 환경에서 간편하게 이용할 수 있습니다.
3+
Kakao(구 Daum) 우편번호 검색 서비스를 React 환경에서 간편하게 이용할 수 있습니다.
44

55
## Install
66

@@ -17,11 +17,11 @@ yarn add react
1717

1818
## Embed
1919

20-
`DaumPostcodeEmbed` 컴포넌트를 사용하여, 우편번호 검색 서비스를 임베드 방식으로 사용할 수 있습니다.
20+
`KakaoPostcodeEmbed` 컴포넌트를 사용하여, 우편번호 검색 서비스를 임베드 방식으로 사용할 수 있습니다.
2121

2222
```javascript
2323
import React from 'react';
24-
import DaumPostcodeEmbed from 'react-daum-postcode';
24+
import KakaoPostcodeEmbed from 'react-daum-postcode';
2525

2626
const Postcode = () => {
2727
const handleComplete = (data) => {
@@ -41,37 +41,37 @@ const Postcode = () => {
4141
console.log(fullAddress); // e.g. '서울 성동구 왕십리로2길 20 (성수동1가)'
4242
};
4343

44-
return <DaumPostcodeEmbed onComplete={handleComplete} {...props} />;
44+
return <KakaoPostcodeEmbed onComplete={handleComplete} {...props} />;
4545
};
4646
```
4747

48-
`DaumPostcodeEmbed` 컴포넌트에 다음 우편번호 서비스의 생성자 및 임베드 설정값 등을 `props`로 전달할 수 있습니다. 전달하지 않은 설정값은 다음 우편번호 서비스의 기본 설정을 따라갑니다.
48+
`KakaoPostcodeEmbed` 컴포넌트에 카카오 우편번호 서비스의 생성자 및 임베드 설정값 등을 `props`로 전달할 수 있습니다. 전달하지 않은 설정값은 카카오 우편번호 서비스의 기본 설정을 따라갑니다.
4949

5050
| name | type | default | description
5151
|:----:|:----:|:-------:|:-----------|
52-
| scriptUrl | `string` | [CURRENT_URL](https://t1.kakaocdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js) | Daum 우편번호 서비스의 스크립트 주소입니다.|
53-
| onComplete | `function` | `undefined` | 우편번호 검색이 끝났을 때 사용자가 선택한 정보를 받아올 콜백함수입니다. 주소 데이터의 구성은 [Daum 가이드](http://postcode.map.daum.net/guide)를 참고해주세요. |
54-
| onSearch | `function` | `undefined` | 주소를 검색할 경우 실행되는 콜백함수입니다. 검색 결과 정보의 구성은 [Daum 가이드](http://postcode.map.daum.net/guide)를 참고해주세요. |
52+
| scriptUrl | `string` | [CURRENT_URL](https://t1.kakaocdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js) | Kakao 우편번호 서비스의 스크립트 주소입니다.|
53+
| onComplete | `function` | `undefined` | 우편번호 검색이 끝났을 때 사용자가 선택한 정보를 받아올 콜백함수입니다. 주소 데이터의 구성은 [Kakao 가이드](http://postcode.map.daum.net/guide)를 참고해주세요. |
54+
| onSearch | `function` | `undefined` | 주소를 검색할 경우 실행되는 콜백함수입니다. 검색 결과 정보의 구성은 [Kakao 가이드](http://postcode.map.daum.net/guide)를 참고해주세요. |
5555
| onClose | `function` | `undefined` | 검색 결과를 선택하여, 서비스가 닫힐 때 실행되는 콜백함수입니다. |
56-
| onResize | `function` | `undefined` | 검색 결과로 인해, 우편번호 서비스의 화면 크기가 변경될 때 호출되는 콜백함수입니다. 변경된 화면 정보의 구성은 [Daum 가이드](http://postcode.map.daum.net/guide)를 참고해주세요. |
56+
| onResize | `function` | `undefined` | 검색 결과로 인해, 우편번호 서비스의 화면 크기가 변경될 때 호출되는 콜백함수입니다. 변경된 화면 정보의 구성은 [Kakao 가이드](http://postcode.map.daum.net/guide)를 참고해주세요. |
5757
| className | `string` | `undefined` | 우편번호 검색창을 감싸는 최상위 엘리먼트에 적용할 클래스 이름입니다. |
5858
| style | `object` | `{ width:"100%", height:400 }` | 우편번호 검색창을 감싸는 최상위 엘리먼트에 적용할 스타일입니다. |
5959
| defaultQuery | `string` | `undefined` | 우편번호 검색창에 기본으로 입력할 검색어입니다.
6060
| autoClose | `boolean` | `true` | 우편번호 검색 완료시 자동 닫힘 여부입니다. 주소를 선택하면, 최상위 엘리먼트를 돔에서 제거합니다. |
61-
| errorMessage | `ReactNode` | `<p>현재 Daum 우편번호 서비스를 이용할 수 없습니다. 잠시 후 다시 시도해주세요.</p>` | 우편번호 서비스 스크립트 로드에 실패했을 때 나타낼 에러 메세지 입니다. |
61+
| errorMessage | `ReactNode` | `<p>현재 Kakao 우편번호 서비스를 이용할 수 없습니다. 잠시 후 다시 시도해주세요.</p>` | 우편번호 서비스 스크립트 로드에 실패했을 때 나타낼 에러 메세지 입니다. |
6262

63-
기타 Daum 우편번호 생성자 속성들을 동일한 이름으로 props를 전달할 수 있습니다. 속성값에 대해서는 [Daum 우편번호 서비스 가이드](http://postcode.map.daum.net/guide#attributes)를 참고해주세요.
63+
기타 Kakao 우편번호 생성자 속성들을 동일한 이름으로 props를 전달할 수 있습니다. 속성값에 대해서는 [Kakao 우편번호 서비스 가이드](http://postcode.map.daum.net/guide#attributes)를 참고해주세요.
6464

6565
## Popup
6666

67-
`useDaumPostcodePopup` hook 을 사용하여, 반환받은 함수를 통해 우편번호 검색 서비스를 팝업 방식으로 이용할 수 있습니다.
67+
`useKakaoPostcodePopup` hook 을 사용하여, 반환받은 함수를 통해 우편번호 검색 서비스를 팝업 방식으로 이용할 수 있습니다.
6868

6969
```javascript
7070
import React from 'react';
71-
import { useDaumPostcodePopup } from 'react-daum-postcode';
71+
import { useKakaoPostcodePopup } from 'react-daum-postcode';
7272

7373
const Postcode = () => {
74-
const open = useDaumPostcodePopup(scriptUrl);
74+
const open = useKakaoPostcodePopup(scriptUrl);
7575

7676
const handleComplete = (data) => {
7777
let fullAddress = data.address;
@@ -102,27 +102,27 @@ const Postcode = () => {
102102
};
103103
```
104104

105-
`useDaumPostcodePopup` 실행 시 우편번호 서비스의 스크립트 주소를 전달할 수 있습니다. 반환한 함수를 실행할 때 다음 우편번호 서비스의 생성자 및 팝업 설정값을 전달할 수 있습니다. 전달하지 않은 설정값은 다음 우편번호 서비스의 기본 설정을 따라갑니다.
105+
`useKakaoPostcodePopup` 실행 시 우편번호 서비스의 스크립트 주소를 전달할 수 있습니다. 반환한 함수를 실행할 때 카카오 우편번호 서비스의 생성자 및 팝업 설정값을 전달할 수 있습니다. 전달하지 않은 설정값은 카카오 우편번호 서비스의 기본 설정을 따라갑니다.
106106

107107
| name | type | default | description
108108
|:----:|:----:|:-------:|:-----------|
109-
| scriptUrl | `string` | [CURRENT_URL](https://t1.kakaocdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js) | Daum 우편번호 서비스의 스크립트 주소입니다.|
110-
| onComplete | `function` | `undefined` | 우편번호 검색이 끝났을 때 사용자가 선택한 정보를 받아올 콜백함수입니다. 주소 데이터의 구성은 [Daum 가이드](http://postcode.map.daum.net/guide)를 참고해주세요. |
111-
| onSearch | `function` | `undefined` | 주소를 검색할 경우 실행되는 콜백함수입니다. 검색 결과 정보의 구성은 [Daum 가이드](http://postcode.map.daum.net/guide)를 참고해주세요. |
109+
| scriptUrl | `string` | [CURRENT_URL](https://t1.kakaocdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js) | Kakao 우편번호 서비스의 스크립트 주소입니다.|
110+
| onComplete | `function` | `undefined` | 우편번호 검색이 끝났을 때 사용자가 선택한 정보를 받아올 콜백함수입니다. 주소 데이터의 구성은 [Kakao 가이드](http://postcode.map.daum.net/guide)를 참고해주세요. |
111+
| onSearch | `function` | `undefined` | 주소를 검색할 경우 실행되는 콜백함수입니다. 검색 결과 정보의 구성은 [Kakao 가이드](http://postcode.map.daum.net/guide)를 참고해주세요. |
112112
| onClose | `function` | `undefined` | 검색 결과를 선택하여, 서비스가 닫힐 때 실행되는 콜백함수입니다. |
113-
| onResize | `function` | `undefined` | 검색 결과로 인해, 우편번호 서비스의 화면 크기가 변경될 때 호출되는 콜백함수입니다. 변경된 화면 정보의 구성은 [Daum 가이드](http://postcode.map.daum.net/guide)를 참고해주세요. |
113+
| onResize | `function` | `undefined` | 검색 결과로 인해, 우편번호 서비스의 화면 크기가 변경될 때 호출되는 콜백함수입니다. 변경된 화면 정보의 구성은 [Kakao 가이드](http://postcode.map.daum.net/guide)를 참고해주세요. |
114114
| width | `string\|number` | `undefined` | 우편번호 검색창의 가로 너비입니다. |
115115
| height | `string\|number` | `undefined` | 우편번호 검색창의 세로 높이입니다. |
116116
| defaultQuery | `string` | `undefined` | 우편번호 검색창에 기본으로 입력할 검색어입니다. |
117117
| top | `string\|number` | `undefined` | 팝업의 Y 위치를 나타내는 값입니다. |
118118
| left | `string\|number` | `undefined` | 팝업의 X 위치를 나타내는 값입니다. |
119-
| popupTitle | `string` | `undefined` | 팝업창의 상태표시줄에 나오는 Title 값을 지정할 수 있습니다. 전달하지 않을 경우, 다음 우편번호의 기본 설정 문구가 출력됩니다. |
119+
| popupTitle | `string` | `undefined` | 팝업창의 상태표시줄에 나오는 Title 값을 지정할 수 있습니다. 전달하지 않을 경우, 카카오 우편번호의 기본 설정 문구가 출력됩니다. |
120120
| popupKey | `string` | `undefined` | 팝업창의 key 입니다. 전달하지 않을 경우 매번 새창이 열리게 됩니다. |
121121
| autoClose | `boolean` | `true` | 우편번호 검색 완료시 자동 닫힘 여부입니다. 주소를 선택하면 팝업창이 닫힙니다.
122122

123-
기타 Daum 우편번호 생성자 속성들을 동일한 이름으로 props를 전달할 수 있습니다. 속성값에 대해서는 [Daum 우편번호 서비스 가이드](http://postcode.map.daum.net/guide#attributes)를 참고해주세요.
123+
기타 Kakao 우편번호 생성자 속성들을 동일한 이름으로 props를 전달할 수 있습니다. 속성값에 대해서는 [Kakao 우편번호 서비스 가이드](http://postcode.map.daum.net/guide#attributes)를 참고해주세요.
124124

125125

126126
## 안내
127127

128-
`react-daum-postcode`Daum 우편번호 서비스와 독립적으로 제작된 패키지입니다. React환경에서 발생하는 `react-daum-postcode`의 버그는 패키지 레포지터리의 [이슈트래커](https://github.com/kimminsik-bernard/react-daum-postcode/issues)에 말씀해주세요. 만약 Daum 우편번호 서비스 자체의 문제라고 생각하신다면, 다음 우편번호 서비스의 [FAQ](https://github.com/daumPostcode/QnA/blob/master/README.md)[이슈트래커](https://github.com/daumPostcode/QnA/issues)를 참조해주세요.
128+
`react-daum-postcode`Kakao 우편번호 서비스와 독립적으로 제작된 패키지입니다. React환경에서 발생하는 `react-daum-postcode`의 버그는 패키지 레포지터리의 [이슈트래커](https://github.com/kimminsik-bernard/react-daum-postcode/issues)에 말씀해주세요. 만약 Kakao 우편번호 서비스 자체의 문제라고 생각하신다면, 카카오 우편번호 서비스의 [FAQ](https://github.com/daumPostcode/QnA/blob/master/README.md)[이슈트래커](https://github.com/daumPostcode/QnA/issues)를 참조해주세요.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-daum-postcode",
33
"version": "3.2.0",
4-
"description": "Daum Postcode service for React",
4+
"description": "Kakao(prev: Daum) Postcode service for React",
55
"main": "./lib/index.cjs.js",
66
"types": "./lib/index.d.ts",
77
"module": "./lib/index.esm.js",
@@ -57,6 +57,7 @@
5757
"keywords": [
5858
"react",
5959
"daum",
60+
"kakao",
6061
"postcode",
6162
"zipcode"
6263
],
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { Component, createRef, CSSProperties } from 'react';
22
import loadPostcode, { postcodeScriptUrl, PostcodeConstructor, PostcodeOptions, EmbedOptions } from './loadPostcode';
33

4-
export interface DaumPostcodeEmbedProps
4+
export interface KakaoPostcodeEmbedProps
55
extends Omit<PostcodeOptions, 'oncomplete' | 'onresize' | 'onclose' | 'onsearch' | 'width' | 'height'>,
66
Omit<EmbedOptions, 'q'> {
77
onComplete?: PostcodeOptions['oncomplete'];
@@ -14,20 +14,13 @@ export interface DaumPostcodeEmbedProps
1414
errorMessage?: string | React.ReactNode;
1515
scriptUrl?: string;
1616
}
17-
/**
18-
* @deprecated
19-
* type 'DaumPostcodeProps' is renamed to 'DaumPostcodeEmbedProps'.
20-
* use 'DaumPostcodeEmbedProps' instead of 'DaumPostcodeProps'.
21-
* it will be removed future version.
22-
*/
23-
export type DaumPostcodeProps = DaumPostcodeEmbedProps;
2417

2518
interface State {
2619
hasError: boolean;
2720
completed: boolean;
2821
}
2922

30-
const defaultErrorMessage = <p>현재 Daum 우편번호 서비스를 이용할 수 없습니다. 잠시 후 다시 시도해주세요.</p>;
23+
const defaultErrorMessage = <p>현재 Kakao 우편번호 서비스를 이용할 수 없습니다. 잠시 후 다시 시도해주세요.</p>;
3124

3225
const defaultStyle = {
3326
width: '100%',
@@ -40,7 +33,7 @@ const defaultProps = {
4033
autoClose: true,
4134
};
4235

43-
class DaumPostcodeEmbed extends Component<DaumPostcodeEmbedProps, State> {
36+
class KakaoPostcodeEmbed extends Component<KakaoPostcodeEmbedProps, State> {
4437
static defaultProps = defaultProps;
4538
/**
4639
* See #61
@@ -105,4 +98,4 @@ class DaumPostcodeEmbed extends Component<DaumPostcodeEmbedProps, State> {
10598
}
10699
}
107100

108-
export default DaumPostcodeEmbed;
101+
export default KakaoPostcodeEmbed;

src/index.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
1-
import DaumPostcodeEmbed from './DaumPostcodeEmbed';
2-
import useDaumPostcodePopup from './useDaumPostcodePopup';
1+
import KakaoPostcodeEmbed from './KakaoPostcodeEmbed';
2+
import useKakaoPostcodePopup from './useKakaoPostcodePopup';
33
import loadPostcode from './loadPostcode';
44

5-
export { loadPostcode, DaumPostcodeEmbed, useDaumPostcodePopup };
6-
export default DaumPostcodeEmbed;
5+
export { loadPostcode, KakaoPostcodeEmbed, useKakaoPostcodePopup };
6+
export default KakaoPostcodeEmbed;
77

8-
import type { DaumPostcodeEmbedProps, DaumPostcodeProps } from './DaumPostcodeEmbed';
9-
import type { DaumPostcodePopupParams } from './useDaumPostcodePopup';
8+
import type { KakaoPostcodeEmbedProps } from './KakaoPostcodeEmbed';
9+
import type { KakaoPostcodePopupParams } from './useKakaoPostcodePopup';
1010
import type { Address, Search, State } from './loadPostcode';
1111

12-
export type { DaumPostcodeEmbedProps, DaumPostcodeProps, DaumPostcodePopupParams, Address, Search, State };
12+
export type { KakaoPostcodeEmbedProps, KakaoPostcodePopupParams, Address, Search, State };
13+
14+
/**
15+
* @deprecated Use `KakaoPostcodeEmbed` instead.
16+
*/
17+
const DaumPostcodeEmbed = KakaoPostcodeEmbed;
18+
/**
19+
* @deprecated Use `useKakaoPostcodePopup` instead.
20+
*/
21+
const useDaumPostcodePopup = useKakaoPostcodePopup;
22+
/**
23+
* @deprecated Use `KakaoPostcodeEmbedProps` instead.
24+
*/
25+
type DaumPostcodeEmbedProps = KakaoPostcodeEmbedProps;
26+
/**
27+
* @deprecated Use `KakaoPostcodePopupParams` instead.
28+
*/
29+
type DaumPostcodePopupParams = KakaoPostcodePopupParams;
30+
31+
export { DaumPostcodeEmbed, useDaumPostcodePopup };
32+
export type { DaumPostcodeEmbedProps, DaumPostcodePopupParams };

src/loadPostcode.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
declare global {
22
interface Window {
33
daum?: {
4+
/**
5+
* @deprecated Use kakao.postcode instead.
6+
*/
47
postcode: {
58
load: (fn: () => void) => void;
69
version: string;
710
_validParam_: boolean;
811
};
12+
/**
13+
* @deprecated Use kakao.postcode instead.
14+
*/
915
Postcode: PostcodeConstructor;
1016
};
1117
kakao?: {
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useCallback, useEffect } from 'react';
22

33
import loadPostcode, { PostcodeOptions, OpenOptions, postcodeScriptUrl } from './loadPostcode';
44

5-
export type DaumPostcodePopupParams = Omit<PostcodeOptions, 'oncomplete' | 'onresize' | 'onclose' | 'onsearch'> &
5+
export type KakaoPostcodePopupParams = Omit<PostcodeOptions, 'oncomplete' | 'onresize' | 'onclose' | 'onsearch'> &
66
Omit<OpenOptions, 'q'> & {
77
onComplete?: PostcodeOptions['oncomplete'];
88
onResize?: PostcodeOptions['onresize'];
@@ -12,13 +12,13 @@ export type DaumPostcodePopupParams = Omit<PostcodeOptions, 'oncomplete' | 'onre
1212
defaultQuery?: string;
1313
};
1414

15-
function useDaumPostcodePopup(scriptUrl = postcodeScriptUrl) {
15+
function useKakaoPostcodePopup(scriptUrl = postcodeScriptUrl) {
1616
useEffect(() => {
1717
loadPostcode(scriptUrl);
1818
}, [scriptUrl]);
1919

2020
const open = useCallback(
21-
(options?: DaumPostcodePopupParams) => {
21+
(options?: KakaoPostcodePopupParams) => {
2222
const { defaultQuery, left, top, popupKey, popupTitle, autoClose, onComplete, onResize, onClose, onSearch, onError, ...others } = {
2323
...options,
2424
};
@@ -42,4 +42,4 @@ function useDaumPostcodePopup(scriptUrl = postcodeScriptUrl) {
4242
return open;
4343
}
4444

45-
export default useDaumPostcodePopup;
45+
export default useKakaoPostcodePopup;

0 commit comments

Comments
 (0)