@f1studio/form-spec 5.0.0-alpha.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/Designer.d.ts +89 -0
  2. package/FormSpec.TS/Components/HelloComponent.js +68 -0
  3. package/FormSpec.TS/Components/HelloComponent.js.map +1 -0
  4. package/FormSpec.TS/Components/HelloComponent.ts.map +1 -0
  5. package/FormSpec.TS/Designer.js +526 -0
  6. package/FormSpec.TS/Designer.js.map +1 -0
  7. package/FormSpec.TS/Designer.ts.map +1 -0
  8. package/FormSpec.TS/FormSpec.js +5400 -0
  9. package/FormSpec.TS/FormSpec.js.map +1 -0
  10. package/FormSpec.TS/FormSpec.ts.map +1 -0
  11. package/FormSpec.TS/FormSpecHelpers.js +382 -0
  12. package/FormSpec.TS/FormSpecHelpers.js.map +1 -0
  13. package/FormSpec.TS/FormSpecHelpers.ts.map +1 -0
  14. package/FormSpec.TS/Helpers.js +732 -0
  15. package/FormSpec.TS/Helpers.js.map +1 -0
  16. package/FormSpec.TS/Helpers.ts.map +1 -0
  17. package/FormSpec.TS/Interfaces.js +257 -0
  18. package/FormSpec.TS/Interfaces.js.map +1 -0
  19. package/FormSpec.TS/Interfaces.ts.map +1 -0
  20. package/FormSpec.TS/Interop/FormSpec.Api.Helpers.js +854 -0
  21. package/FormSpec.TS/Interop/FormSpec.Api.Helpers.js.map +1 -0
  22. package/FormSpec.TS/Interop/FormSpec.Api.Helpers.ts.map +1 -0
  23. package/FormSpec.TS/Interop/FormSpec.Api.Option.js +1961 -0
  24. package/FormSpec.TS/Interop/FormSpec.Api.Option.js.map +1 -0
  25. package/FormSpec.TS/Interop/FormSpec.Api.Option.ts.map +1 -0
  26. package/FormSpec.TS/Interop/FormSpec.Values.Api.Option.js +1367 -0
  27. package/FormSpec.TS/Interop/FormSpec.Values.Api.Option.js.map +1 -0
  28. package/FormSpec.TS/Interop/FormSpec.Values.Api.Option.ts.map +1 -0
  29. package/FormSpec.TS/Logging/LogTypes.js +347 -0
  30. package/FormSpec.TS/Logging/LogTypes.js.map +1 -0
  31. package/FormSpec.TS/Logging/LogTypes.ts.map +1 -0
  32. package/FormSpec.TS/Migrator.js +230 -0
  33. package/FormSpec.TS/Migrator.js.map +1 -0
  34. package/FormSpec.TS/Migrator.ts.map +1 -0
  35. package/FormSpec.TS/PathwayDataExtractor.js +361 -0
  36. package/FormSpec.TS/PathwayDataExtractor.js.map +1 -0
  37. package/FormSpec.TS/PathwayDataExtractor.ts.map +1 -0
  38. package/FormSpec.TS/PathwayExecutor.js +1321 -0
  39. package/FormSpec.TS/PathwayExecutor.js.map +1 -0
  40. package/FormSpec.TS/PathwayExecutor.ts.map +1 -0
  41. package/FormSpec.TS/PathwayValidator.js +346 -0
  42. package/FormSpec.TS/PathwayValidator.js.map +1 -0
  43. package/FormSpec.TS/PathwayValidator.ts.map +1 -0
  44. package/FormSpec.TS/PluginInterface.js +171 -0
  45. package/FormSpec.TS/PluginInterface.js.map +1 -0
  46. package/FormSpec.TS/PluginInterface.ts.map +1 -0
  47. package/FormSpec.TS/Prelude.js +59 -0
  48. package/FormSpec.TS/Prelude.js.map +1 -0
  49. package/FormSpec.TS/Prelude.ts.map +1 -0
  50. package/FormSpec.TS/Renderers/FormSpecMarkdownRenderer.js +958 -0
  51. package/FormSpec.TS/Renderers/FormSpecMarkdownRenderer.js.map +1 -0
  52. package/FormSpec.TS/Renderers/FormSpecMarkdownRenderer.ts.map +1 -0
  53. package/FormSpec.TS/Renderers/MermaidRenderer.js +228 -0
  54. package/FormSpec.TS/Renderers/MermaidRenderer.js.map +1 -0
  55. package/FormSpec.TS/Renderers/MermaidRenderer.ts.map +1 -0
  56. package/FormSpec.TS/Renderers/PathwayRenderers.js +190 -0
  57. package/FormSpec.TS/Renderers/PathwayRenderers.js.map +1 -0
  58. package/FormSpec.TS/Renderers/PathwayRenderers.ts.map +1 -0
  59. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Base.fs +511 -0
  60. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Base.fs.js +437 -0
  61. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Base.fs.js.map +1 -0
  62. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Base.fs.ts.map +1 -0
  63. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Error.fs +16 -0
  64. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Error.fs.js +73 -0
  65. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Error.fs.js.map +1 -0
  66. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Error.fs.ts.map +1 -0
  67. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Extensions.fs +50 -0
  68. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Extensions.fs.js +72 -0
  69. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Extensions.fs.js.map +1 -0
  70. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Extensions.fs.ts.map +1 -0
  71. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Fable.Form.fableproj +28 -0
  72. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Field.fs +24 -0
  73. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Field.fs.js +56 -0
  74. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Field.fs.js.map +1 -0
  75. package/FormSpec.TS/fable_modules/Fable.Form.3.0.0/Field.fs.ts.map +1 -0
  76. package/FormSpec.TS/fable_modules/Fable.Form.Simple.5.0.1/Fable.Form.Simple.fableproj +31 -0
  77. package/FormSpec.TS/fable_modules/Fable.Form.Simple.5.0.1/Form.fs +178 -0
  78. package/FormSpec.TS/fable_modules/Fable.Form.Simple.5.0.1/Form.fs.js +464 -0
  79. package/FormSpec.TS/fable_modules/Fable.Form.Simple.5.0.1/Form.fs.js.map +1 -0
  80. package/FormSpec.TS/fable_modules/Fable.Form.Simple.5.0.1/Form.fs.ts.map +1 -0
  81. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.Extensions.fs +17 -0
  82. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.Hooks.fs +152 -0
  83. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.Hooks.fs.js +25 -0
  84. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.Hooks.fs.js.map +1 -0
  85. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.Hooks.fs.ts.map +1 -0
  86. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.Types.fableproj +28 -0
  87. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.fs +218 -0
  88. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.fs.js +37 -0
  89. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.fs.js.map +1 -0
  90. package/FormSpec.TS/fable_modules/Fable.React.Types.18.3.0/Fable.React.fs.ts.map +1 -0
  91. package/FormSpec.TS/fable_modules/Fable.ReactDom.Types.18.2.0/Fable.ReactDom.Types.fableproj +27 -0
  92. package/FormSpec.TS/fable_modules/Fable.ReactDom.Types.18.2.0/Fable.ReactDom.fs +82 -0
  93. package/FormSpec.TS/fable_modules/Fable.ReactDom.Types.18.2.0/Fable.ReactDom.fs.js +7 -0
  94. package/FormSpec.TS/fable_modules/Fable.ReactDom.Types.18.2.0/Fable.ReactDom.fs.js.map +1 -0
  95. package/FormSpec.TS/fable_modules/Fable.ReactDom.Types.18.2.0/Fable.ReactDom.fs.ts.map +1 -0
  96. package/FormSpec.TS/fable_modules/Feliz.2.7.0/BorderStyle.fs +59 -0
  97. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Colors.fs +154 -0
  98. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Colors.fs.js +32 -0
  99. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Colors.fs.js.map +1 -0
  100. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Colors.fs.ts.map +1 -0
  101. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Feliz.fableproj +42 -0
  102. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Fonts.fs +240 -0
  103. package/FormSpec.TS/fable_modules/Feliz.2.7.0/GridTypes.fs +24 -0
  104. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Html.fs +826 -0
  105. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Interop.fs +83 -0
  106. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Interop.fs.js +292 -0
  107. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Interop.fs.js.map +1 -0
  108. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Interop.fs.ts.map +1 -0
  109. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Key.fs +65 -0
  110. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Key.fs.js +229 -0
  111. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Key.fs.js.map +1 -0
  112. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Key.fs.ts.map +1 -0
  113. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Length.fs +91 -0
  114. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Locale.fs +876 -0
  115. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Properties.fs +4080 -0
  116. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Properties.fs.js +133 -0
  117. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Properties.fs.js.map +1 -0
  118. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Properties.fs.ts.map +1 -0
  119. package/FormSpec.TS/fable_modules/Feliz.2.7.0/React.fs +656 -0
  120. package/FormSpec.TS/fable_modules/Feliz.2.7.0/React.fs.js +561 -0
  121. package/FormSpec.TS/fable_modules/Feliz.2.7.0/React.fs.js.map +1 -0
  122. package/FormSpec.TS/fable_modules/Feliz.2.7.0/React.fs.ts.map +1 -0
  123. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactDOM.fs +25 -0
  124. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactDOM.fs.js +46 -0
  125. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactDOM.fs.js.map +1 -0
  126. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactDOM.fs.ts.map +1 -0
  127. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactInterop.js +63 -0
  128. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactInterop.js.map +1 -0
  129. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactTypes.fs +41 -0
  130. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactTypes.fs.js +7 -0
  131. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactTypes.fs.js.map +1 -0
  132. package/FormSpec.TS/fable_modules/Feliz.2.7.0/ReactTypes.fs.ts.map +1 -0
  133. package/FormSpec.TS/fable_modules/Feliz.2.7.0/StyleTypes.fs +53 -0
  134. package/FormSpec.TS/fable_modules/Feliz.2.7.0/StyleTypes.fs.js +7 -0
  135. package/FormSpec.TS/fable_modules/Feliz.2.7.0/StyleTypes.fs.js.map +1 -0
  136. package/FormSpec.TS/fable_modules/Feliz.2.7.0/StyleTypes.fs.ts.map +1 -0
  137. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Styles.fs +5740 -0
  138. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Svg.fs +1455 -0
  139. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Svg.fs.js +39 -0
  140. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Svg.fs.js.map +1 -0
  141. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Svg.fs.ts.map +1 -0
  142. package/FormSpec.TS/fable_modules/Feliz.2.7.0/TextDecorationLine.fs +13 -0
  143. package/FormSpec.TS/fable_modules/Feliz.2.7.0/TextDecorationStyle.fs +33 -0
  144. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Transform.fs +181 -0
  145. package/FormSpec.TS/fable_modules/Feliz.2.7.0/TransformOrigin.fs +17 -0
  146. package/FormSpec.TS/fable_modules/Feliz.2.7.0/TransitionProperty.fs +162 -0
  147. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Types.fs +13 -0
  148. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Types.fs.js +7 -0
  149. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Types.fs.js.map +1 -0
  150. package/FormSpec.TS/fable_modules/Feliz.2.7.0/Types.fs.ts.map +1 -0
  151. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Decode.fs +1768 -0
  152. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Decode.fs.js +2337 -0
  153. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Decode.fs.js.map +1 -0
  154. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Decode.fs.ts.map +1 -0
  155. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs +811 -0
  156. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.js +465 -0
  157. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.js.map +1 -0
  158. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.ts.map +1 -0
  159. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Extra.fs +47 -0
  160. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Extra.fs.js +18 -0
  161. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Extra.fs.js.map +1 -0
  162. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Extra.fs.ts.map +1 -0
  163. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Thoth.Json.fableproj +34 -0
  164. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Types.fs +68 -0
  165. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Types.fs.js +355 -0
  166. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Types.fs.js.map +1 -0
  167. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Types.fs.ts.map +1 -0
  168. package/FormSpec.TS/fable_modules/project_cracked.json +1 -0
  169. package/FormSpec.d.ts +1257 -0
  170. package/FormSpecHelpers.d.ts +50 -0
  171. package/Helpers.d.ts +147 -0
  172. package/Interfaces.d.ts +70 -0
  173. package/Interop/FormSpec.Api.Helpers.d.ts +247 -0
  174. package/Interop/FormSpec.Api.Helpers.d.ts.map +1 -0
  175. package/Interop/FormSpec.Api.Option.d.ts +384 -0
  176. package/Interop/FormSpec.Api.Option.d.ts.map +1 -0
  177. package/Interop/FormSpec.Values.Api.Option.d.ts +324 -0
  178. package/Interop/FormSpec.Values.Api.Option.d.ts.map +1 -0
  179. package/Migrator.d.ts +59 -0
  180. package/PathwayDataExtractor.d.ts +19 -0
  181. package/PathwayExecutor.d.ts +210 -0
  182. package/PathwayValidator.d.ts +52 -0
  183. package/PluginInterface.d.ts +36 -0
  184. package/Prelude.d.ts +11 -0
  185. package/README.TS.md +622 -0
  186. package/README.md +85 -0
  187. package/package.json +39 -0
  188. package/src/Components/HelloComponent.ts +48 -0
  189. package/src/Components/HelloComponent.ts.map +1 -0
  190. package/src/Designer.ts +389 -0
  191. package/src/Designer.ts.map +1 -0
  192. package/src/FormSpec.ts +3114 -0
  193. package/src/FormSpec.ts.map +1 -0
  194. package/src/FormSpecHelpers.ts +374 -0
  195. package/src/FormSpecHelpers.ts.map +1 -0
  196. package/src/Helpers.ts +765 -0
  197. package/src/Helpers.ts.map +1 -0
  198. package/src/Interfaces.ts +166 -0
  199. package/src/Interfaces.ts.map +1 -0
  200. package/src/Interop/FormSpec.Api.Helpers.ts +872 -0
  201. package/src/Interop/FormSpec.Api.Helpers.ts.map +1 -0
  202. package/src/Interop/FormSpec.Api.Option.ts +1618 -0
  203. package/src/Interop/FormSpec.Api.Option.ts.map +1 -0
  204. package/src/Interop/FormSpec.Values.Api.Option.ts +1214 -0
  205. package/src/Interop/FormSpec.Values.Api.Option.ts.map +1 -0
  206. package/src/Logging/LogTypes.ts +212 -0
  207. package/src/Logging/LogTypes.ts.map +1 -0
  208. package/src/Migrator.ts +156 -0
  209. package/src/Migrator.ts.map +1 -0
  210. package/src/PathwayDataExtractor.ts +290 -0
  211. package/src/PathwayDataExtractor.ts.map +1 -0
  212. package/src/PathwayExecutor.ts +1102 -0
  213. package/src/PathwayExecutor.ts.map +1 -0
  214. package/src/PathwayValidator.ts +244 -0
  215. package/src/PathwayValidator.ts.map +1 -0
  216. package/src/PluginInterface.ts +79 -0
  217. package/src/PluginInterface.ts.map +1 -0
  218. package/src/Prelude.ts +21 -0
  219. package/src/Prelude.ts.map +1 -0
  220. package/src/Renderers/FormSpecMarkdownRenderer.ts +874 -0
  221. package/src/Renderers/FormSpecMarkdownRenderer.ts.map +1 -0
  222. package/src/Renderers/MermaidRenderer.ts +218 -0
  223. package/src/Renderers/MermaidRenderer.ts.map +1 -0
  224. package/src/Renderers/PathwayRenderers.ts +200 -0
  225. package/src/Renderers/PathwayRenderers.ts.map +1 -0
