fact
string
type
string
library
string
imports
list
filename
string
symbolic_name
string
docstring
string
widgetDir : FilePath := "widget" nonrec def Lake.Package.widgetDir (pkg : Package) : FilePath := pkg.dir / widgetDir
def
root
[ "import Lake" ]
lakefile.lean
widgetDir
null
Lake.Package.runNpmCommand (pkg : Package) (args : Array String) : LogIO Unit := -- Running `cmd := "npm.cmd"` directly fails on Windows sometimes -- (https://github.com/leanprover-community/ProofWidgets4/issues/97) -- so run in PowerShell instead (`cmd.exe` also doesn't work.) if Platform.isWindows then proc { cmd := "powershell" args := #["-Command", "npm.cmd"] ++ args cwd := some pkg.widgetDir } (quiet := true) -- use `quiet` here or `lake` will replay the output in downstream projects. else proc { cmd := "npm" args cwd := some pkg.widgetDir } (quiet := true) input_file widgetPackageJson where path := widgetDir / "package.json" text := true /-- Target to update `package-lock.json` whenever `package.json` has changed. -/ target widgetPackageLock pkg : FilePath := do let packageFile ← widgetPackageJson.fetch let packageLockFile := pkg.widgetDir / "package-lock.json" buildFileAfterDep (text := true) packageLockFile packageFile fun _srcFile => do pkg.runNpmCommand #["install"] input_file widgetRollupConfig where path := widgetDir / "rollup.config.js" text := true input_file widgetTsconfig where path := widgetDir / "tsconfig.json" text := true /-- The TypeScript widget modules in `widget/src`. -/ input_dir widgetJsSrcs where path := widgetDir / "src" filter := .extension <| .mem #["ts", "tsx", "js", "jsx"] text := true /-- Target to build all widget modules from `widgetJsSrcs`. -/
def
root
[ "import Lake" ]
lakefile.lean
Lake.Package.runNpmCommand
null
widgetJsAllTarget (pkg : Package) (isDev : Bool) : FetchM (Job Unit) := do let srcs ← widgetJsSrcs.fetch let rollupConfig ← widgetRollupConfig.fetch let tsconfig ← widgetTsconfig.fetch let widgetPackageLock ← widgetPackageLock.fetch /- `widgetJsAll` is built via `needs`, and Lake's default build order is `needs -> cloud release -> main build`. We must instead ensure that the cloud release is fetched first so that this target does not build from scratch unnecessarily. `afterBuildCacheAsync` guarantees this. -/ pkg.afterBuildCacheAsync do srcs.bindM (sync := true) fun _ => rollupConfig.bindM (sync := true) fun _ => tsconfig.bindM (sync := true) fun _ => widgetPackageLock.mapM fun _ => do let traceFile := pkg.buildDir / "js" / "lake.trace" buildUnlessUpToDate traceFile (← getTrace) traceFile do if let some msg := get_config? errorOnBuild then error msg /- HACK: Ensure that NPM modules are installed before building TypeScript, *if* we are building Typescript. It would probably be better to have a proper target for `node_modules` that all the JS/TS modules depend on. BUT when we are being built as a dependency of another package using the cloud releases feature, we wouldn't want that target to trigger since in that case NPM is not necessarily installed. Hence, we put this block inside the build process for JS/TS files rather than as a top-level target. This only runs when some TypeScript needs building. -/ pkg.runNpmCommand #["clean-install"] pkg.runNpmCommand #["run", if isDev then "build-dev" else "build"] target widgetJsAll pkg : Unit := widgetJsAllTarget pkg (isDev := false) target widgetJsAllDev pkg : Unit := widgetJsAllTarget pkg (isDev := true) @[default_target] lean_lib ProofWidgets where needs := #[widgetJsAll] lean_lib ProofWidgets.Demos where needs := #[widgetJsAll] globs := #[.submodules `ProofWidgets.Demos] @[test_driver] lean_lib test where globs := #[.submodules `test]
def
root
[ "import Lake" ]
lakefile.lean
widgetJsAllTarget
/-- Target to build all widget modules from `widgetJsSrcs`. -/
RequestId := Nat
abbrev
ProofWidgets
[]
ProofWidgets/Cancellable.lean
RequestId
null
CancellableTask where task : Task (Except RequestError (LazyEncodable Json)) /- Note: we cannot just `IO.cancel task` because it is a result of `map`. See https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Should.20cancelling.20a.20purely.20mapped.20task.20cancel.20the.20original.3F -/ cancel : IO Unit /-- Maps the ID of each currently executing request to its task. -/ initialize runningRequests : IO.Ref (RequestId × Std.HashMap RequestId CancellableTask) ← IO.mkRef (0, ∅) /-- Transforms a request handler returning `β` into one that returns immediately with a `RequestId`. The ID uniquely identifies the running request: its results can be retrieved using `checkRequest`, and it can be cancelled using `cancelRequest`. -/
structure
ProofWidgets
[]
ProofWidgets/Cancellable.lean
CancellableTask
null
mkCancellable [RpcEncodable β] (handler : α → RequestM (RequestTask β)) : α → RequestM (RequestTask RequestId) := fun a => do RequestM.asTask do let t ← handler a let t' := t.mapCheap (·.map rpcEncode) runningRequests.modifyGet fun (id, m) => (id, (id+1, m.insert id ⟨t'.task, t.cancel⟩)) /-- Cancel the request with ID `rid`. Does nothing if `rid` is invalid. -/ @[server_rpc_method]
def
ProofWidgets
[]
ProofWidgets/Cancellable.lean
mkCancellable
/-- Transforms a request handler returning `β` into one that returns immediately with a `RequestId`. The ID uniquely identifies the running request: its results can be retrieved using `checkRequest`, and it can be cancelled using `cancelRequest`. -/
cancelRequest (rid : RequestId) : RequestM (RequestTask String) := do RequestM.asTask do let t? ← runningRequests.modifyGet fun (id, m) => (m[rid]?, (id, m.erase rid)) if let some t := t? then t.cancel return "ok" /-- The status of a running cancellable request. -/
def
ProofWidgets
[]
ProofWidgets/Cancellable.lean
cancelRequest
/-- Cancel the request with ID `rid`. Does nothing if `rid` is invalid. -/
CheckRequestResponse | running | done (result : LazyEncodable Json) deriving RpcEncodable /-- Check whether a request has finished computing, and return the response if so. The request is removed from `runningRequests` the first time it is checked and found to have finished. Throws an error if the `rid` is invalid, or if the request itself threw an error. -/ /- NOTE: a notification-based version would be better than this polling-based one. But we cannot include RPC references in notifications atm; another possible addition to the RPC protocol? -/ @[server_rpc_method]
inductive
ProofWidgets
[]
ProofWidgets/Cancellable.lean
CheckRequestResponse
/-- The status of a running cancellable request. -/
checkRequest (rid : RequestId) : RequestM (RequestTask CheckRequestResponse) := do RequestM.asTask do let (_, m) ← runningRequests.get match m[rid]? with | none => throw $ RequestError.invalidParams s!"Request '{rid}' has already finished, or the ID is invalid." | some t => if !(← IO.hasFinished t.task) then return .running runningRequests.modify fun (id, m) => (id, m.erase rid) match t.task.get with | .error e => throw e | .ok v => return .done v
def
ProofWidgets
[]
ProofWidgets/Cancellable.lean
checkRequest
/-- Check whether a request has finished computing, and return the response if so. The request is removed from `runningRequests` the first time it is checked and found to have finished. Throws an error if the `rid` is invalid, or if the request itself threw an error. -/
cancellableSuffix : Name := `_cancellable /-- Like `server_rpc_method`, but requests for this method can be cancelled. The method should check for that using `IO.checkCanceled`. Cancellable methods are invoked differently from JavaScript: see `callCancellable` in `cancellable.ts`. -/ initialize registerBuiltinAttribute { name := `server_rpc_method_cancellable descr := "Like `server_rpc_method`, \ but requests for this method can be cancelled. \ The method should check for that using `IO.checkCanceled`. \ Cancellable methods are invoked differently from JavaScript: \ see `callCancellable` in `cancellable.ts`." applicationTime := AttributeApplicationTime.afterCompilation add := fun decl _ _ => Prod.fst <$> MetaM.run do let name := decl ++ cancellableSuffix let value ← mkAppM ``mkCancellable #[mkConst decl] addAndCompile $ .defnDecl { name levelParams := [] type := ← inferType value value hints := .opaque safety := .safe } registerRpcProcedure name }
def
ProofWidgets
[]
ProofWidgets/Cancellable.lean
cancellableSuffix
null
LazyEncodable α := StateM RpcObjectStore α -- back from exile
abbrev
ProofWidgets
[]
ProofWidgets/Compat.lean
LazyEncodable
null
ExprWithCtx where ci : Elab.ContextInfo lctx : LocalContext linsts : LocalInstances expr : Expr deriving TypeName
structure
ProofWidgets
[]
ProofWidgets/Compat.lean
ExprWithCtx
null
ExprWithCtx.runMetaM (e : ExprWithCtx) (x : Expr → MetaM α) : IO α := e.ci.runMetaM {} $ Meta.withLCtx e.lctx e.linsts (x e.expr)
def
ProofWidgets
[]
ProofWidgets/Compat.lean
ExprWithCtx.runMetaM
null
ExprWithCtx.save (e : Expr) : MetaM ExprWithCtx := return { ci := { ← CommandContextInfo.save with } lctx := ← getLCtx linsts := ← Meta.getLocalInstances expr := e }
def
ProofWidgets
[]
ProofWidgets/Compat.lean
ExprWithCtx.save
null
joinArrays {m} [Monad m] [MonadRef m] [MonadQuotation m] (arr : Array Term) : m Term := do if h : 0 < arr.size then arr.foldlM (fun x xs => `($x ++ $xs)) arr[0] (start := 1) else `(#[]) /-- Collapse adjacent `inl (_ : α)`s into a `β` using `f`. For example, `#[.inl a₁, .inl a₂, .inr b, .inl a₃] ↦ #[← f #[a₁, a₂], b, ← f #[a₃]]`. -/
def
ProofWidgets
[]
ProofWidgets/Util.lean
joinArrays
/-- Sends `#[a, b, c]` to `` `(term| $a ++ $b ++ $c)``-/
foldInlsM {m} [Monad m] (arr : Array (α ⊕ β)) (f : Array α → m β) : m (Array β) := do let mut ret : Array β := #[] let mut pending_inls : Array α := #[] for c in arr do match c with | .inl ci => pending_inls := pending_inls.push ci | .inr cis => if pending_inls.size ≠ 0 then ret := ret.push <| ← f pending_inls pending_inls := #[] ret := ret.push cis if pending_inls.size ≠ 0 then ret := ret.push <| ← f pending_inls return ret
def
ProofWidgets
[]
ProofWidgets/Util.lean
foldInlsM
/-- Collapse adjacent `inl (_ : α)`s into a `β` using `f`. For example, `#[.inl a₁, .inl a₂, .inr b, .inl a₃] ↦ #[← f #[a₁, a₂], b, ← f #[a₃]]`. -/
delabListLiteral {α} (elem : DelabM α) : DelabM (Array α) := go #[] where go (acc : Array α) : DelabM (Array α) := do match_expr ← getExpr with | List.nil _ => return acc | List.cons _ _ _ => let hd ← withNaryArg 1 elem withNaryArg 2 $ go (acc.push hd) | _ => failure /-- Delaborate the elements of an array literal separately, calling `elem` on each. -/
def
ProofWidgets
[]
ProofWidgets/Util.lean
delabListLiteral
/-- Delaborate the elements of a list literal separately, calling `elem` on each. -/
delabArrayLiteral {α} (elem : DelabM α) : DelabM (Array α) := do match_expr ← getExpr with | List.toArray _ _ => withNaryArg 1 <| delabListLiteral elem | _ => failure /-- A copy of `Delaborator.annotateTermInfo` for other syntactic categories. -/
def
ProofWidgets
[]
ProofWidgets/Util.lean
delabArrayLiteral
/-- Delaborate the elements of an array literal separately, calling `elem` on each. -/
annotateTermLikeInfo (stx : TSyntax n) : DelabM (TSyntax n) := do let stx ← annotateCurPos ⟨stx⟩ addTermInfo (← getPos) stx (← getExpr) pure ⟨stx⟩ /-- A copy of `Delaborator.withAnnotateTermInfo` for other syntactic categories. -/
def
ProofWidgets
[]
ProofWidgets/Util.lean
annotateTermLikeInfo
/-- A copy of `Delaborator.annotateTermInfo` for other syntactic categories. -/
withAnnotateTermLikeInfo (d : DelabM (TSyntax n)) : DelabM (TSyntax n) := do let stx ← d annotateTermLikeInfo stx
def
ProofWidgets
[]
ProofWidgets/Util.lean
withAnnotateTermLikeInfo
/-- A copy of `Delaborator.withAnnotateTermInfo` for other syntactic categories. -/
CustomProps where val : Nat str : String deriving Server.RpcEncodable
structure
test
[ "import ProofWidgets.Data.Html" ]
test/delab.lean
CustomProps
/-- info: <div {...attrs}>{...children}</div> : ProofWidgets.Html -/
CustomComponent : ProofWidgets.Component CustomProps where javascript := "" -- TODO: spacing between attributes /-- info: <div><CustomComponent val={2}str={"3"}>Content</CustomComponent></div> : ProofWidgets.Html -/ #guard_msgs in #check <div><CustomComponent val={2} str="3">Content</CustomComponent></div>
def
test
[ "import ProofWidgets.Data.Html" ]
test/delab.lean
CustomComponent
/-- info: <div {...attrs}>{...children}</div> : ProofWidgets.Html -/
ProdComponent : ProofWidgets.Component (Nat × Nat) where javascript := "" /-- info: <div><ProdComponent {...(1, 2)}/></div> : ProofWidgets.Html -/ #guard_msgs in #check <div><ProdComponent fst={1} snd={2} /></div> /-- info: <div><ProdComponent {...(1, 2)}/></div> : ProofWidgets.Html -/ #guard_msgs in #check <div><ProdComponent {...Prod.mk 1 2}/></div> /-- info: <div><ProdComponent {...let __src := (1, 2); (__src.fst, 3)}/></div> : ProofWidgets.Html -/ #guard_msgs in #check <div><ProdComponent {...Prod.mk 1 2} snd={3}/></div> -- interactive test: check that the hovers in the infoview on subexpressions are correct #check <span id="test">Hello {.text "<>"} world<CustomComponent val={1} str="3" /></span>
def
test
[ "import ProofWidgets.Data.Html" ]
test/delab.lean
ProdComponent
/-- info: <div><CustomComponent val={2}str={"3"}>Content</CustomComponent></div> : ProofWidgets.Html -/
Component (Props : Type) extends Widget.Module where /-- Which export of the module to use as the component function. -/ «export» : String := "default"
structure
ProofWidgets
[]
ProofWidgets/Component/Basic.lean
Component
null
InteractiveCodeProps where fmt : Widget.CodeWithInfos deriving Server.RpcEncodable /-- Present pretty-printed code as interactive text. The most common use case is to instantiate this component from a `Lean.Expr`. To do so, you must eagerly pretty-print the `Expr` using `Widget.ppExprTagged`. See also `InteractiveExpr`. -/ @[widget_module]
structure
ProofWidgets
[]
ProofWidgets/Component/Basic.lean
InteractiveCodeProps
/-- Which export of the module to use as the component function. -/
InteractiveCode : Component InteractiveCodeProps where javascript := " import { InteractiveCode } from '@leanprover/infoview' import * as React from 'react' export default function(props) { return React.createElement(InteractiveCode, props) }"
def
ProofWidgets
[]
ProofWidgets/Component/Basic.lean
InteractiveCode
/-- Present pretty-printed code as interactive text. The most common use case is to instantiate this component from a `Lean.Expr`. To do so, you must eagerly pretty-print the `Expr` using `Widget.ppExprTagged`. See also `InteractiveExpr`. -/
InteractiveExprProps where expr : Server.WithRpcRef ExprWithCtx deriving Server.RpcEncodable @[server_rpc_method]
structure
ProofWidgets
[]
ProofWidgets/Component/Basic.lean
InteractiveExprProps
null
ppExprTagged : InteractiveExprProps → Server.RequestM (Server.RequestTask Widget.CodeWithInfos) | ⟨ref⟩ => Server.RequestM.asTask <| ref.val.runMetaM Widget.ppExprTagged /-- Lazily pretty-print and present a `Lean.Expr` as interactive text. This component is preferrable over `InteractiveCode` when the `Expr` will not necessarily be displayed in the UI (e.g. it may be hidden by default), in which case laziness saves some work. On the other hand if the `Expr` will likely be shown and you are in a `MetaM` context, it is preferrable to use the eager `InteractiveCode` in order to avoid the extra client-server roundtrip needed for the pretty-printing RPC call. -/ @[widget_module]
def
ProofWidgets
[]
ProofWidgets/Component/Basic.lean
ppExprTagged
null
InteractiveExpr : Component InteractiveExprProps where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "interactiveExpr.js"
def
ProofWidgets
[]
ProofWidgets/Component/Basic.lean
InteractiveExpr
null
InteractiveMessageProps where msg : Server.WithRpcRef MessageData deriving Server.RpcEncodable /-- Present a structured Lean message. -/ @[widget_module]
structure
ProofWidgets
[]
ProofWidgets/Component/Basic.lean
InteractiveMessageProps
null
InteractiveMessage : Component InteractiveMessageProps where javascript := " import { InteractiveMessageData } from '@leanprover/infoview' import * as React from 'react' export default function(props) { return React.createElement(InteractiveMessageData, props) } "
def
ProofWidgets
[]
ProofWidgets/Component/Basic.lean
InteractiveMessage
/-- Present a structured Lean message. -/
MarkdownDisplay.Props where contents : String deriving ToJson, FromJson /-- Render a given string as Markdown. LaTeX is supported with MathJax: use `$...$` for inline math, and `$$...$$` for displayed math. Example usage: ```lean <MarkdownDisplay contents={"$a + b = c$"} /> ``` -/ @[widget_module]
structure
ProofWidgets
[]
ProofWidgets/Component/Basic.lean
MarkdownDisplay.Props
/-- Present a structured Lean message. -/
MarkdownDisplay : Component MarkdownDisplay.Props where javascript := " import { Markdown } from '@leanprover/infoview' import * as React from 'react' export default (props) => React.createElement(Markdown, props) "
def
ProofWidgets
[]
ProofWidgets/Component/Basic.lean
MarkdownDisplay
/-- Render a given string as Markdown. LaTeX is supported with MathJax: use `$...$` for inline math, and `$$...$$` for displayed math. Example usage: ```lean <MarkdownDisplay contents={"$a + b = c$"} /> ``` -/
Lean.MessageData.ofComponent [Server.RpcEncodable Props] (c : ProofWidgets.Component Props) (p : Props) (alt : String) : CoreM MessageData := do let wi ← Widget.WidgetInstance.ofHash c.javascriptHash (Server.RpcEncodable.rpcEncode p) return .ofWidget wi alt
def
ProofWidgets
[]
ProofWidgets/Component/Basic.lean
Lean.MessageData.ofComponent
/-- Construct a structured message from a ProofWidgets component. For the meaning of `alt`, see `MessageData.ofWidget`. -/
FilterDetailsProps where /-- Contents of the `<summary>`. -/ summary : Html /-- What is shown in the filtered state. -/ filtered : Html /-- What is shown in the non-filtered state. -/ all : Html /-- Whether to start in the filtered state. -/ initiallyFiltered : Bool := true deriving Server.RpcEncodable /-- The `FilterDetails` component is like a `<details>` HTML element, but also has a filter button that allows you to switch between filtered and unfiltered states. -/ @[widget_module]
structure
ProofWidgets
[]
ProofWidgets/Component/FilterDetails.lean
FilterDetailsProps
/-- Props for the `FilterDetails` component. -/
FilterDetails : Component FilterDetailsProps where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "filterDetails.js"
def
ProofWidgets
[]
ProofWidgets/Component/FilterDetails.lean
FilterDetails
/-- The `FilterDetails` component is like a `<details>` HTML element, but also has a filter button that allows you to switch between filtered and unfiltered states. -/
mkCircle (attrs : Array (String × Json) := #[]) : Html := <circle r={5} fill="var(--vscode-editor-background)" stroke="var(--vscode-editor-foreground)" strokeWidth={.num 1.5} {...attrs} /> /-- A shape containing the vertex label. Used to position incident edge endpoints. The shape is assumed to be centred on the vertex position. -/ -- TODO: use `getBoundingClientRect` to dynamically compute size
def
ProofWidgets
[]
ProofWidgets/Component/GraphDisplay.lean
mkCircle
/-- A themed `<circle>` SVG element, with optional extra attributes. -/
BoundingShape where /-- A circle of fixed radius. -/ | circle (radius : Float) : BoundingShape /-- A rectangle of fixed dimensions. -/ | rect (width height : Float) : BoundingShape deriving Inhabited, FromJson, ToJson
inductive
ProofWidgets
[]
ProofWidgets/Component/GraphDisplay.lean
BoundingShape
/-- A shape containing the vertex label. Used to position incident edge endpoints. The shape is assumed to be centred on the vertex position. -/
Vertex where /-- Identifier for this vertex. Must be unique. -/ id : String /-- The label is drawn at the vertex position. This must be an SVG element. Use `<foreignObject>` to draw non-SVG elements. -/ label : Html := mkCircle boundingShape : BoundingShape := .circle 5 /-- Details are shown below the graph display after the vertex label has been clicked. See also `Props.showDetails`. -/ details? : Option Html := none deriving Inhabited, RpcEncodable
structure
ProofWidgets
[]
ProofWidgets/Component/GraphDisplay.lean
Vertex
/-- A rectangle of fixed dimensions. -/
Edge where /-- Source vertex. Must match the `id` of one of the vertices. -/ source : String /-- Target vertex. Must match the `id` of one of the vertices. -/ target : String /-- Extra attributes to set on the SVG `<line>` element representing this edge. See also `Props.defaultEdgeAttrs`. -/ attrs : Array (String × Json) := #[] /-- If present, the label is shown over the edge midpoint. This must be an SVG element. Use `<foreignObject>` to draw non-SVG elements. -/ label? : Option Html := none /-- Details are shown below the graph display after the edge has been clicked. See also `Props.showDetails`. -/ details? : Option Html := none deriving Inhabited, RpcEncodable
structure
ProofWidgets
[]
ProofWidgets/Component/GraphDisplay.lean
Edge
/-- Details are shown below the graph display after the vertex label has been clicked. See also `Props.showDetails`. -/
ForceCenterParams where x? : Option Float := none y? : Option Float := none strength? : Option Float := none deriving Inhabited, FromJson, ToJson
structure
ProofWidgets
[]
ProofWidgets/Component/GraphDisplay.lean
ForceCenterParams
/-- Details are shown below the graph display after the edge has been clicked. See also `Props.showDetails`. -/
ForceCollideParams where radius? : Option Float := none strength? : Option Float := none iterations? : Option Nat := none deriving Inhabited, FromJson, ToJson
structure
ProofWidgets
[]
ProofWidgets/Component/GraphDisplay.lean
ForceCollideParams
/-- Details are shown below the graph display after the edge has been clicked. See also `Props.showDetails`. -/
ForceLinkParams where distance? : Option Float := none strength? : Option Float := none iterations? : Option Nat := none deriving Inhabited, FromJson, ToJson
structure
ProofWidgets
[]
ProofWidgets/Component/GraphDisplay.lean
ForceLinkParams
null
ForceManyBodyParams where strength? : Option Float := none theta? : Option Float := none distanceMin? : Option Float := none distanceMax? : Option Float := none deriving Inhabited, FromJson, ToJson
structure
ProofWidgets
[]
ProofWidgets/Component/GraphDisplay.lean
ForceManyBodyParams
null
ForceXParams where x? : Option Float := none strength? : Option Float := none deriving Inhabited, FromJson, ToJson
structure
ProofWidgets
[]
ProofWidgets/Component/GraphDisplay.lean
ForceXParams
null
ForceYParams where y? : Option Float := none strength? : Option Float := none deriving Inhabited, FromJson, ToJson
structure
ProofWidgets
[]
ProofWidgets/Component/GraphDisplay.lean
ForceYParams
null
ForceRadialParams where radius : Float x? : Option Float := none y? : Option Float := none strength? : Option Float := none deriving Inhabited, FromJson, ToJson /-- Settings for the simulation of forces on vertices. See https://d3js.org/d3-force. -/
structure
ProofWidgets
[]
ProofWidgets/Component/GraphDisplay.lean
ForceRadialParams
null
ForceParams where | center : ForceCenterParams → ForceParams | collide : ForceCollideParams → ForceParams | link : ForceLinkParams → ForceParams | manyBody : ForceManyBodyParams → ForceParams | x : ForceXParams → ForceParams | y : ForceYParams → ForceParams | radial : ForceRadialParams → ForceParams deriving Inhabited, FromJson, ToJson
inductive
ProofWidgets
[]
ProofWidgets/Component/GraphDisplay.lean
ForceParams
/-- Settings for the simulation of forces on vertices. See https://d3js.org/d3-force. -/
Props where vertices : Array Vertex /-- At most one edge may exist between any two vertices. Self-loops are allowed, but (TODO) are currently not rendered well. -/ edges : Array Edge /-- Attributes to set by default on `<line>` elements representing edges. -/ defaultEdgeAttrs : Array (String × Json) := #[ ("fill", "var(--vscode-editor-foreground)"), ("stroke", "var(--vscode-editor-foreground)"), ("strokeWidth", 2), ("markerEnd", "url(#arrow)") ] /-- Which forces to apply to the vertices. Most force parameters are optional, using default values if not specified. -/ forces : Array ForceParams := #[ .link {}, .manyBody {}, .x {}, .y {} ] /-- Whether to show a details box below the graph. -/ showDetails : Bool := false deriving Inhabited, RpcEncodable
structure
ProofWidgets
[]
ProofWidgets/Component/GraphDisplay.lean
Props
/-- Settings for the simulation of forces on vertices. See https://d3js.org/d3-force. -/
GraphDisplay : Component GraphDisplay.Props where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "d3Graph.js"
def
ProofWidgets
[]
ProofWidgets/Component/GraphDisplay.lean
GraphDisplay
/-- Display a graph with an interactive force simulation. -/
HtmlDisplayProps where html : Html deriving RpcEncodable @[widget_module]
structure
ProofWidgets
[]
ProofWidgets/Component/HtmlDisplay.lean
HtmlDisplayProps
null
HtmlDisplay : Component HtmlDisplayProps where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "htmlDisplay.js" @[widget_module]
def
ProofWidgets
[]
ProofWidgets/Component/HtmlDisplay.lean
HtmlDisplay
null
HtmlDisplayPanel : Component HtmlDisplayProps where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "htmlDisplayPanel.js" open Lean Server Elab Command /-- Any term `t : α` with a `HtmlEval α` instance can be evaluated in a `#html t` command. This is analogous to how `Lean.MetaEval` supports `#eval`. -/
def
ProofWidgets
[]
ProofWidgets/Component/HtmlDisplay.lean
HtmlDisplayPanel
null
HtmlEval (α : Type u) where eval : α → CommandElabM Html
class
ProofWidgets
[]
ProofWidgets/Component/HtmlDisplay.lean
HtmlEval
/-- Any term `t : α` with a `HtmlEval α` instance can be evaluated in a `#html t` command. This is analogous to how `Lean.MetaEval` supports `#eval`. -/
evalCommandMHtmlUnsafe (stx : Term) : TermElabM (CommandElabM Html) := do let tp := mkApp (mkConst ``CommandElabM) (mkConst ``Html) Term.evalTerm _ tp stx @[implemented_by evalCommandMHtmlUnsafe]
def
ProofWidgets
[]
ProofWidgets/Component/HtmlDisplay.lean
evalCommandMHtmlUnsafe
null
evalCommandMHtml : Term → TermElabM (CommandElabM Html) /-- Display a value of type `Html` in the infoview. The input can be a pure value or a computation in any Lean metaprogramming monad (e.g. `CommandElabM Html`). -/ syntax (name := htmlCmd) "#html " term : command @[command_elab htmlCmd]
opaque
ProofWidgets
[]
ProofWidgets/Component/HtmlDisplay.lean
evalCommandMHtml
null
elabHtmlCmd : CommandElab := fun | stx@`(#html $t:term) => do let htX ← liftTermElabM <| evalCommandMHtml <| ← ``(HtmlEval.eval $t) let ht ← htX liftCoreM <| Widget.savePanelWidgetInfo (hash HtmlDisplayPanel.javascript) (return json% { html: $(← rpcEncode ht) }) stx | stx => throwError "Unexpected syntax {stx}."
def
ProofWidgets
[]
ProofWidgets/Component/HtmlDisplay.lean
elabHtmlCmd
/-- Display a value of type `Html` in the infoview. The input can be a pure value or a computation in any Lean metaprogramming monad (e.g. `CommandElabM Html`). -/
Lean.MessageData.ofHtml (h : ProofWidgets.Html) (alt : String) : CoreM MessageData := MessageData.ofComponent ProofWidgets.HtmlDisplay ⟨h⟩ alt
def
ProofWidgets
[]
ProofWidgets/Component/HtmlDisplay.lean
Lean.MessageData.ofHtml
/-- Construct a structured message from ProofWidgets HTML. For the meaning of `alt`, see `MessageData.ofWidget`. -/
_root_.Float.toInt (x : Float) : Int := if x >= 0 then x.toUInt64.toNat else -((-x).toUInt64.toNat) namespace Svg
def
ProofWidgets
[]
ProofWidgets/Component/InteractiveSvg.lean
_root_.Float.toInt
null
ActionKind where | timeout | mousedown | mouseup | mousemove -- [note] mouse moves only happen when mouse button is down. deriving ToJson, FromJson, DecidableEq
inductive
ProofWidgets
[]
ProofWidgets/Component/InteractiveSvg.lean
ActionKind
null
Action where kind : ActionKind id : Option String data : Option Json deriving ToJson, FromJson /-- The input type `State` is any state the user wants to use and update SvgState in addition automatically handles tracking of time, selection and custom data -/
structure
ProofWidgets
[]
ProofWidgets/Component/InteractiveSvg.lean
Action
null
SvgState (State : Type) where state : State time : Float /-- time in milliseconds -/ selected : Option String mousePos : Option (Int × Int) idToData : List (String × Json) deriving ToJson, FromJson, Server.RpcEncodable
structure
ProofWidgets
[]
ProofWidgets/Component/InteractiveSvg.lean
SvgState
/-- The input type `State` is any state the user wants to use and update SvgState in addition automatically handles tracking of time, selection and custom data -/
UpdateParams (State : Type) where elapsed : Float actions : Array Action state : SvgState State mousePos : Option (Float × Float) -- TODO: change to Option (Int × Int) or do we want to support subpixel precision? deriving ToJson, FromJson
structure
ProofWidgets
[]
ProofWidgets/Component/InteractiveSvg.lean
UpdateParams
/-- time in milliseconds -/
UpdateResult (State : Type) where html : Html state : SvgState State /-- Approximate number of milliseconds to wait before calling again. -/ callbackTime : Option Float := some 33 deriving Server.RpcEncodable -- maybe add title, refresh rate, initial time?, custom selection rendering
structure
ProofWidgets
[]
ProofWidgets/Component/InteractiveSvg.lean
UpdateResult
/-- time in milliseconds -/
InteractiveSvg (State : Type) where init : State frame : Svg.Frame update (time_ms Δt_ms : Float) (action : Action) (mouseStart mouseEnd : Option (Svg.Point frame)) (selectedId : Option String) (getSelectedData : (α : Type) → [FromJson α] → Option α) : State → State render (time_ms : Float) (mouseStart mouseEnd : Option (Svg.Point frame)) : State → Svg frame open Server RequestM Jsx in
structure
ProofWidgets
[]
ProofWidgets/Component/InteractiveSvg.lean
InteractiveSvg
/-- Approximate number of milliseconds to wait before calling again. -/
InteractiveSvg.serverRpcMethod {State : Type} (isvg : InteractiveSvg State) (params : UpdateParams State) : RequestM (RequestTask (UpdateResult State)) := do -- Ideally, each action should have time and mouse position attached -- right now we just assume that all actions are uqually spaced within the frame let Δt := (params.elapsed - params.state.time) / params.actions.size.toFloat let idToData : Std.HashMap String Json := HashMap.ofList params.state.idToData let mut time := params.state.time let mut state := params.state.state let mut selected := params.state.selected let getData := λ (α : Type) [FromJson α] => do let id ← selected; let data ← idToData[id]? match fromJson? (α:=α) data with | .error _ => none | .ok val => some val let mouseStart := params.state.mousePos.map λ (i,j) => (i, j) let mouseEnd := params.mousePos.map λ (x,y) => (x.toInt, y.toInt) for action in params.actions do -- todo: interpolate mouse movenment! -- update state state := isvg.update time Δt action mouseStart mouseEnd selected getData state -- update selection if action.kind == ActionKind.mousedown then selected := action.id if action.kind == ActionKind.mouseup then selected := none -- update time time := time + Δt let mut svg := isvg.render time mouseStart mouseEnd state let svgState : SvgState State := { state := state time := params.elapsed selected := selected mousePos := mouseEnd.map λ p => p.toPixels idToData := svg.idToDataList } -- highlight selection if let some id := selected then if let some idx := svg.idToIdx[id]? then svg := { elements := svg.elements.modify idx λ e => e.setStroke (1.,1.,0.) (.px 5) } return RequestTask.pure { html := <div> {svg.toHtml} </div>, state := svgState, callbackTime := some 33, }
def
ProofWidgets
[]
ProofWidgets/Component/InteractiveSvg.lean
InteractiveSvg.serverRpcMethod
null
Lean.Lsp.Position.advance (p : Position) (s : Substring.Raw) : Position := let (nLinesAfter, lastLineUtf16Sz) := s.foldl (init := (0, 0)) fun (n, l) c => if c == '\n' then (n + 1, 0) else (n, l + c.utf16Size.toNat) { line := p.line + nLinesAfter character := (if nLinesAfter == 0 then p.character else 0) + lastLineUtf16Sz } namespace ProofWidgets open Lean
def
ProofWidgets
[]
ProofWidgets/Component/MakeEditLink.lean
Lean.Lsp.Position.advance
/-- Assuming that `s` is the content of a file starting at position `p`, advance `p` to the end of `s`. -/
MakeEditLinkProps where /-- The edit to perform on the file. -/ edit : Lsp.TextDocumentEdit /-- Which textual range to select after the edit. The range is interpreted in the file that `edit` applies to. If present and `start == end`, the cursor is moved to `start` and nothing is selected. If not present, the selection is not changed. -/ newSelection? : Option Lsp.Range := none /-- The `title` property, if any, to set on the displayed `<a>` link. -/ title? : Option String := none deriving FromJson, ToJson /-- Replace `range` with `newText`. If `newSelection?` is absent, place the cursor at the end of the new text. If `newSelection?` is present, make the specified selection instead. See also `MakeEditLinkProps.ofReplaceRange`. -/
structure
ProofWidgets
[]
ProofWidgets/Component/MakeEditLink.lean
MakeEditLinkProps
/-- Assuming that `s` is the content of a file starting at position `p`, advance `p` to the end of `s`. -/
MakeEditLinkProps.ofReplaceRange' (doc : Server.DocumentMeta) (range : Lsp.Range) (newText : String) (newSelection? : Option Lsp.Range := none) : MakeEditLinkProps := let edit := { textDocument := { uri := doc.uri, version? := doc.version } edits := #[{ range, newText }] } if newSelection?.isSome then { edit, newSelection? } else let endPos := range.start.advance newText.toRawSubstring { edit, newSelection? := some { start := endPos, «end» := endPos } } /-- Replace `range` with `newText`. If `newSelection?` is absent, place the cursor at the end of the new text. If `newSelection?` is present, select the range it specifies within `newText`. See also `MakeEditLinkProps.ofReplaceRange'`. -/
def
ProofWidgets
[]
ProofWidgets/Component/MakeEditLink.lean
MakeEditLinkProps.ofReplaceRange'
/-- Replace `range` with `newText`. If `newSelection?` is absent, place the cursor at the end of the new text. If `newSelection?` is present, make the specified selection instead. See also `MakeEditLinkProps.ofReplaceRange`. -/
MakeEditLinkProps.ofReplaceRange (doc : Server.DocumentMeta) (range : Lsp.Range) (newText : String) (newSelection? : Option (String.Pos.Raw × String.Pos.Raw) := none) : MakeEditLinkProps := ofReplaceRange' doc range newText (newSelection?.map fun (s, e) => let ps := range.start.advance (newText.toRawSubstring.extract 0 s) let pe := ps.advance (newText.toRawSubstring.extract s e) { start := ps, «end» := pe }) /-- A link that, when clicked, makes the specified edit and potentially moves the cursor or makes a selection. -/ @[widget_module]
def
ProofWidgets
[]
ProofWidgets/Component/MakeEditLink.lean
MakeEditLinkProps.ofReplaceRange
/-- Replace `range` with `newText`. If `newSelection?` is absent, place the cursor at the end of the new text. If `newSelection?` is present, select the range it specifies within `newText`. See also `MakeEditLinkProps.ofReplaceRange'`. -/
MakeEditLink : Component MakeEditLinkProps where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "makeEditLink.js"
def
ProofWidgets
[]
ProofWidgets/Component/MakeEditLink.lean
MakeEditLink
/-- A link that, when clicked, makes the specified edit and potentially moves the cursor or makes a selection. -/
ofRpcMethodTemplate := include_str ".." / ".." / ".lake" / "build" / "js" / "ofRpcMethod.js" /-- The elaborator `mk_rpc_widget%` allows writing certain widgets in Lean instead of JavaScript. Specifically, it translates an RPC method of type `MyProps → RequestM (RequestTask Html)` into a widget component of type `Component MyProps`. Even more specifically, we can write: ```lean open Lean Server
def
ProofWidgets
[]
ProofWidgets/Component/OfRpcMethod.lean
ofRpcMethodTemplate
null
MyProps where ... deriving RpcEncodable @[server_rpc_method]
structure
ProofWidgets
[]
ProofWidgets/Component/OfRpcMethod.lean
MyProps
null
MyComponent.rpc (ps : MyProps) : RequestM (RequestTask Html) := ... @[widget_module]
def
ProofWidgets
[]
ProofWidgets/Component/OfRpcMethod.lean
MyComponent.rpc
null
MyComponent : Component MyProps := mk_rpc_widget% MyComponent.rpc ``` This is convenient because we can program the logic that computes an output HTML tree given input props in Lean directly. ⚠️ However, note that there are several limitations on what such component can do compared to ones written natively in TypeScript or JavaScript: - It must be pure, i.e. cannot directly store any React state. Child components may store state as usual. - It cannot pass closures as props to the child components that it returns. For example, it is not currently possible to write click event handlers in Lean and pass them to a `<button onClick={..}>` child. - Every time the input props change, the infoview has to send a message to the Lean server in order to invoke the RPC method. Thus there can be a noticeable visual delay between the input props changing and the display updating. Consequently, components whose props change at a high frequency (e.g. depending on the mouse position) should not be implemented using this method. 💡 Note that an inverse transformation is already possible. Given `MyComponent : Component MyProps`, we can write: ```lean open Lean Server @[server_rpc_method]
def
ProofWidgets
[]
ProofWidgets/Component/OfRpcMethod.lean
MyComponent
null
MyComponent.rpc (ps : MyProps) : RequestM (RequestTask Html) := RequestM.asTask do return Html.ofComponent MyComponent ps #[] ``` -/ elab "mk_rpc_widget%" fn:term : term <= expectedType => do let α ← mkFreshExprMVar (some (.sort levelOne)) (userName := `α) let compT ← mkAppM ``Component #[α] if !(← isDefEq expectedType compT) then throwError "expected type{indentD expectedType}\nis not of the form{indentD compT}" let arr ← mkArrow α (← mkAppM ``RequestM #[← mkAppM ``RequestTask #[.const ``Html []]]) let fn ← Term.elabTermEnsuringType fn arr let fn ← instantiateMVars fn if let .const nm .. := fn then let cancellableNm := nm ++ cancellableSuffix if (← existsBuiltinRpcProcedure cancellableNm) || userRpcProcedures.contains (← getEnv) cancellableNm then -- Use the cancellable variant if possible. let code : StrLit := quote $ ofRpcMethodTemplate |>.replace "$RPC_METHOD" (toString cancellableNm) |>.replace "window.toString()" "'true'" let valStx ← `({ javascript := $code }) let ret ← elabTerm valStx expectedType return ret if !(← existsBuiltinRpcProcedure nm) && !userRpcProcedures.contains (← getEnv) nm then throwError s!"'{nm}' is not a known RPC method. Use `@[server_rpc_method]` to register it." -- https://github.com/leanprover/lean4/issues/1415 let code : StrLit := quote $ ofRpcMethodTemplate |>.replace "$RPC_METHOD" (toString nm) |>.replace "window.toString()" "'false'" let valStx ← `({ javascript := $code }) let ret ← elabTerm valStx expectedType return ret throwError "Expected the name of a constant, got a complex term{indentD fn}"
def
ProofWidgets
[]
ProofWidgets/Component/OfRpcMethod.lean
MyComponent.rpc
null
DiagramProps where embeds : Array (String × Html) dsl : String sty : String sub : String /-- Maximum number of optimization steps to take before showing the diagram. Optimization may converge earlier, before taking this many steps. -/ maxOptSteps : Nat := 500 deriving Inhabited, RpcEncodable /-- Displays the given diagram using [Penrose](https://penrose.cs.cmu.edu/). The website contains explanations of how to write domain (`dsl`), style (`sty`), and substance (`sub`) programs. The diagram may also contain embedded HTML trees which are specified in `embeds`. Each embed is HTML together with the name of an object `x` in the substance program. The object `x` can be of any type but *must* be assigned an `x.textBox : Rectangle` field in the style program. This rectangle will be replaced with the HTML tree. Its dimensions will be overridden in the style program to match those of the HTML node. The following additional constants are prepended to the style program: ```penrose theme { color foreground color tooltipBackground color tooltipForeground color tooltipBorder } ``` and can be accessed as, for example, `theme.foreground` in the provided `sty` in order to match the editor theme. -/ @[widget_module]
structure
ProofWidgets
[]
ProofWidgets/Component/PenroseDiagram.lean
DiagramProps
null
Diagram : Component DiagramProps where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "penroseDisplay.js" /-! # `DiagramBuilderM` -/
def
ProofWidgets
[]
ProofWidgets/Component/PenroseDiagram.lean
Diagram
null
DiagramState where /-- The Penrose substance program. Note that `embeds` are added lazily at the end. -/ sub : String := "" /-- Components to display as labels in the diagram, stored in the map as name ↦ (type, html). -/ embeds : Std.HashMap String (String × Html) := ∅ /-- A monad to easily build Penrose diagrams in. -/
structure
ProofWidgets
[]
ProofWidgets/Component/PenroseDiagram.lean
DiagramState
null
DiagramBuilderM := StateT DiagramState MetaM namespace DiagramBuilderM open scoped Jsx in /-- Assemble the diagram using the provided domain and style programs. `none` is returned iff nothing was added to the diagram. -/
abbrev
ProofWidgets
[]
ProofWidgets/Component/PenroseDiagram.lean
DiagramBuilderM
/-- A monad to easily build Penrose diagrams in. -/
buildDiagram (dsl sty : String) (maxOptSteps : Nat := 500) : DiagramBuilderM (Option Html) := do let st ← get if st.sub == "" && st.embeds.isEmpty then return none let mut sub := "AutoLabel All\n" let mut embedHtmls := #[] for (n, (tp, h)) in st.embeds.toArray do sub := sub ++ s!"{tp} {n}\n" embedHtmls := embedHtmls.push (n, h) -- Note: order matters here, embed variables are declared first. sub := sub ++ st.sub return <Diagram embeds={embedHtmls} dsl={dsl} sty={sty} sub={sub} maxOptSteps={maxOptSteps} /> /-- Add an object `nm` of Penrose type `tp`, labelled by `h`, to the substance program. -/
def
ProofWidgets
[]
ProofWidgets/Component/PenroseDiagram.lean
buildDiagram
/-- Assemble the diagram using the provided domain and style programs. `none` is returned iff nothing was added to the diagram. -/
addEmbed (nm : String) (tp : String) (h : Html) : DiagramBuilderM Unit := do modify fun st => { st with embeds := st.embeds.insert nm (tp, h) } open scoped Jsx in /-- Add an object of Penrose type `tp`, corresponding to (and labelled by) the expression `e`, to the substance program. Return its Penrose name. -/
def
ProofWidgets
[]
ProofWidgets/Component/PenroseDiagram.lean
addEmbed
/-- Add an object `nm` of Penrose type `tp`, labelled by `h`, to the substance program. -/
addExpr (tp : String) (e : Expr) : DiagramBuilderM String := do let nm ← toString <$> Lean.Meta.ppExpr e let h := <InteractiveCode fmt={← Widget.ppExprTagged e} /> addEmbed nm tp h return nm /-- Add an instruction `i` to the substance program. -/
def
ProofWidgets
[]
ProofWidgets/Component/PenroseDiagram.lean
addExpr
/-- Add an object of Penrose type `tp`, corresponding to (and labelled by) the expression `e`, to the substance program. Return its Penrose name. -/
addInstruction (i : String) : DiagramBuilderM Unit := do modify fun st => { st with sub := st.sub ++ s!"{i}\n" }
def
ProofWidgets
[]
ProofWidgets/Component/PenroseDiagram.lean
addInstruction
/-- Add an instruction `i` to the substance program. -/
run (x : DiagramBuilderM α) : MetaM α := x.run' {}
def
ProofWidgets
[]
ProofWidgets/Component/PenroseDiagram.lean
run
/-- Add an instruction `i` to the substance program. -/
PenroseDiagramProps := Penrose.DiagramProps /-- Abbreviation for backwards-compatibility. -/
abbrev
ProofWidgets
[]
ProofWidgets/Component/PenroseDiagram.lean
PenroseDiagramProps
/-- Abbreviation for backwards-compatibility. -/
PenroseDiagram := Penrose.Diagram
abbrev
ProofWidgets
[]
ProofWidgets/Component/PenroseDiagram.lean
PenroseDiagram
/-- Abbreviation for backwards-compatibility. -/
Recharts : Widget.Module where javascript := include_str ".." / ".." / ".lake" / "build" / "js" / "recharts.js"
def
ProofWidgets
[]
ProofWidgets/Component/Recharts.lean
Recharts
null
LineChartLayout where | horizontal | vertical deriving FromJson, ToJson
inductive
ProofWidgets
[]
ProofWidgets/Component/Recharts.lean
LineChartLayout
null
LineChartSyncMethod where | index | value deriving FromJson, ToJson
inductive
ProofWidgets
[]
ProofWidgets/Component/Recharts.lean
LineChartSyncMethod
null
LineChartMargin where top : Nat := 5 right : Nat := 5 bottom : Nat := 5 left : Nat := 5 deriving FromJson, ToJson
structure
ProofWidgets
[]
ProofWidgets/Component/Recharts.lean
LineChartMargin
null
LineChartProps where layout : LineChartLayout := .horizontal syncId? : Option String := none syncMethod? : Option LineChartSyncMethod := some .index width : Nat height : Nat data : Array Json margin : LineChartMargin := {} deriving FromJson, ToJson /-- See https://recharts.org/en-US/api/LineChart. -/
structure
ProofWidgets
[]
ProofWidgets/Component/Recharts.lean
LineChartProps
null
LineChart : Component LineChartProps where javascript := Recharts.javascript «export» := "LineChart"
def
ProofWidgets
[]
ProofWidgets/Component/Recharts.lean
LineChart
/-- See https://recharts.org/en-US/api/LineChart. -/
AxisType where /-- Treat values as numbers: spacing on axis by numeric difference. -/ | number /-- Treat values as categorical: equal spacing between values. -/ | category deriving FromJson, ToJson
inductive
ProofWidgets
[]
ProofWidgets/Component/Recharts.lean
AxisType
/-- See https://recharts.org/en-US/api/LineChart. -/
AxisProps where dataKey? : Option Json := none domain? : Option (Array Json) := none allowDataOverflow : Bool := false /-- How values along this axis should be interpreted. The Recharts default is `category`. -/ type : AxisType := .number -- TODO: There are many more props deriving FromJson, ToJson /-- See https://recharts.org/en-US/api/XAxis. -/
structure
ProofWidgets
[]
ProofWidgets/Component/Recharts.lean
AxisProps
/-- Treat values as categorical: equal spacing between values. -/
XAxis : Component AxisProps where javascript := Recharts.javascript «export» := "XAxis" /-- See https://recharts.org/en-US/api/YAxis. -/
def
ProofWidgets
[]
ProofWidgets/Component/Recharts.lean
XAxis
/-- See https://recharts.org/en-US/api/XAxis. -/
YAxis : Component AxisProps where javascript := Recharts.javascript «export» := "YAxis"
def
ProofWidgets
[]
ProofWidgets/Component/Recharts.lean
YAxis
/-- See https://recharts.org/en-US/api/YAxis. -/
LineType where | basis | basisClosed | basisOpen | linear | linearClosed | natural | monotoneX | monotoneY | monotone | step | stepBefore | stepAfter deriving FromJson, ToJson
inductive
ProofWidgets
[]
ProofWidgets/Component/Recharts.lean
LineType
/-- See https://recharts.org/en-US/api/YAxis. -/
LineProps where type : LineType := .linear dataKey : Json stroke : String dot? : Option Bool := none -- TODO: There are many more props deriving FromJson, ToJson /-- See https://recharts.org/en-US/api/Line. -/
structure
ProofWidgets
[]
ProofWidgets/Component/Recharts.lean
LineProps
/-- See https://recharts.org/en-US/api/YAxis. -/
Line : Component LineProps where javascript := Recharts.javascript «export» := "Line"
def
ProofWidgets
[]
ProofWidgets/Component/Recharts.lean
Line
/-- See https://recharts.org/en-US/api/Line. -/