Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
> - :house: [Internal]
> - :nail_care: [Polish]

## Unreleased

#### :rocket: New Feature

- Add `ReactEvent.Toggle` with typed `oldState`, `newState`, and optional `source` accessors and synthetic-event helpers.

## 0.16.0-beta.1

#### :boom: Breaking Change
Expand Down
12 changes: 12 additions & 0 deletions src/ReactEvent.res
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,15 @@ module Transition = {
@get external pseudoElement: t => string = "pseudoElement"
@get external elapsedTime: t => float = "elapsedTime"
}

module Toggle = {
type tag = JsxEvent.Toggle.tag

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Require the compiler release that defines Toggle

When this package is compiled with the currently supported ReScript 13.0.0-alpha.5, this member does not exist: JsxEvent.Toggle is introduced by compiler PR 9075, while package.json and package-lock.json remain on alpha.5 and the changelog still declares alpha.5 as the minimum. Because the npm package ships its .res and .resi sources, consumers on the allowed minimum cannot compile a release containing this binding; update the compiler requirement, lockfile, and documented minimum to the first release that includes that compiler change.

Useful? React with 👍 / 👎.

type t = synthetic<tag>

include MakeEventWithType({type t = t})

@get external oldState: t => [#closed | #"open"] = "oldState"
@get external newState: t => [#closed | #"open"] = "newState"
/** The element that triggered the toggle. Available in React 19.3 and later. */
@get @return(nullable) external source: t => option<Dom.element> = "source"
}
3 changes: 3 additions & 0 deletions src/ReactEvent.res.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions src/ReactEvent.resi
Original file line number Diff line number Diff line change
Expand Up @@ -470,3 +470,27 @@ module Transition: {
@get external pseudoElement: t => string = "pseudoElement"
@get external elapsedTime: t => float = "elapsedTime"
}

module Toggle: {
type tag = JsxEvent.Toggle.tag
type t = synthetic<tag>
@get external bubbles: t => bool = "bubbles"
@get external cancelable: t => bool = "cancelable"
@get external currentTarget: t => {..} = "currentTarget"
@get external defaultPrevented: t => bool = "defaultPrevented"
@get external eventPhase: t => int = "eventPhase"
@get external isTrusted: t => bool = "isTrusted"
@get external nativeEvent: t => {..} = "nativeEvent"
@send external preventDefault: t => unit = "preventDefault"
@send external isDefaultPrevented: t => bool = "isDefaultPrevented"
@send external stopPropagation: t => unit = "stopPropagation"
@send external isPropagationStopped: t => bool = "isPropagationStopped"
@get external target: t => {..} = "target"
@get external timeStamp: t => float = "timeStamp"
@get external type_: t => string = "type"
@send external persist: t => unit = "persist"
@get external oldState: t => [#closed | #"open"] = "oldState"
@get external newState: t => [#closed | #"open"] = "newState"
/** The element that triggered the toggle. Available in React 19.3 and later. */
@get @return(nullable) external source: t => option<Dom.element> = "source"
}
Loading