Skip to content

Commit

Permalink
Merge pull request #47 from green-labs/v11
Browse files Browse the repository at this point in the history
ReScript v11, rescript-react v0.12
  • Loading branch information
mununki authored Jan 2, 2024
2 parents d267845 + f05d3c3 commit 80dc0b9
Show file tree
Hide file tree
Showing 24 changed files with 123 additions and 110 deletions.
5 changes: 5 additions & 0 deletions .changeset/purple-birds-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@greenlabs/rescript-daum-postcode": minor
---

Support ReScript v11
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
uses: actions/checkout@v2

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

- name: Install Dependencies
run: yarn boot
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"dependencies": {
"@changesets/cli": "^2.24.4",
"lerna": "^5.5.0",
"rescript": "11.0.0-rc.8"
"rescript": "^11.0.0-rc.8"
},
"private": true,
"workspaces": [
Expand All @@ -24,4 +24,4 @@
"devDependencies": {
"lerna-templater": "^1.4.3"
}
}
}
53 changes: 29 additions & 24 deletions packages/rescript-daum-postcode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

## 설치하기

> ReScript 버전 호환 표
| Compiler | res_daum_postcode |
| -------- | ----------------- |
| v11 | >= v0.2.0 |
| v10 | ~<= v0.1.2 |

1. 모듈 설치

```shell
Expand All @@ -12,7 +18,7 @@ or
yarn add @greenlabs/rescript-daum-postcode
```

2. `bsconfig.json` 의존성 추가하기
2. `rescript.json` 의존성 추가하기

