From 02da10cb486ab0aa68e2abfb415ace1b7eb83edb Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Thu, 9 Dec 2021 14:54:01 +0100 Subject: [PATCH 1/2] Binding-Generator: fix int enum handling --- .../docs/project-structure/union-values.md | 6 ++-- examples/src/examples/ExampleSlider.bs.js | 28 +------------------ .../src/examples/ExampleStylingTailwind.bs.js | 2 +- .../src/labExamples/ExampleToggleButton.bs.js | 28 +------------------ public/rescript-material-ui/src/Grid.res | 15 +--------- .../src/classes/property-parser/_enum.ts | 4 +-- 6 files changed, 8 insertions(+), 75 deletions(-) diff --git a/documentation/docs/project-structure/union-values.md b/documentation/docs/project-structure/union-values.md index 14b78a61..01cfe269 100644 --- a/documentation/docs/project-structure/union-values.md +++ b/documentation/docs/project-structure/union-values.md @@ -45,10 +45,8 @@ type variant = [#elevation | #outlined] ## Numeric unions -A union consisting of only numbers will utilize the -[[@int]](https://rescript-lang.org/docs/manual/latest/bind-to-js-function#constrain-arguments-better) -directive. Therefore, numerical unions will accept a form of polymorphic variant -as well. +Numeric unions now work the same way as string only unions now and don't utilize +the `@int` directive anymore. These don't happen often - currently the only place where this applies is in the `Mui.Grid.res` component. diff --git a/examples/src/examples/ExampleSlider.bs.js b/examples/src/examples/ExampleSlider.bs.js index 0b385014..262cf373 100644 --- a/examples/src/examples/ExampleSlider.bs.js +++ b/examples/src/examples/ExampleSlider.bs.js @@ -35,33 +35,7 @@ function ExampleSlider(Props) { alignItems: "center", children: null, container: true, - spacing: (function () { - switch (2) { - case "0" : - return 0; - case "1" : - return 1; - case "2" : - return 2; - case "3" : - return 3; - case "4" : - return 4; - case "5" : - return 5; - case "6" : - return 6; - case "7" : - return 7; - case "8" : - return 8; - case "9" : - return 9; - case "10" : - return 10; - - } - })() + spacing: 2 }, React.createElement(Core.Grid, { children: React.createElement(VolumeUp, {}), item: true diff --git a/examples/src/examples/ExampleStylingTailwind.bs.js b/examples/src/examples/ExampleStylingTailwind.bs.js index f865a156..e7b4f275 100644 --- a/examples/src/examples/ExampleStylingTailwind.bs.js +++ b/examples/src/examples/ExampleStylingTailwind.bs.js @@ -11,7 +11,7 @@ function ExampleStylingTailwind(Props) { onClick: (function (prim) { }), - children: "Hello, BS-CSS & MUI!", + children: "Hello, Tailwind & MUI!", classes: { root: "normal-case justify-start" }, diff --git a/examples/src/labExamples/ExampleToggleButton.bs.js b/examples/src/labExamples/ExampleToggleButton.bs.js index 3c674f0f..dfd8e5d9 100644 --- a/examples/src/labExamples/ExampleToggleButton.bs.js +++ b/examples/src/labExamples/ExampleToggleButton.bs.js @@ -51,33 +51,7 @@ function ExampleToggleButton(Props) { return React.createElement(Core.Grid, { children: null, container: true, - spacing: (function () { - switch (2) { - case "0" : - return 0; - case "1" : - return 1; - case "2" : - return 2; - case "3" : - return 3; - case "4" : - return 4; - case "5" : - return 5; - case "6" : - return 6; - case "7" : - return 7; - case "8" : - return 8; - case "9" : - return 9; - case "10" : - return 10; - - } - })() + spacing: 2 }, React.createElement(Core.Grid, { children: null, item: true, diff --git a/public/rescript-material-ui/src/Grid.res b/public/rescript-material-ui/src/Grid.res index 33494dae..48dfe526 100644 --- a/public/rescript-material-ui/src/Grid.res +++ b/public/rescript-material-ui/src/Grid.res @@ -349,20 +349,7 @@ external make: ( ~lg: Lg.t=?, ~md: Md.t=?, ~sm: Sm.t=?, - ~spacing: @int - [ - | @as(0) #0 - | @as(1) #1 - | @as(2) #2 - | @as(3) #3 - | @as(4) #4 - | @as(5) #5 - | @as(6) #6 - | @as(7) #7 - | @as(8) #8 - | @as(9) #9 - | @as(10) #10 - ]=?, + ~spacing: [#0 | #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 | #10]=?, ~wrap: wrap=?, ~xl: Xl.t=?, ~xs: Xs.t=?, diff --git a/tools/binding-generator/src/classes/property-parser/_enum.ts b/tools/binding-generator/src/classes/property-parser/_enum.ts index cce902ec..1550bbeb 100644 --- a/tools/binding-generator/src/classes/property-parser/_enum.ts +++ b/tools/binding-generator/src/classes/property-parser/_enum.ts @@ -125,8 +125,8 @@ const factory = (propertyType: PropType$Enum) => { .map((name, i) => `#${name}`) .join(' | ')}]; `; - this._reasonType = `@int [${enumValuesReason - .map((name, i) => `@as(${this._enumValues[i]}) #${name}`) + this._reasonType = `[${enumValuesReason + .map((name) => `#${name}`) .join(' | ')}]`; break; } From 22fc36bd294f15c2eddb511e9b63effa1d53e036 Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Thu, 9 Dec 2021 14:56:28 +0100 Subject: [PATCH 2/2] Version 3.0.2 --- documentation/docs/changelog.md | 4 ++++ public/rescript-material-ui-lab/package.json | 2 +- public/rescript-material-ui-ppx/package.json | 2 +- public/rescript-material-ui/package.json | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/documentation/docs/changelog.md b/documentation/docs/changelog.md index 5793dfac..594b13ea 100644 --- a/documentation/docs/changelog.md +++ b/documentation/docs/changelog.md @@ -14,6 +14,10 @@ title: Changelog (_Tags are copied from [babel](https://github.com/babel/babel/blob/master/CHANGELOG.md)_) +## 3.0.2 + +- :bug: Fixed the binding generator's handling of `int` enums. + ## 3.0.1 - :house: Fixed outdated peer dependencies. diff --git a/public/rescript-material-ui-lab/package.json b/public/rescript-material-ui-lab/package.json index dfa0e9eb..27afc1a4 100755 --- a/public/rescript-material-ui-lab/package.json +++ b/public/rescript-material-ui-lab/package.json @@ -1,6 +1,6 @@ { "name": "rescript-material-ui-lab", - "version": "3.0.1", + "version": "3.0.2", "description": "This library provides ReScript bindings for material-ui-lab.", "keywords": [ "rescript", diff --git a/public/rescript-material-ui-ppx/package.json b/public/rescript-material-ui-ppx/package.json index bcdb1a6f..0fada04b 100755 --- a/public/rescript-material-ui-ppx/package.json +++ b/public/rescript-material-ui-ppx/package.json @@ -1,6 +1,6 @@ { "name": "rescript-material-ui-ppx", - "version": "3.0.1", + "version": "3.0.2", "repository": "https://github.com/cca-io/rescript-material-ui", "private": false, "homepage": "https://rescript-material-ui.cca.io/", diff --git a/public/rescript-material-ui/package.json b/public/rescript-material-ui/package.json index e7e8b73d..2bf2e077 100644 --- a/public/rescript-material-ui/package.json +++ b/public/rescript-material-ui/package.json @@ -1,6 +1,6 @@ { "name": "rescript-material-ui", - "version": "3.0.1", + "version": "3.0.2", "description": "This library provides ReScript bindings for material-ui.", "keywords": [ "rescript",