diff --git a/codegen/consts.js b/codegen/consts.js index 9021ffa..69f9396 100644 --- a/codegen/consts.js +++ b/codegen/consts.js @@ -44,6 +44,7 @@ module.exports.types = { "controls": "Boolean", "dangerouslySetInnerHTML": "{ __html :: String }", "default": "Boolean", + "defaultChecked": "Boolean", "defer": "Boolean", "disabled": "Boolean", "draggable": "Boolean", @@ -66,6 +67,7 @@ module.exports.types = { "onCanPlayThrough": "EventHandler", "onChange": "EventHandler", "onClick": "EventHandler", + "onClose": "EventHandler", "onCompositionEnd": "EventHandler", "onCompositionStart": "EventHandler", "onCompositionUpdate": "EventHandler", diff --git a/codegen/index.js b/codegen/index.js index 7dda1b4..4015eaf 100644 --- a/codegen/index.js +++ b/codegen/index.js @@ -5,10 +5,15 @@ const htmlGenFile = "../src/React/Basic/DOM/Generated.purs"; const htmlSimplifiedGenFile = "../src/React/Basic/DOM/Simplified/Generated.purs"; const svgGenFile = "../src/React/Basic/DOM/SVG.purs"; -const htmlHeader = `-- | ---------------------------------------- +const warningHeader = `-- | ------------------------------------------------------------ -- | THIS FILE IS GENERATED -- DO NOT EDIT IT --- | ---------------------------------------- +-- | Instead edit files under 'codegen/' dir and regenerate with: +-- | npm install +-- | node ./index.js +-- | ------------------------------------------------------------ +`; +const htmlHeader = `${warningHeader} module React.Basic.DOM.Generated where import Data.Nullable (Nullable) @@ -23,10 +28,7 @@ import Web.DOM (Node) `; -const simplifiedHtmlHeader = `-- | ---------------------------------------- --- | THIS FILE IS GENERATED -- DO NOT EDIT IT --- | ---------------------------------------- - +const simplifiedHtmlHeader = `${warningHeader} module React.Basic.DOM.Simplified.Generated where import Data.Nullable (Nullable) @@ -55,10 +57,7 @@ const propType = (e, p) => { } } -const svgHeader = `-- | ---------------------------------------- --- | THIS FILE IS GENERATED -- DO NOT EDIT IT --- | ---------------------------------------- - +const svgHeader = `${warningHeader} module React.Basic.DOM.SVG where import Data.Nullable (Nullable) diff --git a/codegen/react-html-attributes.json b/codegen/react-html-attributes.json index be7bf9a..1f3e89d 100644 --- a/codegen/react-html-attributes.json +++ b/codegen/react-html-attributes.json @@ -233,6 +233,7 @@ "title" ], "dialog": [ + "onClose", "open" ], "embed": [ diff --git a/src/React/Basic/DOM.js b/src/React/Basic/DOM.js index de26467..257f887 100644 --- a/src/React/Basic/DOM.js +++ b/src/React/Basic/DOM.js @@ -19,3 +19,7 @@ export function unmount(node) { export function createPortal(jsx) { return (node) => ReactDOM.createPortal(jsx, node); } + +export function flushSync(callback) { + return () => ReactDOM.flushSync(callback); +} diff --git a/src/React/Basic/DOM.purs b/src/React/Basic/DOM.purs index fc20ffb..0acb058 100644 --- a/src/React/Basic/DOM.purs +++ b/src/React/Basic/DOM.purs @@ -13,6 +13,7 @@ module React.Basic.DOM , unmount , createPortal , text + , flushSync , module Generated ) where @@ -100,4 +101,15 @@ foreign import createPortal :: JSX -> Element -> JSX -- | Create a text node. text :: String -> JSX -text = unsafeCoerce \ No newline at end of file +text = unsafeCoerce + +-- | `flushSync` lets you force React to flush any updates inside the provided +-- | callback synchronously. This ensures that the DOM is updated immediately. +-- | +-- | ```purs +-- | let +-- | handleNewChatMessage msg = do +-- | flushSync (setMessages (_ <> [msg])) +-- | scrollToLastMessage +-- | ``` +foreign import flushSync :: forall a. Effect a -> Effect a diff --git a/src/React/Basic/DOM/Generated.purs b/src/React/Basic/DOM/Generated.purs index 3f6113b..03cd1c1 100644 --- a/src/React/Basic/DOM/Generated.purs +++ b/src/React/Basic/DOM/Generated.purs @@ -1,6 +1,9 @@ --- | ---------------------------------------- +-- | ------------------------------------------------------------ -- | THIS FILE IS GENERATED -- DO NOT EDIT IT --- | ---------------------------------------- +-- | Instead edit files under 'codegen/' dir and regenerate with: +-- | npm install +-- | node ./index.js +-- | ------------------------------------------------------------ module React.Basic.DOM.Generated where @@ -4310,6 +4313,7 @@ type Props_dialog = , onAnimationStart :: EventHandler , onBlur :: EventHandler , onClick :: EventHandler + , onClose :: EventHandler , onCompositionEnd :: EventHandler , onCompositionStart :: EventHandler , onCompositionUpdate :: EventHandler @@ -8180,7 +8184,7 @@ type Props_input = , dangerouslySetInnerHTML :: { __html :: String } , datatype :: String , dateTime :: String - , defaultChecked :: String + , defaultChecked :: Boolean , defaultValue :: String , dir :: String , disabled :: Boolean diff --git a/src/React/Basic/DOM/SVG.purs b/src/React/Basic/DOM/SVG.purs index c5ec0dc..2082bb1 100644 --- a/src/React/Basic/DOM/SVG.purs +++ b/src/React/Basic/DOM/SVG.purs @@ -1,6 +1,9 @@ --- | ---------------------------------------- +-- | ------------------------------------------------------------ -- | THIS FILE IS GENERATED -- DO NOT EDIT IT --- | ---------------------------------------- +-- | Instead edit files under 'codegen/' dir and regenerate with: +-- | npm install +-- | node ./index.js +-- | ------------------------------------------------------------ module React.Basic.DOM.SVG where diff --git a/src/React/Basic/DOM/Simplified/Generated.purs b/src/React/Basic/DOM/Simplified/Generated.purs index 775c396..6209ec4 100644 --- a/src/React/Basic/DOM/Simplified/Generated.purs +++ b/src/React/Basic/DOM/Simplified/Generated.purs @@ -1,6 +1,9 @@ --- | ---------------------------------------- +-- | ------------------------------------------------------------ -- | THIS FILE IS GENERATED -- DO NOT EDIT IT --- | ---------------------------------------- +-- | Instead edit files under 'codegen/' dir and regenerate with: +-- | npm install +-- | node ./index.js +-- | ------------------------------------------------------------ module React.Basic.DOM.Simplified.Generated where @@ -3884,6 +3887,7 @@ type Props_dialog = , onAnimationStart :: EventHandler , onBlur :: EventHandler , onClick :: EventHandler + , onClose :: EventHandler , onCompositionEnd :: EventHandler , onCompositionStart :: EventHandler , onCompositionUpdate :: EventHandler