```json
"bs-dependencies": [
Expand All @@ -25,37 +31,36 @@ yarn add @greenlabs/rescript-daum-postcode
```rescript
open DaumPostCode
let option = makeOption(
~oncomplete=data => data->Js.Console.log,
~onresize=size => size->Js.Console.log,
~onclose=state =>
let daumPostCode = make({
oncomplete: data => data->Js.Console.log,
onresize: size => size->Js.Console.log,
onclose: state =>
switch state {
| #FORCE_CLOSE => "fc"->Js.Console.log
| #COMPLETE_CLOSE => "cc"->Js.Console.log
| FORCE_CLOSE => "fc"->Js.Console.log
| COMPLETE_CLOSE => "cc"->Js.Console.log
},
~onsearch=data => data->Js.Console.log,
~width=500.0,
~height=700.0,
(),
)
let daumPostCode = option->make
onsearch: data => data->Js.Console.log,
width: 500.0,
height: 700.0,
})
// 팝업 방식
let openOption = makeOpenOption(
~q=`문정동`,
~left=100.0,
~top=200.0,
~popupName="주소검색",
~autoClose=true,
(),
)
daumPostCode->openPostCode(openOption)
daumPostCode->openPostCode({
q: "문정동",
left: 100.0,
top: 200.0,
popupName: "주소검색",
autoClose: true,
})
// 임베드 방식
open Webapi
let embedOption = makeEmbedOption(~q=`문정동`, ~autoClose=true)
let div = Dom.document |> Dom.Document.getElementById("search-address")
div->Belt.Option.map(el => daumPostCode->embedPostCode(el, embedOption))->ignore
div->Belt.Option.map(el => daumPostCode->embedPostCode(el, {
q: "문정동",
autoClose: true
}))->ignore
```

## API
Expand Down
97 changes: 52 additions & 45 deletions packages/rescript-daum-postcode/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"
File renamed without changes.
8 changes: 3 additions & 5 deletions packages/rescript-hammerjs/src/HammerJs.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@deriving({jsConverter: newType})
type direction =
| @as(1) DIRECTION_NONE
| @as(2) DIRECTION_LEFT
Expand Down Expand Up @@ -41,7 +40,6 @@ type events = [
| #tap
]

@deriving({jsConverter: newType})
type inputEvents =
| @as(1) INPUT_START
| @as(2) INPUT_MOVE
Expand All @@ -68,15 +66,15 @@ module Instance = {
velocityX: float,
velocityY: float,
velocity: float,
direction: abs_direction,
offsetDirection: abs_direction,
direction: direction,
offsetDirection: direction,
scale: float,
rotation: float,
center: position,
srcEvent: Dom.event,
target: Dom.element,
pointerType: pointer,
eventType: abs_inputEvents,
eventType: inputEvents,
isFirst: bool,
isFinal: bool,
pointers: array<pointer>,
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions packages/rescript-jest/test/Jest_test.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ open! Expect

describe("Jest", () => {
describe("Test.each1", () => {
Test.each1(["hello", "world"])(.
(Test.each1(["hello", "world"], ...))(.
"message: %s",
str => {
Js.log(str)
Expand All @@ -12,7 +12,7 @@ describe("Jest", () => {
})

describe("Test.each2", () => {
Test.each2([("hello", "world"), ("green", "labs")])(.
(Test.each2([("hello", "world"), ("green", "labs")], ...))(.
"message: %s",
(str1, str2) => {
Js.log2(str1, str2)
Expand Down
6 changes: 3 additions & 3 deletions packages/rescript-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"directory": "packages/rescript-next"
},
"devDependencies": {
"@rescript/react": "^0.10.3"
"@rescript/react": "^0.12.0-alpha.3"
},
"peerDependencies": {
"@rescript/react": "^0.10.3"
"@rescript/react": "^0.12.0-alpha.3"
}
}
}
File renamed without changes.
6 changes: 3 additions & 3 deletions packages/rescript-nock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
},
"peerDependencies": {
"nock": "^13.2.9",
"rescript-webapi": "^0.6.1"
"rescript-webapi": "^0.9.0"
},
"devDependencies": {
"rescript-webapi": "^0.6.1"
"rescript-webapi": "^0.9.0"
}
}
}
File renamed without changes.
6 changes: 3 additions & 3 deletions packages/rescript-react-hook-form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
"directory": "packages/rescript-react-hook-form"
},
"devDependencies": {
"@rescript/react": "^0.10.3"
"@rescript/react": "^0.12.0-alpha.3"
},
"peerDependencies": {
"@rescript/react": "^0.10.3",
"@rescript/react": "^0.12.0-alpha.3",
"react-hook-form": "^7.31.2"
}
}
}
4 changes: 2 additions & 2 deletions packages/rescript-react-hook-form/src/ReactHookForm.res
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ module Make = (
let getValue = (form: t) => form->_getValues(T.name)

@send
external _setValue: (t, string, T.t, ~option: 'a=?, unit) => unit = "setValue"
let setValue = (form, value) => form->_setValue(T.name, value, ())
external _setValue: (t, string, T.t, ~option: 'a=?) => unit = "setValue"
let setValue = (form, value) => form->_setValue(T.name, value)
let setValueWithOption = (
form,
value,
Expand Down
2 changes: 0 additions & 2 deletions packages/rescript-react-hook-form/src/ReactHookForm.resi
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ module Make: (
~shouldValidate: bool=?,
~shouldDirty: bool=?,
~shouldTouch: bool=?,
unit,
) => unit
let resetField: t => unit
let setError: (t, Error.t) => unit
Expand Down Expand Up @@ -198,7 +197,6 @@ module Make: (
~shouldValidate: bool=?,
~shouldDirty: bool=?,
~shouldTouch: bool=?,
unit,
) => unit
let resetField: t => unit
let setError: (t, Error.t) => unit
Expand Down
6 changes: 3 additions & 3 deletions packages/rescript-react-linkify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"react-linkify": "^1.0.0-alpha"
},
"devDependencies": {
"@rescript/react": "^0.10.3"
"@rescript/react": "^0.12.0-alpha.3"
},
"peerDependencies": {
"@rescript/react": "^0.10.3"
"@rescript/react": "^0.12.0-alpha.3"
}
}
}
10 changes: 5 additions & 5 deletions packages/rescript-testing-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@
},
"peerDependencies": {
"@greenlabs/rescript-jest": "^1.0.1",
"@rescript/react": "^0.10.3",
"@rescript/react": "^0.12.0-alpha.3",
"@testing-library/dom": "^8.18.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^14.4.3",
"rescript-webapi": "^0.6.1"
"rescript-webapi": "^0.9.0"
},
"devDependencies": {
"@greenlabs/rescript-jest": "^1.0.1",
"@rescript/react": "^0.10.3",
"@rescript/react": "^0.12.0-alpha.3",
"@testing-library/dom": "^8.18.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.4.3",
"rescript-webapi": "^0.6.1"
"rescript-webapi": "^0.9.0"
}
}
}
Loading

0 comments on commit 80dc0b9

Please sign in to comment.