diff --git a/CHANGELOG.md b/CHANGELOG.md index 2393ba7..516f062 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,36 @@ > - :house: [Internal] > - :nail_care: [Polish] +## 0.13.1 + +#### :boom: Breaking Change + +- Deprecate JSX 3. https://github.com/rescript-lang/rescript-react/pull/120 +- Deprecate ReactDOMStyle.make. https://github.com/rescript-lang/rescript-react/pull/127 + +#### :nail_care: Polish + +- ReScriptReactRouter: get rid of pipe last. https://github.com/rescript-lang/rescript-react/pull/126 + +## 0.13.0 + +#### :boom: Breaking Change + +- Replace usages of `%external` by binding to `globalThis`. This is to support upcoming ReScript 12 versions. For older browsers, it may be necessary to polyfill `globalThis`. + +#### :bug: Bug Fix + +- Remove hardcoded `require` so it works in both common js and ES module modes. (https://github.com/rescript-lang/rescript-react/pull/117) + +## 0.12.2 + +- Fix incorrect usage of `@uncurry`. +- bsconfig.json -> rescript.json. + +## 0.12.1 + +- Undeprecate numbered hooks for a smoother upgrading experience. + ## 0.12.0 - Requires ReScript 11.0.0 or newer. diff --git a/README.md b/README.md index 62b25b0..5adebb1 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,12 @@ ### Versions -| @rescript/react | ReScript | ReactJS | Documentation | -| --------------- | -------- | ------- | ----------------------------------------------------------------- | -| 0.12.0+ | 11.0+ | 18.0.0+ | [Link](https://rescript-lang.org/docs/react/latest/introduction) | -| 0.11.0 | 10.1 | 18.0.0+ | [Link](https://rescript-lang.org/docs/react/v0.11.0/introduction) | -| 0.10.3 | 8.3 | 16.8.1+ | [Link](https://rescript-lang.org/docs/react/v0.10.0/introduction) | +| @rescript/react | ReScript | ReactJS | Documentation | +| --------------- | ---------------------------------- | ------- | ----------------------------------------------------------------- | +| next (master) | 11.0+ (JSX4 + uncurried mode only) | 18.0.0+ | | +| 0.12.x, 0.13.x | 11.0+ | 18.0.0+ | [Link](https://rescript-lang.org/docs/react/latest/introduction) | +| 0.11.0 | 10.1 | 18.0.0+ | [Link](https://rescript-lang.org/docs/react/v0.11.0/introduction) | +| 0.10.3 | 8.3 | 16.8.1+ | [Link](https://rescript-lang.org/docs/react/v0.10.0/introduction) | ### Development diff --git a/package-lock.json b/package-lock.json index 59995e2..99bed8f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rescript/react", - "version": "0.12.0", + "version": "0.13.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@rescript/react", - "version": "0.12.0", + "version": "0.13.1", "license": "MIT", "devDependencies": { "react": "^18.2.0", diff --git a/package.json b/package.json index fd6ae94..6668fec 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "@rescript/react", - "version": "0.12.0", + "version": "0.13.1", "description": "React bindings for ReScript", "files": [ "README.md", "CHANGELOG.md", "LICENSE", - "bsconfig.json", + "rescript.json", "src/**/*.res", "src/**/*.resi" ], diff --git a/bsconfig.json b/rescript.json similarity index 100% rename from bsconfig.json rename to rescript.json diff --git a/src/React.bs.js b/src/React.bs.js index 08a9db0..c2471b6 100644 --- a/src/React.bs.js +++ b/src/React.bs.js @@ -1,7 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -var Curry = require("rescript/lib/js/curry.js"); var React = require("react"); var Ref = {}; @@ -17,9 +16,9 @@ var StrictMode = {}; var Suspense = {}; function lazy_(load) { - return React.lazy(async function (param) { + return React.lazy(async function () { return { - default: await Curry._1(load, undefined) + default: await load() }; }); } diff --git a/src/React.res b/src/React.res index fe9eb88..0beaa59 100644 --- a/src/React.res +++ b/src/React.res @@ -45,17 +45,6 @@ type fragmentProps = {children?: element} type ref<'value> = {mutable current: 'value} -module Ref = { - @deprecated("Please use the type React.ref instead") - type t<'value> = ref<'value> - - @deprecated("Please directly read from ref.current instead") @get - external current: ref<'value> => 'value = "current" - - @deprecated("Please directly assign to ref.current instead") @set - external setCurrent: (ref<'value>, 'value) => unit = "current" -} - @module("react") external createRef: unit => ref> = "createRef" @@ -63,11 +52,11 @@ module Children = { @module("react") @scope("Children") external map: (element, element => element) => element = "map" @module("react") @scope("Children") - external mapWithIndex: (element, @uncurry (element, int) => element) => element = "map" + external mapWithIndex: (element, (element, int) => element) => element = "map" @module("react") @scope("Children") external forEach: (element, element => unit) => unit = "forEach" @module("react") @scope("Children") - external forEachWithIndex: (element, @uncurry (element, int) => unit) => unit = "forEach" + external forEachWithIndex: (element, (element, int) => unit) => unit = "forEach" @module("react") @scope("Children") external count: element => int = "count" @module("react") @scope("Children") @@ -92,7 +81,7 @@ module Context = { external createContext: 'a => Context.t<'a> = "createContext" @module("react") -external forwardRef: (@uncurry ('props, Js.Nullable.t>) => element) => component<'props> = +external forwardRef: (('props, Js.Nullable.t>) => element) => component<'props> = "forwardRef" @module("react") @@ -101,7 +90,7 @@ external memo: component<'props> => component<'props> = "memo" @module("react") external memoCustomCompareProps: ( component<'props>, - @uncurry ('props, 'props) => bool, + ('props, 'props) => bool, ) => component<'props> = "memo" @module("react") external fragment: component = "Fragment" @@ -143,134 +132,119 @@ let lazy_ = load => lazy_(async () => {default: await load()}) * only way to safely have any type of state and be able to update it correctly. */ @module("react") -external useState: (@uncurry (unit => 'state)) => ('state, ('state => 'state) => unit) = "useState" +external useState: (unit => 'state) => ('state, ('state => 'state) => unit) = "useState" @module("react") -external useReducer: (@uncurry ('state, 'action) => 'state, 'state) => ('state, 'action => unit) = +external useReducer: (('state, 'action) => 'state, 'state) => ('state, 'action => unit) = "useReducer" @module("react") external useReducerWithMapState: ( - @uncurry ('state, 'action) => 'state, + ('state, 'action) => 'state, 'initialState, - @uncurry ('initialState => 'state), + 'initialState => 'state, ) => ('state, 'action => unit) = "useReducer" @module("react") -external useEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = "useEffect" +external useEffectOnEveryRender: (unit => option unit>) => unit = "useEffect" @module("react") -external useEffect: (@uncurry (unit => option unit>), 'deps) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") -external useEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = - "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") -external useEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") -external useEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") -external useEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") -external useEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = - "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") -external useEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = - "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") -external useEffect6: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f)) => unit = +external useEffect: (unit => option unit>, 'deps) => unit = "useEffect" +@module("react") +external useEffect0: (unit => option unit>, @as(json`[]`) _) => unit = "useEffect" +@module("react") +external useEffect1: (unit => option unit>, array<'a>) => unit = "useEffect" +@module("react") +external useEffect2: (unit => option unit>, ('a, 'b)) => unit = "useEffect" +@module("react") +external useEffect3: (unit => option unit>, ('a, 'b, 'c)) => unit = "useEffect" +@module("react") +external useEffect4: (unit => option unit>, ('a, 'b, 'c, 'd)) => unit = "useEffect" +@module("react") +external useEffect5: (unit => option unit>, ('a, 'b, 'c, 'd, 'e)) => unit = "useEffect" +@module("react") +external useEffect6: (unit => option unit>, ('a, 'b, 'c, 'd, 'e, 'f)) => unit = "useEffect" +@module("react") +external useEffect7: (unit => option unit>, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") -external useEffect7: ( - @uncurry (unit => option unit>), - ('a, 'b, 'c, 'd, 'e, 'f, 'g), -) => unit = "useEffect" @module("react") -external useLayoutEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = - "useLayoutEffect" +external useLayoutEffectOnEveryRender: (unit => option unit>) => unit = "useLayoutEffect" @module("react") -external useLayoutEffect: (@uncurry (unit => option unit>), 'deps) => unit = - "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") -external useLayoutEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = - "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") -external useLayoutEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = +external useLayoutEffect: (unit => option unit>, 'deps) => unit = "useLayoutEffect" +@module("react") +external useLayoutEffect0: (unit => option unit>, @as(json`[]`) _) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") -external useLayoutEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = +@module("react") +external useLayoutEffect1: (unit => option unit>, array<'a>) => unit = "useLayoutEffect" +@module("react") +external useLayoutEffect2: (unit => option unit>, ('a, 'b)) => unit = "useLayoutEffect" +@module("react") +external useLayoutEffect3: (unit => option unit>, ('a, 'b, 'c)) => unit = "useLayoutEffect" +@module("react") +external useLayoutEffect4: (unit => option unit>, ('a, 'b, 'c, 'd)) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") -external useLayoutEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = +@module("react") +external useLayoutEffect5: (unit => option unit>, ('a, 'b, 'c, 'd, 'e)) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") -external useLayoutEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = +@module("react") +external useLayoutEffect6: (unit => option unit>, ('a, 'b, 'c, 'd, 'e, 'f)) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") -external useLayoutEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = +@module("react") +external useLayoutEffect7: (unit => option unit>, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") -external useLayoutEffect6: ( - @uncurry (unit => option unit>), - ('a, 'b, 'c, 'd, 'e, 'f), -) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") -external useLayoutEffect7: ( - @uncurry (unit => option unit>), - ('a, 'b, 'c, 'd, 'e, 'f, 'g), -) => unit = "useLayoutEffect" @module("react") -external useMemo: (@uncurry (unit => 'any), 'deps) => 'any = "useMemo" +external useMemo: (unit => 'any, 'deps) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") -external useMemo0: (@uncurry (unit => 'any), @as(json`[]`) _) => 'any = "useMemo" +@module("react") +external useMemo0: (unit => 'any, @as(json`[]`) _) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") -external useMemo1: (@uncurry (unit => 'any), array<'a>) => 'any = "useMemo" +@module("react") +external useMemo1: (unit => 'any, array<'a>) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") -external useMemo2: (@uncurry (unit => 'any), ('a, 'b)) => 'any = "useMemo" +@module("react") +external useMemo2: (unit => 'any, ('a, 'b)) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") -external useMemo3: (@uncurry (unit => 'any), ('a, 'b, 'c)) => 'any = "useMemo" +@module("react") +external useMemo3: (unit => 'any, ('a, 'b, 'c)) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") -external useMemo4: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd)) => 'any = "useMemo" +@module("react") +external useMemo4: (unit => 'any, ('a, 'b, 'c, 'd)) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") -external useMemo5: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e)) => 'any = "useMemo" +@module("react") +external useMemo5: (unit => 'any, ('a, 'b, 'c, 'd, 'e)) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") -external useMemo6: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f)) => 'any = "useMemo" +@module("react") +external useMemo6: (unit => 'any, ('a, 'b, 'c, 'd, 'e, 'f)) => 'any = "useMemo" -@module("react") @deprecated("Please use useMemo instead") -external useMemo7: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'any = "useMemo" +@module("react") +external useMemo7: (unit => 'any, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'any = "useMemo" @module("react") external useCallback: ('f, 'deps) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback0: ('f, @as(json`[]`) _) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback1: ('f, array<'a>) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback2: ('f, ('a, 'b)) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback3: ('f, ('a, 'b, 'c)) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback4: ('f, ('a, 'b, 'c, 'd)) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback5: ('f, ('a, 'b, 'c, 'd, 'e)) => 'f = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback6: ('callback, ('a, 'b, 'c, 'd, 'e, 'f)) => 'callback = "useCallback" -@module("react") @deprecated("Please use useCallback instead") +@module("react") external useCallback7: ('callback, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'callback = "useCallback" @module("react") @@ -279,79 +253,57 @@ external useContext: Context.t<'any> => 'any = "useContext" @module("react") external useRef: 'value => ref<'value> = "useRef" @module("react") -external useImperativeHandleOnEveryRender: ( - Js.Nullable.t>, - @uncurry (unit => 'value), -) => unit = "useImperativeHandle" +external useImperativeHandleOnEveryRender: (Js.Nullable.t>, unit => 'value) => unit = + "useImperativeHandle" @module("react") -external useImperativeHandle: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - 'deps, -) => unit = "useImperativeHandle" +external useImperativeHandle: (Js.Nullable.t>, unit => 'value, 'deps) => unit = + "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle0: ( Js.Nullable.t>, - @uncurry (unit => 'value), + unit => 'value, @as(json`[]`) _, ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") -external useImperativeHandle1: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - array<'a>, -) => unit = "useImperativeHandle" +external useImperativeHandle1: (Js.Nullable.t>, unit => 'value, array<'a>) => unit = + "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") -external useImperativeHandle2: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - ('a, 'b), -) => unit = "useImperativeHandle" +external useImperativeHandle2: (Js.Nullable.t>, unit => 'value, ('a, 'b)) => unit = + "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") -external useImperativeHandle3: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - ('a, 'b, 'c), -) => unit = "useImperativeHandle" +external useImperativeHandle3: (Js.Nullable.t>, unit => 'value, ('a, 'b, 'c)) => unit = + "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle4: ( Js.Nullable.t>, - @uncurry (unit => 'value), + unit => 'value, ('a, 'b, 'c, 'd), ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle5: ( Js.Nullable.t>, - @uncurry (unit => 'value), + unit => 'value, ('a, 'b, 'c, 'd, 'e), ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle6: ( Js.Nullable.t>, - @uncurry (unit => 'value), + unit => 'value, ('a, 'b, 'c, 'd, 'e, 'f), ) => unit = "useImperativeHandle" @module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle7: ( Js.Nullable.t>, - @uncurry (unit => 'value), + unit => 'value, ('a, 'b, 'c, 'd, 'e, 'f, 'g), ) => unit = "useImperativeHandle" @@ -360,109 +312,91 @@ external useImperativeHandle7: ( @module("react") external useDeferredValue: 'value => 'value = "useDeferredValue" @module("react") -external useTransition: unit => (bool, (. unit => unit) => unit) = "useTransition" +external useTransition: unit => (bool, (unit => unit) => unit) = "useTransition" @module("react") -external useInsertionEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = +external useInsertionEffectOnEveryRender: (unit => option unit>) => unit = "useInsertionEffect" @module("react") -external useInsertionEffect: (@uncurry (unit => option unit>), 'deps) => unit = - "useInsertionEffect" +external useInsertionEffect: (unit => option unit>, 'deps) => unit = "useInsertionEffect" @module("react") -@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") -external useInsertionEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = +external useInsertionEffect0: (unit => option unit>, @as(json`[]`) _) => unit = "useInsertionEffect" @module("react") -@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") -external useInsertionEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = +external useInsertionEffect1: (unit => option unit>, array<'a>) => unit = "useInsertionEffect" @module("react") -@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") -external useInsertionEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = +external useInsertionEffect2: (unit => option unit>, ('a, 'b)) => unit = "useInsertionEffect" @module("react") -@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") -external useInsertionEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = +external useInsertionEffect3: (unit => option unit>, ('a, 'b, 'c)) => unit = "useInsertionEffect" @module("react") -@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") -external useInsertionEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = +external useInsertionEffect4: (unit => option unit>, ('a, 'b, 'c, 'd)) => unit = "useInsertionEffect" @module("react") -@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") -external useInsertionEffect5: ( - @uncurry (unit => option unit>), - ('a, 'b, 'c, 'd, 'e), -) => unit = "useInsertionEffect" +external useInsertionEffect5: (unit => option unit>, ('a, 'b, 'c, 'd, 'e)) => unit = + "useInsertionEffect" @module("react") -@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") -external useInsertionEffect6: ( - @uncurry (unit => option unit>), - ('a, 'b, 'c, 'd, 'e, 'f), -) => unit = "useInsertionEffect" +external useInsertionEffect6: (unit => option unit>, ('a, 'b, 'c, 'd, 'e, 'f)) => unit = + "useInsertionEffect" @module("react") -@deprecated("Please use useInsertionEffect or useInsertionEffectOnEveryRender instead") -external useInsertionEffect7: ( - @uncurry (unit => option unit>), - ('a, 'b, 'c, 'd, 'e, 'f, 'g), -) => unit = "useInsertionEffect" +external useInsertionEffect7: (unit => option unit>, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => unit = + "useInsertionEffect" @module("react") external useSyncExternalStore: ( - ~subscribe: @uncurry ((unit => unit) => (. unit) => unit), - ~getSnapshot: @uncurry unit => 'state, + ~subscribe: (unit => unit) => unit => unit, + ~getSnapshot: unit => 'state, ) => 'state = "useSyncExternalStore" @module("react") external useSyncExternalStoreWithServerSnapshot: ( - ~subscribe: @uncurry ((unit => unit) => (. unit) => unit), - ~getSnapshot: @uncurry unit => 'state, - ~getServerSnapshot: @uncurry unit => 'state, + ~subscribe: (unit => unit) => unit => unit, + ~getSnapshot: unit => 'state, + ~getServerSnapshot: unit => 'state, ) => 'state = "useSyncExternalStore" module Uncurried = { @module("react") - external useState: (@uncurry (unit => 'state)) => ('state, (. 'state => 'state) => unit) = - "useState" + external useState: (unit => 'state) => ('state, ('state => 'state) => unit) = "useState" @module("react") - external useReducer: ( - @uncurry ('state, 'action) => 'state, - 'state, - ) => ('state, (. 'action) => unit) = "useReducer" + external useReducer: (('state, 'action) => 'state, 'state) => ('state, 'action => unit) = + "useReducer" @module("react") external useReducerWithMapState: ( - @uncurry ('state, 'action) => 'state, + ('state, 'action) => 'state, 'initialState, - @uncurry ('initialState => 'state), - ) => ('state, (. 'action) => unit) = "useReducer" + 'initialState => 'state, + ) => ('state, 'action => unit) = "useReducer" @module("react") external useCallback: ('f, 'deps) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback0: ('f, @as(json`[]`) _) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback1: ('f, array<'a>) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback2: ('f, ('a, 'b)) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback3: ('f, ('a, 'b, 'c)) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback4: ('f, ('a, 'b, 'c, 'd)) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback5: ('f, ('a, 'b, 'c, 'd, 'e)) => 'f = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback6: ('callback, ('a, 'b, 'c, 'd, 'e, 'f)) => 'callback = "useCallback" - @module("react") @deprecated("Please use useCallback instead") + @module("react") external useCallback7: ('callback, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'callback = "useCallback" } diff --git a/src/ReactDOM.res b/src/ReactDOM.res index 72bce53..04c39c2 100644 --- a/src/ReactDOM.res +++ b/src/ReactDOM.res @@ -9,12 +9,6 @@ @val @return(nullable) external querySelector: string => option = "document.querySelector" -@module("react-dom") -@deprecated( - "ReactDOM.render is no longer supported in React 18. Use ReactDOM.Client.createRoot instead." -) -external render: (React.element, Dom.element) => unit = "render" - module Client = { module Root = { type t @@ -31,21 +25,9 @@ module Client = { external hydrateRoot: (Dom.element, React.element) => Root.t = "hydrateRoot" } -@module("react-dom") -@deprecated( - "ReactDOM.hydrate is no longer supported in React 18. Use ReactDOM.Client.hydrateRoot instead." -) -external hydrate: (React.element, Dom.element) => unit = "hydrate" - @module("react-dom") external createPortal: (React.element, Dom.element) => React.element = "createPortal" -@module("react-dom") -@deprecated( - "ReactDOM.unmountComponentAtNode is no longer supported in React 18. Use ReactDOM.Client.Root.unmount instead." -) -external unmountComponentAtNode: Dom.element => unit = "unmountComponentAtNode" - external domElementToObj: Dom.element => {..} = "%identity" type style = ReactDOMStyle.t @@ -63,1038 +45,6 @@ module Ref = { type domProps = JsxDOM.domProps -@deprecated("Please use type ReactDOM.domProps") -type props = JsxDOM.domProps - -module Props = { - @deprecated("Please use type ReactDOM.domProps") - type domProps = JsxDOM.domProps - - /** DEPRECATED */ - @deriving(abstract) - @deprecated("Please use type ReactDOM.domProps") - type props = { - @optional - key: string, - @optional - ref: Js.nullable => unit, - /* accessibility */ - /* https://www.w3.org/TR/wai-aria-1.1/ */ - /* https://accessibilityresources.org/ is a great resource for these */ - /* [@optional] [@as "aria-current"] ariaCurrent: page|step|location|date|time|true|false, */ - @optional @as("aria-details") - ariaDetails: string, - @optional @as("aria-disabled") - ariaDisabled: bool, - @optional @as("aria-hidden") - ariaHidden: bool, - /* [@optional] [@as "aria-invalid"] ariaInvalid: grammar|false|spelling|true, */ - @optional @as("aria-keyshortcuts") - ariaKeyshortcuts: string, - @optional @as("aria-label") - ariaLabel: string, - @optional @as("aria-roledescription") - ariaRoledescription: string, - /* Widget Attributes */ - /* [@optional] [@as "aria-autocomplete"] ariaAutocomplete: inline|list|both|none, */ - /* [@optional] [@as "aria-checked"] ariaChecked: true|false|mixed, /* https://www.w3.org/TR/wai-aria-1.1/#valuetype_tristate */ */ - @optional @as("aria-expanded") - ariaExpanded: bool, - /* [@optional] [@as "aria-haspopup"] ariaHaspopup: false|true|menu|listbox|tree|grid|dialog, */ - @optional @as("aria-level") - ariaLevel: int, - @optional @as("aria-modal") - ariaModal: bool, - @optional @as("aria-multiline") - ariaMultiline: bool, - @optional @as("aria-multiselectable") - ariaMultiselectable: bool, - /* [@optional] [@as "aria-orientation"] ariaOrientation: horizontal|vertical|undefined, */ - @optional @as("aria-placeholder") - ariaPlaceholder: string, - /* [@optional] [@as "aria-pressed"] ariaPressed: true|false|mixed, /* https://www.w3.org/TR/wai-aria-1.1/#valuetype_tristate */ */ - @optional @as("aria-readonly") - ariaReadonly: bool, - @optional @as("aria-required") - ariaRequired: bool, - @optional @as("aria-selected") - ariaSelected: bool, - @optional @as("aria-sort") - ariaSort: string, - @optional @as("aria-valuemax") - ariaValuemax: float, - @optional @as("aria-valuemin") - ariaValuemin: float, - @optional @as("aria-valuenow") - ariaValuenow: float, - @optional @as("aria-valuetext") - ariaValuetext: string, - /* Live Region Attributes */ - @optional @as("aria-atomic") - ariaAtomic: bool, - @optional @as("aria-busy") - ariaBusy: bool, - /* [@optional] [@as "aria-live"] ariaLive: off|polite|assertive|rude, */ - @optional @as("aria-relevant") - ariaRelevant: string, - /* Drag-and-Drop Attributes */ - /* [@optional] [@as "aria-dropeffect"] ariaDropeffect: copy|move|link|execute|popup|none, */ - @optional @as("aria-grabbed") - ariaGrabbed: bool, - /* Relationship Attributes */ - @optional @as("aria-activedescendant") - ariaActivedescendant: string, - @optional @as("aria-colcount") - ariaColcount: int, - @optional @as("aria-colindex") - ariaColindex: int, - @optional @as("aria-colspan") - ariaColspan: int, - @optional @as("aria-controls") - ariaControls: string, - @optional @as("aria-describedby") - ariaDescribedby: string, - @optional @as("aria-errormessage") - ariaErrormessage: string, - @optional @as("aria-flowto") - ariaFlowto: string, - @optional @as("aria-labelledby") - ariaLabelledby: string, - @optional @as("aria-owns") - ariaOwns: string, - @optional @as("aria-posinset") - ariaPosinset: int, - @optional @as("aria-rowcount") - ariaRowcount: int, - @optional @as("aria-rowindex") - ariaRowindex: int, - @optional @as("aria-rowspan") - ariaRowspan: int, - @optional @as("aria-setsize") - ariaSetsize: int, - /* react textarea/input */ - @optional - defaultChecked: bool, - @optional - defaultValue: string, - /* global html attributes */ - @optional - accessKey: string, - @optional - className: string /* substitute for "class" */, - @optional - contentEditable: bool, - @optional - contextMenu: string, - @optional - dir: string /* "ltr", "rtl" or "auto" */, - @optional - draggable: bool, - @optional - hidden: bool, - @optional - id: string, - @optional - lang: string, - @optional - role: string /* ARIA role */, - @optional - style: style, - @optional - spellCheck: bool, - @optional - tabIndex: int, - @optional - title: string, - /* html5 microdata */ - @optional - itemID: string, - @optional - itemProp: string, - @optional - itemRef: string, - @optional - itemScope: bool, - @optional - itemType: string /* uri */, - /* tag-specific html attributes */ - @optional - accept: string, - @optional - acceptCharset: string, - @optional - action: string /* uri */, - @optional - allow: string, - @optional - allowFullScreen: bool, - @optional - alt: string, - @optional - async: bool, - @optional - autoComplete: string /* has a fixed, but large-ish, set of possible values */, - @optional - autoCapitalize: string /* Mobile Safari specific */, - @optional - autoFocus: bool, - @optional - autoPlay: bool, - @optional - challenge: string, - @optional - charSet: string, - @optional - checked: bool, - @optional - cite: string /* uri */, - @optional - crossorigin: bool, - @optional - cols: int, - @optional - colSpan: int, - @optional - content: string, - @optional - controls: bool, - @optional - coords: string /* set of values specifying the coordinates of a region */, - @optional - data: string /* uri */, - @optional - dateTime: string /* "valid date string with optional time" */, - @optional - default: bool, - @optional - defer: bool, - @optional - disabled: bool, - @optional - download: string /* should really be either a boolean, signifying presence, or a string */, - @optional - encType: string /* "application/x-www-form-urlencoded", "multipart/form-data" or "text/plain" */, - @optional - form: string, - @optional - formAction: string /* uri */, - @optional - formTarget: string /* "_blank", "_self", etc. */, - @optional - formMethod: string /* "post", "get", "put" */, - @optional - frameBorder: int /* deprecated, prefer to use css border instead */, - @optional - headers: string, - @optional - height: string /* in html5 this can only be a number, but in html4 it can ba a percentage as well */, - @optional - high: int, - @optional - href: string /* uri */, - @optional - hrefLang: string, - @optional - htmlFor: string /* substitute for "for" */, - @optional - httpEquiv: string /* has a fixed set of possible values */, - @optional - icon: string /* uri? */, - @optional - inputMode: string /* "verbatim", "latin", "numeric", etc. */, - @optional - integrity: string, - @optional - keyType: string, - @optional - kind: string /* has a fixed set of possible values */, - @optional - label: string, - @optional - list: string, - @optional - loop: bool, - @optional - low: int, - @optional - manifest: string /* uri */, - @optional - max: string /* should be int or Js.Date.t */, - @optional - maxLength: int, - @optional - media: string /* a valid media query */, - @optional - mediaGroup: string, - @optional - method: string /* "post" or "get" */, - @optional - min: string, - @optional - minLength: int, - @optional - multiple: bool, - @optional - muted: bool, - @optional - name: string, - @optional - nonce: string, - @optional - noValidate: bool, - @optional @as("open") - open_: bool /* use this one. Previous one is deprecated */, - @optional - optimum: int, - @optional - pattern: string /* valid Js RegExp */, - @optional - placeholder: string, - @optional - poster: string /* uri */, - @optional - preload: string /* "none", "metadata" or "auto" (and "" as a synonym for "auto") */, - @optional - radioGroup: string, - @optional - readOnly: bool, - @optional - rel: string /* a space- or comma-separated (depending on the element) list of a fixed set of "link types" */, - @optional - required: bool, - @optional - reversed: bool, - @optional - rows: int, - @optional - rowSpan: int, - @optional - sandbox: string /* has a fixed set of possible values */, - @optional - scope: string /* has a fixed set of possible values */, - @optional - scoped: bool, - @optional - scrolling: string /* html4 only, "auto", "yes" or "no" */, - /* seamless - supported by React, but removed from the html5 spec */ - @optional - selected: bool, - @optional - shape: string, - @optional - size: int, - @optional - sizes: string, - @optional - span: int, - @optional - src: string /* uri */, - @optional - srcDoc: string, - @optional - srcLang: string, - @optional - srcSet: string, - @optional - start: int, - @optional - step: float, - @optional - summary: string /* deprecated */, - @optional - target: string, - @optional @as("type") - type_: string /* has a fixed but large-ish set of possible values */ /* use this one. Previous one is deprecated */, - @optional - useMap: string, - @optional - value: string, - @optional - width: string /* in html5 this can only be a number, but in html4 it can ba a percentage as well */, - @optional - wrap: string /* "hard" or "soft" */, - /* Clipboard events */ - @optional - onCopy: ReactEvent.Clipboard.t => unit, - @optional - onCut: ReactEvent.Clipboard.t => unit, - @optional - onPaste: ReactEvent.Clipboard.t => unit, - /* Composition events */ - @optional - onCompositionEnd: ReactEvent.Composition.t => unit, - @optional - onCompositionStart: ReactEvent.Composition.t => unit, - @optional - onCompositionUpdate: ReactEvent.Composition.t => unit, - /* Keyboard events */ - @optional - onKeyDown: ReactEvent.Keyboard.t => unit, - @optional - onKeyPress: ReactEvent.Keyboard.t => unit, - @optional - onKeyUp: ReactEvent.Keyboard.t => unit, - /* Focus events */ - @optional - onFocus: ReactEvent.Focus.t => unit, - @optional - onBlur: ReactEvent.Focus.t => unit, - /* Form events */ - @optional - onChange: ReactEvent.Form.t => unit, - @optional - onInput: ReactEvent.Form.t => unit, - @optional - onSubmit: ReactEvent.Form.t => unit, - @optional - onInvalid: ReactEvent.Form.t => unit, - /* Mouse events */ - @optional - onClick: ReactEvent.Mouse.t => unit, - @optional - onContextMenu: ReactEvent.Mouse.t => unit, - @optional - onDoubleClick: ReactEvent.Mouse.t => unit, - @optional - onDrag: ReactEvent.Mouse.t => unit, - @optional - onDragEnd: ReactEvent.Mouse.t => unit, - @optional - onDragEnter: ReactEvent.Mouse.t => unit, - @optional - onDragExit: ReactEvent.Mouse.t => unit, - @optional - onDragLeave: ReactEvent.Mouse.t => unit, - @optional - onDragOver: ReactEvent.Mouse.t => unit, - @optional - onDragStart: ReactEvent.Mouse.t => unit, - @optional - onDrop: ReactEvent.Mouse.t => unit, - @optional - onMouseDown: ReactEvent.Mouse.t => unit, - @optional - onMouseEnter: ReactEvent.Mouse.t => unit, - @optional - onMouseLeave: ReactEvent.Mouse.t => unit, - @optional - onMouseMove: ReactEvent.Mouse.t => unit, - @optional - onMouseOut: ReactEvent.Mouse.t => unit, - @optional - onMouseOver: ReactEvent.Mouse.t => unit, - @optional - onMouseUp: ReactEvent.Mouse.t => unit, - /* Selection events */ - @optional - onSelect: ReactEvent.Selection.t => unit, - /* Touch events */ - @optional - onTouchCancel: ReactEvent.Touch.t => unit, - @optional - onTouchEnd: ReactEvent.Touch.t => unit, - @optional - onTouchMove: ReactEvent.Touch.t => unit, - @optional - onTouchStart: ReactEvent.Touch.t => unit, - // Pointer events - @optional - onPointerOver: ReactEvent.Pointer.t => unit, - @optional - onPointerEnter: ReactEvent.Pointer.t => unit, - @optional - onPointerDown: ReactEvent.Pointer.t => unit, - @optional - onPointerMove: ReactEvent.Pointer.t => unit, - @optional - onPointerUp: ReactEvent.Pointer.t => unit, - @optional - onPointerCancel: ReactEvent.Pointer.t => unit, - @optional - onPointerOut: ReactEvent.Pointer.t => unit, - @optional - onPointerLeave: ReactEvent.Pointer.t => unit, - @optional - onGotPointerCapture: ReactEvent.Pointer.t => unit, - @optional - onLostPointerCapture: ReactEvent.Pointer.t => unit, - /* UI events */ - @optional - onScroll: ReactEvent.UI.t => unit, - /* Wheel events */ - @optional - onWheel: ReactEvent.Wheel.t => unit, - /* Media events */ - @optional - onAbort: ReactEvent.Media.t => unit, - @optional - onCanPlay: ReactEvent.Media.t => unit, - @optional - onCanPlayThrough: ReactEvent.Media.t => unit, - @optional - onDurationChange: ReactEvent.Media.t => unit, - @optional - onEmptied: ReactEvent.Media.t => unit, - @optional - onEncrypetd: ReactEvent.Media.t => unit, - @optional - onEnded: ReactEvent.Media.t => unit, - @optional - onError: ReactEvent.Media.t => unit, - @optional - onLoadedData: ReactEvent.Media.t => unit, - @optional - onLoadedMetadata: ReactEvent.Media.t => unit, - @optional - onLoadStart: ReactEvent.Media.t => unit, - @optional - onPause: ReactEvent.Media.t => unit, - @optional - onPlay: ReactEvent.Media.t => unit, - @optional - onPlaying: ReactEvent.Media.t => unit, - @optional - onProgress: ReactEvent.Media.t => unit, - @optional - onRateChange: ReactEvent.Media.t => unit, - @optional - onSeeked: ReactEvent.Media.t => unit, - @optional - onSeeking: ReactEvent.Media.t => unit, - @optional - onStalled: ReactEvent.Media.t => unit, - @optional - onSuspend: ReactEvent.Media.t => unit, - @optional - onTimeUpdate: ReactEvent.Media.t => unit, - @optional - onVolumeChange: ReactEvent.Media.t => unit, - @optional - onWaiting: ReactEvent.Media.t => unit, - /* Image events */ - @optional - onLoad: ReactEvent.Image.t => unit /* duplicate */ /* ~onError: ReactEvent.Image.t => unit=?, */, - /* Animation events */ - @optional - onAnimationStart: ReactEvent.Animation.t => unit, - @optional - onAnimationEnd: ReactEvent.Animation.t => unit, - @optional - onAnimationIteration: ReactEvent.Animation.t => unit, - /* Transition events */ - @optional - onTransitionEnd: ReactEvent.Transition.t => unit, - /* svg */ - @optional - accentHeight: string, - @optional - accumulate: string, - @optional - additive: string, - @optional - alignmentBaseline: string, - @optional - allowReorder: string, - @optional - alphabetic: string, - @optional - amplitude: string, - @optional - arabicForm: string, - @optional - ascent: string, - @optional - attributeName: string, - @optional - attributeType: string, - @optional - autoReverse: string, - @optional - azimuth: string, - @optional - baseFrequency: string, - @optional - baseProfile: string, - @optional - baselineShift: string, - @optional - bbox: string, - @optional @as("begin") - begin_: string /* use this one. Previous one is deprecated */, - @optional - bias: string, - @optional - by: string, - @optional - calcMode: string, - @optional - capHeight: string, - @optional - clip: string, - @optional - clipPath: string, - @optional - clipPathUnits: string, - @optional - clipRule: string, - @optional - colorInterpolation: string, - @optional - colorInterpolationFilters: string, - @optional - colorProfile: string, - @optional - colorRendering: string, - @optional - contentScriptType: string, - @optional - contentStyleType: string, - @optional - cursor: string, - @optional - cx: string, - @optional - cy: string, - @optional - d: string, - @optional - decelerate: string, - @optional - descent: string, - @optional - diffuseConstant: string, - @optional - direction: string, - @optional - display: string, - @optional - divisor: string, - @optional - dominantBaseline: string, - @optional - dur: string, - @optional - dx: string, - @optional - dy: string, - @optional - edgeMode: string, - @optional - elevation: string, - @optional - enableBackground: string, - @optional @as("end") - end_: string /* use this one. Previous one is deprecated */, - @optional - exponent: string, - @optional - externalResourcesRequired: string, - @optional - fill: string, - @optional - fillOpacity: string, - @optional - fillRule: string, - @optional - filter: string, - @optional - filterRes: string, - @optional - filterUnits: string, - @optional - floodColor: string, - @optional - floodOpacity: string, - @optional - focusable: string, - @optional - fontFamily: string, - @optional - fontSize: string, - @optional - fontSizeAdjust: string, - @optional - fontStretch: string, - @optional - fontStyle: string, - @optional - fontVariant: string, - @optional - fontWeight: string, - @optional - fomat: string, - @optional - from: string, - @optional - fx: string, - @optional - fy: string, - @optional - g1: string, - @optional - g2: string, - @optional - glyphName: string, - @optional - glyphOrientationHorizontal: string, - @optional - glyphOrientationVertical: string, - @optional - glyphRef: string, - @optional - gradientTransform: string, - @optional - gradientUnits: string, - @optional - hanging: string, - @optional - horizAdvX: string, - @optional - horizOriginX: string, - @optional - ideographic: string, - @optional - imageRendering: string, - @optional @as("in") - in_: string /* use this one. Previous one is deprecated */, - @optional - in2: string, - @optional - intercept: string, - @optional - k: string, - @optional - k1: string, - @optional - k2: string, - @optional - k3: string, - @optional - k4: string, - @optional - kernelMatrix: string, - @optional - kernelUnitLength: string, - @optional - kerning: string, - @optional - keyPoints: string, - @optional - keySplines: string, - @optional - keyTimes: string, - @optional - lengthAdjust: string, - @optional - letterSpacing: string, - @optional - lightingColor: string, - @optional - limitingConeAngle: string, - @optional - local: string, - @optional - markerEnd: string, - @optional - markerHeight: string, - @optional - markerMid: string, - @optional - markerStart: string, - @optional - markerUnits: string, - @optional - markerWidth: string, - @optional - mask: string, - @optional - maskContentUnits: string, - @optional - maskUnits: string, - @optional - mathematical: string, - @optional - mode: string, - @optional - numOctaves: string, - @optional - offset: string, - @optional - opacity: string, - @optional - operator: string, - @optional - order: string, - @optional - orient: string, - @optional - orientation: string, - @optional - origin: string, - @optional - overflow: string, - @optional - overflowX: string, - @optional - overflowY: string, - @optional - overlinePosition: string, - @optional - overlineThickness: string, - @optional - paintOrder: string, - @optional - panose1: string, - @optional - pathLength: string, - @optional - patternContentUnits: string, - @optional - patternTransform: string, - @optional - patternUnits: string, - @optional - pointerEvents: string, - @optional - points: string, - @optional - pointsAtX: string, - @optional - pointsAtY: string, - @optional - pointsAtZ: string, - @optional - preserveAlpha: string, - @optional - preserveAspectRatio: string, - @optional - primitiveUnits: string, - @optional - r: string, - @optional - radius: string, - @optional - refX: string, - @optional - refY: string, - @optional - renderingIntent: string, - @optional - repeatCount: string, - @optional - repeatDur: string, - @optional - requiredExtensions: string, - @optional - requiredFeatures: string, - @optional - restart: string, - @optional - result: string, - @optional - rotate: string, - @optional - rx: string, - @optional - ry: string, - @optional - scale: string, - @optional - seed: string, - @optional - shapeRendering: string, - @optional - slope: string, - @optional - spacing: string, - @optional - specularConstant: string, - @optional - specularExponent: string, - @optional - speed: string, - @optional - spreadMethod: string, - @optional - startOffset: string, - @optional - stdDeviation: string, - @optional - stemh: string, - @optional - stemv: string, - @optional - stitchTiles: string, - @optional - stopColor: string, - @optional - stopOpacity: string, - @optional - strikethroughPosition: string, - @optional - strikethroughThickness: string, - @optional - string: string, - @optional - stroke: string, - @optional - strokeDasharray: string, - @optional - strokeDashoffset: string, - @optional - strokeLinecap: string, - @optional - strokeLinejoin: string, - @optional - strokeMiterlimit: string, - @optional - strokeOpacity: string, - @optional - strokeWidth: string, - @optional - surfaceScale: string, - @optional - systemLanguage: string, - @optional - tableValues: string, - @optional - targetX: string, - @optional - targetY: string, - @optional - textAnchor: string, - @optional - textDecoration: string, - @optional - textLength: string, - @optional - textRendering: string, - @optional @as("to") - to_: string /* use this one. Previous one is deprecated */, - @optional - transform: string, - @optional - u1: string, - @optional - u2: string, - @optional - underlinePosition: string, - @optional - underlineThickness: string, - @optional - unicode: string, - @optional - unicodeBidi: string, - @optional - unicodeRange: string, - @optional - unitsPerEm: string, - @optional - vAlphabetic: string, - @optional - vHanging: string, - @optional - vIdeographic: string, - @optional - vMathematical: string, - @optional - values: string, - @optional - vectorEffect: string, - @optional - version: string, - @optional - vertAdvX: string, - @optional - vertAdvY: string, - @optional - vertOriginX: string, - @optional - vertOriginY: string, - @optional - viewBox: string, - @optional - viewTarget: string, - @optional - visibility: string, - /* width::string? => */ - @optional - widths: string, - @optional - wordSpacing: string, - @optional - writingMode: string, - @optional - x: string, - @optional - x1: string, - @optional - x2: string, - @optional - xChannelSelector: string, - @optional - xHeight: string, - @optional - xlinkActuate: string, - @optional - xlinkArcrole: string, - @optional - xlinkHref: string, - @optional - xlinkRole: string, - @optional - xlinkShow: string, - @optional - xlinkTitle: string, - @optional - xlinkType: string, - @optional - xmlns: string, - @optional - xmlnsXlink: string, - @optional - xmlBase: string, - @optional - xmlLang: string, - @optional - xmlSpace: string, - @optional - y: string, - @optional - y1: string, - @optional - y2: string, - @optional - yChannelSelector: string, - @optional - z: string, - @optional - zoomAndPan: string, - /* RDFa */ - @optional - about: string, - @optional - datatype: string, - @optional - inlist: string, - @optional - prefix: string, - @optional - property: string, - @optional - resource: string, - @optional - typeof: string, - @optional - vocab: string, - /* react-specific */ - @optional - dangerouslySetInnerHTML: {"__html": string}, - @optional - suppressContentEditableWarning: bool, - } -} - @variadic @module("react") external createElement: (string, ~props: domProps=?, array) => React.element = "createElement" @@ -1120,8 +70,4 @@ external jsxs: (string, JsxDOM.domProps) => Jsx.element = "jsxs" @module("react/jsx-runtime") external jsxsKeyed: (string, JsxDOM.domProps, ~key: string=?, @ignore unit) => Jsx.element = "jsxs" -// Currently, not used by JSX ppx -@deprecated("Please use ReactDOM.createElement instead.") -external stringToComponent: string => React.component<'a> = "%identity" - module Style = ReactDOMStyle diff --git a/src/ReactDOMStyle.res b/src/ReactDOMStyle.res index 02b8b49..ae68d03 100644 --- a/src/ReactDOMStyle.res +++ b/src/ReactDOMStyle.res @@ -1,426 +1,5 @@ type t = JsxDOMStyle.t -@obj -external make: ( - ~azimuth: string=?, - ~backdropFilter: string=?, - ~background: string=?, - ~backgroundAttachment: string=?, - ~backgroundColor: string=?, - ~backgroundImage: string=?, - ~backgroundPosition: string=?, - ~backgroundRepeat: string=?, - ~border: string=?, - ~borderCollapse: string=?, - ~borderColor: string=?, - ~borderSpacing: string=?, - ~borderStyle: string=?, - ~borderTop: string=?, - ~borderRight: string=?, - ~borderBottom: string=?, - ~borderLeft: string=?, - ~borderTopColor: string=?, - ~borderRightColor: string=?, - ~borderBottomColor: string=?, - ~borderLeftColor: string=?, - ~borderTopStyle: string=?, - ~borderRightStyle: string=?, - ~borderBottomStyle: string=?, - ~borderLeftStyle: string=?, - ~borderTopWidth: string=?, - ~borderRightWidth: string=?, - ~borderBottomWidth: string=?, - ~borderLeftWidth: string=?, - ~borderWidth: string=?, - ~bottom: string=?, - ~captionSide: string=?, - ~clear: string=?, - ~clip: string=?, - ~color: string=?, - ~content: string=?, - ~counterIncrement: string=?, - ~counterReset: string=?, - ~cue: string=?, - ~cueAfter: string=?, - ~cueBefore: string=?, - ~cursor: string=?, - ~direction: string=?, - ~display: string=?, - ~elevation: string=?, - ~emptyCells: string=?, - ~float: string=?, - ~font: string=?, - ~fontFamily: string=?, - ~fontSize: string=?, - ~fontSizeAdjust: string=?, - ~fontStretch: string=?, - ~fontStyle: string=?, - ~fontVariant: string=?, - ~fontWeight: string=?, - ~height: string=?, - ~left: string=?, - ~letterSpacing: string=?, - ~lineHeight: string=?, - ~listStyle: string=?, - ~listStyleImage: string=?, - ~listStylePosition: string=?, - ~listStyleType: string=?, - ~margin: string=?, - ~marginTop: string=?, - ~marginRight: string=?, - ~marginBottom: string=?, - ~marginLeft: string=?, - ~markerOffset: string=?, - ~marks: string=?, - ~maxHeight: string=?, - ~maxWidth: string=?, - ~minHeight: string=?, - ~minWidth: string=?, - ~orphans: string=?, - ~outline: string=?, - ~outlineColor: string=?, - ~outlineStyle: string=?, - ~outlineWidth: string=?, - ~overflow: string=?, - ~overflowX: string=?, - ~overflowY: string=?, - ~padding: string=?, - ~paddingTop: string=?, - ~paddingRight: string=?, - ~paddingBottom: string=?, - ~paddingLeft: string=?, - ~page: string=?, - ~pageBreakAfter: string=?, - ~pageBreakBefore: string=?, - ~pageBreakInside: string=?, - ~pause: string=?, - ~pauseAfter: string=?, - ~pauseBefore: string=?, - ~pitch: string=?, - ~pitchRange: string=?, - ~playDuring: string=?, - ~position: string=?, - ~quotes: string=?, - ~richness: string=?, - ~right: string=?, - ~size: string=?, - ~speak: string=?, - ~speakHeader: string=?, - ~speakNumeral: string=?, - ~speakPunctuation: string=?, - ~speechRate: string=?, - ~stress: string=?, - ~tableLayout: string=?, - ~textAlign: string=?, - ~textDecoration: string=?, - ~textIndent: string=?, - ~textShadow: string=?, - ~textTransform: string=?, - ~top: string=?, - ~unicodeBidi: string=?, - ~verticalAlign: string=?, - ~visibility: string=?, - ~voiceFamily: string=?, - ~volume: string=?, - ~whiteSpace: string=?, - ~widows: string=?, - ~width: string=?, - ~wordSpacing: string=?, - ~zIndex: string=?, - ~opacity: /* Below properties based on https://www.w3.org/Style/CSS/all-properties */ - /* Color Level 3 - REC */ - string=?, - ~backgroundOrigin: /* Backgrounds and Borders Level 3 - CR */ - /* backgroundRepeat - already defined by CSS2Properties */ - /* backgroundAttachment - already defined by CSS2Properties */ - string=?, - ~backgroundSize: string=?, - ~backgroundClip: string=?, - ~borderRadius: string=?, - ~borderTopLeftRadius: string=?, - ~borderTopRightRadius: string=?, - ~borderBottomLeftRadius: string=?, - ~borderBottomRightRadius: string=?, - ~borderImage: string=?, - ~borderImageSource: string=?, - ~borderImageSlice: string=?, - ~borderImageWidth: string=?, - ~borderImageOutset: string=?, - ~borderImageRepeat: string=?, - ~boxShadow: string=?, - ~columns: /* Multi-column Layout - CR */ - string=?, - ~columnCount: string=?, - ~columnFill: string=?, - ~columnGap: string=?, - ~columnRule: string=?, - ~columnRuleColor: string=?, - ~columnRuleStyle: string=?, - ~columnRuleWidth: string=?, - ~columnSpan: string=?, - ~columnWidth: string=?, - ~breakAfter: string=?, - ~breakBefore: string=?, - ~breakInside: string=?, - ~rest: /* Speech - CR */ - string=?, - ~restAfter: string=?, - ~restBefore: string=?, - ~speakAs: string=?, - ~voiceBalance: string=?, - ~voiceDuration: string=?, - ~voicePitch: string=?, - ~voiceRange: string=?, - ~voiceRate: string=?, - ~voiceStress: string=?, - ~voiceVolume: string=?, - ~objectFit: /* Image Values and Replaced Content Level 3 - CR */ - string=?, - ~objectPosition: string=?, - ~imageResolution: string=?, - ~imageOrientation: string=?, - ~alignContent: /* Flexible Box Layout - CR */ - string=?, - ~alignItems: string=?, - ~alignSelf: string=?, - ~flex: string=?, - ~flexBasis: string=?, - ~flexDirection: string=?, - ~flexFlow: string=?, - ~flexGrow: string=?, - ~flexShrink: string=?, - ~flexWrap: string=?, - ~justifyContent: string=?, - ~order: string=?, - ~gap: string=?, - ~textDecorationColor: /* Text Decoration Level 3 - CR */ - /* textDecoration - already defined by CSS2Properties */ - string=?, - ~textDecorationLine: string=?, - ~textDecorationSkip: string=?, - ~textDecorationStyle: string=?, - ~textEmphasis: string=?, - ~textEmphasisColor: string=?, - ~textEmphasisPosition: string=?, - ~textEmphasisStyle: string=?, - ~textUnderlinePosition: /* textShadow - already defined by CSS2Properties */ - string=?, - ~fontFeatureSettings: /* Fonts Level 3 - CR */ - string=?, - ~fontKerning: string=?, - ~fontLanguageOverride: string=?, - ~fontSynthesis: /* fontSizeAdjust - already defined by CSS2Properties */ - /* fontStretch - already defined by CSS2Properties */ - string=?, - ~forntVariantAlternates: string=?, - ~fontVariantCaps: string=?, - ~fontVariantEastAsian: string=?, - ~fontVariantLigatures: string=?, - ~fontVariantNumeric: string=?, - ~fontVariantPosition: string=?, - ~all: /* Cascading and Inheritance Level 3 - CR */ - string=?, - ~glyphOrientationVertical: /* Writing Modes Level 3 - CR */ - string=?, - ~textCombineUpright: string=?, - ~textOrientation: string=?, - ~writingMode: string=?, - ~shapeImageThreshold: /* Shapes Level 1 - CR */ - string=?, - ~shapeMargin: string=?, - ~shapeOutside: string=?, - ~clipPath: /* Masking Level 1 - CR */ - string=?, - ~clipRule: string=?, - ~mask: string=?, - ~maskBorder: string=?, - ~maskBorderMode: string=?, - ~maskBorderOutset: string=?, - ~maskBorderRepeat: string=?, - ~maskBorderSlice: string=?, - ~maskBorderSource: string=?, - ~maskBorderWidth: string=?, - ~maskClip: string=?, - ~maskComposite: string=?, - ~maskImage: string=?, - ~maskMode: string=?, - ~maskOrigin: string=?, - ~maskPosition: string=?, - ~maskRepeat: string=?, - ~maskSize: string=?, - ~maskType: string=?, - ~backgroundBlendMode: /* Compositing and Blending Level 1 - CR */ - string=?, - ~isolation: string=?, - ~mixBlendMode: string=?, - ~boxDecorationBreak: /* Fragmentation Level 3 - CR */ - string=?, - ~boxSizing: /* breakAfter - already defined by Multi-column Layout */ - /* breakBefore - already defined by Multi-column Layout */ - /* breakInside - already defined by Multi-column Layout */ - /* Basic User Interface Level 3 - CR */ - string=?, - ~caretColor: string=?, - ~navDown: string=?, - ~navLeft: string=?, - ~navRight: string=?, - ~navUp: string=?, - ~outlineOffset: string=?, - ~resize: string=?, - ~textOverflow: string=?, - ~grid: /* Grid Layout Level 1 - CR */ - string=?, - ~gridArea: string=?, - ~gridAutoColumns: string=?, - ~gridAutoFlow: string=?, - ~gridAutoRows: string=?, - ~gridColumn: string=?, - ~gridColumnEnd: string=?, - ~gridColumnGap: string=?, - ~gridColumnStart: string=?, - ~gridGap: string=?, - ~gridRow: string=?, - ~gridRowEnd: string=?, - ~gridRowGap: string=?, - ~gridRowStart: string=?, - ~gridTemplate: string=?, - ~gridTemplateAreas: string=?, - ~gridTemplateColumns: string=?, - ~gridTemplateRows: string=?, - ~willChange: /* Will Change Level 1 - CR */ - string=?, - ~hangingPunctuation: /* Text Level 3 - LC */ - string=?, - ~hyphens: string=?, - ~lineBreak: /* letterSpacing - already defined by CSS2Properties */ - string=?, - ~overflowWrap: string=?, - ~tabSize: string=?, - ~textAlignLast: /* textAlign - already defined by CSS2Properties */ - string=?, - ~textJustify: string=?, - ~wordBreak: string=?, - ~wordWrap: string=?, - ~animation: /* Animations - WD */ - string=?, - ~animationDelay: string=?, - ~animationDirection: string=?, - ~animationDuration: string=?, - ~animationFillMode: string=?, - ~animationIterationCount: string=?, - ~animationName: string=?, - ~animationPlayState: string=?, - ~animationTimingFunction: string=?, - ~transition: /* Transitions - WD */ - string=?, - ~transitionDelay: string=?, - ~transitionDuration: string=?, - ~transitionProperty: string=?, - ~transitionTimingFunction: string=?, - ~backfaceVisibility: /* Transforms Level 1 - WD */ - string=?, - ~perspective: string=?, - ~perspectiveOrigin: string=?, - ~transform: string=?, - ~transformOrigin: string=?, - ~transformStyle: string=?, - ~justifyItems: /* Box Alignment Level 3 - WD */ - /* alignContent - already defined by Flexible Box Layout */ - /* alignItems - already defined by Flexible Box Layout */ - string=?, - ~justifySelf: string=?, - ~placeContent: string=?, - ~placeItems: string=?, - ~placeSelf: string=?, - ~appearance: /* Basic User Interface Level 4 - FPWD */ - string=?, - ~caret: string=?, - ~caretAnimation: string=?, - ~caretShape: string=?, - ~userSelect: string=?, - ~maxLines: /* Overflow Level 3 - WD */ - string=?, - ~marqueeDirection: /* Basix Box Model - WD */ - string=?, - ~marqueeLoop: string=?, - ~marqueeSpeed: string=?, - ~marqueeStyle: string=?, - ~overflowStyle: string=?, - ~rotation: string=?, - ~rotationPoint: string=?, - ~alignmentBaseline: /* SVG 1.1 - REC */ - string=?, - ~baselineShift: string=?, - ~clip: string=?, - ~clipPath: string=?, - ~clipRule: string=?, - ~colorInterpolation: string=?, - ~colorInterpolationFilters: string=?, - ~colorProfile: string=?, - ~colorRendering: string=?, - ~cursor: string=?, - ~dominantBaseline: string=?, - ~fill: string=?, - ~fillOpacity: string=?, - ~fillRule: string=?, - ~filter: string=?, - ~floodColor: string=?, - ~floodOpacity: string=?, - ~glyphOrientationHorizontal: string=?, - ~glyphOrientationVertical: string=?, - ~imageRendering: string=?, - ~kerning: string=?, - ~lightingColor: string=?, - ~markerEnd: string=?, - ~markerMid: string=?, - ~markerStart: string=?, - ~pointerEvents: string=?, - ~shapeRendering: string=?, - ~stopColor: string=?, - ~stopOpacity: string=?, - ~stroke: string=?, - ~strokeDasharray: string=?, - ~strokeDashoffset: string=?, - ~strokeLinecap: string=?, - ~strokeLinejoin: string=?, - ~strokeMiterlimit: string=?, - ~strokeOpacity: string=?, - ~strokeWidth: string=?, - ~textAnchor: string=?, - ~textRendering: string=?, - ~rubyAlign: /* Ruby Layout Level 1 - WD */ - string=?, - ~rubyMerge: string=?, - ~rubyPosition: string=?, - /* Lists and Counters Level 3 - WD */ - /* listStyle - already defined by CSS2Properties */ - /* listStyleImage - already defined by CSS2Properties */ - /* listStylePosition - already defined by CSS2Properties */ - /* listStyleType - already defined by CSS2Properties */ - /* counterIncrement - already defined by CSS2Properties */ - /* counterReset - already defined by CSS2Properties */ - /* Not added yet - * ------------- - * Generated Content for Paged Media - WD - * Generated Content Level 3 - WD - * Line Grid Level 1 - WD - * Regions - WD - * Inline Layout Level 3 - WD - * Round Display Level 1 - WD - * Image Values and Replaced Content Level 4 - WD - * Positioned Layout Level 3 - WD - * Filter Effects Level 1 - -WD - * Exclusions Level 1 - WD - * Text Level 4 - FPWD - * SVG Markers - FPWD - * Motion Path Level 1 - FPWD - * Color Level 4 - FPWD - * SVG Strokes - FPWD - * Table Level 3 - FPWD - */ - unit, -) => t = "" - /* CSS2Properties: https://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSS2Properties */ @val external combine: (@as(json`{}`) _, t, t) => t = "Object.assign" diff --git a/src/ReactTestUtils.bs.js b/src/ReactTestUtils.bs.js index 9913094..7ddadac 100644 --- a/src/ReactTestUtils.bs.js +++ b/src/ReactTestUtils.bs.js @@ -1,20 +1,19 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -var Curry = require("rescript/lib/js/curry.js"); var Caml_option = require("rescript/lib/js/caml_option.js"); var TestUtils = require("react-dom/test-utils"); function act(func) { var reactFunc = function () { - Curry._1(func, undefined); + func(); }; TestUtils.act(reactFunc); } function actAsync(func) { return TestUtils.act(function () { - return Curry._1(func, undefined); + return func(); }); } diff --git a/src/ReactTestUtils.res b/src/ReactTestUtils.res index 5b3bc09..a6c2b5e 100644 --- a/src/ReactTestUtils.res +++ b/src/ReactTestUtils.res @@ -3,10 +3,10 @@ type undefined = Js.undefined let undefined: undefined = Js.Undefined.empty @module("react-dom/test-utils") -external reactAct: ((. unit) => undefined) => unit = "act" +external reactAct: (unit => undefined) => unit = "act" let act: (unit => unit) => unit = func => { - let reactFunc = (. ()) => { + let reactFunc = () => { func() undefined } @@ -14,10 +14,10 @@ let act: (unit => unit) => unit = func => { } @module("react-dom/test-utils") -external reactActAsync: ((. unit) => Js.Promise.t<'a>) => Js.Promise.t = "act" +external reactActAsync: (unit => Js.Promise.t<'a>) => Js.Promise.t = "act" let actAsync = func => { - let reactFunc = (. ()) => func() + let reactFunc = () => func() reactActAsync(reactFunc) } diff --git a/src/RescriptReactErrorBoundary.bs.js b/src/RescriptReactErrorBoundary.bs.js index 3a0c291..fe5f73e 100644 --- a/src/RescriptReactErrorBoundary.bs.js +++ b/src/RescriptReactErrorBoundary.bs.js @@ -1,9 +1,14 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; - var React = require("react"); +var noOp = (function (_x) {}); + +var reactComponentClass = React.Component; + +noOp(reactComponentClass); + var ErrorBoundary = (function (Component) { function ErrorBoundary(props) { Component.call(this); @@ -19,10 +24,10 @@ var ErrorBoundary = (function (Component) { : this.props.children; }; return ErrorBoundary; -})(React.Component); +})(reactComponentClass); ; var make = ErrorBoundary; exports.make = make; -/* Not a pure module */ +/* reactComponentClass Not a pure module */ diff --git a/src/RescriptReactErrorBoundary.res b/src/RescriptReactErrorBoundary.res index 7f7019c..3caa0e8 100644 --- a/src/RescriptReactErrorBoundary.res +++ b/src/RescriptReactErrorBoundary.res @@ -10,8 +10,14 @@ type params<'error> = { info: info, } +type reactComponentClass +@module("react") external component: reactComponentClass = "Component" +let noOp: reactComponentClass => unit = %raw(`function (_x) {}`) +let reactComponentClass = component +// this is so that the compiler doesn't optimize away the previous line +noOp(reactComponentClass) + %%raw(` -var React = require("react"); var ErrorBoundary = (function (Component) { function ErrorBoundary(props) { @@ -28,7 +34,7 @@ var ErrorBoundary = (function (Component) { : this.props.children; }; return ErrorBoundary; -})(React.Component); +})(reactComponentClass); `) @react.component @val diff --git a/src/RescriptReactRouter.bs.js b/src/RescriptReactRouter.bs.js index de69385..eb542b6 100644 --- a/src/RescriptReactRouter.bs.js +++ b/src/RescriptReactRouter.bs.js @@ -1,10 +1,8 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -var Curry = require("rescript/lib/js/curry.js"); var React = require("react"); -var Js_array = require("rescript/lib/js/js_array.js"); -var Js_string = require("rescript/lib/js/js_string.js"); +var Caml_option = require("rescript/lib/js/caml_option.js"); function safeMakeEvent(eventName) { if (typeof Event === "function") { @@ -21,14 +19,14 @@ function pathParse(str) { case "/" : return /* [] */0; default: - var raw = Js_string.sliceToEnd(1, str); + var raw = str.slice(1); var match = raw[raw.length - 1 | 0]; - var raw$1 = match === "/" ? Js_string.slice(0, -1, raw) : raw; - var match$1 = Js_string.splitAtMost("?", 2, raw$1); + var raw$1 = match === "/" ? raw.slice(0, -1) : raw; + var match$1 = raw$1.split("?", 2); var raw$2 = match$1.length !== 2 ? raw$1 : match$1[0]; - var a = Js_array.filter((function (item) { - return item.length !== 0; - }), Js_string.split("/", raw$2)); + var a = raw$2.split("/").filter(function (item) { + return item.length !== 0; + }); var _i = a.length - 1 | 0; var _res = /* [] */0; while(true) { @@ -48,28 +46,28 @@ function pathParse(str) { } function path(serverUrlString, param) { - var match = typeof window === "undefined" ? undefined : window; + var match = globalThis.window; if (serverUrlString !== undefined) { return pathParse(serverUrlString); } else if (match !== undefined) { - return pathParse(match.location.pathname); + return pathParse(Caml_option.valFromOption(match).location.pathname); } else { return /* [] */0; } } -function hash(param) { - var $$window = typeof window === "undefined" ? undefined : window; +function hash() { + var $$window = globalThis.window; if ($$window === undefined) { return ""; } - var raw = $$window.location.hash; + var raw = Caml_option.valFromOption($$window).location.hash; switch (raw) { case "" : case "#" : return ""; default: - return Js_string.sliceToEnd(1, raw); + return raw.slice(1); } } @@ -79,7 +77,7 @@ function searchParse(str) { case "?" : return ""; default: - var match = Js_string.splitAtMost("?", 2, str); + var match = str.split("?", 2); if (match.length !== 2) { return ""; } else { @@ -89,33 +87,33 @@ function searchParse(str) { } function search(serverUrlString, param) { - var match = typeof window === "undefined" ? undefined : window; + var match = globalThis.window; if (serverUrlString !== undefined) { return searchParse(serverUrlString); } else if (match !== undefined) { - return searchParse(match.location.search); + return searchParse(Caml_option.valFromOption(match).location.search); } else { return ""; } } function push(path) { - var match = typeof history === "undefined" ? undefined : history; - var match$1 = typeof window === "undefined" ? undefined : window; + var match = globalThis.history; + var match$1 = globalThis.window; if (match !== undefined && match$1 !== undefined) { - match.pushState(null, "", path); - match$1.dispatchEvent(safeMakeEvent("popstate")); + Caml_option.valFromOption(match).pushState(null, "", path); + Caml_option.valFromOption(match$1).dispatchEvent(safeMakeEvent("popstate")); return ; } } function replace(path) { - var match = typeof history === "undefined" ? undefined : history; - var match$1 = typeof window === "undefined" ? undefined : window; + var match = globalThis.history; + var match$1 = globalThis.window; if (match !== undefined && match$1 !== undefined) { - match.replaceState(null, "", path); - match$1.dispatchEvent(safeMakeEvent("popstate")); + Caml_option.valFromOption(match).replaceState(null, "", path); + Caml_option.valFromOption(match$1).dispatchEvent(safeMakeEvent("popstate")); return ; } @@ -153,36 +151,36 @@ function urlNotEqual(a, b) { function url(serverUrlString, param) { return { path: path(serverUrlString, undefined), - hash: hash(undefined), + hash: hash(), search: search(serverUrlString, undefined) }; } function watchUrl(callback) { - var $$window = typeof window === "undefined" ? undefined : window; + var $$window = globalThis.window; if ($$window === undefined) { - return function (param) { + return function () { }; } - var watcherID = function (param) { - Curry._1(callback, url(undefined, undefined)); + var watcherID = function () { + callback(url(undefined, undefined)); }; - $$window.addEventListener("popstate", watcherID); + Caml_option.valFromOption($$window).addEventListener("popstate", watcherID); return watcherID; } function unwatchUrl(watcherID) { - var $$window = typeof window === "undefined" ? undefined : window; + var $$window = globalThis.window; if ($$window !== undefined) { - $$window.removeEventListener("popstate", watcherID); + Caml_option.valFromOption($$window).removeEventListener("popstate", watcherID); return ; } } function useUrl(serverUrl, param) { - var match = React.useState(function (param) { + var match = React.useState(function () { if (serverUrl !== undefined) { return serverUrl; } else { @@ -191,19 +189,19 @@ function useUrl(serverUrl, param) { }); var setUrl = match[1]; var url$1 = match[0]; - React.useEffect((function (param) { + React.useEffect((function () { var watcherId = watchUrl(function (url) { - Curry._1(setUrl, (function (param) { - return url; - })); + setUrl(function (param) { + return url; + }); }); var newUrl = url(undefined, undefined); if (urlNotEqual(newUrl, url$1)) { - Curry._1(setUrl, (function (param) { - return newUrl; - })); + setUrl(function (param) { + return newUrl; + }); } - return (function (param) { + return (function () { unwatchUrl(watcherId); }); }), []); diff --git a/src/RescriptReactRouter.res b/src/RescriptReactRouter.res index 24e3222..80f3d75 100644 --- a/src/RescriptReactRouter.res +++ b/src/RescriptReactRouter.res @@ -1,3 +1,9 @@ +@scope("globalThis") +external window: option = "window" + +@scope("globalThis") +external history: option = "history" + @get external location: Dom.window => Dom.location = "location" /* actually the cb is Dom.event => unit, but let's restrict the access for now */ @@ -49,9 +55,9 @@ let arrayToList = a => { if i < 0 { res } else { - tolist(i - 1, list{Array.unsafe_get(a, i), ...res}) + tolist(i - 1, list{a->Js.Array2.unsafe_get(i), ...res}) } - tolist(Array.length(a) - 1, list{}) + tolist(a->Js.Array2.length - 1, list{}) } /* if we ever roll our own parser in the future, make sure you test all url combinations e.g. foo.com/?#bar @@ -66,37 +72,37 @@ let pathParse = str => list{} | raw => /* remove the preceeding /, which every pathname seems to have */ - let raw = Js.String.sliceToEnd(~from=1, raw) + let raw = raw->Js.String2.sliceToEnd(~from=1) /* remove the trailing /, which some pathnames might have. Ugh */ - let raw = switch Js.String.get(raw, Js.String.length(raw) - 1) { - | "/" => Js.String.slice(~from=0, ~to_=-1, raw) + let raw = switch raw->Js.String2.get(raw->Js.String2.length - 1) { + | "/" => raw->Js.String2.slice(~from=0, ~to_=-1) | _ => raw } /* remove search portion if present in string */ - let raw = switch raw |> Js.String.splitAtMost("?", ~limit=2) { + let raw = switch raw->Js.String2.splitAtMost("?", ~limit=2) { | [path, _] => path | _ => raw } - raw |> Js.String.split("/") |> Js.Array.filter(item => String.length(item) != 0) |> arrayToList + raw->Js.String2.split("/")->Js.Array2.filter(item => item->Js.String2.length != 0)->arrayToList } let path = (~serverUrlString=?, ()) => - switch (serverUrlString, %external(window)) { + switch (serverUrlString, window) { | (None, None) => list{} | (Some(serverUrlString), _) => pathParse(serverUrlString) - | (_, Some(window: Dom.window)) => pathParse(window |> location |> pathname) + | (_, Some(window: Dom.window)) => pathParse(window->location->pathname) } let hash = () => - switch %external(window) { + switch window { | None => "" | Some(window: Dom.window) => - switch window |> location |> hash { + switch window->location->hash { | "" | "#" => "" | raw => /* remove the preceeding #, which every hash seems to have. Why is this even included in location.hash?? */ - raw |> Js.String.sliceToEnd(~from=1) + raw->Js.String2.sliceToEnd(~from=1) } } let searchParse = str => @@ -104,21 +110,21 @@ let searchParse = str => | "" | "?" => "" | raw => - switch raw |> Js.String.splitAtMost("?", ~limit=2) { + switch raw->Js.String2.splitAtMost("?", ~limit=2) { | [_, search] => search | _ => "" } } let search = (~serverUrlString=?, ()) => - switch (serverUrlString, %external(window)) { + switch (serverUrlString, window) { | (None, None) => "" | (Some(serverUrlString), _) => searchParse(serverUrlString) - | (_, Some(window: Dom.window)) => searchParse(window |> location |> search) + | (_, Some(window: Dom.window)) => searchParse(window->location->search) } let push = path => - switch (%external(history), %external(window)) { + switch (history, window) { | (None, _) | (_, None) => () | (Some(history: Dom.history), Some(window: Dom.window)) => @@ -127,7 +133,7 @@ let push = path => } let replace = path => - switch (%external(history), %external(window)) { + switch (history, window) { | (None, _) | (_, None) => () | (Some(history: Dom.history), Some(window: Dom.window)) => @@ -169,7 +175,7 @@ let url = (~serverUrlString=?, ()) => { let dangerouslyGetInitialUrl = url let watchUrl = callback => - switch %external(window) { + switch window { | None => () => () | Some(window: Dom.window) => let watcherID = () => callback(url()) @@ -178,7 +184,7 @@ let watchUrl = callback => } let unwatchUrl = watcherID => - switch %external(window) { + switch window { | None => () | Some(window: Dom.window) => removeEventListener(window, "popstate", watcherID) } diff --git a/src/legacy/ReactDOMRe.res b/src/legacy/ReactDOMRe.res deleted file mode 100644 index c528baa..0000000 --- a/src/legacy/ReactDOMRe.res +++ /dev/null @@ -1,19 +0,0 @@ -/** -This module is kept for ReScript react-jsx v3 compatibility -We removed all functionality that is not needed for JSX usage -**/ -include ReactDOM_V3.Props - -@variadic @module("react") -external createDOMElementVariadic: ( - string, - ~props: ReactDOM_V3.domProps=?, - array, -) => React.element = "createElement" - -@variadic @module("react") -external createElement: ( - string, - ~props: ReactDOM_V3.domProps=?, - array, -) => React.element = "createElement" diff --git a/src/legacy/ReasonReact.res b/src/legacy/ReasonReact.res deleted file mode 100644 index 95ec6eb..0000000 --- a/src/legacy/ReasonReact.res +++ /dev/null @@ -1,6 +0,0 @@ -/** -This module is kept for ReScript react-jsx v3 compatibility -We removed all functionality that is not needed for JSX usage -**/ - -@module("react") external fragment: 'a = "Fragment" diff --git a/src/v3/ReactDOMStyle_V3.bs.js b/src/v3/ReactDOMStyle_V3.bs.js deleted file mode 100644 index 18702c8..0000000 --- a/src/v3/ReactDOMStyle_V3.bs.js +++ /dev/null @@ -1,12 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function unsafeAddProp(style, key, value) { - var dict = {}; - dict[key] = value; - return Object.assign({}, style, dict); -} - -exports.unsafeAddProp = unsafeAddProp; -/* No side effect */ diff --git a/src/v3/ReactDOMStyle_V3.res b/src/v3/ReactDOMStyle_V3.res deleted file mode 100644 index 19c04a4..0000000 --- a/src/v3/ReactDOMStyle_V3.res +++ /dev/null @@ -1,435 +0,0 @@ -type t = ReactDOMStyle.t - -@obj -external make: ( - ~azimuth: string=?, - ~background: string=?, - ~backgroundAttachment: string=?, - ~backgroundColor: string=?, - ~backgroundImage: string=?, - ~backgroundPosition: string=?, - ~backgroundRepeat: string=?, - ~border: string=?, - ~borderCollapse: string=?, - ~borderColor: string=?, - ~borderSpacing: string=?, - ~borderStyle: string=?, - ~borderTop: string=?, - ~borderRight: string=?, - ~borderBottom: string=?, - ~borderLeft: string=?, - ~borderTopColor: string=?, - ~borderRightColor: string=?, - ~borderBottomColor: string=?, - ~borderLeftColor: string=?, - ~borderTopStyle: string=?, - ~borderRightStyle: string=?, - ~borderBottomStyle: string=?, - ~borderLeftStyle: string=?, - ~borderTopWidth: string=?, - ~borderRightWidth: string=?, - ~borderBottomWidth: string=?, - ~borderLeftWidth: string=?, - ~borderWidth: string=?, - ~bottom: string=?, - ~captionSide: string=?, - ~clear: string=?, - ~clip: string=?, - ~color: string=?, - ~content: string=?, - ~counterIncrement: string=?, - ~counterReset: string=?, - ~cue: string=?, - ~cueAfter: string=?, - ~cueBefore: string=?, - ~cursor: string=?, - ~direction: string=?, - ~display: string=?, - ~elevation: string=?, - ~emptyCells: string=?, - ~float: string=?, - ~font: string=?, - ~fontFamily: string=?, - ~fontSize: string=?, - ~fontSizeAdjust: string=?, - ~fontStretch: string=?, - ~fontStyle: string=?, - ~fontVariant: string=?, - ~fontWeight: string=?, - ~height: string=?, - ~left: string=?, - ~letterSpacing: string=?, - ~lineHeight: string=?, - ~listStyle: string=?, - ~listStyleImage: string=?, - ~listStylePosition: string=?, - ~listStyleType: string=?, - ~margin: string=?, - ~marginTop: string=?, - ~marginRight: string=?, - ~marginBottom: string=?, - ~marginLeft: string=?, - ~markerOffset: string=?, - ~marks: string=?, - ~maxHeight: string=?, - ~maxWidth: string=?, - ~minHeight: string=?, - ~minWidth: string=?, - ~orphans: string=?, - ~outline: string=?, - ~outlineColor: string=?, - ~outlineStyle: string=?, - ~outlineWidth: string=?, - ~overflow: string=?, - ~overflowX: string=?, - ~overflowY: string=?, - ~padding: string=?, - ~paddingTop: string=?, - ~paddingRight: string=?, - ~paddingBottom: string=?, - ~paddingLeft: string=?, - ~page: string=?, - ~pageBreakAfter: string=?, - ~pageBreakBefore: string=?, - ~pageBreakInside: string=?, - ~pause: string=?, - ~pauseAfter: string=?, - ~pauseBefore: string=?, - ~pitch: string=?, - ~pitchRange: string=?, - ~playDuring: string=?, - ~position: string=?, - ~quotes: string=?, - ~richness: string=?, - ~right: string=?, - ~size: string=?, - ~speak: string=?, - ~speakHeader: string=?, - ~speakNumeral: string=?, - ~speakPunctuation: string=?, - ~speechRate: string=?, - ~stress: string=?, - ~tableLayout: string=?, - ~textAlign: string=?, - ~textDecoration: string=?, - ~textIndent: string=?, - ~textShadow: string=?, - ~textTransform: string=?, - ~top: string=?, - ~unicodeBidi: string=?, - ~verticalAlign: string=?, - ~visibility: string=?, - ~voiceFamily: string=?, - ~volume: string=?, - ~whiteSpace: string=?, - ~widows: string=?, - ~width: string=?, - ~wordSpacing: string=?, - ~zIndex: string=?, - ~opacity: /* Below properties based on https://www.w3.org/Style/CSS/all-properties */ - /* Color Level 3 - REC */ - string=?, - ~backgroundOrigin: /* Backgrounds and Borders Level 3 - CR */ - /* backgroundRepeat - already defined by CSS2Properties */ - /* backgroundAttachment - already defined by CSS2Properties */ - string=?, - ~backgroundSize: string=?, - ~backgroundClip: string=?, - ~borderRadius: string=?, - ~borderTopLeftRadius: string=?, - ~borderTopRightRadius: string=?, - ~borderBottomLeftRadius: string=?, - ~borderBottomRightRadius: string=?, - ~borderImage: string=?, - ~borderImageSource: string=?, - ~borderImageSlice: string=?, - ~borderImageWidth: string=?, - ~borderImageOutset: string=?, - ~borderImageRepeat: string=?, - ~boxShadow: string=?, - ~columns: /* Multi-column Layout - CR */ - string=?, - ~columnCount: string=?, - ~columnFill: string=?, - ~columnGap: string=?, - ~columnRule: string=?, - ~columnRuleColor: string=?, - ~columnRuleStyle: string=?, - ~columnRuleWidth: string=?, - ~columnSpan: string=?, - ~columnWidth: string=?, - ~breakAfter: string=?, - ~breakBefore: string=?, - ~breakInside: string=?, - ~rest: /* Speech - CR */ - string=?, - ~restAfter: string=?, - ~restBefore: string=?, - ~speakAs: string=?, - ~voiceBalance: string=?, - ~voiceDuration: string=?, - ~voicePitch: string=?, - ~voiceRange: string=?, - ~voiceRate: string=?, - ~voiceStress: string=?, - ~voiceVolume: string=?, - ~objectFit: /* Image Values and Replaced Content Level 3 - CR */ - string=?, - ~objectPosition: string=?, - ~imageResolution: string=?, - ~imageOrientation: string=?, - ~alignContent: /* Flexible Box Layout - CR */ - string=?, - ~alignItems: string=?, - ~alignSelf: string=?, - ~flex: string=?, - ~flexBasis: string=?, - ~flexDirection: string=?, - ~flexFlow: string=?, - ~flexGrow: string=?, - ~flexShrink: string=?, - ~flexWrap: string=?, - ~justifyContent: string=?, - ~order: string=?, - ~textDecorationColor: /* Text Decoration Level 3 - CR */ - /* textDecoration - already defined by CSS2Properties */ - string=?, - ~textDecorationLine: string=?, - ~textDecorationSkip: string=?, - ~textDecorationStyle: string=?, - ~textEmphasis: string=?, - ~textEmphasisColor: string=?, - ~textEmphasisPosition: string=?, - ~textEmphasisStyle: string=?, - ~textUnderlinePosition: /* textShadow - already defined by CSS2Properties */ - string=?, - ~fontFeatureSettings: /* Fonts Level 3 - CR */ - string=?, - ~fontKerning: string=?, - ~fontLanguageOverride: string=?, - ~fontSynthesis: /* fontSizeAdjust - already defined by CSS2Properties */ - /* fontStretch - already defined by CSS2Properties */ - string=?, - ~forntVariantAlternates: string=?, - ~fontVariantCaps: string=?, - ~fontVariantEastAsian: string=?, - ~fontVariantLigatures: string=?, - ~fontVariantNumeric: string=?, - ~fontVariantPosition: string=?, - ~all: /* Cascading and Inheritance Level 3 - CR */ - string=?, - ~glyphOrientationVertical: /* Writing Modes Level 3 - CR */ - string=?, - ~textCombineUpright: string=?, - ~textOrientation: string=?, - ~writingMode: string=?, - ~shapeImageThreshold: /* Shapes Level 1 - CR */ - string=?, - ~shapeMargin: string=?, - ~shapeOutside: string=?, - ~clipPath: /* Masking Level 1 - CR */ - string=?, - ~clipRule: string=?, - ~mask: string=?, - ~maskBorder: string=?, - ~maskBorderMode: string=?, - ~maskBorderOutset: string=?, - ~maskBorderRepeat: string=?, - ~maskBorderSlice: string=?, - ~maskBorderSource: string=?, - ~maskBorderWidth: string=?, - ~maskClip: string=?, - ~maskComposite: string=?, - ~maskImage: string=?, - ~maskMode: string=?, - ~maskOrigin: string=?, - ~maskPosition: string=?, - ~maskRepeat: string=?, - ~maskSize: string=?, - ~maskType: string=?, - ~backgroundBlendMode: /* Compositing and Blending Level 1 - CR */ - string=?, - ~isolation: string=?, - ~mixBlendMode: string=?, - ~boxDecorationBreak: /* Fragmentation Level 3 - CR */ - string=?, - ~boxSizing: /* breakAfter - already defined by Multi-column Layout */ - /* breakBefore - already defined by Multi-column Layout */ - /* breakInside - already defined by Multi-column Layout */ - /* Basic User Interface Level 3 - CR */ - string=?, - ~caretColor: string=?, - ~navDown: string=?, - ~navLeft: string=?, - ~navRight: string=?, - ~navUp: string=?, - ~outlineOffset: string=?, - ~resize: string=?, - ~textOverflow: string=?, - ~grid: /* Grid Layout Level 1 - CR */ - string=?, - ~gridArea: string=?, - ~gridAutoColumns: string=?, - ~gridAutoFlow: string=?, - ~gridAutoRows: string=?, - ~gridColumn: string=?, - ~gridColumnEnd: string=?, - ~gridColumnGap: string=?, - ~gridColumnStart: string=?, - ~gridGap: string=?, - ~gridRow: string=?, - ~gridRowEnd: string=?, - ~gridRowGap: string=?, - ~gridRowStart: string=?, - ~gridTemplate: string=?, - ~gridTemplateAreas: string=?, - ~gridTemplateColumns: string=?, - ~gridTemplateRows: string=?, - ~willChange: /* Will Change Level 1 - CR */ - string=?, - ~hangingPunctuation: /* Text Level 3 - LC */ - string=?, - ~hyphens: string=?, - ~lineBreak: /* letterSpacing - already defined by CSS2Properties */ - string=?, - ~overflowWrap: string=?, - ~tabSize: string=?, - ~textAlignLast: /* textAlign - already defined by CSS2Properties */ - string=?, - ~textJustify: string=?, - ~wordBreak: string=?, - ~wordWrap: string=?, - ~animation: /* Animations - WD */ - string=?, - ~animationDelay: string=?, - ~animationDirection: string=?, - ~animationDuration: string=?, - ~animationFillMode: string=?, - ~animationIterationCount: string=?, - ~animationName: string=?, - ~animationPlayState: string=?, - ~animationTimingFunction: string=?, - ~transition: /* Transitions - WD */ - string=?, - ~transitionDelay: string=?, - ~transitionDuration: string=?, - ~transitionProperty: string=?, - ~transitionTimingFunction: string=?, - ~backfaceVisibility: /* Transforms Level 1 - WD */ - string=?, - ~perspective: string=?, - ~perspectiveOrigin: string=?, - ~transform: string=?, - ~transformOrigin: string=?, - ~transformStyle: string=?, - ~justifyItems: /* Box Alignment Level 3 - WD */ - /* alignContent - already defined by Flexible Box Layout */ - /* alignItems - already defined by Flexible Box Layout */ - string=?, - ~justifySelf: string=?, - ~placeContent: string=?, - ~placeItems: string=?, - ~placeSelf: string=?, - ~appearance: /* Basic User Interface Level 4 - FPWD */ - string=?, - ~caret: string=?, - ~caretAnimation: string=?, - ~caretShape: string=?, - ~userSelect: string=?, - ~maxLines: /* Overflow Level 3 - WD */ - string=?, - ~marqueeDirection: /* Basix Box Model - WD */ - string=?, - ~marqueeLoop: string=?, - ~marqueeSpeed: string=?, - ~marqueeStyle: string=?, - ~overflowStyle: string=?, - ~rotation: string=?, - ~rotationPoint: string=?, - ~alignmentBaseline: /* SVG 1.1 - REC */ - string=?, - ~baselineShift: string=?, - ~clip: string=?, - ~clipPath: string=?, - ~clipRule: string=?, - ~colorInterpolation: string=?, - ~colorInterpolationFilters: string=?, - ~colorProfile: string=?, - ~colorRendering: string=?, - ~cursor: string=?, - ~dominantBaseline: string=?, - ~fill: string=?, - ~fillOpacity: string=?, - ~fillRule: string=?, - ~filter: string=?, - ~floodColor: string=?, - ~floodOpacity: string=?, - ~glyphOrientationHorizontal: string=?, - ~glyphOrientationVertical: string=?, - ~imageRendering: string=?, - ~kerning: string=?, - ~lightingColor: string=?, - ~markerEnd: string=?, - ~markerMid: string=?, - ~markerStart: string=?, - ~pointerEvents: string=?, - ~shapeRendering: string=?, - ~stopColor: string=?, - ~stopOpacity: string=?, - ~stroke: string=?, - ~strokeDasharray: string=?, - ~strokeDashoffset: string=?, - ~strokeLinecap: string=?, - ~strokeLinejoin: string=?, - ~strokeMiterlimit: string=?, - ~strokeOpacity: string=?, - ~strokeWidth: string=?, - ~textAnchor: string=?, - ~textRendering: string=?, - ~rubyAlign: /* Ruby Layout Level 1 - WD */ - string=?, - ~rubyMerge: string=?, - ~rubyPosition: string=?, - /* Lists and Counters Level 3 - WD */ - /* listStyle - already defined by CSS2Properties */ - /* listStyleImage - already defined by CSS2Properties */ - /* listStylePosition - already defined by CSS2Properties */ - /* listStyleType - already defined by CSS2Properties */ - /* counterIncrement - already defined by CSS2Properties */ - /* counterReset - already defined by CSS2Properties */ - /* Not added yet - * ------------- - * Generated Content for Paged Media - WD - * Generated Content Level 3 - WD - * Line Grid Level 1 - WD - * Regions - WD - * Inline Layout Level 3 - WD - * Round Display Level 1 - WD - * Image Values and Replaced Content Level 4 - WD - * Positioned Layout Level 3 - WD - * Filter Effects Level 1 - -WD - * Exclusions Level 1 - WD - * Text Level 4 - FPWD - * SVG Markers - FPWD - * Motion Path Level 1 - FPWD - * Color Level 4 - FPWD - * SVG Strokes - FPWD - * Table Level 3 - FPWD - */ - unit, -) => t = "" - -/* CSS2Properties: https://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSS2Properties */ -@val -external combine: (@as(json`{}`) _, t, t) => t = "Object.assign" - -external _dictToStyle: Js.Dict.t => t = "%identity" - -let unsafeAddProp = (style, key, value) => { - let dict = Js.Dict.empty() - Js.Dict.set(dict, key, value) - combine(style, _dictToStyle(dict)) -} - -@val -external unsafeAddStyle: (@as(json`{}`) _, t, {..}) => t = "Object.assign" diff --git a/src/v3/ReactDOM_V3.bs.js b/src/v3/ReactDOM_V3.bs.js deleted file mode 100644 index e2bdd8a..0000000 --- a/src/v3/ReactDOM_V3.bs.js +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -var Experimental = {}; - -var Ref = {}; - -var Props = {}; - -var Style; - -exports.Experimental = Experimental; -exports.Ref = Ref; -exports.Props = Props; -exports.Style = Style; -/* No side effect */ diff --git a/src/v3/ReactDOM_V3.res b/src/v3/ReactDOM_V3.res deleted file mode 100644 index 80dd3aa..0000000 --- a/src/v3/ReactDOM_V3.res +++ /dev/null @@ -1,2113 +0,0 @@ -/* First time reading a ReScript file? */ -/* `external` is the foreign function call in OCaml. */ -/* here we're saying `I guarantee that on the JS side, we have a `render` function in the module "react-dom" - that takes in a reactElement, a dom element, and returns unit (nothing) */ -/* It's like `let`, except you're pointing the implementation to the JS side. The compiler will inline these - calls and add the appropriate `require("react-dom")` in the file calling this `render` */ - -// Helper so that ReactDOM itself doesn't bring any runtime -@val @return(nullable) -external querySelector: string => option = "document.querySelector" - -@module("react-dom") -external render: (React.element, Dom.element) => unit = "render" - -module Experimental = { - type root = ReactDOM.Client.Root.t - - @module("react-dom") - external createRoot: Dom.element => root = "createRoot" - - @module("react-dom") - external createBlockingRoot: Dom.element => root = "createBlockingRoot" - - @send external render: (root, React.element) => unit = "render" -} - -@module("react-dom") -external hydrate: (React.element, Dom.element) => unit = "hydrate" - -@module("react-dom") -external createPortal: (React.element, Dom.element) => React.element = "createPortal" - -@module("react-dom") -external unmountComponentAtNode: Dom.element => unit = "unmountComponentAtNode" - -external domElementToObj: Dom.element => {..} = "%identity" - -type style = ReactDOMStyle.t - -type domRef = ReactDOM.domRef - -module Ref = { - type t = domRef - type currentDomRef = React.ref> - type callbackDomRef = Js.nullable => unit - - external domRef: currentDomRef => domRef = "%identity" - external callbackDomRef: callbackDomRef => domRef = "%identity" -} - -module Props = { - /* This list isn't exhaustive. We'll add more as we go. */ - /* - * Watch out! There are two props types and the only difference is the type of ref. - * Please keep in sync. - */ - @deriving(abstract) - type domProps = { - @optional - key: string, - @optional - ref: domRef, - /* accessibility */ - /* https://www.w3.org/TR/wai-aria-1.1/ */ - /* https://accessibilityresources.org/ is a great resource for these */ - /* [@optional] [@as "aria-current"] ariaCurrent: page|step|location|date|time|true|false, */ - @optional @as("aria-details") - ariaDetails: string, - @optional @as("aria-disabled") - ariaDisabled: bool, - @optional @as("aria-hidden") - ariaHidden: bool, - /* [@optional] [@as "aria-invalid"] ariaInvalid: grammar|false|spelling|true, */ - @optional @as("aria-keyshortcuts") - ariaKeyshortcuts: string, - @optional @as("aria-label") - ariaLabel: string, - @optional @as("aria-roledescription") - ariaRoledescription: string, - /* Widget Attributes */ - /* [@optional] [@as "aria-autocomplete"] ariaAutocomplete: inline|list|both|none, */ - /* [@optional] [@as "aria-checked"] ariaChecked: true|false|mixed, /* https://www.w3.org/TR/wai-aria-1.1/#valuetype_tristate */ */ - @optional @as("aria-expanded") - ariaExpanded: bool, - /* [@optional] [@as "aria-haspopup"] ariaHaspopup: false|true|menu|listbox|tree|grid|dialog, */ - @optional @as("aria-level") - ariaLevel: int, - @optional @as("aria-modal") - ariaModal: bool, - @optional @as("aria-multiline") - ariaMultiline: bool, - @optional @as("aria-multiselectable") - ariaMultiselectable: bool, - /* [@optional] [@as "aria-orientation"] ariaOrientation: horizontal|vertical|undefined, */ - @optional @as("aria-placeholder") - ariaPlaceholder: string, - /* [@optional] [@as "aria-pressed"] ariaPressed: true|false|mixed, /* https://www.w3.org/TR/wai-aria-1.1/#valuetype_tristate */ */ - @optional @as("aria-readonly") - ariaReadonly: bool, - @optional @as("aria-required") - ariaRequired: bool, - @optional @as("aria-selected") - ariaSelected: bool, - @optional @as("aria-sort") - ariaSort: string, - @optional @as("aria-valuemax") - ariaValuemax: float, - @optional @as("aria-valuemin") - ariaValuemin: float, - @optional @as("aria-valuenow") - ariaValuenow: float, - @optional @as("aria-valuetext") - ariaValuetext: string, - /* Live Region Attributes */ - @optional @as("aria-atomic") - ariaAtomic: bool, - @optional @as("aria-busy") - ariaBusy: bool, - /* [@optional] [@as "aria-live"] ariaLive: off|polite|assertive|rude, */ - @optional @as("aria-relevant") - ariaRelevant: string, - /* Drag-and-Drop Attributes */ - /* [@optional] [@as "aria-dropeffect"] ariaDropeffect: copy|move|link|execute|popup|none, */ - @optional @as("aria-grabbed") - ariaGrabbed: bool, - /* Relationship Attributes */ - @optional @as("aria-activedescendant") - ariaActivedescendant: string, - @optional @as("aria-colcount") - ariaColcount: int, - @optional @as("aria-colindex") - ariaColindex: int, - @optional @as("aria-colspan") - ariaColspan: int, - @optional @as("aria-controls") - ariaControls: string, - @optional @as("aria-describedby") - ariaDescribedby: string, - @optional @as("aria-errormessage") - ariaErrormessage: string, - @optional @as("aria-flowto") - ariaFlowto: string, - @optional @as("aria-labelledby") - ariaLabelledby: string, - @optional @as("aria-owns") - ariaOwns: string, - @optional @as("aria-posinset") - ariaPosinset: int, - @optional @as("aria-rowcount") - ariaRowcount: int, - @optional @as("aria-rowindex") - ariaRowindex: int, - @optional @as("aria-rowspan") - ariaRowspan: int, - @optional @as("aria-setsize") - ariaSetsize: int, - /* react textarea/input */ - @optional - defaultChecked: bool, - @optional - defaultValue: string, - /* global html attributes */ - @optional - accessKey: string, - @optional - className: string /* substitute for "class" */, - @optional - contentEditable: bool, - @optional - contextMenu: string, - @optional - dir: string /* "ltr", "rtl" or "auto" */, - @optional - draggable: bool, - @optional - hidden: bool, - @optional - id: string, - @optional - lang: string, - @optional - role: string /* ARIA role */, - @optional - style: style, - @optional - spellCheck: bool, - @optional - tabIndex: int, - @optional - title: string, - /* html5 microdata */ - @optional - itemID: string, - @optional - itemProp: string, - @optional - itemRef: string, - @optional - itemScope: bool, - @optional - itemType: string /* uri */, - /* tag-specific html attributes */ - @optional - accept: string, - @optional - acceptCharset: string, - @optional - action: string /* uri */, - @optional - allowFullScreen: bool, - @optional - alt: string, - @optional - async: bool, - @optional - autoComplete: string /* has a fixed, but large-ish, set of possible values */, - @optional - autoCapitalize: string /* Mobile Safari specific */, - @optional - autoFocus: bool, - @optional - autoPlay: bool, - @optional - challenge: string, - @optional - charSet: string, - @optional - checked: bool, - @optional - cite: string /* uri */, - @optional - crossOrigin: string /* anonymous, use-credentials */, - @optional - cols: int, - @optional - colSpan: int, - @optional - content: string, - @optional - controls: bool, - @optional - coords: string /* set of values specifying the coordinates of a region */, - @optional - data: string /* uri */, - @optional - dateTime: string /* "valid date string with optional time" */, - @optional - default: bool, - @optional - defer: bool, - @optional - disabled: bool, - @optional - download: string /* should really be either a boolean, signifying presence, or a string */, - @optional - encType: string /* "application/x-www-form-urlencoded", "multipart/form-data" or "text/plain" */, - @optional - form: string, - @optional - formAction: string /* uri */, - @optional - formTarget: string /* "_blank", "_self", etc. */, - @optional - formMethod: string /* "post", "get", "put" */, - @optional - headers: string, - @optional - height: string /* in html5 this can only be a number, but in html4 it can ba a percentage as well */, - @optional - high: int, - @optional - href: string /* uri */, - @optional - hrefLang: string, - @optional - htmlFor: string /* substitute for "for" */, - @optional - httpEquiv: string /* has a fixed set of possible values */, - @optional - icon: string /* uri? */, - @optional - inputMode: string /* "verbatim", "latin", "numeric", etc. */, - @optional - integrity: string, - @optional - keyType: string, - @optional - kind: string /* has a fixed set of possible values */, - @optional - label: string, - @optional - list: string, - @optional - loading: [#"lazy" | #eager], - @optional - loop: bool, - @optional - low: int, - @optional - manifest: string /* uri */, - @optional - max: string /* should be int or Js.Date.t */, - @optional - maxLength: int, - @optional - media: string /* a valid media query */, - @optional - mediaGroup: string, - @optional - method: string /* "post" or "get" */, - @optional - min: string, - @optional - minLength: int, - @optional - multiple: bool, - @optional - muted: bool, - @optional - name: string, - @optional - nonce: string, - @optional - noValidate: bool, - @optional @as("open") - open_: bool /* use this one. Previous one is deprecated */, - @optional - optimum: int, - @optional - pattern: string /* valid Js RegExp */, - @optional - placeholder: string, - @optional - playsInline: bool, - @optional - poster: string /* uri */, - @optional - preload: string /* "none", "metadata" or "auto" (and "" as a synonym for "auto") */, - @optional - radioGroup: string, - @optional - readOnly: bool, - @optional - rel: string /* a space- or comma-separated (depending on the element) list of a fixed set of "link types" */, - @optional - required: bool, - @optional - reversed: bool, - @optional - rows: int, - @optional - rowSpan: int, - @optional - sandbox: string /* has a fixed set of possible values */, - @optional - scope: string /* has a fixed set of possible values */, - @optional - scoped: bool, - @optional - scrolling: string /* html4 only, "auto", "yes" or "no" */, - /* seamless - supported by React, but removed from the html5 spec */ - @optional - selected: bool, - @optional - shape: string, - @optional - size: int, - @optional - sizes: string, - @optional - span: int, - @optional - src: string /* uri */, - @optional - srcDoc: string, - @optional - srcLang: string, - @optional - srcSet: string, - @optional - start: int, - @optional - step: float, - @optional - summary: string /* deprecated */, - @optional - target: string, - @optional @as("type") - type_: string /* has a fixed but large-ish set of possible values */ /* use this one. Previous one is deprecated */, - @optional - useMap: string, - @optional - value: string, - @optional - width: string /* in html5 this can only be a number, but in html4 it can ba a percentage as well */, - @optional - wrap: string /* "hard" or "soft" */, - /* Clipboard events */ - @optional - onCopy: ReactEvent.Clipboard.t => unit, - @optional - onCut: ReactEvent.Clipboard.t => unit, - @optional - onPaste: ReactEvent.Clipboard.t => unit, - /* Composition events */ - @optional - onCompositionEnd: ReactEvent.Composition.t => unit, - @optional - onCompositionStart: ReactEvent.Composition.t => unit, - @optional - onCompositionUpdate: ReactEvent.Composition.t => unit, - /* Keyboard events */ - @optional - onKeyDown: ReactEvent.Keyboard.t => unit, - @optional - onKeyPress: ReactEvent.Keyboard.t => unit, - @optional - onKeyUp: ReactEvent.Keyboard.t => unit, - /* Focus events */ - @optional - onFocus: ReactEvent.Focus.t => unit, - @optional - onBlur: ReactEvent.Focus.t => unit, - /* Form events */ - @optional - onChange: ReactEvent.Form.t => unit, - @optional - onInput: ReactEvent.Form.t => unit, - @optional - onSubmit: ReactEvent.Form.t => unit, - @optional - onInvalid: ReactEvent.Form.t => unit, - /* Mouse events */ - @optional - onClick: ReactEvent.Mouse.t => unit, - @optional - onContextMenu: ReactEvent.Mouse.t => unit, - @optional - onDoubleClick: ReactEvent.Mouse.t => unit, - @optional - onDrag: ReactEvent.Mouse.t => unit, - @optional - onDragEnd: ReactEvent.Mouse.t => unit, - @optional - onDragEnter: ReactEvent.Mouse.t => unit, - @optional - onDragExit: ReactEvent.Mouse.t => unit, - @optional - onDragLeave: ReactEvent.Mouse.t => unit, - @optional - onDragOver: ReactEvent.Mouse.t => unit, - @optional - onDragStart: ReactEvent.Mouse.t => unit, - @optional - onDrop: ReactEvent.Mouse.t => unit, - @optional - onMouseDown: ReactEvent.Mouse.t => unit, - @optional - onMouseEnter: ReactEvent.Mouse.t => unit, - @optional - onMouseLeave: ReactEvent.Mouse.t => unit, - @optional - onMouseMove: ReactEvent.Mouse.t => unit, - @optional - onMouseOut: ReactEvent.Mouse.t => unit, - @optional - onMouseOver: ReactEvent.Mouse.t => unit, - @optional - onMouseUp: ReactEvent.Mouse.t => unit, - /* Selection events */ - @optional - onSelect: ReactEvent.Selection.t => unit, - /* Touch events */ - @optional - onTouchCancel: ReactEvent.Touch.t => unit, - @optional - onTouchEnd: ReactEvent.Touch.t => unit, - @optional - onTouchMove: ReactEvent.Touch.t => unit, - @optional - onTouchStart: ReactEvent.Touch.t => unit, - // Pointer events - @optional - onPointerOver: ReactEvent.Pointer.t => unit, - @optional - onPointerEnter: ReactEvent.Pointer.t => unit, - @optional - onPointerDown: ReactEvent.Pointer.t => unit, - @optional - onPointerMove: ReactEvent.Pointer.t => unit, - @optional - onPointerUp: ReactEvent.Pointer.t => unit, - @optional - onPointerCancel: ReactEvent.Pointer.t => unit, - @optional - onPointerOut: ReactEvent.Pointer.t => unit, - @optional - onPointerLeave: ReactEvent.Pointer.t => unit, - @optional - onGotPointerCapture: ReactEvent.Pointer.t => unit, - @optional - onLostPointerCapture: ReactEvent.Pointer.t => unit, - /* UI events */ - @optional - onScroll: ReactEvent.UI.t => unit, - /* Wheel events */ - @optional - onWheel: ReactEvent.Wheel.t => unit, - /* Media events */ - @optional - onAbort: ReactEvent.Media.t => unit, - @optional - onCanPlay: ReactEvent.Media.t => unit, - @optional - onCanPlayThrough: ReactEvent.Media.t => unit, - @optional - onDurationChange: ReactEvent.Media.t => unit, - @optional - onEmptied: ReactEvent.Media.t => unit, - @optional - onEncrypted: ReactEvent.Media.t => unit, - @optional - onEnded: ReactEvent.Media.t => unit, - @optional - onError: ReactEvent.Media.t => unit, - @optional - onLoadedData: ReactEvent.Media.t => unit, - @optional - onLoadedMetadata: ReactEvent.Media.t => unit, - @optional - onLoadStart: ReactEvent.Media.t => unit, - @optional - onPause: ReactEvent.Media.t => unit, - @optional - onPlay: ReactEvent.Media.t => unit, - @optional - onPlaying: ReactEvent.Media.t => unit, - @optional - onProgress: ReactEvent.Media.t => unit, - @optional - onRateChange: ReactEvent.Media.t => unit, - @optional - onSeeked: ReactEvent.Media.t => unit, - @optional - onSeeking: ReactEvent.Media.t => unit, - @optional - onStalled: ReactEvent.Media.t => unit, - @optional - onSuspend: ReactEvent.Media.t => unit, - @optional - onTimeUpdate: ReactEvent.Media.t => unit, - @optional - onVolumeChange: ReactEvent.Media.t => unit, - @optional - onWaiting: ReactEvent.Media.t => unit, - /* Image events */ - @optional - onLoad: ReactEvent.Image.t => unit /* duplicate */ /* ~onError: ReactEvent.Image.t => unit=?, */, - /* Animation events */ - @optional - onAnimationStart: ReactEvent.Animation.t => unit, - @optional - onAnimationEnd: ReactEvent.Animation.t => unit, - @optional - onAnimationIteration: ReactEvent.Animation.t => unit, - /* Transition events */ - @optional - onTransitionEnd: ReactEvent.Transition.t => unit, - /* svg */ - @optional - accentHeight: string, - @optional - accumulate: string, - @optional - additive: string, - @optional - alignmentBaseline: string, - @optional - allowReorder: string, - @optional - alphabetic: string, - @optional - amplitude: string, - @optional - arabicForm: string, - @optional - ascent: string, - @optional - attributeName: string, - @optional - attributeType: string, - @optional - autoReverse: string, - @optional - azimuth: string, - @optional - baseFrequency: string, - @optional - baseProfile: string, - @optional - baselineShift: string, - @optional - bbox: string, - @optional @as("begin") - begin_: string /* use this one. Previous one is deprecated */, - @optional - bias: string, - @optional - by: string, - @optional - calcMode: string, - @optional - capHeight: string, - @optional - clip: string, - @optional - clipPath: string, - @optional - clipPathUnits: string, - @optional - clipRule: string, - @optional - colorInterpolation: string, - @optional - colorInterpolationFilters: string, - @optional - colorProfile: string, - @optional - colorRendering: string, - @optional - contentScriptType: string, - @optional - contentStyleType: string, - @optional - cursor: string, - @optional - cx: string, - @optional - cy: string, - @optional - d: string, - @optional - decelerate: string, - @optional - descent: string, - @optional - diffuseConstant: string, - @optional - direction: string, - @optional - display: string, - @optional - divisor: string, - @optional - dominantBaseline: string, - @optional - dur: string, - @optional - dx: string, - @optional - dy: string, - @optional - edgeMode: string, - @optional - elevation: string, - @optional - enableBackground: string, - @optional @as("end") - end_: string /* use this one. Previous one is deprecated */, - @optional - exponent: string, - @optional - externalResourcesRequired: string, - @optional - fill: string, - @optional - fillOpacity: string, - @optional - fillRule: string, - @optional - filter: string, - @optional - filterRes: string, - @optional - filterUnits: string, - @optional - floodColor: string, - @optional - floodOpacity: string, - @optional - focusable: string, - @optional - fontFamily: string, - @optional - fontSize: string, - @optional - fontSizeAdjust: string, - @optional - fontStretch: string, - @optional - fontStyle: string, - @optional - fontVariant: string, - @optional - fontWeight: string, - @optional - fomat: string, - @optional - from: string, - @optional - fx: string, - @optional - fy: string, - @optional - g1: string, - @optional - g2: string, - @optional - glyphName: string, - @optional - glyphOrientationHorizontal: string, - @optional - glyphOrientationVertical: string, - @optional - glyphRef: string, - @optional - gradientTransform: string, - @optional - gradientUnits: string, - @optional - hanging: string, - @optional - horizAdvX: string, - @optional - horizOriginX: string, - @optional - ideographic: string, - @optional - imageRendering: string, - @optional @as("in") - in_: string /* use this one. Previous one is deprecated */, - @optional - in2: string, - @optional - intercept: string, - @optional - k: string, - @optional - k1: string, - @optional - k2: string, - @optional - k3: string, - @optional - k4: string, - @optional - kernelMatrix: string, - @optional - kernelUnitLength: string, - @optional - kerning: string, - @optional - keyPoints: string, - @optional - keySplines: string, - @optional - keyTimes: string, - @optional - lengthAdjust: string, - @optional - letterSpacing: string, - @optional - lightingColor: string, - @optional - limitingConeAngle: string, - @optional - local: string, - @optional - markerEnd: string, - @optional - markerHeight: string, - @optional - markerMid: string, - @optional - markerStart: string, - @optional - markerUnits: string, - @optional - markerWidth: string, - @optional - mask: string, - @optional - maskContentUnits: string, - @optional - maskUnits: string, - @optional - mathematical: string, - @optional - mode: string, - @optional - numOctaves: string, - @optional - offset: string, - @optional - opacity: string, - @optional - operator: string, - @optional - order: string, - @optional - orient: string, - @optional - orientation: string, - @optional - origin: string, - @optional - overflow: string, - @optional - overflowX: string, - @optional - overflowY: string, - @optional - overlinePosition: string, - @optional - overlineThickness: string, - @optional - paintOrder: string, - @optional - panose1: string, - @optional - pathLength: string, - @optional - patternContentUnits: string, - @optional - patternTransform: string, - @optional - patternUnits: string, - @optional - pointerEvents: string, - @optional - points: string, - @optional - pointsAtX: string, - @optional - pointsAtY: string, - @optional - pointsAtZ: string, - @optional - preserveAlpha: string, - @optional - preserveAspectRatio: string, - @optional - primitiveUnits: string, - @optional - r: string, - @optional - radius: string, - @optional - refX: string, - @optional - refY: string, - @optional - renderingIntent: string, - @optional - repeatCount: string, - @optional - repeatDur: string, - @optional - requiredExtensions: string, - @optional - requiredFeatures: string, - @optional - restart: string, - @optional - result: string, - @optional - rotate: string, - @optional - rx: string, - @optional - ry: string, - @optional - scale: string, - @optional - seed: string, - @optional - shapeRendering: string, - @optional - slope: string, - @optional - spacing: string, - @optional - specularConstant: string, - @optional - specularExponent: string, - @optional - speed: string, - @optional - spreadMethod: string, - @optional - startOffset: string, - @optional - stdDeviation: string, - @optional - stemh: string, - @optional - stemv: string, - @optional - stitchTiles: string, - @optional - stopColor: string, - @optional - stopOpacity: string, - @optional - strikethroughPosition: string, - @optional - strikethroughThickness: string, - @optional - string: string, - @optional - stroke: string, - @optional - strokeDasharray: string, - @optional - strokeDashoffset: string, - @optional - strokeLinecap: string, - @optional - strokeLinejoin: string, - @optional - strokeMiterlimit: string, - @optional - strokeOpacity: string, - @optional - strokeWidth: string, - @optional - surfaceScale: string, - @optional - systemLanguage: string, - @optional - tableValues: string, - @optional - targetX: string, - @optional - targetY: string, - @optional - textAnchor: string, - @optional - textDecoration: string, - @optional - textLength: string, - @optional - textRendering: string, - @optional @as("to") - to_: string /* use this one. Previous one is deprecated */, - @optional - transform: string, - @optional - u1: string, - @optional - u2: string, - @optional - underlinePosition: string, - @optional - underlineThickness: string, - @optional - unicode: string, - @optional - unicodeBidi: string, - @optional - unicodeRange: string, - @optional - unitsPerEm: string, - @optional - vAlphabetic: string, - @optional - vHanging: string, - @optional - vIdeographic: string, - @optional - vMathematical: string, - @optional - values: string, - @optional - vectorEffect: string, - @optional - version: string, - @optional - vertAdvX: string, - @optional - vertAdvY: string, - @optional - vertOriginX: string, - @optional - vertOriginY: string, - @optional - viewBox: string, - @optional - viewTarget: string, - @optional - visibility: string, - /* width::string? => */ - @optional - widths: string, - @optional - wordSpacing: string, - @optional - writingMode: string, - @optional - x: string, - @optional - x1: string, - @optional - x2: string, - @optional - xChannelSelector: string, - @optional - xHeight: string, - @optional - xlinkActuate: string, - @optional - xlinkArcrole: string, - @optional - xlinkHref: string, - @optional - xlinkRole: string, - @optional - xlinkShow: string, - @optional - xlinkTitle: string, - @optional - xlinkType: string, - @optional - xmlns: string, - @optional - xmlnsXlink: string, - @optional - xmlBase: string, - @optional - xmlLang: string, - @optional - xmlSpace: string, - @optional - y: string, - @optional - y1: string, - @optional - y2: string, - @optional - yChannelSelector: string, - @optional - z: string, - @optional - zoomAndPan: string, - /* RDFa */ - @optional - about: string, - @optional - datatype: string, - @optional - inlist: string, - @optional - prefix: string, - @optional - property: string, - @optional - resource: string, - @optional - typeof: string, - @optional - vocab: string, - /* react-specific */ - @optional - dangerouslySetInnerHTML: {"__html": string}, - @optional - suppressContentEditableWarning: bool, - } - - /* This list isn't exhaustive. We'll add more as we go. */ - /* - * Watch out! There are two props types and the only difference is the type of ref. - * Please keep in sync. - */ - @deriving(abstract) - type props = { - @optional - key: string, - @optional - ref: Js.nullable => unit, - /* accessibility */ - /* https://www.w3.org/TR/wai-aria-1.1/ */ - /* https://accessibilityresources.org/ is a great resource for these */ - /* [@optional] [@as "aria-current"] ariaCurrent: page|step|location|date|time|true|false, */ - @optional @as("aria-details") - ariaDetails: string, - @optional @as("aria-disabled") - ariaDisabled: bool, - @optional @as("aria-hidden") - ariaHidden: bool, - /* [@optional] [@as "aria-invalid"] ariaInvalid: grammar|false|spelling|true, */ - @optional @as("aria-keyshortcuts") - ariaKeyshortcuts: string, - @optional @as("aria-label") - ariaLabel: string, - @optional @as("aria-roledescription") - ariaRoledescription: string, - /* Widget Attributes */ - /* [@optional] [@as "aria-autocomplete"] ariaAutocomplete: inline|list|both|none, */ - /* [@optional] [@as "aria-checked"] ariaChecked: true|false|mixed, /* https://www.w3.org/TR/wai-aria-1.1/#valuetype_tristate */ */ - @optional @as("aria-expanded") - ariaExpanded: bool, - /* [@optional] [@as "aria-haspopup"] ariaHaspopup: false|true|menu|listbox|tree|grid|dialog, */ - @optional @as("aria-level") - ariaLevel: int, - @optional @as("aria-modal") - ariaModal: bool, - @optional @as("aria-multiline") - ariaMultiline: bool, - @optional @as("aria-multiselectable") - ariaMultiselectable: bool, - /* [@optional] [@as "aria-orientation"] ariaOrientation: horizontal|vertical|undefined, */ - @optional @as("aria-placeholder") - ariaPlaceholder: string, - /* [@optional] [@as "aria-pressed"] ariaPressed: true|false|mixed, /* https://www.w3.org/TR/wai-aria-1.1/#valuetype_tristate */ */ - @optional @as("aria-readonly") - ariaReadonly: bool, - @optional @as("aria-required") - ariaRequired: bool, - @optional @as("aria-selected") - ariaSelected: bool, - @optional @as("aria-sort") - ariaSort: string, - @optional @as("aria-valuemax") - ariaValuemax: float, - @optional @as("aria-valuemin") - ariaValuemin: float, - @optional @as("aria-valuenow") - ariaValuenow: float, - @optional @as("aria-valuetext") - ariaValuetext: string, - /* Live Region Attributes */ - @optional @as("aria-atomic") - ariaAtomic: bool, - @optional @as("aria-busy") - ariaBusy: bool, - /* [@optional] [@as "aria-live"] ariaLive: off|polite|assertive|rude, */ - @optional @as("aria-relevant") - ariaRelevant: string, - /* Drag-and-Drop Attributes */ - /* [@optional] [@as "aria-dropeffect"] ariaDropeffect: copy|move|link|execute|popup|none, */ - @optional @as("aria-grabbed") - ariaGrabbed: bool, - /* Relationship Attributes */ - @optional @as("aria-activedescendant") - ariaActivedescendant: string, - @optional @as("aria-colcount") - ariaColcount: int, - @optional @as("aria-colindex") - ariaColindex: int, - @optional @as("aria-colspan") - ariaColspan: int, - @optional @as("aria-controls") - ariaControls: string, - @optional @as("aria-describedby") - ariaDescribedby: string, - @optional @as("aria-errormessage") - ariaErrormessage: string, - @optional @as("aria-flowto") - ariaFlowto: string, - @optional @as("aria-labelledby") - ariaLabelledby: string, - @optional @as("aria-owns") - ariaOwns: string, - @optional @as("aria-posinset") - ariaPosinset: int, - @optional @as("aria-rowcount") - ariaRowcount: int, - @optional @as("aria-rowindex") - ariaRowindex: int, - @optional @as("aria-rowspan") - ariaRowspan: int, - @optional @as("aria-setsize") - ariaSetsize: int, - /* react textarea/input */ - @optional - defaultChecked: bool, - @optional - defaultValue: string, - /* global html attributes */ - @optional - accessKey: string, - @optional - className: string /* substitute for "class" */, - @optional - contentEditable: bool, - @optional - contextMenu: string, - @optional - dir: string /* "ltr", "rtl" or "auto" */, - @optional - draggable: bool, - @optional - hidden: bool, - @optional - id: string, - @optional - lang: string, - @optional - role: string /* ARIA role */, - @optional - style: style, - @optional - spellCheck: bool, - @optional - tabIndex: int, - @optional - title: string, - /* html5 microdata */ - @optional - itemID: string, - @optional - itemProp: string, - @optional - itemRef: string, - @optional - itemScope: bool, - @optional - itemType: string /* uri */, - /* tag-specific html attributes */ - @optional - accept: string, - @optional - acceptCharset: string, - @optional - action: string /* uri */, - @optional - allow: string, - @optional - allowFullScreen: bool, - @optional - alt: string, - @optional - async: bool, - @optional - autoComplete: string /* has a fixed, but large-ish, set of possible values */, - @optional - autoCapitalize: string /* Mobile Safari specific */, - @optional - autoFocus: bool, - @optional - autoPlay: bool, - @optional - challenge: string, - @optional - charSet: string, - @optional - checked: bool, - @optional - cite: string /* uri */, - @optional - crossorigin: bool, - @optional - cols: int, - @optional - colSpan: int, - @optional - content: string, - @optional - controls: bool, - @optional - coords: string /* set of values specifying the coordinates of a region */, - @optional - data: string /* uri */, - @optional - dateTime: string /* "valid date string with optional time" */, - @optional - default: bool, - @optional - defer: bool, - @optional - disabled: bool, - @optional - download: string /* should really be either a boolean, signifying presence, or a string */, - @optional - encType: string /* "application/x-www-form-urlencoded", "multipart/form-data" or "text/plain" */, - @optional - form: string, - @optional - formAction: string /* uri */, - @optional - formTarget: string /* "_blank", "_self", etc. */, - @optional - formMethod: string /* "post", "get", "put" */, - @optional - frameBorder: int /* deprecated, prefer to use css border instead */, - @optional - headers: string, - @optional - height: string /* in html5 this can only be a number, but in html4 it can ba a percentage as well */, - @optional - high: int, - @optional - href: string /* uri */, - @optional - hrefLang: string, - @optional - htmlFor: string /* substitute for "for" */, - @optional - httpEquiv: string /* has a fixed set of possible values */, - @optional - icon: string /* uri? */, - @optional - inputMode: string /* "verbatim", "latin", "numeric", etc. */, - @optional - integrity: string, - @optional - keyType: string, - @optional - kind: string /* has a fixed set of possible values */, - @optional - label: string, - @optional - list: string, - @optional - loop: bool, - @optional - low: int, - @optional - manifest: string /* uri */, - @optional - max: string /* should be int or Js.Date.t */, - @optional - maxLength: int, - @optional - media: string /* a valid media query */, - @optional - mediaGroup: string, - @optional - method: string /* "post" or "get" */, - @optional - min: string, - @optional - minLength: int, - @optional - multiple: bool, - @optional - muted: bool, - @optional - name: string, - @optional - nonce: string, - @optional - noValidate: bool, - @optional @as("open") - open_: bool /* use this one. Previous one is deprecated */, - @optional - optimum: int, - @optional - pattern: string /* valid Js RegExp */, - @optional - placeholder: string, - @optional - poster: string /* uri */, - @optional - preload: string /* "none", "metadata" or "auto" (and "" as a synonym for "auto") */, - @optional - radioGroup: string, - @optional - readOnly: bool, - @optional - rel: string /* a space- or comma-separated (depending on the element) list of a fixed set of "link types" */, - @optional - required: bool, - @optional - reversed: bool, - @optional - rows: int, - @optional - rowSpan: int, - @optional - sandbox: string /* has a fixed set of possible values */, - @optional - scope: string /* has a fixed set of possible values */, - @optional - scoped: bool, - @optional - scrolling: string /* html4 only, "auto", "yes" or "no" */, - /* seamless - supported by React, but removed from the html5 spec */ - @optional - selected: bool, - @optional - shape: string, - @optional - size: int, - @optional - sizes: string, - @optional - span: int, - @optional - src: string /* uri */, - @optional - srcDoc: string, - @optional - srcLang: string, - @optional - srcSet: string, - @optional - start: int, - @optional - step: float, - @optional - summary: string /* deprecated */, - @optional - target: string, - @optional @as("type") - type_: string /* has a fixed but large-ish set of possible values */ /* use this one. Previous one is deprecated */, - @optional - useMap: string, - @optional - value: string, - @optional - width: string /* in html5 this can only be a number, but in html4 it can ba a percentage as well */, - @optional - wrap: string /* "hard" or "soft" */, - /* Clipboard events */ - @optional - onCopy: ReactEvent.Clipboard.t => unit, - @optional - onCut: ReactEvent.Clipboard.t => unit, - @optional - onPaste: ReactEvent.Clipboard.t => unit, - /* Composition events */ - @optional - onCompositionEnd: ReactEvent.Composition.t => unit, - @optional - onCompositionStart: ReactEvent.Composition.t => unit, - @optional - onCompositionUpdate: ReactEvent.Composition.t => unit, - /* Keyboard events */ - @optional - onKeyDown: ReactEvent.Keyboard.t => unit, - @optional - onKeyPress: ReactEvent.Keyboard.t => unit, - @optional - onKeyUp: ReactEvent.Keyboard.t => unit, - /* Focus events */ - @optional - onFocus: ReactEvent.Focus.t => unit, - @optional - onBlur: ReactEvent.Focus.t => unit, - /* Form events */ - @optional - onChange: ReactEvent.Form.t => unit, - @optional - onInput: ReactEvent.Form.t => unit, - @optional - onSubmit: ReactEvent.Form.t => unit, - @optional - onInvalid: ReactEvent.Form.t => unit, - /* Mouse events */ - @optional - onClick: ReactEvent.Mouse.t => unit, - @optional - onContextMenu: ReactEvent.Mouse.t => unit, - @optional - onDoubleClick: ReactEvent.Mouse.t => unit, - @optional - onDrag: ReactEvent.Mouse.t => unit, - @optional - onDragEnd: ReactEvent.Mouse.t => unit, - @optional - onDragEnter: ReactEvent.Mouse.t => unit, - @optional - onDragExit: ReactEvent.Mouse.t => unit, - @optional - onDragLeave: ReactEvent.Mouse.t => unit, - @optional - onDragOver: ReactEvent.Mouse.t => unit, - @optional - onDragStart: ReactEvent.Mouse.t => unit, - @optional - onDrop: ReactEvent.Mouse.t => unit, - @optional - onMouseDown: ReactEvent.Mouse.t => unit, - @optional - onMouseEnter: ReactEvent.Mouse.t => unit, - @optional - onMouseLeave: ReactEvent.Mouse.t => unit, - @optional - onMouseMove: ReactEvent.Mouse.t => unit, - @optional - onMouseOut: ReactEvent.Mouse.t => unit, - @optional - onMouseOver: ReactEvent.Mouse.t => unit, - @optional - onMouseUp: ReactEvent.Mouse.t => unit, - /* Selection events */ - @optional - onSelect: ReactEvent.Selection.t => unit, - /* Touch events */ - @optional - onTouchCancel: ReactEvent.Touch.t => unit, - @optional - onTouchEnd: ReactEvent.Touch.t => unit, - @optional - onTouchMove: ReactEvent.Touch.t => unit, - @optional - onTouchStart: ReactEvent.Touch.t => unit, - // Pointer events - @optional - onPointerOver: ReactEvent.Pointer.t => unit, - @optional - onPointerEnter: ReactEvent.Pointer.t => unit, - @optional - onPointerDown: ReactEvent.Pointer.t => unit, - @optional - onPointerMove: ReactEvent.Pointer.t => unit, - @optional - onPointerUp: ReactEvent.Pointer.t => unit, - @optional - onPointerCancel: ReactEvent.Pointer.t => unit, - @optional - onPointerOut: ReactEvent.Pointer.t => unit, - @optional - onPointerLeave: ReactEvent.Pointer.t => unit, - @optional - onGotPointerCapture: ReactEvent.Pointer.t => unit, - @optional - onLostPointerCapture: ReactEvent.Pointer.t => unit, - /* UI events */ - @optional - onScroll: ReactEvent.UI.t => unit, - /* Wheel events */ - @optional - onWheel: ReactEvent.Wheel.t => unit, - /* Media events */ - @optional - onAbort: ReactEvent.Media.t => unit, - @optional - onCanPlay: ReactEvent.Media.t => unit, - @optional - onCanPlayThrough: ReactEvent.Media.t => unit, - @optional - onDurationChange: ReactEvent.Media.t => unit, - @optional - onEmptied: ReactEvent.Media.t => unit, - @optional - onEncrypetd: ReactEvent.Media.t => unit, - @optional - onEnded: ReactEvent.Media.t => unit, - @optional - onError: ReactEvent.Media.t => unit, - @optional - onLoadedData: ReactEvent.Media.t => unit, - @optional - onLoadedMetadata: ReactEvent.Media.t => unit, - @optional - onLoadStart: ReactEvent.Media.t => unit, - @optional - onPause: ReactEvent.Media.t => unit, - @optional - onPlay: ReactEvent.Media.t => unit, - @optional - onPlaying: ReactEvent.Media.t => unit, - @optional - onProgress: ReactEvent.Media.t => unit, - @optional - onRateChange: ReactEvent.Media.t => unit, - @optional - onSeeked: ReactEvent.Media.t => unit, - @optional - onSeeking: ReactEvent.Media.t => unit, - @optional - onStalled: ReactEvent.Media.t => unit, - @optional - onSuspend: ReactEvent.Media.t => unit, - @optional - onTimeUpdate: ReactEvent.Media.t => unit, - @optional - onVolumeChange: ReactEvent.Media.t => unit, - @optional - onWaiting: ReactEvent.Media.t => unit, - /* Image events */ - @optional - onLoad: ReactEvent.Image.t => unit /* duplicate */ /* ~onError: ReactEvent.Image.t => unit=?, */, - /* Animation events */ - @optional - onAnimationStart: ReactEvent.Animation.t => unit, - @optional - onAnimationEnd: ReactEvent.Animation.t => unit, - @optional - onAnimationIteration: ReactEvent.Animation.t => unit, - /* Transition events */ - @optional - onTransitionEnd: ReactEvent.Transition.t => unit, - /* svg */ - @optional - accentHeight: string, - @optional - accumulate: string, - @optional - additive: string, - @optional - alignmentBaseline: string, - @optional - allowReorder: string, - @optional - alphabetic: string, - @optional - amplitude: string, - @optional - arabicForm: string, - @optional - ascent: string, - @optional - attributeName: string, - @optional - attributeType: string, - @optional - autoReverse: string, - @optional - azimuth: string, - @optional - baseFrequency: string, - @optional - baseProfile: string, - @optional - baselineShift: string, - @optional - bbox: string, - @optional @as("begin") - begin_: string /* use this one. Previous one is deprecated */, - @optional - bias: string, - @optional - by: string, - @optional - calcMode: string, - @optional - capHeight: string, - @optional - clip: string, - @optional - clipPath: string, - @optional - clipPathUnits: string, - @optional - clipRule: string, - @optional - colorInterpolation: string, - @optional - colorInterpolationFilters: string, - @optional - colorProfile: string, - @optional - colorRendering: string, - @optional - contentScriptType: string, - @optional - contentStyleType: string, - @optional - cursor: string, - @optional - cx: string, - @optional - cy: string, - @optional - d: string, - @optional - decelerate: string, - @optional - descent: string, - @optional - diffuseConstant: string, - @optional - direction: string, - @optional - display: string, - @optional - divisor: string, - @optional - dominantBaseline: string, - @optional - dur: string, - @optional - dx: string, - @optional - dy: string, - @optional - edgeMode: string, - @optional - elevation: string, - @optional - enableBackground: string, - @optional @as("end") - end_: string /* use this one. Previous one is deprecated */, - @optional - exponent: string, - @optional - externalResourcesRequired: string, - @optional - fill: string, - @optional - fillOpacity: string, - @optional - fillRule: string, - @optional - filter: string, - @optional - filterRes: string, - @optional - filterUnits: string, - @optional - floodColor: string, - @optional - floodOpacity: string, - @optional - focusable: string, - @optional - fontFamily: string, - @optional - fontSize: string, - @optional - fontSizeAdjust: string, - @optional - fontStretch: string, - @optional - fontStyle: string, - @optional - fontVariant: string, - @optional - fontWeight: string, - @optional - fomat: string, - @optional - from: string, - @optional - fx: string, - @optional - fy: string, - @optional - g1: string, - @optional - g2: string, - @optional - glyphName: string, - @optional - glyphOrientationHorizontal: string, - @optional - glyphOrientationVertical: string, - @optional - glyphRef: string, - @optional - gradientTransform: string, - @optional - gradientUnits: string, - @optional - hanging: string, - @optional - horizAdvX: string, - @optional - horizOriginX: string, - @optional - ideographic: string, - @optional - imageRendering: string, - @optional @as("in") - in_: string /* use this one. Previous one is deprecated */, - @optional - in2: string, - @optional - intercept: string, - @optional - k: string, - @optional - k1: string, - @optional - k2: string, - @optional - k3: string, - @optional - k4: string, - @optional - kernelMatrix: string, - @optional - kernelUnitLength: string, - @optional - kerning: string, - @optional - keyPoints: string, - @optional - keySplines: string, - @optional - keyTimes: string, - @optional - lengthAdjust: string, - @optional - letterSpacing: string, - @optional - lightingColor: string, - @optional - limitingConeAngle: string, - @optional - local: string, - @optional - markerEnd: string, - @optional - markerHeight: string, - @optional - markerMid: string, - @optional - markerStart: string, - @optional - markerUnits: string, - @optional - markerWidth: string, - @optional - mask: string, - @optional - maskContentUnits: string, - @optional - maskUnits: string, - @optional - mathematical: string, - @optional - mode: string, - @optional - numOctaves: string, - @optional - offset: string, - @optional - opacity: string, - @optional - operator: string, - @optional - order: string, - @optional - orient: string, - @optional - orientation: string, - @optional - origin: string, - @optional - overflow: string, - @optional - overflowX: string, - @optional - overflowY: string, - @optional - overlinePosition: string, - @optional - overlineThickness: string, - @optional - paintOrder: string, - @optional - panose1: string, - @optional - pathLength: string, - @optional - patternContentUnits: string, - @optional - patternTransform: string, - @optional - patternUnits: string, - @optional - pointerEvents: string, - @optional - points: string, - @optional - pointsAtX: string, - @optional - pointsAtY: string, - @optional - pointsAtZ: string, - @optional - preserveAlpha: string, - @optional - preserveAspectRatio: string, - @optional - primitiveUnits: string, - @optional - r: string, - @optional - radius: string, - @optional - refX: string, - @optional - refY: string, - @optional - renderingIntent: string, - @optional - repeatCount: string, - @optional - repeatDur: string, - @optional - requiredExtensions: string, - @optional - requiredFeatures: string, - @optional - restart: string, - @optional - result: string, - @optional - rotate: string, - @optional - rx: string, - @optional - ry: string, - @optional - scale: string, - @optional - seed: string, - @optional - shapeRendering: string, - @optional - slope: string, - @optional - spacing: string, - @optional - specularConstant: string, - @optional - specularExponent: string, - @optional - speed: string, - @optional - spreadMethod: string, - @optional - startOffset: string, - @optional - stdDeviation: string, - @optional - stemh: string, - @optional - stemv: string, - @optional - stitchTiles: string, - @optional - stopColor: string, - @optional - stopOpacity: string, - @optional - strikethroughPosition: string, - @optional - strikethroughThickness: string, - @optional - string: string, - @optional - stroke: string, - @optional - strokeDasharray: string, - @optional - strokeDashoffset: string, - @optional - strokeLinecap: string, - @optional - strokeLinejoin: string, - @optional - strokeMiterlimit: string, - @optional - strokeOpacity: string, - @optional - strokeWidth: string, - @optional - surfaceScale: string, - @optional - systemLanguage: string, - @optional - tableValues: string, - @optional - targetX: string, - @optional - targetY: string, - @optional - textAnchor: string, - @optional - textDecoration: string, - @optional - textLength: string, - @optional - textRendering: string, - @optional @as("to") - to_: string /* use this one. Previous one is deprecated */, - @optional - transform: string, - @optional - u1: string, - @optional - u2: string, - @optional - underlinePosition: string, - @optional - underlineThickness: string, - @optional - unicode: string, - @optional - unicodeBidi: string, - @optional - unicodeRange: string, - @optional - unitsPerEm: string, - @optional - vAlphabetic: string, - @optional - vHanging: string, - @optional - vIdeographic: string, - @optional - vMathematical: string, - @optional - values: string, - @optional - vectorEffect: string, - @optional - version: string, - @optional - vertAdvX: string, - @optional - vertAdvY: string, - @optional - vertOriginX: string, - @optional - vertOriginY: string, - @optional - viewBox: string, - @optional - viewTarget: string, - @optional - visibility: string, - /* width::string? => */ - @optional - widths: string, - @optional - wordSpacing: string, - @optional - writingMode: string, - @optional - x: string, - @optional - x1: string, - @optional - x2: string, - @optional - xChannelSelector: string, - @optional - xHeight: string, - @optional - xlinkActuate: string, - @optional - xlinkArcrole: string, - @optional - xlinkHref: string, - @optional - xlinkRole: string, - @optional - xlinkShow: string, - @optional - xlinkTitle: string, - @optional - xlinkType: string, - @optional - xmlns: string, - @optional - xmlnsXlink: string, - @optional - xmlBase: string, - @optional - xmlLang: string, - @optional - xmlSpace: string, - @optional - y: string, - @optional - y1: string, - @optional - y2: string, - @optional - yChannelSelector: string, - @optional - z: string, - @optional - zoomAndPan: string, - /* RDFa */ - @optional - about: string, - @optional - datatype: string, - @optional - inlist: string, - @optional - prefix: string, - @optional - property: string, - @optional - resource: string, - @optional - typeof: string, - @optional - vocab: string, - /* react-specific */ - @optional - dangerouslySetInnerHTML: {"__html": string}, - @optional - suppressContentEditableWarning: bool, - } -} - -include Props - -// As we've removed `ReactDOMRe.createElement`, this enables patterns like -// React.createElement(ReactDOM.stringToComponent(multiline ? "textarea" : "input"), ...) -external stringToComponent: string => React.component = "%identity" - -module Style = ReactDOMStyle diff --git a/src/v3/ReactEvent_V3.bs.js b/src/v3/ReactEvent_V3.bs.js deleted file mode 100644 index 179cde2..0000000 --- a/src/v3/ReactEvent_V3.bs.js +++ /dev/null @@ -1,53 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -var Synthetic = {}; - -var Clipboard = {}; - -var Composition = {}; - -var Keyboard = {}; - -var Focus = {}; - -var Form = {}; - -var Mouse = {}; - -var Pointer = {}; - -var $$Selection = {}; - -var $$Touch = {}; - -var UI = {}; - -var Wheel = {}; - -var Media = {}; - -var $$Image = {}; - -var $$Animation = {}; - -var Transition = {}; - -exports.Synthetic = Synthetic; -exports.Clipboard = Clipboard; -exports.Composition = Composition; -exports.Keyboard = Keyboard; -exports.Focus = Focus; -exports.Form = Form; -exports.Mouse = Mouse; -exports.Pointer = Pointer; -exports.$$Selection = $$Selection; -exports.$$Touch = $$Touch; -exports.UI = UI; -exports.Wheel = Wheel; -exports.Media = Media; -exports.$$Image = $$Image; -exports.$$Animation = $$Animation; -exports.Transition = Transition; -/* No side effect */ diff --git a/src/v3/ReactEvent_V3.res b/src/v3/ReactEvent_V3.res deleted file mode 100644 index da92752..0000000 --- a/src/v3/ReactEvent_V3.res +++ /dev/null @@ -1,272 +0,0 @@ -type synthetic<'a> = ReactEvent.synthetic<'a> - -module MakeEventWithType = ( - Type: { - type t - }, -) => { - @get external bubbles: Type.t => bool = "bubbles" - @get external cancelable: Type.t => bool = "cancelable" - @get - external currentTarget: Type.t => {..} = "currentTarget" /* Should return Dom.eventTarget */ - @get external defaultPrevented: Type.t => bool = "defaultPrevented" - @get external eventPhase: Type.t => int = "eventPhase" - @get external isTrusted: Type.t => bool = "isTrusted" - @get external nativeEvent: Type.t => {..} = "nativeEvent" /* Should return Dom.event */ - @send external preventDefault: Type.t => unit = "preventDefault" - @send - external isDefaultPrevented: Type.t => bool = "isDefaultPrevented" - @send external stopPropagation: Type.t => unit = "stopPropagation" - @send - external isPropagationStopped: Type.t => bool = "isPropagationStopped" - @get external target: Type.t => {..} = "target" /* Should return Dom.eventTarget */ - @get external timeStamp: Type.t => float = "timeStamp" - @get external type_: Type.t => string = "type" - @send external persist: Type.t => unit = "persist" -} - -module Synthetic = { - type tag = ReactEvent.Synthetic.tag - type t = synthetic - @get external bubbles: synthetic<'a> => bool = "bubbles" - @get external cancelable: synthetic<'a> => bool = "cancelable" - @get - external currentTarget: synthetic<'a> => {..} = - "currentTarget" /* Should return Dom.eventTarget */ - @get - external defaultPrevented: synthetic<'a> => bool = "defaultPrevented" - @get external eventPhase: synthetic<'a> => int = "eventPhase" - @get external isTrusted: synthetic<'a> => bool = "isTrusted" - @get - external nativeEvent: synthetic<'a> => {..} = "nativeEvent" /* Should return Dom.event */ - @send - external preventDefault: synthetic<'a> => unit = "preventDefault" - @send - external isDefaultPrevented: synthetic<'a> => bool = "isDefaultPrevented" - @send - external stopPropagation: synthetic<'a> => unit = "stopPropagation" - @send - external isPropagationStopped: synthetic<'a> => bool = "isPropagationStopped" - @get external target: synthetic<'a> => {..} = "target" /* Should return Dom.eventTarget */ - @get external timeStamp: synthetic<'a> => float = "timeStamp" - @get external type_: synthetic<'a> => string = "type" - @send external persist: synthetic<'a> => unit = "persist" -} - -/* Cast any event type to the general synthetic type. This is safe, since synthetic is more general */ -external toSyntheticEvent: synthetic<'a> => Synthetic.t = "%identity" - -module Clipboard = { - type tag = ReactEvent.Clipboard.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @get external clipboardData: t => {..} = "clipboardData" /* Should return Dom.dataTransfer */ -} - -module Composition = { - type tag = ReactEvent.Composition.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @get external data: t => string = "data" -} - -module Keyboard = { - type tag = ReactEvent.Keyboard.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @get external altKey: t => bool = "altKey" - @get external charCode: t => int = "charCode" - @get external ctrlKey: t => bool = "ctrlKey" - @send - external getModifierState: (t, string) => bool = "getModifierState" - @get external key: t => string = "key" - @get external keyCode: t => int = "keyCode" - @get external locale: t => string = "locale" - @get external location: t => int = "location" - @get external metaKey: t => bool = "metaKey" - @get external repeat: t => bool = "repeat" - @get external shiftKey: t => bool = "shiftKey" - @get external which: t => int = "which" -} - -module Focus = { - type tag = ReactEvent.Focus.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @get @return(nullable) - external relatedTarget: t => option<{..}> = "relatedTarget" /* Should return Dom.eventTarget */ -} - -module Form = { - type tag = ReactEvent.Form.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) -} - -module Mouse = { - type tag = ReactEvent.Mouse.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @get external altKey: t => bool = "altKey" - @get external button: t => int = "button" - @get external buttons: t => int = "buttons" - @get external clientX: t => int = "clientX" - @get external clientY: t => int = "clientY" - @get external ctrlKey: t => bool = "ctrlKey" - @send - external getModifierState: (t, string) => bool = "getModifierState" - @get external metaKey: t => bool = "metaKey" - @get external movementX: t => int = "movementX" - @get external movementY: t => int = "movementY" - @get external pageX: t => int = "pageX" - @get external pageY: t => int = "pageY" - @get @return(nullable) - external relatedTarget: t => option<{..}> = "relatedTarget" /* Should return Dom.eventTarget */ - @get external screenX: t => int = "screenX" - @get external screenY: t => int = "screenY" - @get external shiftKey: t => bool = "shiftKey" -} - -module Pointer = { - type tag = ReactEvent.Pointer.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - - // UIEvent - @get external detail: t => int = "detail" - @get external view: t => Dom.window = "view" /* Should return DOMAbstractView/WindowProxy */ - - // MouseEvent - @get external screenX: t => int = "screenX" - @get external screenY: t => int = "screenY" - @get external clientX: t => int = "clientX" - @get external clientY: t => int = "clientY" - @get external pageX: t => int = "pageX" - @get external pageY: t => int = "pageY" - @get external movementX: t => int = "movementX" - @get external movementY: t => int = "movementY" - - @get external ctrlKey: t => bool = "ctrlKey" - @get external shiftKey: t => bool = "shiftKey" - @get external altKey: t => bool = "altKey" - @get external metaKey: t => bool = "metaKey" - @send - external getModifierState: (t, string) => bool = "getModifierState" - - @get external button: t => int = "button" - @get external buttons: t => int = "buttons" - - @get @return(nullable) - external relatedTarget: t => option<{..}> = "relatedTarget" /* Should return Dom.eventTarget */ - - // PointerEvent - @get external pointerId: t => Dom.eventPointerId = "pointerId" - @get external width: t => float = "width" - @get external height: t => float = "height" - @get external pressure: t => float = "pressure" - @get external tangentialPressure: t => float = "tangentialPressure" - @get external tiltX: t => int = "tiltX" - @get external tiltY: t => int = "tiltY" - @get external twist: t => int = "twist" - @get external pointerType: t => string = "pointerType" - @get external isPrimary: t => bool = "isPrimary" -} - -module Selection = { - type tag = ReactEvent.Selection.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) -} - -module Touch = { - type tag = ReactEvent.Touch.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @get external altKey: t => bool = "altKey" - @get external changedTouches: t => {..} = "changedTouches" /* Should return Dom.touchList */ - @get external ctrlKey: t => bool = "ctrlKey" - @send - external getModifierState: (t, string) => bool = "getModifierState" - @get external metaKey: t => bool = "metaKey" - @get external shiftKey: t => bool = "shiftKey" - @get external targetTouches: t => {..} = "targetTouches" /* Should return Dom.touchList */ - @get external touches: t => {..} = "touches" /* Should return Dom.touchList */ -} - -module UI = { - type tag = ReactEvent.UI.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @get external detail: t => int = "detail" - @get external view: t => Dom.window = "view" /* Should return DOMAbstractView/WindowProxy */ -} - -module Wheel = { - type tag = ReactEvent.Wheel.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @get external deltaMode: t => int = "deltaMode" - @get external deltaX: t => float = "deltaX" - @get external deltaY: t => float = "deltaY" - @get external deltaZ: t => float = "deltaZ" -} - -module Media = { - type tag = ReactEvent.Media.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) -} - -module Image = { - type tag = ReactEvent.Image.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) -} - -module Animation = { - type tag = ReactEvent.Animation.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @get external animationName: t => string = "animationName" - @get external pseudoElement: t => string = "pseudoElement" - @get external elapsedTime: t => float = "elapsedTime" -} - -module Transition = { - type tag = ReactEvent.Transition.tag - type t = synthetic - include MakeEventWithType({ - type t = t - }) - @get external propertyName: t => string = "propertyName" - @get external pseudoElement: t => string = "pseudoElement" - @get external elapsedTime: t => float = "elapsedTime" -} diff --git a/src/v3/ReactEvent_V3.resi b/src/v3/ReactEvent_V3.resi deleted file mode 100644 index e4ac845..0000000 --- a/src/v3/ReactEvent_V3.resi +++ /dev/null @@ -1,471 +0,0 @@ -/* This is the whole synthetic event system of ReactJS/ReasonReact. The first module `Synthetic` represents - the generic synthetic event. The rest are the specific ones. - - In each module, the type `t` commonly means "the type of that module" (OCaml convention). In our case, e.g. - `ReactEvent.Mouse.t` represents a ReactJS synthetic mouse event. You'd use it to type your props: - - ``` - type props = { - onClick: ReactEvent.Mouse.t => unit - }; - ``` - - All the methods and properties of a type of event are in the module, as seen below. - - Each module also has a `tag` type. You can ignore it; they're only needed by their `t` type. This way, we - get to allow a base `Synthetic` event module with generic methods. So e.g. even a mouse event (`Mouse.t`) - get to be passed to a generic handler: - - ``` - let handleClick = ({state, props}, event) => { - ReactEvent.Mouse.preventDefault(event); - ... - }; - let handleSubmit = ({state, props}, event) => { - // this handler can be triggered by either a Keyboard or a Mouse event; - // conveniently use the generic preventDefault - ReactEvent.Synthetic.preventDefault(event); - ... - }; - - let render = (_) => ; - ``` - - How to translate idioms from ReactJS: - - 1. myMouseEvent.preventDefault() -> ReactEvent.Mouse.preventDefault(myMouseEvent) - 2. myKeyboardEvent.which -> ReactEvent.Keyboard.which(myKeyboardEvent) - */ -type synthetic<'a> = ReactEvent.synthetic<'a> - -module Synthetic: { - type tag = ReactEvent.Synthetic.tag - type t = synthetic - @get external bubbles: synthetic<'a> => bool = "bubbles" - @get external cancelable: synthetic<'a> => bool = "cancelable" - @get - external currentTarget: synthetic<'a> => {..} = "currentTarget" - @get - external defaultPrevented: synthetic<'a> => bool = "defaultPrevented" - @get external eventPhase: synthetic<'a> => int = "eventPhase" - @get external isTrusted: synthetic<'a> => bool = "isTrusted" - @get - external nativeEvent: synthetic<'a> => {..} = "nativeEvent" - @send - external preventDefault: synthetic<'a> => unit = "preventDefault" - @send - external isDefaultPrevented: synthetic<'a> => bool = "isDefaultPrevented" - @send - external stopPropagation: synthetic<'a> => unit = "stopPropagation" - @send - external isPropagationStopped: synthetic<'a> => bool = "isPropagationStopped" - @get external target: synthetic<'a> => {..} = "target" - @get external timeStamp: synthetic<'a> => float = "timeStamp" - @get external type_: synthetic<'a> => string = "type" - @send external persist: synthetic<'a> => unit = "persist" -} - -/* Cast any event type to the general synthetic type. This is safe, since synthetic is more general */ -external toSyntheticEvent: synthetic<'a> => Synthetic.t = "%identity" - -module Clipboard: { - type tag = ReactEvent.Clipboard.tag - type t = synthetic - @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 clipboardData: t => {..} = "clipboardData" /* Should return Dom.dataTransfer */ -} - -module Composition: { - type tag = ReactEvent.Composition.tag - type t = synthetic - @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 data: t => string = "data" -} - -module Keyboard: { - type tag = ReactEvent.Keyboard.tag - type t = synthetic - @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 altKey: t => bool = "altKey" - @get external charCode: t => int = "charCode" - @get external ctrlKey: t => bool = "ctrlKey" - @send - external getModifierState: (t, string) => bool = "getModifierState" - @get external key: t => string = "key" - @get external keyCode: t => int = "keyCode" - @get external locale: t => string = "locale" - @get external location: t => int = "location" - @get external metaKey: t => bool = "metaKey" - @get external repeat: t => bool = "repeat" - @get external shiftKey: t => bool = "shiftKey" - @get external which: t => int = "which" -} - -module Focus: { - type tag = ReactEvent.Focus.tag - type t = synthetic - @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 @return(nullable) - external relatedTarget: t => option<{..}> = "relatedTarget" /* Should return Dom.eventTarget */ -} - -module Form: { - type tag = ReactEvent.Form.tag - type t = synthetic - @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" -} - -module Mouse: { - type tag = ReactEvent.Mouse.tag - type t = synthetic - @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 altKey: t => bool = "altKey" - @get external button: t => int = "button" - @get external buttons: t => int = "buttons" - @get external clientX: t => int = "clientX" - @get external clientY: t => int = "clientY" - @get external ctrlKey: t => bool = "ctrlKey" - @send - external getModifierState: (t, string) => bool = "getModifierState" - @get external metaKey: t => bool = "metaKey" - @get external movementX: t => int = "movementX" - @get external movementY: t => int = "movementY" - @get external pageX: t => int = "pageX" - @get external pageY: t => int = "pageY" - @get @return(nullable) - external relatedTarget: t => option<{..}> = "relatedTarget" /* Should return Dom.eventTarget */ - @get external screenX: t => int = "screenX" - @get external screenY: t => int = "screenY" - @get external shiftKey: t => bool = "shiftKey" -} - -module Pointer: { - type tag = ReactEvent.Pointer.tag - type t = synthetic - - // Event - @get external type_: t => string = "type" - @get external target: t => {..} = "target" - @get external currentTarget: t => {..} = "currentTarget" - - @get external eventPhase: t => int = "eventPhase" - - @send external stopPropagation: t => unit = "stopPropagation" // aka cancelBubble - @get external bubbles: t => bool = "bubbles" - @get external cancelable: t => bool = "cancelable" - @send external preventDefault: t => unit = "preventDefault" - @get external defaultPrevented: t => bool = "defaultPrevented" - - @get external isTrusted: t => bool = "isTrusted" - @get external timeStamp: t => float = "timeStamp" - - // SyntheticEvent - @get external nativeEvent: t => {..} = "nativeEvent" - @send external isDefaultPrevented: t => bool = "isDefaultPrevented" - @send external isPropagationStopped: t => bool = "isPropagationStopped" - @send external persist: t => unit = "persist" - - // UIEvent - @get external detail: t => int = "detail" - @get external view: t => Dom.window = "view" /* Should return DOMAbstractView/WindowProxy */ - - // MouseEvent - @get external screenX: t => int = "screenX" - @get external screenY: t => int = "screenY" - @get external clientX: t => int = "clientX" - @get external clientY: t => int = "clientY" - @get external pageX: t => int = "pageX" - @get external pageY: t => int = "pageY" - @get external movementX: t => int = "movementX" - @get external movementY: t => int = "movementY" - - @get external ctrlKey: t => bool = "ctrlKey" - @get external shiftKey: t => bool = "shiftKey" - @get external altKey: t => bool = "altKey" - @get external metaKey: t => bool = "metaKey" - @send - external getModifierState: (t, string) => bool = "getModifierState" - - @get external button: t => int = "button" - @get external buttons: t => int = "buttons" - - @get @return(nullable) - external relatedTarget: t => option<{..}> = "relatedTarget" /* Should return Dom.eventTarget */ - - // PointerEvent - @get external pointerId: t => Dom.eventPointerId = "pointerId" - @get external width: t => float = "width" - @get external height: t => float = "height" - @get external pressure: t => float = "pressure" - @get external tangentialPressure: t => float = "tangentialPressure" - @get external tiltX: t => int = "tiltX" - @get external tiltY: t => int = "tiltY" - @get external twist: t => int = "twist" - @get external pointerType: t => string = "pointerType" - @get external isPrimary: t => bool = "isPrimary" -} - -module Selection: { - type tag = ReactEvent.Selection.tag - type t = synthetic - @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" -} - -module Touch: { - type tag = ReactEvent.Touch.tag - type t = synthetic - @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 altKey: t => bool = "altKey" - @get external changedTouches: t => {..} = "changedTouches" /* Should return Dom.touchList */ - @get external ctrlKey: t => bool = "ctrlKey" - @send - external getModifierState: (t, string) => bool = "getModifierState" - @get external metaKey: t => bool = "metaKey" - @get external shiftKey: t => bool = "shiftKey" - @get external targetTouches: t => {..} = "targetTouches" /* Should return Dom.touchList */ - @get external touches: t => {..} = "touches" /* Should return Dom.touchList */ -} - -module UI: { - type tag = ReactEvent.UI.tag - type t = synthetic - @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 detail: t => int = "detail" - @get external view: t => Dom.window = "view" /* Should return DOMAbstractView/WindowProxy */ -} - -module Wheel: { - type tag = ReactEvent.Wheel.tag - type t = synthetic - @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 deltaMode: t => int = "deltaMode" - @get external deltaX: t => float = "deltaX" - @get external deltaY: t => float = "deltaY" - @get external deltaZ: t => float = "deltaZ" -} - -module Media: { - type tag = ReactEvent.Media.tag - type t = synthetic - @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" -} - -module Image: { - type tag = ReactEvent.Image.tag - type t = synthetic - @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" -} - -module Animation: { - type tag = ReactEvent.Animation.tag - type t = synthetic - @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 animationName: t => string = "animationName" - @get external pseudoElement: t => string = "pseudoElement" - @get external elapsedTime: t => float = "elapsedTime" -} - -module Transition: { - type tag = ReactEvent.Transition.tag - type t = synthetic - @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 propertyName: t => string = "propertyName" - @get external pseudoElement: t => string = "pseudoElement" - @get external elapsedTime: t => float = "elapsedTime" -} diff --git a/src/v3/ReactV3.bs.js b/src/v3/ReactV3.bs.js deleted file mode 100644 index e083669..0000000 --- a/src/v3/ReactV3.bs.js +++ /dev/null @@ -1,21 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var React_V3 = require("./React_V3.bs.js"); -var ReactDOM_V3 = require("./ReactDOM_V3.bs.js"); -var ReactEvent_V3 = require("./ReactEvent_V3.bs.js"); -var ReactDOMStyle_V3 = require("./ReactDOMStyle_V3.bs.js"); - -var React = React_V3; - -var ReactDOM = ReactDOM_V3; - -var ReactDOMStyle = ReactDOMStyle_V3; - -var ReactEvent = ReactEvent_V3; - -exports.React = React; -exports.ReactDOM = ReactDOM; -exports.ReactDOMStyle = ReactDOMStyle; -exports.ReactEvent = ReactEvent; -/* No side effect */ diff --git a/src/v3/ReactV3.res b/src/v3/ReactV3.res deleted file mode 100644 index 9c7dff5..0000000 --- a/src/v3/ReactV3.res +++ /dev/null @@ -1,35 +0,0 @@ -/*** -ReactV3 module is for the backward compatibility. - -`open ReactV3` enables using the rescript-react for V3. - -```rescript -module C = { - @@jsxConfig({version: 3}) - open ReactV3 - - @react.component - let make = ... -} -``` -or in project level, -- open ReactV3 globally -- install the compiler>=10.1 -- install the rescript-react>=0.11.0 -*/ - -module React = { - include React_V3 -} - -module ReactDOM = { - include ReactDOM_V3 -} - -module ReactDOMStyle = { - include ReactDOMStyle_V3 -} - -module ReactEvent = { - include ReactEvent_V3 -} diff --git a/src/v3/React_V3.bs.js b/src/v3/React_V3.bs.js deleted file mode 100644 index a858df8..0000000 --- a/src/v3/React_V3.bs.js +++ /dev/null @@ -1,26 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -var Ref = {}; - -var Children = {}; - -var Context = {}; - -var Fragment = {}; - -var StrictMode = {}; - -var Suspense = {}; - -var Uncurried = {}; - -exports.Ref = Ref; -exports.Children = Children; -exports.Context = Context; -exports.Fragment = Fragment; -exports.StrictMode = StrictMode; -exports.Suspense = Suspense; -exports.Uncurried = Uncurried; -/* No side effect */ diff --git a/src/v3/React_V3.res b/src/v3/React_V3.res deleted file mode 100644 index 33c3efb..0000000 --- a/src/v3/React_V3.res +++ /dev/null @@ -1,411 +0,0 @@ -/** Binding to React.element enables the compatibility with v3 */ -type element = React.element - -@val external null: element = "null" - -external float: float => element = "%identity" -external int: int => element = "%identity" -external string: string => element = "%identity" - -external array: array => element = "%identity" - -type componentLike<'props, 'return> = React.componentLike<'props, 'return> - -type component<'props> = React.component<'props> - -/* this function exists to prepare for making `component` abstract */ -external component: componentLike<'props, element> => component<'props> = "%identity" - -@module("react") -external createElement: (component<'props>, 'props) => element = "createElement" - -@module("react") -external cloneElement: (element, 'props) => element = "cloneElement" - -@variadic @module("react") -external createElementVariadic: (component<'props>, 'props, array) => element = - "createElement" - -@module("react") @deprecated("Please use JSX syntax directly.") -external jsxKeyed: (component<'props>, 'props, string) => element = "jsx" - -@module("react") @deprecated("Please use JSX syntax directly.") -external jsx: (component<'props>, 'props) => element = "jsx" - -@module("react") @deprecated("Please use JSX syntax directly.") -external jsxs: (component<'props>, 'props) => element = "jsxs" - -@module("react") @deprecated("Please use JSX syntax directly.") -external jsxsKeyed: (component<'props>, 'props, string) => element = "jsxs" - -type ref<'value> = React.ref<'value> = {mutable current: 'value} - -module Ref = { - @deprecated("Please use the type React.ref instead") - type t<'value> = ref<'value> - - @deprecated("Please directly read from ref.current instead") @get - external current: ref<'value> => 'value = "current" - - @deprecated("Please directly assign to ref.current instead") @set - external setCurrent: (ref<'value>, 'value) => unit = "current" -} - -@module("react") -external createRef: unit => ref> = "createRef" - -module Children = { - @module("react") @scope("Children") - external map: (element, element => element) => element = "map" - @module("react") @scope("Children") - external mapWithIndex: (element, @uncurry (element, int) => element) => element = "map" - @module("react") @scope("Children") - external forEach: (element, element => unit) => unit = "forEach" - @module("react") @scope("Children") - external forEachWithIndex: (element, @uncurry (element, int) => unit) => unit = "forEach" - @module("react") @scope("Children") - external count: element => int = "count" - @module("react") @scope("Children") - external only: element => element = "only" - @module("react") @scope("Children") - external toArray: element => array = "toArray" -} - -module Context = { - type t<'props> = React.Context.t<'props> - - @obj - external makeProps: ( - ~value: 'props, - ~children: element, - unit, - ) => {"value": 'props, "children": element} = "" - - @get - external provider: t<'props> => component<{"value": 'props, "children": element}> = "Provider" -} - -@module("react") -external createContext: 'a => Context.t<'a> = "createContext" - -@module("react") -external forwardRef: (@uncurry ('props, Js.Nullable.t>) => element) => component<'props> = - "forwardRef" - -@module("react") -external memo: component<'props> => component<'props> = "memo" - -@module("react") -external memoCustomCompareProps: ( - component<'props>, - @uncurry ('props, 'props) => bool, -) => component<'props> = "memo" - -module Fragment = { - @obj - external makeProps: (~children: element, ~key: 'key=?, unit) => {"children": element} = "" - @module("react") - external make: component<{ - "children": element, - }> = "Fragment" -} - -module StrictMode = { - @obj - external makeProps: (~children: element, ~key: 'key=?, unit) => {"children": element} = "" - @module("react") - external make: component<{ - "children": element, - }> = "StrictMode" -} - -module Suspense = { - @obj - external makeProps: ( - ~children: element=?, - ~fallback: element=?, - ~key: 'key=?, - unit, - ) => {"children": option, "fallback": option} = "" - @module("react") - external make: component<{ - "children": option, - "fallback": option, - }> = "Suspense" -} - -/* HOOKS */ - -/* - * Yeah, we know this api isn't great. tl;dr: useReducer instead. - * It's because useState can take functions or non-function values and treats - * them differently. Lazy initializer + callback which returns state is the - * only way to safely have any type of state and be able to update it correctly. - */ -@module("react") -external useState: (@uncurry (unit => 'state)) => ('state, ('state => 'state) => unit) = "useState" - -@module("react") -external useReducer: (@uncurry ('state, 'action) => 'state, 'state) => ('state, 'action => unit) = - "useReducer" - -@module("react") -external useReducerWithMapState: ( - @uncurry ('state, 'action) => 'state, - 'initialState, - @uncurry ('initialState => 'state), -) => ('state, 'action => unit) = "useReducer" - -@module("react") -external useEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = "useEffect" -@module("react") -external useEffect: (@uncurry (unit => option unit>), 'deps) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") -external useEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = - "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") -external useEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") -external useEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") -external useEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") -external useEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = - "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") -external useEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = - "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") -external useEffect6: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e, 'f)) => unit = - "useEffect" -@module("react") @deprecated("Please use useEffect or useEffectOnEveryRender instead") -external useEffect7: ( - @uncurry (unit => option unit>), - ('a, 'b, 'c, 'd, 'e, 'f, 'g), -) => unit = "useEffect" - -@module("react") -external useLayoutEffectOnEveryRender: (@uncurry (unit => option unit>)) => unit = - "useLayoutEffect" -@module("react") -external useLayoutEffect: (@uncurry (unit => option unit>), 'deps) => unit = - "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") -external useLayoutEffect0: (@uncurry (unit => option unit>), @as(json`[]`) _) => unit = - "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") -external useLayoutEffect1: (@uncurry (unit => option unit>), array<'a>) => unit = - "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") -external useLayoutEffect2: (@uncurry (unit => option unit>), ('a, 'b)) => unit = - "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") -external useLayoutEffect3: (@uncurry (unit => option unit>), ('a, 'b, 'c)) => unit = - "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") -external useLayoutEffect4: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd)) => unit = - "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") -external useLayoutEffect5: (@uncurry (unit => option unit>), ('a, 'b, 'c, 'd, 'e)) => unit = - "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") -external useLayoutEffect6: ( - @uncurry (unit => option unit>), - ('a, 'b, 'c, 'd, 'e, 'f), -) => unit = "useLayoutEffect" -@module("react") @deprecated("Please use useLayoutEffect or useLayoutEffectOnEveryRender instead") -external useLayoutEffect7: ( - @uncurry (unit => option unit>), - ('a, 'b, 'c, 'd, 'e, 'f, 'g), -) => unit = "useLayoutEffect" - -@module("react") -external useMemo: (@uncurry (unit => 'any), 'deps) => 'any = "useMemo" - -@module("react") @deprecated("Please use useMemo instead") -external useMemo0: (@uncurry (unit => 'any), @as(json`[]`) _) => 'any = "useMemo" - -@module("react") @deprecated("Please use useMemo instead") -external useMemo1: (@uncurry (unit => 'any), array<'a>) => 'any = "useMemo" - -@module("react") @deprecated("Please use useMemo instead") -external useMemo2: (@uncurry (unit => 'any), ('a, 'b)) => 'any = "useMemo" - -@module("react") @deprecated("Please use useMemo instead") -external useMemo3: (@uncurry (unit => 'any), ('a, 'b, 'c)) => 'any = "useMemo" - -@module("react") @deprecated("Please use useMemo instead") -external useMemo4: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd)) => 'any = "useMemo" - -@module("react") @deprecated("Please use useMemo instead") -external useMemo5: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e)) => 'any = "useMemo" - -@module("react") @deprecated("Please use useMemo instead") -external useMemo6: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f)) => 'any = "useMemo" - -@module("react") @deprecated("Please use useMemo instead") -external useMemo7: (@uncurry (unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'any = "useMemo" - -@module("react") -external useCallback: ('f, 'deps) => 'f = "useCallback" - -@module("react") @deprecated("Please use useCallback instead") -external useCallback0: ('f, @as(json`[]`) _) => 'f = "useCallback" - -@module("react") @deprecated("Please use useCallback instead") -external useCallback1: ('f, array<'a>) => 'f = "useCallback" - -@module("react") @deprecated("Please use useCallback instead") -external useCallback2: ('f, ('a, 'b)) => 'f = "useCallback" - -@module("react") @deprecated("Please use useCallback instead") -external useCallback3: ('f, ('a, 'b, 'c)) => 'f = "useCallback" - -@module("react") @deprecated("Please use useCallback instead") -external useCallback4: ('f, ('a, 'b, 'c, 'd)) => 'f = "useCallback" - -@module("react") @deprecated("Please use useCallback instead") -external useCallback5: ('f, ('a, 'b, 'c, 'd, 'e)) => 'f = "useCallback" - -@module("react") @deprecated("Please use useCallback instead") -external useCallback6: ('callback, ('a, 'b, 'c, 'd, 'e, 'f)) => 'callback = "useCallback" - -@module("react") @deprecated("Please use useCallback instead") -external useCallback7: ('callback, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'callback = "useCallback" - -@module("react") -external useContext: Context.t<'any> => 'any = "useContext" - -@module("react") external useRef: 'value => ref<'value> = "useRef" - -@module("react") -external useImperativeHandleOnEveryRender: ( - Js.Nullable.t>, - @uncurry (unit => 'value), -) => unit = "useImperativeHandle" - -@module("react") -external useImperativeHandle: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - 'deps, -) => unit = "useImperativeHandle" - -@module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") -external useImperativeHandle0: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - @as(json`[]`) _, -) => unit = "useImperativeHandle" - -@module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") -external useImperativeHandle1: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - array<'a>, -) => unit = "useImperativeHandle" - -@module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") -external useImperativeHandle2: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - ('a, 'b), -) => unit = "useImperativeHandle" - -@module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") -external useImperativeHandle3: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - ('a, 'b, 'c), -) => unit = "useImperativeHandle" - -@module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") -external useImperativeHandle4: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - ('a, 'b, 'c, 'd), -) => unit = "useImperativeHandle" - -@module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") -external useImperativeHandle5: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - ('a, 'b, 'c, 'd, 'e), -) => unit = "useImperativeHandle" - -@module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") -external useImperativeHandle6: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - ('a, 'b, 'c, 'd, 'e, 'f), -) => unit = "useImperativeHandle" - -@module("react") -@deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") -external useImperativeHandle7: ( - Js.Nullable.t>, - @uncurry (unit => 'value), - ('a, 'b, 'c, 'd, 'e, 'f, 'g), -) => unit = "useImperativeHandle" - -module Uncurried = { - @module("react") - external useState: (@uncurry (unit => 'state)) => ('state, (. 'state => 'state) => unit) = - "useState" - - @module("react") - external useReducer: ( - @uncurry ('state, 'action) => 'state, - 'state, - ) => ('state, (. 'action) => unit) = "useReducer" - - @module("react") - external useReducerWithMapState: ( - @uncurry ('state, 'action) => 'state, - 'initialState, - @uncurry ('initialState => 'state), - ) => ('state, (. 'action) => unit) = "useReducer" - - @module("react") - external useCallback: ('f, 'deps) => 'f = "useCallback" - - @module("react") @deprecated("Please use useCallback instead") - external useCallback0: ('f, @as(json`[]`) _) => 'f = "useCallback" - - @module("react") @deprecated("Please use useCallback instead") - external useCallback1: ('f, array<'a>) => 'f = "useCallback" - - @module("react") @deprecated("Please use useCallback instead") - external useCallback2: ('f, ('a, 'b)) => 'f = "useCallback" - - @module("react") @deprecated("Please use useCallback instead") - external useCallback3: ('f, ('a, 'b, 'c)) => 'f = "useCallback" - - @module("react") @deprecated("Please use useCallback instead") - external useCallback4: ('f, ('a, 'b, 'c, 'd)) => 'f = "useCallback" - - @module("react") @deprecated("Please use useCallback instead") - external useCallback5: ('f, ('a, 'b, 'c, 'd, 'e)) => 'f = "useCallback" - - @module("react") @deprecated("Please use useCallback instead") - external useCallback6: ('callback, ('a, 'b, 'c, 'd, 'e, 'f)) => 'callback = "useCallback" - - @module("react") @deprecated("Please use useCallback instead") - external useCallback7: ('callback, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'callback = "useCallback" -} - -@module("react") -external useTransition: unit => (bool, (. unit => unit) => unit) = "useTransition" - -@set -external setDisplayName: (component<'props>, string) => unit = "displayName" - -@get @return(nullable) -external displayName: component<'props> => option = "displayName"