Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

리스크립트 v11 대응 #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# CHANGELOG

## 0.2.0

- ReScript v11 지원
- API 파라미터에 옵셔널 필드 레코드 사용
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

## 설치하기

> ReScript 버전 호환 표

| Compiler | res_daum_postcode |
| -------- | ----------------- |
| v11 | >= v0.2.0 |
| v10 | ~<= v0.1.1 |

1. 모듈 설치

```shell
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@greenlabs/res-daum-postcode",
"version": "0.1.1",
"version": "0.2.0",
"description": "ReScript binding to Daum Postcode",
"scripts": {
"res:watch": "rescript build -w",
Expand All @@ -22,6 +22,6 @@
},
"homepage": "https://github.com/green-labs/res-daum-postcode#readme",
"devDependencies": {
"rescript": "^10"
"rescript": "11.0.0-rc.7"
}
}
19 changes: 19 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
97 changes: 52 additions & 45 deletions src/DaumPostCode.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type t
type addressType = [#R | #J] // #R 도로명 | #J 지번
type selected = [#Y | #N] // 선택 상태
type lang = [#K | #E] // #K 한글주소 | #E 영문주소
type addressType = R | J // R 도로명 | J 지번
type selected = Y | N // 선택 상태
type lang = K | E // K 한글주소 | E 영문주소

type oncompleteResponse = {
address: string,
Expand Down Expand Up @@ -48,52 +48,59 @@ type onresizeResponse = {
width: float,
height: float,
}
type oncloseResponse = [#FORCE_CLOSE | #COMPLETE_CLOSE]
type oncloseResponse = FORCE_CLOSE | COMPLETE_CLOSE
type onsearchResponse = {q: string, count: int}

type option
@obj
external makeOption: (
~oncomplete: oncompleteResponse => unit=?,
~onresize: onresizeResponse => unit=?,
~onclose: oncloseResponse => unit=?,
~onsearch: onsearchResponse => unit=?,
~width: float=?,
~height: float=?,
~animation: bool=?,
~focusInput: bool=?,
~autoMapping: bool=?,
~shorthand: bool=?,
~pleaseReadGuide: int=?,
~pleaseReadGuideTimer: float=?,
~maxSuggestItems: int=?,
~showMoreHName: bool=?,
~hideMapBtn: bool=?,
~hideEngBtn: bool=?,
~alwaysShowEngAddr: bool=?,
~useBannerLink: bool=?,
~theme: {..}=?,
~submitMode: bool=?,
unit,
) => option = ""
type themeObj = {
bgColor?: string, // 바탕 배경색
searchBgColor?: string, // 검색창 배경색
contentBgColor?: string, // 본문 배경색(검색결과,결과없음,첫화면,검색서제스트)
pageBgColor?: string, // 페이지 배경색
textColor?: string, // 기본 글자색
queryTextColor?: string, // 검색창 글자색
postcodeTextColor?: string, // 우편번호 글자색
emphTextColor?: string, // 강조 글자색
outlineColor?: string, // 테두리
}

@new @scope("daum") external make: option => t = "Postcode"
type params = {
oncomplete?: oncompleteResponse => unit,
onresize?: onresizeResponse => unit,
onclose?: oncloseResponse => unit,
onsearch?: onsearchResponse => unit,
width?: float,
height?: float,
animation?: bool,
focusInput?: bool,
autoMapping?: bool,
shorthand?: bool,
pleaseReadGuide?: int,
pleaseReadGuideTimer?: float,
maxSuggestItems?: int,
showMoreHName?: bool,
hideMapBtn?: bool,
hideEngBtn?: bool,
alwaysShowEngAddr?: bool,
useBannerLink?: bool,
theme?: themeObj,
submitMode?: bool,
}

type openOption
@obj
external makeOpenOption: (
~q: string=?,
~left: float=?,
~top: float=?,
~popupName: string=?,
~autoClose: bool=?,
unit,
) => openOption = ""
@new @scope("daum") external make: params => t = "Postcode"

@send external openPostCode: (t, openOption) => unit = "open"
type openParams = {
q?: string,
left?: float,
top?: float,
popupName?: string,
autoClose?: bool,
}

type embedOption
@obj
external makeEmbedOption: (~q: string=?, ~autoClose: bool=?) => embedOption = ""
@send external openPostCode: (t, openParams) => unit = "open"

type embedParams = {
q?: string,
autoClose?: bool,
}

@send external embedPostCode: (t, Dom.element, embedOption) => unit = "embed"
@send external embedPostCode: (t, Dom.element, embedParams) => unit = "embed"