Skip to content

Commit 80dc0b9

Browse files
authored
Merge pull request #47 from green-labs/v11
ReScript v11, rescript-react v0.12
2 parents d267845 + f05d3c3 commit 80dc0b9

File tree

24 files changed

+123
-110
lines changed

24 files changed

+123
-110
lines changed

.changeset/purple-birds-know.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@greenlabs/rescript-daum-postcode": minor
3+
---
4+
5+
Support ReScript v11

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
uses: actions/checkout@v2
1818

1919
- name: Setup Node.js
20-
uses: actions/setup-node@v2
20+
uses: actions/setup-node@v4
2121
with:
22-
node-version: '14'
22+
node-version: '20'
2323

2424
- name: Install Dependencies
2525
run: yarn boot

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"dependencies": {
44
"@changesets/cli": "^2.24.4",
55
"lerna": "^5.5.0",
6-
"rescript": "11.0.0-rc.8"
6+
"rescript": "^11.0.0-rc.8"
77
},
88
"private": true,
99
"workspaces": [
@@ -24,4 +24,4 @@
2424
"devDependencies": {
2525
"lerna-templater": "^1.4.3"
2626
}
27-
}
27+
}

packages/rescript-daum-postcode/README.md

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
## 설치하기
66

7+
> ReScript 버전 호환 표
8+
| Compiler | res_daum_postcode |
9+
| -------- | ----------------- |
10+
| v11 | >= v0.2.0 |
11+
| v10 | ~<= v0.1.2 |
12+
713
1. 모듈 설치
814

915
```shell
@@ -12,7 +18,7 @@ or
1218
yarn add @greenlabs/rescript-daum-postcode
1319
```
1420

15-
2. `bsconfig.json` 의존성 추가하기
21+
2. `rescript.json` 의존성 추가하기
1622

