From dc20cc0f134e2268fed54c3c51b27961ee7ba2cc Mon Sep 17 00:00:00 2001 From: Thomas Honeyman Date: Fri, 19 Nov 2021 11:48:14 -0500 Subject: [PATCH] Introduce purs-tidy formatter (#182) * Add purs-tidy formatter * Run purs-tidy * review --- .github/workflows/ci.yml | 9 +- .gitignore | 1 + .tidyrc.json | 10 + CHANGELOG.md | 1 + src/React.purs | 339 +++++++++++++++++++--------------- src/React/DOM.purs | 7 +- src/React/DOM/Dynamic.purs | 2 +- src/React/DOM/Props.purs | 6 +- src/React/Ref.purs | 11 +- src/React/SyntheticEvent.purs | 246 ++++++++++++------------ 10 files changed, 339 insertions(+), 293 deletions(-) create mode 100644 .tidyrc.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b3ca67..43f9f20 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,8 @@ jobs: - name: Set up PureScript toolchain uses: purescript-contrib/setup-purescript@main + with: + purs-tidy: "latest" - name: Cache PureScript dependencies uses: actions/cache@v2 @@ -25,9 +27,9 @@ jobs: output - name: Set up Node toolchain - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: - node-version: "12.x" + node-version: "14.x" - name: Cache NPM dependencies uses: actions/cache@v2 @@ -49,3 +51,6 @@ jobs: - name: Run tests run: npm run test + + - name: Check formatting + run: purs-tidy check src test diff --git a/.gitignore b/.gitignore index 5a54e2f..6a45203 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ !.gitignore !.github !.editorconfig +!.tidyrc.json !.eslintrc.json output diff --git a/.tidyrc.json b/.tidyrc.json new file mode 100644 index 0000000..4f013c1 --- /dev/null +++ b/.tidyrc.json @@ -0,0 +1,10 @@ +{ + "importSort": "source", + "importWrap": "source", + "indent": 2, + "operatorsFile": null, + "ribbon": 1, + "typeArrowPlacement": "first", + "unicode": "never", + "width": null +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 28aede8..7770782 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ New features: Bugfixes: Other improvements: +- Added `purs-tidy` formatter (#182 by @thomashoneyman) ## [v9.0.0](https://github.com/purescript-contrib/purescript-react/releases/tag/v9.0.0) - 2021-02-26 diff --git a/src/React.purs b/src/React.purs index ff7b217..e590767 100644 --- a/src/React.purs +++ b/src/React.purs @@ -156,21 +156,19 @@ type ReactSpecShouldComponentUpdate props state = ( shouldComponentUpdate :: ShouldComponentUpdate props state ) -type ReactSpecAll props state snapshot - = ReactSpecRequired state - + ReactSpecOptional props state snapshot - + ReactSpecShouldComponentUpdate props state +type ReactSpecAll props state snapshot = + ReactSpecRequired state + + ReactSpecOptional props state snapshot + + ReactSpecShouldComponentUpdate props state -type ReactSpecPure props state snapshot - = ReactSpecRequired state - + ReactSpecOptional props state snapshot () +type ReactSpecPure props state snapshot = + ReactSpecRequired state + + ReactSpecOptional props state snapshot () -- | The signature for a ReactClass constructor. A constructor takes the -- | `ReactThis` context and returns a record with appropriate lifecycle -- | methods. -type ReactClassConstructor props state r = - ReactThis props state -> - Effect (Record r) +type ReactClassConstructor props state r = ReactThis props state -> Effect (Record r) class ReactComponentSpec :: Type -> Type -> Type -> Row Type -> Row Type -> Constraint class ReactComponentSpec props state snapshot (given :: Row Type) (spec :: Row Type) @@ -191,64 +189,73 @@ instance reactPureComponentSpec :: ReactPureComponentSpec props state snapshot given spec -- | Creates a `ReactClass` inherited from `React.Component`. -component :: forall props state snapshot given spec. - ReactComponentSpec (Record props) (Record state) snapshot given spec => - String -> - ReactClassConstructor (Record props) (Record state) given -> - ReactClass (Record props) +component + :: forall props state snapshot given spec + . ReactComponentSpec (Record props) (Record state) snapshot given spec + => String + -> ReactClassConstructor (Record props) (Record state) given + -> ReactClass (Record props) component = componentImpl -- | Like `component`, but takes a `getDerivedStateFromProps` handler. -componentWithDerivedState :: forall props state snapshot given spec. - ReactComponentSpec (Record props) (Record state) snapshot given spec => - String -> - (Record props -> Record state -> Record state) -> - ReactClassConstructor (Record props) (Record state) given -> - ReactClass (Record props) +componentWithDerivedState + :: forall props state snapshot given spec + . ReactComponentSpec (Record props) (Record state) snapshot given spec + => String + -> (Record props -> Record state -> Record state) + -> ReactClassConstructor (Record props) (Record state) given + -> ReactClass (Record props) componentWithDerivedState = componentWithDerivedStateImpl -- | Creates a `ReactClass` inherited from `React.PureComponent`. -pureComponent :: forall props state snapshot given spec. - ReactPureComponentSpec (Record props) (Record state) snapshot given spec => - String -> - ReactClassConstructor (Record props) (Record state) given -> - ReactClass (Record props) +pureComponent + :: forall props state snapshot given spec + . ReactPureComponentSpec (Record props) (Record state) snapshot given spec + => String + -> ReactClassConstructor (Record props) (Record state) given + -> ReactClass (Record props) pureComponent = pureComponentImpl -- | Like `pureComponent`, but takes a `getDerivedStateFromProps` handler. -pureComponentWithDerivedState :: forall props state snapshot given spec. - ReactPureComponentSpec (Record props) (Record state) snapshot given spec => - String -> - (Record props -> Record state -> Record state) -> - ReactClassConstructor (Record props) (Record state) given -> - ReactClass (Record props) +pureComponentWithDerivedState + :: forall props state snapshot given spec + . ReactPureComponentSpec (Record props) (Record state) snapshot given spec + => String + -> (Record props -> Record state -> Record state) + -> ReactClassConstructor (Record props) (Record state) given + -> ReactClass (Record props) pureComponentWithDerivedState = componentWithDerivedStateImpl -foreign import componentImpl :: forall this props r. - String -> - (this -> Effect r) -> - ReactClass props - -foreign import componentWithDerivedStateImpl :: forall this props state r. - String -> - (props -> state -> state) -> - (this -> Effect r) -> - ReactClass props - -foreign import pureComponentImpl :: forall this props r. - String -> - (this -> Effect r) -> - ReactClass props - -foreign import pureComponentWithDerivedStateImpl :: forall this props state r. - String -> - (props -> state -> state) -> - (this -> Effect r) -> - ReactClass props - -foreign import statelessComponent :: forall props. - (Record props -> ReactElement) -> - ReactClass (Record props) +foreign import componentImpl + :: forall this props r + . String + -> (this -> Effect r) + -> ReactClass props + +foreign import componentWithDerivedStateImpl + :: forall this props state r + . String + -> (props -> state -> state) + -> (this -> Effect r) + -> ReactClass props + +foreign import pureComponentImpl + :: forall this props r + . String + -> (this -> Effect r) + -> ReactClass props + +foreign import pureComponentWithDerivedStateImpl + :: forall this props state r + . String + -> (props -> state -> state) + -> (this -> Effect r) + -> ReactClass props + +foreign import statelessComponent + :: forall props + . (Record props -> ReactElement) + -> ReactClass (Record props) -- | React class for components. foreign import data ReactClass :: Type -> Type @@ -258,73 +265,83 @@ type role ReactClass representational foreign import fragment :: ReactClass { children :: Children } -- | Read the component props. -foreign import getProps :: forall props state. - ReactThis props state -> - Effect props - -foreign import setStateImpl :: forall props state update. - ReactThis props state -> - update -> - Effect Unit - -foreign import setStateWithCallbackImpl :: forall props state update. - ReactThis props state -> - update -> - Effect Unit -> - Effect Unit +foreign import getProps + :: forall props state + . ReactThis props state + -> Effect props + +foreign import setStateImpl + :: forall props state update + . ReactThis props state + -> update + -> Effect Unit + +foreign import setStateWithCallbackImpl + :: forall props state update + . ReactThis props state + -> update + -> Effect Unit + -> Effect Unit -- | Get the component state. -foreign import getState :: forall props state. - ReactThis props state -> - Effect state +foreign import getState + :: forall props state + . ReactThis props state + -> Effect state -- | Update component state given some sub-set of state properties. -setState :: forall props given rest all. - Row.Union given rest all => - ReactThis props (Record all) -> - Record given -> - Effect Unit +setState + :: forall props given rest all + . Row.Union given rest all + => ReactThis props (Record all) + -> Record given + -> Effect Unit setState = setStateImpl -- | Update component state given some sub-set of state properties, while -- | also invoking a callback when applied. -setStateWithCallback :: forall props given rest all. - Row.Union given rest all => - ReactThis props (Record all) -> - Record given -> - Effect Unit -> - Effect Unit +setStateWithCallback + :: forall props given rest all + . Row.Union given rest all + => ReactThis props (Record all) + -> Record given + -> Effect Unit + -> Effect Unit setStateWithCallback = setStateWithCallbackImpl -- | Update component state. -writeState :: forall props all. - ReactThis props (Record all) -> - Record all -> - Effect Unit +writeState + :: forall props all + . ReactThis props (Record all) + -> Record all + -> Effect Unit writeState = setStateImpl -- | Update component state, while also invoking a callback when applied. -writeStateWithCallback :: forall props all. - ReactThis props (Record all) -> - Record all -> - Effect Unit -> - Effect Unit +writeStateWithCallback + :: forall props all + . ReactThis props (Record all) + -> Record all + -> Effect Unit + -> Effect Unit writeStateWithCallback = setStateWithCallbackImpl -- | Update component state given a modification function. -modifyState :: forall props state. - ReactThis props state -> - (state -> state) -> - Effect Unit +modifyState + :: forall props state + . ReactThis props state + -> (state -> state) + -> Effect Unit modifyState = setStateImpl -- | Update component state given a modification function, while also invoking -- | a callback when applied. -modifyStateWithCallback :: forall props state. - ReactThis props state -> - (state -> state) -> - Effect Unit -> - Effect Unit +modifyStateWithCallback + :: forall props state + . ReactThis props state + -> (state -> state) + -> Effect Unit + -> Effect Unit modifyStateWithCallback = setStateWithCallbackImpl -- | Force render of a react component. @@ -332,10 +349,11 @@ forceUpdate :: forall props state. ReactThis props state -> Effect Unit forceUpdate this = forceUpdateWithCallback this (pure unit) -- | Force render and then run an Effect. -foreign import forceUpdateWithCallback :: forall props state. - ReactThis props state -> - Effect Unit -> - Effect Unit +foreign import forceUpdateWithCallback + :: forall props state + . ReactThis props state + -> Effect Unit + -> Effect Unit class ReactPropFields (required :: Row Type) (given :: Row Type) @@ -352,75 +370,100 @@ instance reactPropFields :: ReactPropFields required given -- | Create an element from a React class spreading the children array. Used when the children are known up front. -createElement :: forall required given. - ReactPropFields required given => - ReactClass { children :: Children | required } -> - { | given } -> - Array ReactElement -> - ReactElement +createElement + :: forall required given + . ReactPropFields required given + => ReactClass { children :: Children | required } + -> { | given } + -> Array ReactElement + -> ReactElement createElement = createElementImpl -- | An unsafe version of `createElement` which does not enforce the reserved -- | properties "key" and "ref". -unsafeCreateElement :: forall props. - ReactClass { children :: Children | props } -> - { | props } -> - Array ReactElement -> - ReactElement +unsafeCreateElement + :: forall props + . ReactClass { children :: Children | props } + -> { | props } + -> Array ReactElement + -> ReactElement unsafeCreateElement = createElementImpl -- | Create an element from a React class passing the children array. Used for a dynamic array of children. -createElementDynamic :: forall required given. - ReactPropFields required given => - ReactClass { children :: Children | required } -> - { | given } -> - Array ReactElement -> - ReactElement +createElementDynamic + :: forall required given + . ReactPropFields required given + => ReactClass { children :: Children | required } + -> { | given } + -> Array ReactElement + -> ReactElement createElementDynamic = createElementDynamicImpl -- | An unsafe version of `createElementDynamic` which does not enforce the reserved -- | properties "key" and "ref". -unsafeCreateElementDynamic :: forall props. - ReactClass { children :: Children | props } -> - { | props } -> - Array ReactElement -> - ReactElement +unsafeCreateElementDynamic + :: forall props + . ReactClass { children :: Children | props } + -> { | props } + -> Array ReactElement + -> ReactElement unsafeCreateElementDynamic = createElementDynamicImpl -foreign import createElementImpl :: forall required given children. - ReactClass required -> given -> Array children -> ReactElement +foreign import createElementImpl + :: forall required given children + . ReactClass required + -> given + -> Array children + -> ReactElement -foreign import createElementDynamicImpl :: forall required given children. - ReactClass required -> given -> Array children -> ReactElement +foreign import createElementDynamicImpl + :: forall required given children + . ReactClass required + -> given + -> Array children + -> ReactElement -- | Create an element from a React class that does not require children. Additionally it can be used -- | when the children are represented /only/ through the `children` prop - for instance, a `ContextConsumer` -- | would be turned into a `ReactElement` with `createLeafElement someContext.consumer { children: \x -> ... }`. -createLeafElement :: forall required given. - ReactPropFields required given => - ReactClass { | required } -> - { | given } -> - ReactElement +createLeafElement + :: forall required given + . ReactPropFields required given + => ReactClass { | required } + -> { | given } + -> ReactElement createLeafElement = createLeafElementImpl -- | An unsafe version of `createLeafElement` which does not enforce the reserved -- | properties "key" and "ref". -unsafeCreateLeafElement :: forall props. - ReactClass props -> - props -> - ReactElement +unsafeCreateLeafElement + :: forall props + . ReactClass props + -> props + -> ReactElement unsafeCreateLeafElement = createLeafElementImpl -foreign import createLeafElementImpl :: forall required given. - ReactClass required -> given -> ReactElement +foreign import createLeafElementImpl + :: forall required given + . ReactClass required + -> given + -> ReactElement -- | Create an element from a tag name spreading the children array. Used when the children are known up front. -foreign import createElementTagName :: forall props. - TagName -> props -> Array ReactElement -> ReactElement +foreign import createElementTagName + :: forall props + . TagName + -> props + -> Array ReactElement + -> ReactElement -- | Create an element from a tag name passing the children array. Used for a dynamic array of children. -foreign import createElementTagNameDynamic :: forall props. - TagName -> props -> Array ReactElement -> ReactElement +foreign import createElementTagNameDynamic + :: forall props + . TagName + -> props + -> Array ReactElement + -> ReactElement -- | Internal representation for the children elements passed to a component foreign import data Children :: Type diff --git a/src/React/DOM.purs b/src/React/DOM.purs index 3c1fbf0..2755cb1 100644 --- a/src/React/DOM.purs +++ b/src/React/DOM.purs @@ -6,15 +6,14 @@ import Unsafe.Coerce (unsafeCoerce) newtype IsDynamic = IsDynamic Boolean -mkDOM :: - IsDynamic -> TagName -> Array Props -> Array ReactElement -> ReactElement +mkDOM :: IsDynamic -> TagName -> Array Props -> Array ReactElement -> ReactElement mkDOM dynamic tag props = createElement tag (unsafeFromPropsArray props) where createElement :: TagName -> Array Props -> Array ReactElement -> ReactElement createElement = case dynamic of - IsDynamic false -> createElementTagName - IsDynamic true -> createElementTagNameDynamic + IsDynamic false -> createElementTagName + IsDynamic true -> createElementTagNameDynamic text :: String -> ReactElement text = unsafeCoerce diff --git a/src/React/DOM/Dynamic.purs b/src/React/DOM/Dynamic.purs index 8a013d6..e5fe3c4 100644 --- a/src/React/DOM/Dynamic.purs +++ b/src/React/DOM/Dynamic.purs @@ -1,8 +1,8 @@ module React.DOM.Dynamic where import React (ReactElement) -import React.DOM.Props (Props) import React.DOM as DOM +import React.DOM.Props (Props) text :: String -> ReactElement text = DOM.text diff --git a/src/React/DOM/Props.purs b/src/React/DOM/Props.purs index 34d90e4..65e9e1e 100644 --- a/src/React/DOM/Props.purs +++ b/src/React/DOM/Props.purs @@ -6,13 +6,13 @@ import Effect (Effect) import Effect.Uncurried (mkEffectFn1) import React.Ref as Ref import React.SyntheticEvent - ( SyntheticEvent - , SyntheticAnimationEvent + ( SyntheticAnimationEvent , SyntheticClipboardEvent , SyntheticCompositionEvent + , SyntheticEvent + , SyntheticFocusEvent , SyntheticInputEvent , SyntheticKeyboardEvent - , SyntheticFocusEvent , SyntheticMouseEvent , SyntheticTouchEvent , SyntheticTransitionEvent diff --git a/src/React/Ref.purs b/src/React/Ref.purs index a8a57ef..4cd8be9 100644 --- a/src/React/Ref.purs +++ b/src/React/Ref.purs @@ -11,11 +11,12 @@ module React.Ref ) where import Prelude -import Effect (Effect) + import Data.Maybe (Maybe) import Data.Nullable (Nullable) import Data.Nullable as Nullable -import Effect.Uncurried (EffectFn1, runEffectFn1, mkEffectFn1) +import Effect (Effect) +import Effect.Uncurried (EffectFn1, mkEffectFn1, runEffectFn1) import Unsafe.Coerce (unsafeCoerce) --- | An instance of a React class. @@ -33,28 +34,22 @@ foreign import data RefHandler :: Type -> Type type role RefHandler representational - foreign import createRef :: forall a. Effect (Ref a) foreign import liftCallbackRef :: forall a. Ref a -> Ref a - createNodeRef :: Effect (Ref NativeNode) createNodeRef = createRef - createInstanceRef :: Effect (Ref ReactInstance) createInstanceRef = createRef - fromRef :: forall a. Ref a -> RefHandler a fromRef = unsafeCoerce - fromEffect :: forall a. (Ref a -> Effect Unit) -> RefHandler a fromEffect f = unsafeCoerce $ mkEffectFn1 (f <<< liftCallbackRef) - foreign import getCurrentRef_ :: forall a. EffectFn1 (Ref a) (Nullable a) getCurrentRef :: forall a. Ref a -> Effect (Maybe a) diff --git a/src/React/SyntheticEvent.purs b/src/React/SyntheticEvent.purs index 25592a6..f4c97e0 100644 --- a/src/React/SyntheticEvent.purs +++ b/src/React/SyntheticEvent.purs @@ -98,41 +98,29 @@ import Effect (Effect) import Prim.Row as Row import Type.Proxy (Proxy(..)) -type SyntheticEvent - = SyntheticEvent_ (SyntheticEvent' ()) +type SyntheticEvent = SyntheticEvent_ (SyntheticEvent' ()) -type SyntheticAnimationEvent - = SyntheticEvent_ (SyntheticAnimationEvent' (SyntheticEvent' ())) +type SyntheticAnimationEvent = SyntheticEvent_ (SyntheticAnimationEvent' (SyntheticEvent' ())) -type SyntheticClipboardEvent - = SyntheticEvent_ (SyntheticClipboardEvent' (SyntheticEvent' ())) +type SyntheticClipboardEvent = SyntheticEvent_ (SyntheticClipboardEvent' (SyntheticEvent' ())) -type SyntheticCompositionEvent - = SyntheticEvent_ (SyntheticCompositionEvent' (SyntheticUIEvent' (SyntheticEvent' ()))) +type SyntheticCompositionEvent = SyntheticEvent_ (SyntheticCompositionEvent' (SyntheticUIEvent' (SyntheticEvent' ()))) -type SyntheticInputEvent - = SyntheticEvent_ (SyntheticUIEvent' (SyntheticEvent' ())) +type SyntheticInputEvent = SyntheticEvent_ (SyntheticUIEvent' (SyntheticEvent' ())) -type SyntheticKeyboardEvent - = SyntheticEvent_ (SyntheticKeyboardEvent' (SyntheticUIEvent' (SyntheticEvent' ()))) +type SyntheticKeyboardEvent = SyntheticEvent_ (SyntheticKeyboardEvent' (SyntheticUIEvent' (SyntheticEvent' ()))) -type SyntheticFocusEvent - = SyntheticEvent_ (SyntheticFocusEvent' (SyntheticUIEvent' (SyntheticEvent' ()))) +type SyntheticFocusEvent = SyntheticEvent_ (SyntheticFocusEvent' (SyntheticUIEvent' (SyntheticEvent' ()))) -type SyntheticMouseEvent - = SyntheticEvent_ (SyntheticMouseEvent' (SyntheticUIEvent' (SyntheticEvent' ()))) +type SyntheticMouseEvent = SyntheticEvent_ (SyntheticMouseEvent' (SyntheticUIEvent' (SyntheticEvent' ()))) -type SyntheticTouchEvent - = SyntheticEvent_ (SyntheticTouchEvent' (SyntheticUIEvent' (SyntheticEvent' ()))) +type SyntheticTouchEvent = SyntheticEvent_ (SyntheticTouchEvent' (SyntheticUIEvent' (SyntheticEvent' ()))) -type SyntheticTransitionEvent - = SyntheticEvent_ (SyntheticTransitionEvent' (SyntheticEvent' ())) +type SyntheticTransitionEvent = SyntheticEvent_ (SyntheticTransitionEvent' (SyntheticEvent' ())) -type SyntheticUIEvent - = SyntheticEvent_ (SyntheticUIEvent' (SyntheticEvent' ())) +type SyntheticUIEvent = SyntheticEvent_ (SyntheticUIEvent' (SyntheticEvent' ())) -type SyntheticWheelEvent - = SyntheticEvent_ (SyntheticWheelEvent' (SyntheticMouseEvent' (SyntheticEvent' ()))) +type SyntheticWheelEvent = SyntheticEvent_ (SyntheticWheelEvent' (SyntheticMouseEvent' (SyntheticEvent' ()))) foreign import data SyntheticEvent_ :: Row Type -> Type @@ -148,108 +136,108 @@ foreign import data NativeAbstractView :: Type foreign import data NativeTouchList :: Type -type SyntheticEvent' r - = ( bubbles :: Boolean - , cancelable :: Boolean - , currentTarget :: NativeEventTarget - , defaultPrevented :: Boolean - , eventPhase :: Number - , isTrusted :: Boolean - , nativeEvent :: NativeEvent - , target :: NativeEventTarget - , timeStamp :: Number - , type :: String - | r - ) - -type SyntheticAnimationEvent' r - = ( animationName :: String - , pseudoElement :: String - , elapsedTime :: Number - | r - ) - -type SyntheticClipboardEvent' r - = ( clipboardData :: NativeDataTransfer - | r - ) - -type SyntheticCompositionEvent' r - = ( data :: String - | r - ) - -type SyntheticFocusEvent' r - = ( relatedTarget :: NativeEventTarget - | r - ) - -type SyntheticKeyboardEvent' r - = ( altKey :: Boolean - , ctrlKey :: Boolean - , getModifierState :: String -> Boolean - , charCode :: Int - , key :: String - , keyCode :: Number - , locale :: String - , location :: Number - , metaKey :: Boolean - , repeat :: Boolean - , shiftKey :: Boolean - , which :: Number - | r - ) - -type SyntheticMouseEvent' r - = ( altKey :: Boolean - , button :: Number - , buttons :: Number - , clientX :: Number - , clientY :: Number - , ctrlKey :: Boolean - , getModifierState :: String -> Boolean - , metaKey :: Boolean - , pageX :: Number - , pageY :: Number - , relatedTarget :: NativeEventTarget - , screenX :: Number - , screenY :: Number - , shiftKey :: Boolean - | r - ) - -type SyntheticTouchEvent' r - = ( altKey :: Boolean - , changedTouches :: NativeTouchList - , ctrlKey :: Boolean - , getModifierState :: String -> Boolean - , metaKey :: Boolean - , targetTouches :: NativeTouchList - , shiftKey :: Boolean - , touches :: NativeTouchList - | r - ) - -type SyntheticTransitionEvent' r - = ( propertyName :: String - , pseudoElement :: String - , elapsedTime :: Number - | r - ) - -type SyntheticUIEvent' r - = ( detail :: Number - , view :: NativeAbstractView - | r - ) - -type SyntheticWheelEvent' r - = ( deltaMode :: Number - , deltaX :: Number - , deltaY :: Number - , deltaZ :: Number - | r - ) +type SyntheticEvent' r = + ( bubbles :: Boolean + , cancelable :: Boolean + , currentTarget :: NativeEventTarget + , defaultPrevented :: Boolean + , eventPhase :: Number + , isTrusted :: Boolean + , nativeEvent :: NativeEvent + , target :: NativeEventTarget + , timeStamp :: Number + , type :: String + | r + ) + +type SyntheticAnimationEvent' r = + ( animationName :: String + , pseudoElement :: String + , elapsedTime :: Number + | r + ) + +type SyntheticClipboardEvent' r = + ( clipboardData :: NativeDataTransfer + | r + ) + +type SyntheticCompositionEvent' r = + ( data :: String + | r + ) + +type SyntheticFocusEvent' r = + ( relatedTarget :: NativeEventTarget + | r + ) + +type SyntheticKeyboardEvent' r = + ( altKey :: Boolean + , ctrlKey :: Boolean + , getModifierState :: String -> Boolean + , charCode :: Int + , key :: String + , keyCode :: Number + , locale :: String + , location :: Number + , metaKey :: Boolean + , repeat :: Boolean + , shiftKey :: Boolean + , which :: Number + | r + ) + +type SyntheticMouseEvent' r = + ( altKey :: Boolean + , button :: Number + , buttons :: Number + , clientX :: Number + , clientY :: Number + , ctrlKey :: Boolean + , getModifierState :: String -> Boolean + , metaKey :: Boolean + , pageX :: Number + , pageY :: Number + , relatedTarget :: NativeEventTarget + , screenX :: Number + , screenY :: Number + , shiftKey :: Boolean + | r + ) + +type SyntheticTouchEvent' r = + ( altKey :: Boolean + , changedTouches :: NativeTouchList + , ctrlKey :: Boolean + , getModifierState :: String -> Boolean + , metaKey :: Boolean + , targetTouches :: NativeTouchList + , shiftKey :: Boolean + , touches :: NativeTouchList + | r + ) + +type SyntheticTransitionEvent' r = + ( propertyName :: String + , pseudoElement :: String + , elapsedTime :: Number + | r + ) + +type SyntheticUIEvent' r = + ( detail :: Number + , view :: NativeAbstractView + | r + ) + +type SyntheticWheelEvent' r = + ( deltaMode :: Number + , deltaX :: Number + , deltaY :: Number + , deltaZ :: Number + | r + ) bubbles :: forall r. SyntheticEvent_ (bubbles :: Boolean | r) -> Effect Boolean bubbles = get (Proxy :: Proxy "bubbles") @@ -396,7 +384,11 @@ foreign import isPropagationStopped :: forall r. SyntheticEvent_ r -> Effect Boo foreign import persist :: forall r. SyntheticEvent_ r -> Effect Unit -foreign import getModifierState :: forall r. String -> SyntheticEvent_ (getModifierState :: String -> Boolean | r) -> Effect Boolean +foreign import getModifierState + :: forall r + . String + -> SyntheticEvent_ (getModifierState :: String -> Boolean | r) + -> Effect Boolean get :: forall l r s a proxy