Skip to content

Codegen now supports global and React-specific attributes. #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 4, 2019
1 change: 1 addition & 0 deletions codegen/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ module.exports.types = {
"open": "Boolean",
"playsInline": "Boolean",
"readOnly": "Boolean",
"ref": "Ref (Nullable Node)",
"required": "Boolean",
"reversed": "Boolean",
"rowSpan": "Int",
Expand Down
4 changes: 3 additions & 1 deletion codegen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ const header = `-- | ----------------------------------------

module React.Basic.DOM.Generated where

import Data.Nullable (Nullable)
import Prim.Row (class Union)
import React.Basic (JSX, element)
import Web.DOM (Node)
import React.Basic (JSX, Ref, element)
import React.Basic.DOM.Internal (CSS, unsafeCreateDOMComponent)
import React.Basic.Events (EventHandler)

Expand Down
1 change: 1 addition & 0 deletions codegen/react-html-attributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"property",
"radioGroup",
"readOnly",
"ref",
"resource",
"role",
"rowSpan",
Expand Down
16 changes: 11 additions & 5 deletions generated-docs/React/Basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#### `ComponentSpec`

``` purescript
type ComponentSpec props state = (initialState :: state, render :: Self props state -> JSX, didMount :: Self props state -> Effect Unit, shouldUpdate :: Self props state -> { nextProps :: props, nextState :: state } -> Boolean, didUpdate :: Self props state -> { prevProps :: props, prevState :: state } -> Effect Unit, willUnmount :: Self props state -> Effect Unit)
type ComponentSpec props state = (didMount :: Self props state -> Effect Unit, didUpdate :: Self props state -> { prevProps :: props, prevState :: state } -> Effect Unit, initialState :: state, render :: Self props state -> JSX, shouldUpdate :: Self props state -> { nextProps :: props, nextState :: state } -> Boolean, willUnmount :: Self props state -> Effect Unit)
```

`ComponentSpec` represents a React-Basic component implementation.
Expand Down Expand Up @@ -112,7 +112,7 @@ __*For the curious:* This is the "class" React will use to render and
#### `Self`

``` purescript
type Self props state = { props :: props, state :: state, setState :: (state -> state) -> Effect Unit, setStateThen :: (state -> state) -> Effect Unit -> Effect Unit, instance_ :: ReactComponentInstance props state }
type Self props state = { instance_ :: ReactComponentInstance props state, props :: props, setState :: (state -> state) -> Effect Unit, setStateThen :: (state -> state) -> Effect Unit -> Effect Unit, state :: state }
```

`Self` represents the component instance at a particular point in time.
Expand Down Expand Up @@ -299,7 +299,7 @@ __*See also:* `JSX`__
#### `element`

``` purescript
element :: forall props. ReactComponent { | props } -> { | props } -> JSX
element :: forall props. ReactComponent (Record props) -> Record props -> JSX
```

Create a `JSX` node from a `ReactComponent`, by providing the props.
Expand All @@ -312,7 +312,7 @@ __*See also:* `ReactComponent`, `elementKeyed`__
#### `elementKeyed`

``` purescript
elementKeyed :: forall props. ReactComponent { | props } -> { key :: String | props } -> JSX
elementKeyed :: forall props. ReactComponent (Record props) -> { key :: String | props } -> JSX
```

Create a `JSX` node from a `ReactComponent`, by providing the props and a key.
Expand Down Expand Up @@ -372,7 +372,7 @@ caution.
#### `toReactComponent`

``` purescript
toReactComponent :: forall spec spec_ jsProps props state. Union spec spec_ (ComponentSpec props state) => ({ | jsProps } -> props) -> Component props -> { render :: Self props state -> JSX | spec } -> ReactComponent { | jsProps }
toReactComponent :: forall spec spec_ jsProps props state. Union spec spec_ (ComponentSpec props state) => (Record jsProps -> props) -> Component props -> { render :: Self props state -> JSX | spec } -> ReactComponent (Record jsProps)
```

Convert a React-Basic `ComponentSpec` to a JavaScript-friendly React component.
Expand All @@ -385,4 +385,10 @@ __*Note:* Like `createComponent`, `toReactComponent` is side effecting in that

__*See also:* `ReactComponent`__

#### `Ref`

``` purescript
data Ref :: Type -> Type
```


10 changes: 5 additions & 5 deletions generated-docs/React/Basic/Compat.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ type Component = ReactComponent
#### `component`

``` purescript
component :: forall props state. { displayName :: String, initialState :: { | state }, receiveProps :: Self { | props } { | state } -> Effect Unit, render :: Self { | props } { | state } -> JSX } -> ReactComponent { | props }
component :: forall props state. { displayName :: String, initialState :: Record state, receiveProps :: Self (Record props) (Record state) -> Effect Unit, render :: Self (Record props) (Record state) -> JSX } -> ReactComponent (Record props)
```

Supports a common subset of the v2 API to ease the upgrade process

#### `stateless`

``` purescript
stateless :: forall props. { displayName :: String, render :: { | props } -> JSX } -> ReactComponent { | props }
stateless :: forall props. { displayName :: String, render :: Record props -> JSX } -> ReactComponent (Record props)
```

Supports a common subset of the v2 API to ease the upgrade process
Expand All @@ -31,7 +31,7 @@ Supports a common subset of the v2 API to ease the upgrade process
#### `Self`

``` purescript
type Self props state = { props :: props, state :: state, setState :: (state -> state) -> Effect Unit, setStateThen :: (state -> state) -> Effect Unit -> Effect Unit, instance_ :: ReactComponentInstance props state }
type Self props state = { instance_ :: ReactComponentInstance props state, props :: props, setState :: (state -> state) -> Effect Unit, setStateThen :: (state -> state) -> Effect Unit -> Effect Unit, state :: state }
```

`Self` represents the component instance at a particular point in time.
Expand Down Expand Up @@ -111,7 +111,7 @@ __*See also:* `JSX`, Monoid `guard`__
#### `elementKeyed`

``` purescript
elementKeyed :: forall props. ReactComponent { | props } -> { key :: String | props } -> JSX
elementKeyed :: forall props. ReactComponent (Record props) -> { key :: String | props } -> JSX
```

Create a `JSX` node from a `ReactComponent`, by providing the props and a key.
Expand All @@ -124,7 +124,7 @@ __*See also:* `ReactComponent`, `element`, React's documentation regarding the s
#### `element`

``` purescript
element :: forall props. ReactComponent { | props } -> { | props } -> JSX
element :: forall props. ReactComponent (Record props) -> Record props -> JSX
```

Create a `JSX` node from a `ReactComponent`, by providing the props.
Expand Down
Loading