@@ -0,0 +1,656 @@
1
+ namespace Feliz
2
+
3
+ open System
4
+ open System.ComponentModel
5
+ open Fable.Core
6
+ open Fable.Core.JsInterop
7
+ open Browser.Types
8
+
9
+ module internal ReactInterop =
10
+ let useDebugValueWithFormatter<'t>(value: 't, formatter: 't -> string) : unit = import "useDebugValue" "./ReactInterop.js"
11
+ let useEffect (effect: obj) : unit = import "useEffect" "./ReactInterop.js"
12
+ let useEffectWithDeps (effect: obj) (deps: obj) : unit = import "useEffectWithDeps" "./ReactInterop.js"
13
+ let useLayoutEffect (effect: obj) : unit = import "useLayoutEffect" "./ReactInterop.js"
14
+ let useLayoutEffectWithDeps (effect: obj) (deps: obj) : unit = import "useLayoutEffectWithDeps" "./ReactInterop.js"
15
+
16
+ [<EditorBrowsable(EditorBrowsableState.Never);Erase>]
17
+ [<RequireQualifiedAccess>]
18
+ module Helpers =
19
+ let inline optDispose (disposeOption: #IDisposable option) =
20
+ { new IDisposable with member _.Dispose () = disposeOption |> Option.iter (fun d -> d.Dispose()) }
21
+
22
+ type internal Internal() =
23
+ static let propsWithKey (withKey: ('props -> string) option) props =
24
+ match withKey with
25
+ | Some f ->
26
+ props?key <- f props
27
+ props
28
+ | None -> props
29
+ static member
30
+ functionComponent
31
+ (
32
+ renderElement: 'props -> ReactElement,
33
+ ?name: string,
34
+ ?withKey: 'props -> string
35
+ )
36
+ : 'props -> Fable.React.ReactElement =
37
+ name |> Option.iter (fun name -> renderElement?displayName <- name)
38
+ #if FABLE_COMPILER_3
39
+ Browser.Dom.console.warn("Feliz: using React.functionComponent in Fable 3 is obsolete, please consider using the [<ReactComponent>] attribute instead which makes Feliz output better Javascript code that is compatible with react-refresh")
40
+ #endif
41
+ fun props ->
42
+ let props = props |> propsWithKey withKey
43
+ Interop.reactApi.createElement(renderElement, props)
44
+ static member
45
+ memo
46
+ (
47
+ renderElement: 'props -> ReactElement,
48
+ ?name: string,
49
+ ?areEqual: 'props -> 'props -> bool,
50
+ ?withKey: 'props -> string
51
+ )
52
+ : 'props -> Fable.React.ReactElement =
53
+ let memoElementType = Interop.reactApi.memo(renderElement, (defaultArg areEqual (unbox null)))
54
+ name |> Option.iter (fun name -> renderElement?displayName <- name)
55
+ fun props ->
56
+ let props = props |> propsWithKey withKey
57
+ Interop.reactApi.createElement(memoElementType, props)
58
+
59
+ type React =
60
+ /// Creates a disposable instance by providing the implementation of the dispose member.
61
+ static member createDisposable(dispose: unit -> unit) =
62
+ { new IDisposable with member _.Dispose() = dispose() }
63
+
64
+ /// The `React.fragment` component lets you return multiple elements in your `render()` method without creating an additional DOM element.
65
+ static member inline fragment xs =
66
+ Fable.React.ReactBindings.React.createElement(Fable.React.ReactBindings.React.Fragment, obj(), xs)
67
+
68
+ /// The `React.fragment` component lets you return multiple elements in your `render()` method without creating an additional DOM element.
69
+ static member inline keyedFragment(key: int, xs) = // Fable.React.Helpers.fragment [ !!("key", key) ] xs
70
+ Fable.React.ReactBindings.React.createElement(Fable.React.ReactBindings.React.Fragment, createObj ["key" ==> key], xs)
71
+
72
+ /// The `React.fragment` component lets you return multiple elements in your `render()` method without creating an additional DOM element.
73
+ static member inline keyedFragment(key: string, xs) =
74
+ Fable.React.ReactBindings.React.createElement(Fable.React.ReactBindings.React.Fragment, createObj ["key" ==> key], xs)
75
+
76
+ /// The `React.fragment` component lets you return multiple elements in your `render()` method without creating an additional DOM element.
77
+ static member inline keyedFragment(key: System.Guid, xs) =
78
+ Fable.React.ReactBindings.React.createElement(Fable.React.ReactBindings.React.Fragment, createObj ["key" ==> string key], xs)
79
+
80
+ /// Placeholder empty React element to be used when importing external React components with the `[<ReactComponent>]` attribute.
81
+ static member inline imported() = Html.none
82
+
83
+ /// The `useState` hook that creates a state variable for React function components from an initialization function.
84
+ [<Hook>]
85
+ static member useState<'t>(initializer: unit -> 't) = Interop.reactApi.useState<unit -> 't,'t>(initializer)
86
+
87
+ /// Accepts a reducer and returns the current state paired with a dispatch.
88
+ [<Hook>]
89
+ static member useReducer(update, initialState) = Interop.reactApi.useReducer update initialState
90
+
91
+ /// The `useEffect` hook that creates a disposable effect for React function components.
92
+ /// This effect has no dependencies which means the effect is re-executed on every re-render.
93
+ /// To make the effect run once (for example you subscribe once to web sockets) then provide an empty array
94
+ /// for the dependencies: `React.useEffect(disposableEffect, [| |])`.
95
+ [<Hook>]
96
+ static member useEffect(effect: unit -> #IDisposable) : unit = ReactInterop.useEffect(effect)
97
+ /// The `useEffect` hook that creates a disposable effect for React function components.
98
+ /// This effect has no dependencies which means the effect is re-executed on every re-render.
99
+ /// To make the effect run once (for example you subscribe once to web sockets) then provide an empty array
100
+ /// for the dependencies: `React.useEffect(disposableEffect, [| |])`.
101
+ [<Hook>]
102
+ static member inline useEffect(effect: unit -> #IDisposable option) = React.useEffect(effect >> Helpers.optDispose)
103
+ /// The `useEffect` hook that creates a disposable effect for React function components.
104
+ /// This effect takes an array of *dependencies*.
105
+ /// Whenever any of these dependencies change, the effect is re-executed. To execute the effect only once,
106
+ /// you have to explicitly provide an empty array for the dependencies: `React.useEffect(effect, [| |])`.
107
+ [<Hook>]
108
+ static member useEffect(effect: unit -> #IDisposable, dependencies: obj []) : unit = ReactInterop.useEffectWithDeps effect dependencies
109
+ /// The `useEffect` hook that creates a disposable effect for React function components.
110
+ /// This effect takes an array of *dependencies*.
111
+ /// Whenever any of these dependencies change, the effect is re-executed. To execute the effect only once,
112
+ /// you have to explicitly provide an empty array for the dependencies: `React.useEffect(effect, [| |])`.
113
+ [<Hook>]
114
+ static member inline useEffect(effect: unit -> #IDisposable option, dependencies: obj []) = React.useEffect(effect >> Helpers.optDispose, dependencies)
115
+
116
+ /// The `useLayoutEffect` hook that creates a disposable effect for React function components.
117
+ /// This effect has no dependencies which means the effect is re-executed on every re-render.
118
+ /// To make the effect run once (for example you subscribe once to web sockets) then provide an empty array
119
+ /// for the dependencies: `React.useLayoutEffect(disposableEffect, [| |])`.
120
+ /// The signature is identical to useEffect, but it fires synchronously after all DOM mutations. Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside useLayoutEffect will be flushed synchronously, before the browser has a chance to paint.
121
+ [<Hook>]
122
+ static member useLayoutEffect(effect: unit -> #IDisposable) : unit = ReactInterop.useLayoutEffect(effect)
123
+ /// The `useLayoutEffect` hook that creates a disposable effect for React function components.
124
+ /// This effect has no dependencies which means the effect is re-executed on every re-render.
125
+ /// To make the effect run once (for example you subscribe once to web sockets) then provide an empty array
126
+ /// for the dependencies: `React.useLayoutEffect(disposableEffect, [| |])`.
127
+ /// The signature is identical to useEffect, but it fires synchronously after all DOM mutations. Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside useLayoutEffect will be flushed synchronously, before the browser has a chance to paint.
128
+ [<Hook>]
129
+ static member inline useLayoutEffect(effect: unit -> #IDisposable option) = React.useLayoutEffect(effect >> Helpers.optDispose)
130
+ /// The `useLayoutEffect` hook that creates a disposable effect for React function components.
131
+ /// This effect takes an array of *dependencies*.
132
+ /// Whenever any of these dependencies change, the effect is re-executed. To execute the effect only once,
133
+ /// you have to explicitly provide an empty array for the dependencies: `React.useLayoutEffect(effect, [| |])`.
134
+ /// The signature is identical to useEffect, but it fires synchronously after all DOM mutations. Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside useLayoutEffect will be flushed synchronously, before the browser has a chance to paint.
135
+ [<Hook>]
136
+ static member useLayoutEffect(effect: unit -> #IDisposable, dependencies: obj []) : unit = ReactInterop.useLayoutEffectWithDeps effect dependencies
137
+ /// The `useLayoutEffect` hook that creates a disposable effect for React function components.
138
+ /// This effect takes an array of *dependencies*.
139
+ /// Whenever any of these dependencies change, the effect is re-executed. To execute the effect only once,
140
+ /// you have to explicitly provide an empty array for the dependencies: `React.useLayoutEffect(effect, [| |])`.
141
+ /// The signature is identical to useEffect, but it fires synchronously after all DOM mutations. Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside useLayoutEffect will be flushed synchronously, before the browser has a chance to paint.
142
+ [<Hook>]
143
+ static member inline useLayoutEffect(effect: unit -> #IDisposable option, dependencies: obj []) =
144
+ React.useLayoutEffect(effect >> Helpers.optDispose, dependencies)
145
+
146
+ /// The signature is identical to useEffect, but it fires synchronously after all DOM mutations. Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside useLayoutEffect will be flushed synchronously, before the browser has a chance to paint.
147
+ /// This effect is executed on every (re)render
148
+ [<Hook>]
149
+ static member useLayoutEffect(effect: unit -> unit) =
150
+ ReactInterop.useLayoutEffect
151
+ (fun _ ->
152
+ effect()
153
+ React.createDisposable(ignore))
154
+
155
+ /// The signature is identical to useEffect, but it fires synchronously after all DOM mutations. Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside useLayoutEffect will be flushed synchronously, before the browser has a chance to paint.
156
+ [<Hook>]
157
+ static member useLayoutEffect(effect: unit -> unit, dependencies: obj []) =
158
+ ReactInterop.useLayoutEffectWithDeps
159
+ (fun _ ->
160
+ effect()
161
+ React.createDisposable(ignore))
162
+ dependencies
163
+
164
+ [<Hook>]
165
+ static member inline useLayoutEffectOnce(effect: unit -> unit) =
166
+ React.useLayoutEffect(effect, [| |])
167
+
168
+ [<Hook>]
169
+ static member inline useLayoutEffectOnce(effect: unit -> #IDisposable) =
170
+ React.useLayoutEffect(effect, [| |])
171
+
172
+ [<Hook>]
173
+ static member inline useLayoutEffectOnce(effect: unit -> #IDisposable option) =
174
+ React.useLayoutEffect(effect, [| |])
175
+
176
+ /// React hook to define and use an effect only once when a function component renders for the first time.
177
+ /// This is an alias for `React.useEffect(effect, [| |])` which explicitly provides an empty array for the dependencies of the effect which means the effect will only run once.
178
+ [<Hook>]
179
+ static member useEffectOnce(effect: unit -> unit) =
180
+ let calledOnce = Interop.reactApi.useRefInternal false
181
+
182
+ React.useEffect (fun () ->
183
+ if calledOnce.current
184
+ then ()
185
+ else
186
+ calledOnce.current <- true
187
+ effect()
188
+ , [||])
189
+
190
+ /// React hook to define and use a disposable effect only once when a function component renders for the first time.
191
+ /// This is an alias for `React.useEffect(effect, [| |])` which explicitly provides an empty array for the dependencies of the effect which means the effect will only run once.
192
+ [<Hook>]
193
+ static member useEffectOnce(effect: unit -> #IDisposable) =
194
+ let destroyFunc = Interop.reactApi.useRefInternal None
195
+ let calledOnce = Interop.reactApi.useRefInternal false
196
+ let renderAfterCalled = Interop.reactApi.useRefInternal false
197
+
198
+ if calledOnce.current then
199
+ renderAfterCalled.current <- true
200
+
201
+ React.useEffect (fun () ->
202
+ if calledOnce.current
203
+ then None
204
+ else
205
+ calledOnce.current <- true
206
+ destroyFunc.current <- effect() |> Some
207
+
208
+ if renderAfterCalled.current
209
+ then destroyFunc.current
210
+ else None
211
+ , [||])
212
+
213
+ /// React hook to define and use a disposable effect only once when a function component renders for the first time.
214
+ /// This is an alias for `React.useEffect(effect, [| |])` which explicitly provide an empty array for the dependencies of the effect which means the effect will only run once.
215
+ [<Hook>]
216
+ static member useEffectOnce(effect: unit -> #IDisposable option) =
217
+ let destroyFunc = Interop.reactApi.useRefInternal None
218
+ let calledOnce = Interop.reactApi.useRefInternal false
219
+ let renderAfterCalled = Interop.reactApi.useRefInternal false
220
+
221
+ if calledOnce.current then
222
+ renderAfterCalled.current <- true
223
+
224
+ React.useEffect (fun () ->
225
+ if calledOnce.current
226
+ then None
227
+ else
228
+ calledOnce.current <- true
229
+ destroyFunc.current <- effect()
230
+
231
+ if renderAfterCalled.current
232
+ then destroyFunc.current
233
+ else None
234
+ , [||])
235
+
236
+ /// The `useEffect` hook that creates an effect for React function components.
237
+ /// This effect is executed *every time* the function component re-renders.
238
+ ///
239
+ /// To make the effect run only once, write: `React.useEffect(effect, [| |])` which explicitly states
240
+ /// that this effect has no dependencies and should only run once on initial render.
241
+ [<Hook>]
242
+ static member useEffect(effect: unit -> unit) : unit =
243
+ ReactInterop.useEffect
244
+ (fun _ ->
245
+ effect()
246
+ React.createDisposable(ignore))
247
+
248
+ /// The `useEffect` hook that creates an effect for React function components. This effect takes an array of *dependencies*.
249
+ /// Whenever any of these dependencies change, the effect is re-executed. To execute the effect only once,
250
+ /// you have to explicitly provide an empty array for the dependencies: `React.useEffect(effect, [| |])`.
251
+ [<Hook>]
252
+ static member useEffect(effect: unit -> unit, dependencies: obj []) : unit =
253
+ ReactInterop.useEffectWithDeps
254
+ (fun _ ->
255
+ effect()
256
+ React.createDisposable(ignore))
257
+ dependencies
258
+
259
+ /// Can be used to display a label for custom hooks in React DevTools.
260
+ [<Hook>]
261
+ static member useDebugValue(value: string) =
262
+ ReactInterop.useDebugValueWithFormatter(value, id)
263
+
264
+ /// Can be used to display a label for custom hooks in React DevTools.
265
+ [<Hook>]
266
+ static member useDebugValue(value: 't, formatter: 't -> string) =
267
+ ReactInterop.useDebugValueWithFormatter(value, formatter)
268
+
269
+ /// <summary>
270
+ /// The `useCallback` hook. Returns a memoized callback. Pass an inline callback and an array of dependencies.
271
+ /// `useCallback` will return a memoized version of the callback that only changes if one of the dependencies has changed.
272
+ /// </summary>
273
+ /// <param name='callbackFunction'>A callback function to be memoized.</param>
274
+ /// <param name='dependencies'>An array of dependencies upon which the callback function depends.
275
+ /// If not provided, defaults to empty array, representing dependencies that never change.</param>
276
+ [<Hook>]
277
+ static member useCallback(callbackFunction: 'a -> 'b, ?dependencies: obj array) =
278
+ Interop.reactApi.useCallback callbackFunction (defaultArg dependencies [||])
279
+
280
+ /// Returns a mutable ref object whose .current property is initialized to the passed argument (initialValue). The returned object will persist for the full lifetime of the component.
281
+ ///
282
+ /// Essentially, useRef is like a container that can hold a mutable value in its .current property.
283
+ [<Hook>]
284
+ static member useRef<'t>(initialValue: 't) = Interop.reactApi.useRefInternal(initialValue)
285
+
286
+ /// A specialized version of React.useRef() that creates a reference to an input element.
287
+ ///
288
+ /// Useful for controlling the internal properties and methods of that element, for example to enable focus().
289
+ [<Hook>]
290
+ static member useInputRef() : IRefValue<HTMLInputElement option> = React.useRef(None)
291
+
292
+ /// A specialized version of React.useRef() that creates a reference to a button element.
293
+ [<Hook>]
294
+ static member useButtonRef() : Fable.React.IRefValue<HTMLButtonElement option> = React.useRef(None)
295
+
296
+ /// A specialized version of React.useRef() that creates a reference to a generic HTML element.
297
+ ///
298
+ /// Useful for controlling the internal properties and methods of that element, for integration with third-party libraries that require a Html element.
299
+ [<Hook>]
300
+ static member useElementRef() : IRefValue<HTMLElement option> = React.useRef(None)
301
+
302
+ /// <summary>
303
+ /// The `useMemo` hook. Returns a memoized value. Pass a "create" function and an array of dependencies.
304
+ /// `useMemo` will only recompute the memoized value when one of the dependencies has changed.
305
+ /// </summary>
306
+ /// <param name='createFunction'>A create function returning a value to be memoized.</param>
307
+ /// <param name='dependencies'>An array of dependencies upon which the create function depends.
308
+ /// If not provided, defaults to empty array, representing dependencies that never change.</param>
309
+ [<Hook>]
310
+ static member useMemo(createFunction: unit -> 'a, ?dependencies: obj array) =
311
+ Interop.reactApi.useMemo createFunction (defaultArg dependencies [||])
312
+
313
+ //
314
+ // React.functionComponent
315
+ //
316
+
317
+ /// <summary>
318
+ /// Creates a React function component from a function that accepts a "props" object and renders a result.
319
+ /// A component key can be provided in the props object, or a custom `withKey` function can be provided.
320
+ /// </summary>
321
+ /// <param name='render'>A render function that returns an element.</param>
322
+ /// <param name='withKey'>A function to derive a component key from the props.</param>
323
+ static member functionComponent(render: 'props -> ReactElement, ?withKey: 'props -> string) =
324
+ Internal.functionComponent(render, ?withKey=withKey)
325
+
326
+ /// <summary>
327
+ /// Creates a React function component from a function that accepts a "props" object and renders a result.
328
+ /// A component key can be provided in the props object, or a custom `withKey` function can be provided.
329
+ /// </summary>
330
+ /// <param name='name'>The component name to display in the React dev tools.</param>
331
+ /// <param name='render'>A render function that returns an element.</param>
332
+ /// <param name='withKey'>A function to derive a component key from the props.</param>
333
+ [<Obsolete "React.functionComponent is obsolete. Use [<ReactComponent>] attribute to automatically convert them to React components">]
334
+ static member functionComponent(name: string, render: 'props -> ReactElement, ?withKey: 'props -> string) =
335
+ Internal.functionComponent(render, name, ?withKey=withKey)
336
+
337
+ /// <summary>
338
+ /// Creates a React function component from a function that accepts a "props" object and renders a result.
339
+ /// A component key can be provided in the props object, or a custom `withKey` function can be provided.
340
+ /// </summary>
341
+ /// <param name='render'>A render function that returns a list of elements.</param>
342
+ /// <param name='withKey'>A function to derive a component key from the props.</param>
343
+ [<Obsolete "React.functionComponent is obsolete. Use [<ReactComponent>] attribute to automatically convert them to React components">]
344
+ static member functionComponent(render: 'props -> #seq<ReactElement>, ?withKey: 'props -> string) =
345
+ Internal.functionComponent(render >> React.fragment, ?withKey=withKey)
346
+
347
+ /// <summary>
348
+ /// Creates a React function component from a function that accepts a "props" object and renders a result.
349
+ /// A component key can be provided in the props object, or a custom `withKey` function can be provided.
350
+ /// </summary>
351
+ /// <param name='render'>A render function that returns a list of elements.</param>
352
+ /// <param name='name'>The component name to display in the React dev tools.</param>
353
+ /// <param name='withKey'>A function to derive a component key from the props.</param>
354
+ [<Obsolete "React.functionComponent is obsolete. Use [<ReactComponent>] attribute to automatically convert them to React components">]
355
+ static member functionComponent(name: string, render: 'props -> #seq<ReactElement>, ?withKey: 'props -> string) =
356
+ Internal.functionComponent(render >> React.fragment, name, ?withKey=withKey)
357
+
358
+ //
359
+ // React.memo
360
+ //
361
+
362
+ /// <summary>
363
+ /// `React.memo` memoizes the result of a function component. Given the same props, React will skip rendering the component, and reuse the last rendered result.
364
+ /// By default it will only shallowly compare complex objects in the props object. For more control, a custom `areEqual` function can be provided.
365
+ /// A component key can be provided in the props object, or a custom `withKey` function can be provided.
366
+ /// </summary>
367
+ /// <param name='render'>A render function or a React.functionComponent.</param>
368
+ /// <param name='areEqual'>A custom comparison function to use instead of React's default shallow compare.</param>
369
+ /// <param name='withKey'>A function to derive a component key from the props.</param>
370
+ static member memo(render: 'props -> ReactElement, ?withKey: 'props -> string, ?areEqual: 'props -> 'props -> bool) =
371
+ Internal.memo(render, ?areEqual=areEqual, ?withKey=withKey)
372
+
373
+ /// <summary>
374
+ /// `React.memo` memoizes the result of a function component. Given the same props, React will skip rendering the component, and reuse the last rendered result.
375
+ /// By default it will only shallowly compare complex objects in the props object. For more control, a custom `areEqual` function can be provided.
376
+ /// A component key can be provided in the props object, or a custom `withKey` function can be provided.
377
+ /// </summary>
378
+ /// <param name='name'>The component name to display in the React dev tools.</param>
379
+ /// <param name='render'>A render function or a React.functionComponent.</param>
380
+ /// <param name='areEqual'>A custom comparison function to use instead of React's default shallow compare.</param>
381
+ /// <param name='withKey'>A function to derive a component key from the props.</param>
382
+ static member memo(name: string, render: 'props -> ReactElement, ?withKey: 'props -> string, ?areEqual: 'props -> 'props -> bool) =
383
+ Internal.memo(render, name, ?areEqual=areEqual, ?withKey=withKey)
384
+
385
+ /// <summary>
386
+ /// `React.memo` memoizes the result of a function component. Given the same props, React will skip rendering the component, and reuse the last rendered result.
387
+ /// By default it will only shallowly compare complex objects in the props object. For more control, a custom `areEqual` function can be provided.
388
+ /// A component key can be provided in the props object, or a custom `withKey` function can be provided.
389
+ /// </summary>
390
+ /// <param name='render'>A render function that returns a list of elements.</param>
391
+ /// <param name='withKey'>A function to derive a component key from the props.</param>
392
+ /// <param name='areEqual'>A custom comparison function to use instead of React's default shallow compare.</param>
393
+ static member memo(render: 'props -> #seq<ReactElement>, ?withKey: 'props -> string, ?areEqual: 'props -> 'props -> bool) =
394
+ Internal.memo(render >> React.fragment, ?areEqual=areEqual, ?withKey=withKey)
395
+
396
+ /// <summary>
397
+ /// `React.memo` memoizes the result of a function component. Given the same props, React will skip rendering the component, and reuse the last rendered result.
398
+ /// By default it will only shallowly compare complex objects in the props object. For more control, a custom `areEqual` function can be provided.
399
+ /// A component key can be provided in the props object, or a custom `withKey` function can be provided.
400
+ /// </summary>
401
+ /// <param name='name'>The component name to display in the React dev tools.</param>
402
+ /// <param name='render'>A render function that returns a list of elements.</param>
403
+ /// <param name='withKey'>A function to derive a component key from the props.</param>
404
+ /// <param name='areEqual'>A custom comparison function to use instead of React's default shallow compare.</param>
405
+ static member memo(name: string, render: 'props -> #seq<ReactElement>, ?withKey: 'props -> string, ?areEqual: 'props -> 'props -> bool) =
406
+ Internal.memo(render >> React.fragment, name, ?areEqual=areEqual, ?withKey=withKey)
407
+
408
+ //
409
+ // React.useContext
410
+ //
411
+
412
+ /// <summary>
413
+ /// Creates a Context object. When React renders a component that subscribes to this Context object
414
+ /// it will read the current context value from the closest matching Provider above it in the tree.
415
+ /// </summary>
416
+ /// <param name='name'>The component name to display in the React dev tools.</param>
417
+ /// <param name='defaultValue'>A default value that is only used when a component does not have a matching Provider above it in the tree.</param>
418
+ static member createContext<'a>(?name: string, ?defaultValue: 'a) =
419
+ let contextObject = Interop.reactApi.createContext (defaultArg defaultValue Fable.Core.JS.undefined<'a>)
420
+ name |> Option.iter (fun name -> contextObject?displayName <- name)
421
+ contextObject
422
+
423
+ /// <summary>
424
+ /// A Provider component that allows consuming components to subscribe to context changes.
425
+ /// </summary>
426
+ /// <param name='contextObject'>A context object returned from a previous React.createContext call.</param>
427
+ /// <param name='contextValue'>The context value to be provided to descendant components.</param>
428
+ /// <param name='child'>A child element.</param>
429
+ static member contextProvider(contextObject: Fable.React.IContext<'a>, contextValue: 'a, child: ReactElement) : ReactElement =
430
+ Interop.reactApi.createElement(contextObject?Provider, createObj ["value" ==> contextValue], [child])
431
+ /// <summary>
432
+ /// A Provider component that allows consuming components to subscribe to context changes.
433
+ /// </summary>
434
+ /// <param name='contextObject'>A context object returned from a previous React.createContext call.</param>
435
+ /// <param name='contextValue'>The context value to be provided to descendant components.</param>
436
+ /// <param name='children'>A sequence of child elements.</param>
437
+ static member contextProvider(contextObject: Fable.React.IContext<'a>, contextValue: 'a, children: #seq<ReactElement>) : ReactElement =
438
+ Interop.reactApi.createElement(contextObject?Provider, createObj ["value" ==> contextValue], children)
439
+
440
+ /// <summary>
441
+ /// A Consumer component that subscribes to context changes.
442
+ /// </summary>
443
+ /// <param name='contextObject'>A context object returned from a previous React.createContext call.</param>
444
+ /// <param name='render'>A render function that returns an element.</param>
445
+ static member contextConsumer(contextObject: Fable.React.IContext<'a>, render: 'a -> ReactElement) : ReactElement =
446
+ Interop.reactApi.createElement(contextObject?Consumer, null, [!!render])
447
+ /// <summary>
448
+ /// A Consumer component that subscribes to context changes.
449
+ /// </summary>
450
+ /// <param name='contextObject'>A context object returned from a previous React.createContext call.</param>
451
+ /// <param name='render'>A render function that returns a sequence of elements.</param>
452
+ static member contextConsumer(contextObject: Fable.React.IContext<'a>, render: 'a -> #seq<ReactElement>) : ReactElement =
453
+ Interop.reactApi.createElement(contextObject?Consumer, null, [!!(render >> React.fragment)])
454
+
455
+ /// <summary>
456
+ /// The `useContext` hook. Accepts a context object (the value returned from React.createContext) and returns the current context value for that context.
457
+ /// The current context value is determined by the value prop of the nearest Provider component above the calling component in the tree.
458
+ /// </summary>
459
+ /// <param name='contextObject'>A context object returned from a previous React.createContext call.</param>
460
+ [<Hook>]
461
+ static member useContext(contextObject: Fable.React.IContext<'a>) = Interop.reactApi.useContext contextObject
462
+
463
+ /// <summary>
464
+ /// Creates a callback that keeps the same reference during the entire lifecycle of the component while having access to
465
+ /// the current value of the dependencies on every call.
466
+ ///
467
+ /// This hook should only be used for (like a dispatch) functions that are not used to provide information during render.
468
+ ///
469
+ /// This is not a complete replacement for the `useCallback` hook. It returns a callback that does not need explicit
470
+ /// dependency declarations and never causes a re-render.
471
+ /// </summary>
472
+ /// <param name='callback'>The function call.</param>
473
+ [<Hook>]
474
+ static member useCallbackRef(callback: ('a -> 'b)) =
475
+ let lastRenderCallbackRef = React.useRef(callback)
476
+
477
+ let callbackRef =
478
+ React.useCallback((fun (arg: 'a) ->
479
+ lastRenderCallbackRef.current(arg)
480
+ ), [||])
481
+
482
+ React.useLayoutEffect(fun () ->
483
+ // render is commited - it's safe to update the callback
484
+ lastRenderCallbackRef.current <- callback
485
+ )
486
+
487
+ callbackRef
488
+
489
+ /// <summary>
490
+ /// Just like React.useState except that the updater function uses the previous state of the state variable as input and allows you to compute the next value using it.
491
+ /// This is useful in cases where defining helpers functions inside the definition of a React function component would actually cache the initial value (because they become closures) during first render as opposed to using the current value after multiple render cycles.
492
+ ///
493
+ /// Use this instead of React.useState when your state variable is a list, an array, a dictionary, a map or other complex structures.
494
+ /// </summary>
495
+ static member useStateWithUpdater (initial: 't) : ('t * (('t -> 't) -> unit)) = import "useState" "react"
496
+
497
+ /// <summary>
498
+ /// Forwards a given ref, allowing you to pass it further down to a child.
499
+ /// </summary>
500
+ /// <param name='render'>A render function that returns an element.</param>
501
+ static member forwardRef(render: ('props * IRefValue<'t> -> ReactElement)) : ('props * IRefValue<'t> -> ReactElement) =
502
+ let forwardRefType = Interop.reactApi.forwardRef(Func<'props,IRefValue<'t>,ReactElement> (fun props ref -> render(props,ref)))
503
+ fun (props, ref) ->
504
+ let propsObj = props |> JsInterop.toPlainJsObj
505
+ propsObj?ref <- ref
506
+ Interop.reactApi.createElement(forwardRefType, propsObj)
507
+
508
+ /// <summary>
509
+ /// Forwards a given ref, allowing you to pass it further down to a child.
510
+ /// </summary>
511
+ /// <param name='name'>The component name to display in the React dev tools.</param>
512
+ /// <param name='render'>A render function that returns an element.</param>
513
+ static member forwardRef(name: string, render: ('props * IRefValue<'t> -> ReactElement)) : ('props * IRefValue<'t> -> ReactElement) =
514
+ let forwardRefType = Interop.reactApi.forwardRef(Func<'props,IRefValue<'t>,ReactElement> (fun props ref -> render(props,ref)))
515
+ render?displayName <- name
516
+ fun (props, ref) ->
517
+ let propsObj = props |> JsInterop.toPlainJsObj
518
+ propsObj?ref <- ref
519
+ Interop.reactApi.createElement(forwardRefType, propsObj)
520
+
521
+ /// <summary>
522
+ /// Highlights potential problems in an application by enabling additional checks
523
+ /// and warnings for descendants. As well as double rendering function components.
524
+ ///
525
+ /// This *does not do anything* in production mode. You do not need to hide it
526
+ /// with compiler directives.
527
+ /// </summary>
528
+ /// <param name='children'>The elements that will be rendered with additional
529
+ /// checks and warnings.</param>
530
+ static member strictMode(children: ReactElement list) =
531
+ Interop.reactApi.createElement(Interop.reactApi.StrictMode, None, children)
532
+
533
+ /// <summary>
534
+ /// Lets you define a component that is loaded dynamically. Which helps with code splitting.
535
+ /// </summary>
536
+ /// <param name='dynamicImport'>
537
+ /// The dynamicImport of the component.
538
+ ///
539
+ /// Such as `let asyncComponent : JS.Promise[unit -> ReactElement] = JsInterop.importDynamic "./CodeSplitting.fs"`.
540
+ ///
541
+ /// Where you would then pass in `asyncComponent`.
542
+ /// </param>
543
+ /// <param name="props">The props to be passed to the component.</param>
544
+ static member lazy'<'t,'props>(dynamicImport: JS.Promise<'t>, props: 'props) =
545
+ Interop.reactApi.createElement(Interop.reactApi.lazy'(fun () -> dynamicImport),props)
546
+ /// <summary>
547
+ /// Lets you define a component that is loaded dynamically. Which helps with code
548
+ /// splitting.
549
+ /// </summary>
550
+ /// <param name='dynamicImport'>
551
+ /// The dynamicImport of the component.
552
+ ///
553
+ /// Such as `let asyncComponent : JS.Promise[unit -> ReactElement] = JsInterop.importDynamic "./CodeSplitting.fs"`.
554
+ ///
555
+ /// Where you would then pass in `fun () -> asyncComponent`.
556
+ /// </param>
557
+ /// <param name="props">The props to be passed to the component.</param>
558
+ static member lazy'<'t,'props>(dynamicImport: unit -> JS.Promise<'t>, props: 'props) =
559
+ Interop.reactApi.createElement(Interop.reactApi.lazy'(dynamicImport),props)
560
+
561
+ /// <summary>
562
+ /// Lets you specify a loading indicator whenever a child element is not yet ready
563
+ /// to render.
564
+ ///
565
+ /// Currently this is only usable with `React.lazy'`.
566
+ /// </summary>
567
+ /// <param name='children'>The elements that will be rendered within the suspense block.</param>
568
+ static member suspense(children: ReactElement list) =
569
+ Interop.reactApi.createElement(Interop.reactApi.Suspense, {| fallback = Html.none |} |> JsInterop.toPlainJsObj, children)
570
+ /// <summary>
571
+ /// Lets you specify a loading indicator whenever a child element is not yet ready
572
+ /// to render.
573
+ ///
574
+ /// Currently this is only usable with `React.lazy'`.
575
+ /// </summary>
576
+ /// <param name='children'>The elements that will be rendered within the suspense block.</param>
577
+ /// <param name='fallback'>The element that will be rendered while the children are loading.</param>
578
+ static member suspense(children: ReactElement list, fallback: ReactElement) =
579
+ Interop.reactApi.createElement(Interop.reactApi.Suspense, {| fallback = fallback |} |> JsInterop.toPlainJsObj, children)
580
+
581
+ /// <summary>
582
+ /// Allows you to override the behavior of a given ref.
583
+ ///
584
+ /// </summary>
585
+ /// <param name='ref'>The ref you want to override.</param>
586
+ /// <param name='createHandle'>A function that returns a new ref with changed behavior.</param>
587
+ [<Hook>]
588
+ static member useImperativeHandle(ref: IRefValue<'t>, createHandle: unit -> 't) =
589
+ Interop.reactApi.useImperativeHandleNoDeps ref createHandle
590
+
591
+ /// <summary>
592
+ /// Lets you specify a loading indicator whenever a child element is not yet ready
593
+ /// to render.
594
+ ///
595
+ /// Currently this is only usable with `React.lazy'`.
596
+ /// </summary>
597
+ /// <param name='ref'>The ref you want to override.</param>
598
+ /// <param name='createHandle'>A function that returns a new ref with changed behavior.</param>
599
+ /// <param name='dependencies'>An array of dependencies upon which the imperative handle function depends.</param>
600
+ [<Hook>]
601
+ static member useImperativeHandle(ref: IRefValue<'t>, createHandle: unit -> 't, dependencies: obj []) =
602
+ Interop.reactApi.useImperativeHandle ref createHandle dependencies
603
+
604
+ /// <summary>
605
+ /// Creates a CancellationToken that is cancelled when a component is unmounted.
606
+ /// </summary>
607
+ [<Hook>]
608
+ static member inline useCancellationToken () =
609
+ let cts = React.useRef(new System.Threading.CancellationTokenSource())
610
+ let token = React.useRef(cts.current.Token)
611
+
612
+ React.useEffectOnce(fun () ->
613
+ React.createDisposable(fun () ->
614
+ cts.current.Cancel()
615
+ cts.current.Dispose()
616
+ )
617
+ )
618
+
619
+ token
620
+
621
+ [<AutoOpen>]
622
+ module ReactOverloadMagic =
623
+ type React with
624
+ /// Creates a disposable instance by merging multiple IDisposables.
625
+ static member inline createDisposable([<ParamArray>] disposables: #IDisposable []) =
626
+ React.createDisposable(fun () ->
627
+ disposables
628
+ |> Array.iter (fun d -> d.Dispose())
629
+ )
630
+ /// Creates a disposable instance by merging multiple IDisposable options.
631
+ static member inline createDisposable([<ParamArray>] disposables: #IDisposable option []) =
632
+ React.createDisposable(fun () ->
633
+ disposables
634
+ |> Array.iter (Option.iter (fun d -> d.Dispose()))
635
+ )
636
+ /// Creates a disposable instance by merging multiple IDisposable refs.
637
+ static member inline createDisposable([<ParamArray>] disposables: IRefValue<#IDisposable> []) =
638
+ React.createDisposable(fun () ->
639
+ disposables
640
+ |> Array.iter (fun d -> d.current.Dispose())
641
+ )
642
+
643
+ /// Creates a disposable instance by merging multiple IDisposable refs.
644
+ static member inline createDisposable([<ParamArray>] disposables: IRefValue<#IDisposable option> []) =
645
+ React.createDisposable(fun () ->
646
+ disposables
647
+ |> Array.iter (fun d -> d.current |> Option.iter (fun d -> d.Dispose()))
648
+ )
649
+
650
+ /// The `useState` hook that creates a state variable for React function components.
651
+ [<Hook>]
652
+ static member useState<'t>(initial: 't) = Interop.reactApi.useState<'t,'t>(initial)
653
+
654
+
655
+ [<Hook>]
656
+ static member useStateWithUpdater<'t>(initializer: unit -> 't): ('t * (('t -> 't) -> unit)) = import "useState" "react"