@greenlabs/rescript-kakao-postcode 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021-2026 Greenlabs
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.
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # 카카오 주소 검색 리스크립트 바인딩
2
+
3
+ `rescript-kakao-postcode`는 [카카오 주소 검색](https://postcode.map.kakao.com/guide) 자바스크립트 모듈의 리스크립트(ReScript) 바인딩 입니다.
4
+
5
+ > 기존 `@greenlabs/rescript-daum-postcode` 패키지의 서비스 도메인이 변경됨에 따라 새롭게 만들어진 패키지입니다.
6
+
7
+ ## 설치하기
8
+
9
+ > ReScript 버전 호환 표
10
+
11
+ | Compiler | rescript_kakao_postcode |
12
+ | -------- | ---------------------- |
13
+ | v12 | >= v0.1.0 |
14
+
15
+ 1. 모듈 설치
16
+
17
+ ```shell
18
+ npm i @greenlabs/rescript-kakao-postcode
19
+ or
20
+ yarn add @greenlabs/rescript-kakao-postcode
21
+ ```
22
+
23
+ 2. `rescript.json` 의존성 추가하기
24
+
25
+ ```json
26
+ "dependencies": [
27
+ "@greenlabs/rescript-kakao-postcode"
28
+ ]
29
+ ```
30
+
31
+ ## 사용방법
32
+
33
+ ```rescript
34
+ open KakaoPostCode
35
+
36
+ let kakaoPostCode = make({
37
+ oncomplete: data => data->Js.Console.log,
38
+ onresize: size => size->Js.Console.log,
39
+ onclose: state =>
40
+ switch state {
41
+ | FORCE_CLOSE => "fc"->Js.Console.log
42
+ | COMPLETE_CLOSE => "cc"->Js.Console.log
43
+ },
44
+ onsearch: data => data->Js.Console.log,
45
+ width: 500.0,
46
+ height: 700.0,
47
+ })
48
+
49
+ // 팝업 방식
50
+ kakaoPostCode->openPostCode({
51
+ q: "문정동",
52
+ left: 100.0,
53
+ top: 200.0,
54
+ popupName: "주소검색",
55
+ autoClose: true,
56
+ })
57
+
58
+ // 임베드 방식
59
+ open Webapi
60
+
61
+ let div = Dom.document |> Dom.Document.getElementById("search-address")
62
+ div->Belt.Option.map(el => kakaoPostCode->embedPostCode(el, {
63
+ q: "문정동",
64
+ autoClose: true
65
+ }))->ignore
66
+ ```
67
+
68
+ ## API
69
+
70
+ [카카오 주소 검색 API](https://postcode.map.kakao.com/guide#attributes)
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@greenlabs/rescript-kakao-postcode",
3
+ "version": "0.1.0",
4
+ "description": "ReScript binding to Kakao Postcode",
5
+ "scripts": {
6
+ "start": "rescript watch",
7
+ "build": "rescript",
8
+ "clean": "rescript clean"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/green-labs/rescript-bindings.git",
13
+ "directory": "packages/rescript-kakao-postcode"
14
+ },
15
+ "keywords": [
16
+ "ReScript",
17
+ "Kakao Postcode"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "author": "Greenlabs Dev <developer@greenlabs.co.kr>",
23
+ "license": "MIT",
24
+ "bugs": "https://github.com/green-labs/rescript-bindings/issues",
25
+ "homepage": "https://github.com/green-labs/rescript-bindings/tree/main/packages/rescript-kakao-postcode",
26
+ "devDependencies": {
27
+ "rescript": "^12.0.0"
28
+ }
29
+ }
package/rescript.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@greenlabs/rescript-kakao-postcode",
3
+ "compiler-flags": [],
4
+ "sources": [
5
+ {
6
+ "dir": "src"
7
+ }
8
+ ],
9
+ "package-specs": [
10
+ {
11
+ "module": "esmodule",
12
+ "in-source": true
13
+ }
14
+ ],
15
+ "suffix": ".bs.js",
16
+ "dev-dependencies": []
17
+ }
@@ -0,0 +1,106 @@
1
+ type t
2
+ type addressType = R | J // R 도로명 | J 지번
3
+ type selected = Y | N // 선택 상태
4
+ type lang = K | E // K 한글주소 | E 영문주소
5
+
6
+ type oncompleteResponse = {
7
+ address: string,
8
+ addressEnglish: string,
9
+ addressType: addressType,
10
+ apartment: selected,
11
+ autoJibunAddress: string,
12
+ autoJibunAddressEnglish: string,
13
+ autoRoadAddress: string,
14
+ autoRoadAddressEnglish: string,
15
+ bcode: string,
16
+ bname: string,
17
+ bname1: string,
18
+ bname1English: string,
19
+ bname2: string,
20
+ bname2English: string,
21
+ bnameEnglish: string,
22
+ buildingCode: string,
23
+ buildingName: string,
24
+ hname: string,
25
+ jibunAddress: string,
26
+ jibunAddressEnglish: string,
27
+ noSelected: selected,
28
+ postcode: string,
29
+ postcode1: string,
30
+ postcode2: string,
31
+ postcodeSeq: string,
32
+ query: string,
33
+ roadAddress: string,
34
+ roadAddressEnglish: string,
35
+ roadname: string,
36
+ roadnameCode: string,
37
+ roadnameEnglish: string,
38
+ sido: string,
39
+ sidoEnglish: string,
40
+ sigungu: string,
41
+ sigunguCode: string,
42
+ sigunguEnglish: string,
43
+ userLanguageType: lang,
44
+ userSelectedType: addressType,
45
+ zonecode: string,
46
+ }
47
+ type onresizeResponse = {
48
+ width: float,
49
+ height: float,
50
+ }
51
+ type oncloseResponse = FORCE_CLOSE | COMPLETE_CLOSE
52
+ type onsearchResponse = {q: string, count: int}
53
+
54
+ type themeObj = {
55
+ bgColor?: string, // 바탕 배경색
56
+ searchBgColor?: string, // 검색창 배경색
57
+ contentBgColor?: string, // 본문 배경색(검색결과,결과없음,첫화면,검색서제스트)
58
+ pageBgColor?: string, // 페이지 배경색
59
+ textColor?: string, // 기본 글자색
60
+ queryTextColor?: string, // 검색창 글자색
61
+ postcodeTextColor?: string, // 우편번호 글자색
62
+ emphTextColor?: string, // 강조 글자색
63
+ outlineColor?: string, // 테두리
64
+ }
65
+
66
+ type params = {
67
+ oncomplete?: oncompleteResponse => unit,
68
+ onresize?: onresizeResponse => unit,
69
+ onclose?: oncloseResponse => unit,
70
+ onsearch?: onsearchResponse => unit,
71
+ width?: float,
72
+ height?: float,
73
+ animation?: bool,
74
+ focusInput?: bool,
75
+ autoMapping?: bool,
76
+ shorthand?: bool,
77
+ pleaseReadGuide?: int,
78
+ pleaseReadGuideTimer?: float,
79
+ maxSuggestItems?: int,
80
+ showMoreHName?: bool,
81
+ hideMapBtn?: bool,
82
+ hideEngBtn?: bool,
83
+ alwaysShowEngAddr?: bool,
84
+ useBannerLink?: bool,
85
+ theme?: themeObj,
86
+ submitMode?: bool,
87
+ }
88
+
89
+ @new @scope("kakao") external make: params => t = "Postcode"
90
+
91
+ type openParams = {
92
+ q?: string,
93
+ left?: float,
94
+ top?: float,
95
+ popupName?: string,
96
+ autoClose?: bool,
97
+ }
98
+
99
+ @send external openPostCode: (t, openParams) => unit = "open"
100
+
101
+ type embedParams = {
102
+ q?: string,
103
+ autoClose?: bool,
104
+ }
105
+
106
+ @send external embedPostCode: (t, Dom.element, embedParams) => unit = "embed"