1723
```json
1824
"bs-dependencies": [
@@ -25,37 +31,36 @@ yarn add @greenlabs/rescript-daum-postcode
2531
```rescript
2632
open DaumPostCode
2733
28-
let option = makeOption(
29-
~oncomplete=data => data->Js.Console.log,
30-
~onresize=size => size->Js.Console.log,
31-
~onclose=state =>
34+
let daumPostCode = make({
35+
oncomplete: data => data->Js.Console.log,
36+
onresize: size => size->Js.Console.log,
37+
onclose: state =>
3238
switch state {
33-
| #FORCE_CLOSE => "fc"->Js.Console.log
34-
| #COMPLETE_CLOSE => "cc"->Js.Console.log
39+
| FORCE_CLOSE => "fc"->Js.Console.log
40+
| COMPLETE_CLOSE => "cc"->Js.Console.log
3541
},
36-
~onsearch=data => data->Js.Console.log,
37-
~width=500.0,
38-
~height=700.0,
39-
(),
40-
)
41-
let daumPostCode = option->make
42+
onsearch: data => data->Js.Console.log,
43+
width: 500.0,
44+
height: 700.0,
45+
})
4246
4347
// 팝업 방식
44-
let openOption = makeOpenOption(
45-
~q=`문정동`,
46-
~left=100.0,
47-
~top=200.0,
48-
~popupName="주소검색",
49-
~autoClose=true,
50-
(),
51-
)
52-
daumPostCode->openPostCode(openOption)
48+
daumPostCode->openPostCode({
49+
q: "문정동",
50+
left: 100.0,
51+
top: 200.0,
52+
popupName: "주소검색",
53+
autoClose: true,
54+
})
5355
5456
// 임베드 방식
5557
open Webapi
56-
let embedOption = makeEmbedOption(~q=`문정동`, ~autoClose=true)
58+
5759
let div = Dom.document |> Dom.Document.getElementById("search-address")
58-
div->Belt.Option.map(el => daumPostCode->embedPostCode(el, embedOption))->ignore
60+
div->Belt.Option.map(el => daumPostCode->embedPostCode(el, {
61+
q: "문정동",
62+
autoClose: true
63+
}))->ignore
5964
```
6065

6166
## API
Lines changed: 52 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
type t
2-
type addressType = [#R | #J] // #R 도로명 | #J 지번
3-
type selected = [#Y | #N] // 선택 상태
4-
type lang = [#K | #E] // #K 한글주소 | #E 영문주소
2+
type addressType = R | J // R 도로명 | J 지번
3+
type selected = Y | N // 선택 상태
4+
type lang = K | E // K 한글주소 | E 영문주소
55

66
type oncompleteResponse = {
77
address: string,
@@ -48,52 +48,59 @@ type onresizeResponse = {
4848
width: float,
4949
height: float,
5050
}
51-
type oncloseResponse = [#FORCE_CLOSE | #COMPLETE_CLOSE]
51+
type oncloseResponse = FORCE_CLOSE | COMPLETE_CLOSE
5252
type onsearchResponse = {q: string, count: int}
5353

54-
type option
55-
@obj
56-
external makeOption: (
57-
~oncomplete: oncompleteResponse => unit=?,
58-
~onresize: onresizeResponse => unit=?,
59-
~onclose: oncloseResponse => unit=?,
60-
~onsearch: onsearchResponse => unit=?,
61-
~width: float=?,
62-
~height: float=?,
63-
~animation: bool=?,
64-
~focusInput: bool=?,
65-
~autoMapping: bool=?,
66-
~shorthand: bool=?,
67-
~pleaseReadGuide: int=?,
68-
~pleaseReadGuideTimer: float=?,
69-
~maxSuggestItems: int=?,
70-
~showMoreHName: bool=?,
71-
~hideMapBtn: bool=?,
72-
~hideEngBtn: bool=?,
73-
~alwaysShowEngAddr: bool=?,
74-
~useBannerLink: bool=?,
75-
~theme: {..}=?,
76-
~submitMode: bool=?,
77-
unit,
78-
) => option = ""
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+
}
7965

80-
@new @scope("daum") external make: option => t = "Postcode"
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+
}
8188

82-
type openOption
83-
@obj
84-
external makeOpenOption: (
85-
~q: string=?,
86-
~left: float=?,
87-
~top: float=?,
88-
~popupName: string=?,
89-
~autoClose: bool=?,
90-
unit,
91-
) => openOption = ""
89+
@new @scope("daum") external make: params => t = "Postcode"
9290

93-
@send external openPostCode: (t, openOption) => unit = "open"
91+
type openParams = {
92+
q?: string,
93+
left?: float,
94+
top?: float,
95+
popupName?: string,
96+
autoClose?: bool,
97+
}
9498

95-
type embedOption
96-
@obj
97-
external makeEmbedOption: (~q: string=?, ~autoClose: bool=?) => embedOption = ""
99+
@send external openPostCode: (t, openParams) => unit = "open"
100+
101+
type embedParams = {
102+
q?: string,
103+
autoClose?: bool,
104+
}
98105

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

packages/rescript-hammerjs/src/HammerJs.res

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@deriving({jsConverter: newType})
21
type direction =
32
| @as(1) DIRECTION_NONE
43
| @as(2) DIRECTION_LEFT
@@ -41,7 +40,6 @@ type events = [
4140
| #tap
4241
]
4342

44-
@deriving({jsConverter: newType})
4543
type inputEvents =
4644
| @as(1) INPUT_START
4745
| @as(2) INPUT_MOVE
@@ -68,15 +66,15 @@ module Instance = {
6866
velocityX: float,
6967
velocityY: float,
7068
velocity: float,
71-
direction: abs_direction,
72-
offsetDirection: abs_direction,
69+
direction: direction,
70+
offsetDirection: direction,
7371
scale: float,
7472
rotation: float,
7573
center: position,
7674
srcEvent: Dom.event,
7775
target: Dom.element,
7876
pointerType: pointer,
79-
eventType: abs_inputEvents,
77+
eventType: inputEvents,
8078
isFirst: bool,
8179
isFinal: bool,
8280
pointers: array<pointer>,
File renamed without changes.

packages/rescript-jest/test/Jest_test.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ open! Expect
33

44
describe("Jest", () => {
55
describe("Test.each1", () => {
6-
Test.each1(["hello", "world"])(.
6+
(Test.each1(["hello", "world"], ...))(.
77
"message: %s",
88
str => {
99
Js.log(str)
@@ -12,7 +12,7 @@ describe("Jest", () => {
1212
})
1313

1414
describe("Test.each2", () => {
15-
Test.each2([("hello", "world"), ("green", "labs")])(.
15+
(Test.each2([("hello", "world"), ("green", "labs")], ...))(.
1616
"message: %s",
1717
(str1, str2) => {
1818
Js.log2(str1, str2)

0 commit comments

Comments
 (0)