Commit 43b0f387 authored by Andrei Barbu's avatar Andrei Barbu

Update widgets for the latest ipywidgets. Most widgets work

parent 0b889810
...@@ -3,8 +3,6 @@ module IHaskell.Display.Widgets (module X) where ...@@ -3,8 +3,6 @@ module IHaskell.Display.Widgets (module X) where
import IHaskell.Display.Widgets.Button as X import IHaskell.Display.Widgets.Button as X
import IHaskell.Display.Widgets.Box.Box as X import IHaskell.Display.Widgets.Box.Box as X
import IHaskell.Display.Widgets.Box.Proxy as X
import IHaskell.Display.Widgets.Box.PlaceProxy as X
import IHaskell.Display.Widgets.Box.FlexBox as X import IHaskell.Display.Widgets.Box.FlexBox as X
import IHaskell.Display.Widgets.Box.SelectionContainer.Accordion as X import IHaskell.Display.Widgets.Box.SelectionContainer.Accordion as X
import IHaskell.Display.Widgets.Box.SelectionContainer.Tab as X import IHaskell.Display.Widgets.Box.SelectionContainer.Tab as X
...@@ -36,7 +34,7 @@ import IHaskell.Display.Widgets.Selection.ToggleButtons as X ...@@ -36,7 +34,7 @@ import IHaskell.Display.Widgets.Selection.ToggleButtons as X
import IHaskell.Display.Widgets.Selection.SelectMultiple as X import IHaskell.Display.Widgets.Selection.SelectMultiple as X
import IHaskell.Display.Widgets.String.HTML as X import IHaskell.Display.Widgets.String.HTML as X
import IHaskell.Display.Widgets.String.Latex as X import IHaskell.Display.Widgets.String.Label as X
import IHaskell.Display.Widgets.String.Text as X import IHaskell.Display.Widgets.String.Text as X
import IHaskell.Display.Widgets.String.TextArea as X import IHaskell.Display.Widgets.String.TextArea as X
......
...@@ -33,7 +33,7 @@ mkCheckBox = do ...@@ -33,7 +33,7 @@ mkCheckBox = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let widgetState = WidgetState $ defaultBoolWidget "CheckboxView" let widgetState = WidgetState $ defaultBoolWidget "CheckboxView" "CheckboxModel"
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -34,7 +34,7 @@ mkToggleButton = do ...@@ -34,7 +34,7 @@ mkToggleButton = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let boolState = defaultBoolWidget "ToggleButtonView" let boolState = defaultBoolWidget "ToggleButtonView" "ToggleButtonModel"
toggleState = (Tooltip =:: "") toggleState = (Tooltip =:: "")
:& (Icon =:: "") :& (Icon =:: "")
:& (ButtonStyle =:: DefaultButton) :& (ButtonStyle =:: DefaultButton)
......
...@@ -32,7 +32,7 @@ mkValidWidget = do ...@@ -32,7 +32,7 @@ mkValidWidget = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let boolState = defaultBoolWidget "ValidView" let boolState = defaultBoolWidget "ValidView" "ValidModel"
validState = (ReadOutMsg =:: "") :& RNil validState = (ReadOutMsg =:: "") :& RNil
widgetState = WidgetState $ boolState <+> validState widgetState = WidgetState $ boolState <+> validState
......
...@@ -30,7 +30,7 @@ mkBox = do ...@@ -30,7 +30,7 @@ mkBox = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let widgetState = WidgetState $ defaultBoxWidget "BoxView" let widgetState = WidgetState $ defaultBoxWidget "BoxView" "BoxModel"
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -32,7 +32,7 @@ mkFlexBox = do ...@@ -32,7 +32,7 @@ mkFlexBox = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let boxAttrs = defaultBoxWidget "FlexBoxView" let boxAttrs = defaultBoxWidget "FlexBoxView" "FlexBoxModel"
flxAttrs = (Orientation =:: HorizontalOrientation) flxAttrs = (Orientation =:: HorizontalOrientation)
:& (Flex =:: 0) :& (Flex =:: 0)
:& (Pack =:: StartLocation) :& (Pack =:: StartLocation)
......
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.Box.PlaceProxy (
-- * The PlaceProxy widget
PlaceProxy,
-- * Constructor
mkPlaceProxy) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
import Data.Aeson
import Data.IORef (newIORef)
import Data.Vinyl (Rec(..), (<+>))
import Data.Vinyl.Lens (rput)
import IHaskell.Display
import IHaskell.Eval.Widgets
import IHaskell.IPython.Message.UUID as U
import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Common
-- | A 'Box' represents a Box widget from IPython.html.widgets.
type PlaceProxy = IPythonWidget PlaceProxyType
-- | Create a new box
mkPlaceProxy :: IO PlaceProxy
mkPlaceProxy = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetClassState = defaultWidget "PlaceProxyView"
baseState = rput (ModelName =:: "ProxyModel") widgetClassState
proxyState = (Child =:: Nothing) :& (Selector =:: "") :& RNil
widgetState = WidgetState $ baseState <+> proxyState
stateIO <- newIORef widgetState
let widget = IPythonWidget uuid stateIO
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen widget $ toJSON widgetState
-- Return the widget
return widget
instance IHaskellDisplay PlaceProxy where
display b = do
widgetSendView b
return $ Display []
instance IHaskellWidget PlaceProxy where
getCommUUID = uuid
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.Box.Proxy (
-- * The Proxy widget
ProxyWidget,
-- * Constructor
mkProxyWidget) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
import Data.Aeson
import Data.IORef (newIORef)
import Data.Vinyl (Rec(..), (<+>))
import Data.Vinyl.Lens (rput)
import IHaskell.Display
import IHaskell.Eval.Widgets
import IHaskell.IPython.Message.UUID as U
import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Common
-- | A 'Box' represents a Box widget from IPython.html.widgets.
type ProxyWidget = IPythonWidget ProxyType
-- | Create a new box
mkProxyWidget :: IO ProxyWidget
mkProxyWidget = do
-- Default properties, with a random uuid
uuid <- U.random
let widgetClassState = defaultWidget "ProxyView"
baseState = rput (ModelName =:: "ProxyModel") widgetClassState
proxyState = (Child =:: Nothing) :& RNil
widgetState = WidgetState $ baseState <+> proxyState
stateIO <- newIORef widgetState
let proxy = IPythonWidget uuid stateIO
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen proxy $ toJSON widgetState
-- Return the widget
return proxy
instance IHaskellDisplay ProxyWidget where
display b = do
widgetSendView b
return $ Display []
instance IHaskellWidget ProxyWidget where
getCommUUID = uuid
...@@ -34,7 +34,7 @@ mkAccordion = do ...@@ -34,7 +34,7 @@ mkAccordion = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let widgetState = WidgetState $ defaultSelectionContainerWidget "AccordionView" let widgetState = WidgetState $ defaultSelectionContainerWidget "AccordionView" "AccordionModel"
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -34,7 +34,7 @@ mkTabWidget = do ...@@ -34,7 +34,7 @@ mkTabWidget = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let widgetState = WidgetState $ defaultSelectionContainerWidget "TabView" let widgetState = WidgetState $ defaultSelectionContainerWidget "TabView" "TabModel"
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -35,7 +35,7 @@ mkButton = do ...@@ -35,7 +35,7 @@ mkButton = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let dom = defaultDOMWidget "ButtonView" let dom = defaultDOMWidget "ButtonView" "ButtonModel"
but = (Description =:: "") but = (Description =:: "")
:& (Tooltip =:: "") :& (Tooltip =:: "")
:& (Disabled =:: False) :& (Disabled =:: False)
......
...@@ -35,7 +35,7 @@ mkBoundedFloatText = do ...@@ -35,7 +35,7 @@ mkBoundedFloatText = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let widgetState = WidgetState $ defaultBoundedFloatWidget "FloatTextView" let widgetState = WidgetState $ defaultBoundedFloatWidget "FloatTextView" "FloatTextModel"
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -32,7 +32,7 @@ mkFloatProgress = do ...@@ -32,7 +32,7 @@ mkFloatProgress = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let boundedFloatAttrs = defaultBoundedFloatWidget "ProgressView" let boundedFloatAttrs = defaultBoundedFloatWidget "ProgressView" "ProgressModel"
progressAttrs = (Orientation =:: HorizontalOrientation) progressAttrs = (Orientation =:: HorizontalOrientation)
:& (BarStyle =:: DefaultBar) :& (BarStyle =:: DefaultBar)
:& RNil :& RNil
......
...@@ -35,7 +35,7 @@ mkFloatSlider = do ...@@ -35,7 +35,7 @@ mkFloatSlider = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let boundedFloatAttrs = defaultBoundedFloatWidget "FloatSliderView" let boundedFloatAttrs = defaultBoundedFloatWidget "FloatSliderView" "FloatSliderModel"
sliderAttrs = (Orientation =:: HorizontalOrientation) sliderAttrs = (Orientation =:: HorizontalOrientation)
:& (ShowRange =:: False) :& (ShowRange =:: False)
:& (ReadOut =:: True) :& (ReadOut =:: True)
......
...@@ -37,7 +37,7 @@ mkFloatRangeSlider = do ...@@ -37,7 +37,7 @@ mkFloatRangeSlider = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let boundedFloatAttrs = defaultBoundedFloatRangeWidget "FloatSliderView" let boundedFloatAttrs = defaultBoundedFloatRangeWidget "FloatSliderView" "FloatSliderModel"
sliderAttrs = (Orientation =:: HorizontalOrientation) sliderAttrs = (Orientation =:: HorizontalOrientation)
:& (ShowRange =:: True) :& (ShowRange =:: True)
:& (ReadOut =:: True) :& (ReadOut =:: True)
......
...@@ -34,7 +34,7 @@ mkFloatText = do ...@@ -34,7 +34,7 @@ mkFloatText = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let widgetState = WidgetState $ defaultFloatWidget "FloatTextView" let widgetState = WidgetState $ defaultFloatWidget "FloatTextView" "FloatTextModel"
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -33,7 +33,7 @@ mkImageWidget = do ...@@ -33,7 +33,7 @@ mkImageWidget = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let dom = defaultDOMWidget "ImageView" let dom = defaultDOMWidget "ImageView" "ImageModel"
img = (ImageFormat =:: PNG) img = (ImageFormat =:: PNG)
:& (Width =:+ 0) :& (Width =:+ 0)
:& (Height =:+ 0) :& (Height =:+ 0)
......
...@@ -34,7 +34,7 @@ mkBoundedIntText = do ...@@ -34,7 +34,7 @@ mkBoundedIntText = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let widgetState = WidgetState $ defaultBoundedIntWidget "IntTextView" let widgetState = WidgetState $ defaultBoundedIntWidget "IntTextView" "IntTextModel"
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -32,7 +32,7 @@ mkIntProgress = do ...@@ -32,7 +32,7 @@ mkIntProgress = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let boundedIntAttrs = defaultBoundedIntWidget "ProgressView" let boundedIntAttrs = defaultBoundedIntWidget "ProgressView" "ProgressModel"
progressAttrs = (Orientation =:: HorizontalOrientation) progressAttrs = (Orientation =:: HorizontalOrientation)
:& (BarStyle =:: DefaultBar) :& (BarStyle =:: DefaultBar)
:& RNil :& RNil
......
...@@ -35,7 +35,7 @@ mkIntSlider = do ...@@ -35,7 +35,7 @@ mkIntSlider = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let boundedIntAttrs = defaultBoundedIntWidget "IntSliderView" let boundedIntAttrs = defaultBoundedIntWidget "IntSliderView" "IntSliderModel"
sliderAttrs = (Orientation =:: HorizontalOrientation) sliderAttrs = (Orientation =:: HorizontalOrientation)
:& (ShowRange =:: False) :& (ShowRange =:: False)
:& (ReadOut =:: True) :& (ReadOut =:: True)
......
...@@ -36,7 +36,7 @@ mkIntRangeSlider = do ...@@ -36,7 +36,7 @@ mkIntRangeSlider = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let boundedIntAttrs = defaultBoundedIntRangeWidget "IntSliderView" let boundedIntAttrs = defaultBoundedIntRangeWidget "IntSliderView" "IntSliderModel"
sliderAttrs = (Orientation =:: HorizontalOrientation) sliderAttrs = (Orientation =:: HorizontalOrientation)
:& (ShowRange =:: True) :& (ShowRange =:: True)
:& (ReadOut =:: True) :& (ReadOut =:: True)
......
...@@ -34,7 +34,7 @@ mkIntText = do ...@@ -34,7 +34,7 @@ mkIntText = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let widgetState = WidgetState $ defaultIntWidget "IntTextView" let widgetState = WidgetState $ defaultIntWidget "IntTextView" "IntTextModel"
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UndecidableSuperClasses #-}
{-# LANGUAGE PolyKinds #-} {-# LANGUAGE PolyKinds #-}
module IHaskell.Display.Widgets.Interactive (interactive, uncurryHList, Rec(..), Argument(..)) where module IHaskell.Display.Widgets.Interactive (interactive, uncurryHList, Rec(..), Argument(..)) where
......
...@@ -36,7 +36,7 @@ mkOutputWidget = do ...@@ -36,7 +36,7 @@ mkOutputWidget = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let widgetState = WidgetState $ defaultDOMWidget "OutputView" let widgetState = WidgetState $ defaultDOMWidget "OutputView" "OutputModel"
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -34,7 +34,7 @@ mkDropdown :: IO Dropdown ...@@ -34,7 +34,7 @@ mkDropdown :: IO Dropdown
mkDropdown = do mkDropdown = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let selectionAttrs = defaultSelectionWidget "DropdownView" let selectionAttrs = defaultSelectionWidget "DropdownView" "DropdownModel"
dropdownAttrs = (ButtonStyle =:: DefaultButton) :& RNil dropdownAttrs = (ButtonStyle =:: DefaultButton) :& RNil
widgetState = WidgetState $ selectionAttrs <+> dropdownAttrs widgetState = WidgetState $ selectionAttrs <+> dropdownAttrs
......
...@@ -33,7 +33,7 @@ mkRadioButtons :: IO RadioButtons ...@@ -33,7 +33,7 @@ mkRadioButtons :: IO RadioButtons
mkRadioButtons = do mkRadioButtons = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let widgetState = WidgetState $ defaultSelectionWidget "RadioButtonsView" let widgetState = WidgetState $ defaultSelectionWidget "RadioButtonsView" "RadioButtonsModel"
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -34,7 +34,7 @@ mkSelect :: IO Select ...@@ -34,7 +34,7 @@ mkSelect :: IO Select
mkSelect = do mkSelect = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let widgetState = WidgetState $ defaultSelectionWidget "SelectView" let widgetState = WidgetState $ defaultSelectionWidget "SelectView" "SelectModel"
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -34,7 +34,7 @@ mkSelectMultiple :: IO SelectMultiple ...@@ -34,7 +34,7 @@ mkSelectMultiple :: IO SelectMultiple
mkSelectMultiple = do mkSelectMultiple = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let widgetState = WidgetState $ defaultMultipleSelectionWidget "SelectMultipleView" let widgetState = WidgetState $ defaultMultipleSelectionWidget "SelectMultipleView" "SelectMultipleModel"
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -34,7 +34,7 @@ mkToggleButtons :: IO ToggleButtons ...@@ -34,7 +34,7 @@ mkToggleButtons :: IO ToggleButtons
mkToggleButtons = do mkToggleButtons = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let selectionAttrs = defaultSelectionWidget "ToggleButtonsView" let selectionAttrs = defaultSelectionWidget "ToggleButtonsView" "ToggleButtonsModel"
toggleButtonsAttrs = (Tooltips =:: []) toggleButtonsAttrs = (Tooltips =:: [])
:& (Icons =:: []) :& (Icons =:: [])
:& (ButtonStyle =:: DefaultButton) :& (ButtonStyle =:: DefaultButton)
......
...@@ -29,7 +29,7 @@ mkHTMLWidget :: IO HTMLWidget ...@@ -29,7 +29,7 @@ mkHTMLWidget :: IO HTMLWidget
mkHTMLWidget = do mkHTMLWidget = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let widgetState = WidgetState $ defaultStringWidget "HTMLView" let widgetState = WidgetState $ defaultStringWidget "HTMLView" "HTMLModel"
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.String.Latex ( module IHaskell.Display.Widgets.String.Label (
-- * The Latex Widget -- * The Label Widget
LatexWidget, LabelWidget,
-- * Constructor -- * Constructor
mkLatexWidget) where mkLabelWidget) where
-- To keep `cabal repl` happy when running from the ihaskell repo -- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude import Prelude
...@@ -21,15 +21,15 @@ import IHaskell.IPython.Message.UUID as U ...@@ -21,15 +21,15 @@ import IHaskell.IPython.Message.UUID as U
import IHaskell.Display.Widgets.Types import IHaskell.Display.Widgets.Types
-- | A 'LatexWidget' represents a Latex widget from IPython.html.widgets. -- | A 'LabelWidget' represents a Label widget from IPython.html.widgets.
type LatexWidget = IPythonWidget LatexType type LabelWidget = IPythonWidget LabelType
-- | Create a new Latex widget -- | Create a new Label widget
mkLatexWidget :: IO LatexWidget mkLabelWidget :: IO LabelWidget
mkLatexWidget = do mkLabelWidget = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let widgetState = WidgetState $ defaultStringWidget "LatexView" let widgetState = WidgetState $ defaultStringWidget "LabelView" "LabelModel"
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
...@@ -41,10 +41,10 @@ mkLatexWidget = do ...@@ -41,10 +41,10 @@ mkLatexWidget = do
-- Return the widget -- Return the widget
return widget return widget
instance IHaskellDisplay LatexWidget where instance IHaskellDisplay LabelWidget where
display b = do display b = do
widgetSendView b widgetSendView b
return $ Display [] return $ Display []
instance IHaskellWidget LatexWidget where instance IHaskellWidget LabelWidget where
getCommUUID = uuid getCommUUID = uuid
...@@ -33,7 +33,7 @@ mkTextWidget :: IO TextWidget ...@@ -33,7 +33,7 @@ mkTextWidget :: IO TextWidget
mkTextWidget = do mkTextWidget = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let strWidget = defaultStringWidget "TextView" let strWidget = defaultStringWidget "TextView" "TextModel"
txtWidget = (SubmitHandler =:: return ()) :& (ChangeHandler =:: return ()) :& RNil txtWidget = (SubmitHandler =:: return ()) :& (ChangeHandler =:: return ()) :& RNil
widgetState = WidgetState $ strWidget <+> txtWidget widgetState = WidgetState $ strWidget <+> txtWidget
......
...@@ -33,7 +33,7 @@ mkTextArea :: IO TextArea ...@@ -33,7 +33,7 @@ mkTextArea :: IO TextArea
mkTextArea = do mkTextArea = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
uuid <- U.random uuid <- U.random
let strAttrs = defaultStringWidget "TextareaView" let strAttrs = defaultStringWidget "TextareaView" "TextareaModel"
wgtAttrs = (ChangeHandler =:: return ()) :& RNil wgtAttrs = (ChangeHandler =:: return ()) :& RNil
widgetState = WidgetState $ strAttrs <+> wgtAttrs widgetState = WidgetState $ strAttrs <+> wgtAttrs
......
...@@ -241,7 +241,7 @@ data WidgetType = ButtonType ...@@ -241,7 +241,7 @@ data WidgetType = ButtonType
| ImageType | ImageType
| OutputType | OutputType
| HTMLType | HTMLType
| LatexType | LabelType
| TextType | TextType
| TextAreaType | TextAreaType
| CheckBoxType | CheckBoxType
...@@ -263,8 +263,6 @@ data WidgetType = ButtonType ...@@ -263,8 +263,6 @@ data WidgetType = ButtonType
| FloatProgressType | FloatProgressType
| FloatRangeSliderType | FloatRangeSliderType
| BoxType | BoxType
| ProxyType
| PlaceProxyType
| FlexBoxType | FlexBoxType
| AccordionType | AccordionType
| TabType | TabType
...@@ -280,7 +278,7 @@ type family WidgetFields (w :: WidgetType) :: [Field] where ...@@ -280,7 +278,7 @@ type family WidgetFields (w :: WidgetType) :: [Field] where
DOMWidgetClass :++ '[S.ImageFormat, S.Width, S.Height, S.B64Value] DOMWidgetClass :++ '[S.ImageFormat, S.Width, S.Height, S.B64Value]
WidgetFields OutputType = DOMWidgetClass WidgetFields OutputType = DOMWidgetClass
WidgetFields HTMLType = StringClass WidgetFields HTMLType = StringClass
WidgetFields LatexType = StringClass WidgetFields LabelType = StringClass
WidgetFields TextType = WidgetFields TextType =
StringClass :++ '[S.SubmitHandler, S.ChangeHandler] StringClass :++ '[S.SubmitHandler, S.ChangeHandler]
WidgetFields TextAreaType = StringClass :++ '[S.ChangeHandler] WidgetFields TextAreaType = StringClass :++ '[S.ChangeHandler]
...@@ -315,9 +313,6 @@ type family WidgetFields (w :: WidgetType) :: [Field] where ...@@ -315,9 +313,6 @@ type family WidgetFields (w :: WidgetType) :: [Field] where
BoundedFloatRangeClass :++ BoundedFloatRangeClass :++
'[S.Orientation, S.ShowRange, S.ReadOut, S.SliderColor] '[S.Orientation, S.ShowRange, S.ReadOut, S.SliderColor]
WidgetFields BoxType = BoxClass WidgetFields BoxType = BoxClass
WidgetFields ProxyType = WidgetClass :++ '[S.Child]
WidgetFields PlaceProxyType =
WidgetFields ProxyType :++ '[S.Selector]
WidgetFields FlexBoxType = WidgetFields FlexBoxType =
BoxClass :++ '[S.Orientation, S.Flex, S.Pack, S.Align] BoxClass :++ '[S.Orientation, S.Flex, S.Pack, S.Align]
WidgetFields AccordionType = SelectionContainerClass WidgetFields AccordionType = SelectionContainerClass
...@@ -619,23 +614,23 @@ s =:+ val = Attr ...@@ -619,23 +614,23 @@ s =:+ val = Attr
(reflect s) (reflect s)
-- | Get a field from a singleton Adapted from: http://stackoverflow.com/a/28033250/2388535 -- | Get a field from a singleton Adapted from: http://stackoverflow.com/a/28033250/2388535
reflect :: forall (f :: Field). (SingI f, SingKind ('KProxy :: KProxy Field)) => Sing f -> Field reflect :: forall (f :: Field). (SingI f) => Sing f -> Field
reflect = fromSing reflect = fromSing
-- | A record representing an object of the Widget class from IPython -- | A record representing an object of the Widget class from IPython
defaultWidget :: FieldType S.ViewName -> Rec Attr WidgetClass defaultWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr WidgetClass
defaultWidget viewName = (ViewModule =:: "") defaultWidget viewName modelName = (ViewModule =:: "jupyter-js-widgets")
:& (ViewName =:: viewName) :& (ViewName =:: viewName)
:& (ModelModule =:: "") :& (ModelModule =:: "jupyter-js-widgets")
:& (ModelName =:: "WidgetModel") :& (ModelName =:: modelName)
:& (MsgThrottle =:+ 3) :& (MsgThrottle =:+ 3)
:& (Version =:: 0) :& (Version =:: 0)
:& (DisplayHandler =:: return ()) :& (DisplayHandler =:: return ())
:& RNil :& RNil
-- | A record representing an object of the DOMWidget class from IPython -- | A record representing an object of the DOMWidget class from IPython
defaultDOMWidget :: FieldType S.ViewName -> Rec Attr DOMWidgetClass defaultDOMWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr DOMWidgetClass
defaultDOMWidget viewName = defaultWidget viewName <+> domAttrs defaultDOMWidget viewName modelName = defaultWidget viewName modelName <+> domAttrs
where where
domAttrs = (Visible =:: True) domAttrs = (Visible =:: True)
:& (CSS =:: []) :& (CSS =:: [])
...@@ -657,8 +652,8 @@ defaultDOMWidget viewName = defaultWidget viewName <+> domAttrs ...@@ -657,8 +652,8 @@ defaultDOMWidget viewName = defaultWidget viewName <+> domAttrs
:& RNil :& RNil
-- | A record representing a widget of the _String class from IPython -- | A record representing a widget of the _String class from IPython
defaultStringWidget :: FieldType S.ViewName -> Rec Attr StringClass defaultStringWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr StringClass
defaultStringWidget viewName = defaultDOMWidget viewName <+> strAttrs defaultStringWidget viewName modelName = defaultDOMWidget viewName modelName <+> strAttrs
where where
strAttrs = (StringValue =:: "") strAttrs = (StringValue =:: "")
:& (Disabled =:: False) :& (Disabled =:: False)
...@@ -667,8 +662,8 @@ defaultStringWidget viewName = defaultDOMWidget viewName <+> strAttrs ...@@ -667,8 +662,8 @@ defaultStringWidget viewName = defaultDOMWidget viewName <+> strAttrs
:& RNil :& RNil
-- | A record representing a widget of the _Bool class from IPython -- | A record representing a widget of the _Bool class from IPython
defaultBoolWidget :: FieldType S.ViewName -> Rec Attr BoolClass defaultBoolWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr BoolClass
defaultBoolWidget viewName = defaultDOMWidget viewName <+> boolAttrs defaultBoolWidget viewName modelName = defaultDOMWidget viewName modelName <+> boolAttrs
where where
boolAttrs = (BoolValue =:: False) boolAttrs = (BoolValue =:: False)
:& (Disabled =:: False) :& (Disabled =:: False)
...@@ -677,8 +672,8 @@ defaultBoolWidget viewName = defaultDOMWidget viewName <+> boolAttrs ...@@ -677,8 +672,8 @@ defaultBoolWidget viewName = defaultDOMWidget viewName <+> boolAttrs
:& RNil :& RNil
-- | A record representing a widget of the _Selection class from IPython -- | A record representing a widget of the _Selection class from IPython
defaultSelectionWidget :: FieldType S.ViewName -> Rec Attr SelectionClass defaultSelectionWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr SelectionClass
defaultSelectionWidget viewName = defaultDOMWidget viewName <+> selectionAttrs defaultSelectionWidget viewName modelName = defaultDOMWidget viewName modelName <+> selectionAttrs
where where
selectionAttrs = (Options =:: OptionLabels []) selectionAttrs = (Options =:: OptionLabels [])
:& (SelectedValue =:: "") :& (SelectedValue =:: "")
...@@ -689,8 +684,8 @@ defaultSelectionWidget viewName = defaultDOMWidget viewName <+> selectionAttrs ...@@ -689,8 +684,8 @@ defaultSelectionWidget viewName = defaultDOMWidget viewName <+> selectionAttrs
:& RNil :& RNil
-- | A record representing a widget of the _MultipleSelection class from IPython -- | A record representing a widget of the _MultipleSelection class from IPython
defaultMultipleSelectionWidget :: FieldType S.ViewName -> Rec Attr MultipleSelectionClass defaultMultipleSelectionWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr MultipleSelectionClass
defaultMultipleSelectionWidget viewName = defaultDOMWidget viewName <+> mulSelAttrs defaultMultipleSelectionWidget viewName modelName = defaultDOMWidget viewName modelName <+> mulSelAttrs
where where
mulSelAttrs = (Options =:: OptionLabels []) mulSelAttrs = (Options =:: OptionLabels [])
:& (SelectedValues =:: []) :& (SelectedValues =:: [])
...@@ -701,8 +696,8 @@ defaultMultipleSelectionWidget viewName = defaultDOMWidget viewName <+> mulSelAt ...@@ -701,8 +696,8 @@ defaultMultipleSelectionWidget viewName = defaultDOMWidget viewName <+> mulSelAt
:& RNil :& RNil
-- | A record representing a widget of the _Int class from IPython -- | A record representing a widget of the _Int class from IPython
defaultIntWidget :: FieldType S.ViewName -> Rec Attr IntClass defaultIntWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr IntClass
defaultIntWidget viewName = defaultDOMWidget viewName <+> intAttrs defaultIntWidget viewName modelName = defaultDOMWidget viewName modelName <+> intAttrs
where where
intAttrs = (IntValue =:: 0) intAttrs = (IntValue =:: 0)
:& (Disabled =:: False) :& (Disabled =:: False)
...@@ -711,8 +706,8 @@ defaultIntWidget viewName = defaultDOMWidget viewName <+> intAttrs ...@@ -711,8 +706,8 @@ defaultIntWidget viewName = defaultDOMWidget viewName <+> intAttrs
:& RNil :& RNil
-- | A record representing a widget of the _BoundedInt class from IPython -- | A record representing a widget of the _BoundedInt class from IPython
defaultBoundedIntWidget :: FieldType S.ViewName -> Rec Attr BoundedIntClass defaultBoundedIntWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr BoundedIntClass
defaultBoundedIntWidget viewName = defaultIntWidget viewName <+> boundedIntAttrs defaultBoundedIntWidget viewName modelName = defaultIntWidget viewName modelName <+> boundedIntAttrs
where where
boundedIntAttrs = (StepInt =:: 1) boundedIntAttrs = (StepInt =:: 1)
:& (MinInt =:: 0) :& (MinInt =:: 0)
...@@ -720,8 +715,8 @@ defaultBoundedIntWidget viewName = defaultIntWidget viewName <+> boundedIntAttrs ...@@ -720,8 +715,8 @@ defaultBoundedIntWidget viewName = defaultIntWidget viewName <+> boundedIntAttrs
:& RNil :& RNil
-- | A record representing a widget of the _BoundedInt class from IPython -- | A record representing a widget of the _BoundedInt class from IPython
defaultIntRangeWidget :: FieldType S.ViewName -> Rec Attr IntRangeClass defaultIntRangeWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr IntRangeClass
defaultIntRangeWidget viewName = defaultIntWidget viewName <+> rangeAttrs defaultIntRangeWidget viewName modelName = defaultIntWidget viewName modelName <+> rangeAttrs
where where
rangeAttrs = (IntPairValue =:: (25, 75)) rangeAttrs = (IntPairValue =:: (25, 75))
:& (LowerInt =:: 0) :& (LowerInt =:: 0)
...@@ -729,8 +724,8 @@ defaultIntRangeWidget viewName = defaultIntWidget viewName <+> rangeAttrs ...@@ -729,8 +724,8 @@ defaultIntRangeWidget viewName = defaultIntWidget viewName <+> rangeAttrs
:& RNil :& RNil
-- | A record representing a widget of the _BoundedIntRange class from IPython -- | A record representing a widget of the _BoundedIntRange class from IPython
defaultBoundedIntRangeWidget :: FieldType S.ViewName -> Rec Attr BoundedIntRangeClass defaultBoundedIntRangeWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr BoundedIntRangeClass
defaultBoundedIntRangeWidget viewName = defaultIntRangeWidget viewName <+> boundedIntRangeAttrs defaultBoundedIntRangeWidget viewName modelName = defaultIntRangeWidget viewName modelName <+> boundedIntRangeAttrs
where where
boundedIntRangeAttrs = (StepInt =:+ 1) boundedIntRangeAttrs = (StepInt =:+ 1)
:& (MinInt =:: 0) :& (MinInt =:: 0)
...@@ -738,8 +733,8 @@ defaultBoundedIntRangeWidget viewName = defaultIntRangeWidget viewName <+> bound ...@@ -738,8 +733,8 @@ defaultBoundedIntRangeWidget viewName = defaultIntRangeWidget viewName <+> bound
:& RNil :& RNil
-- | A record representing a widget of the _Float class from IPython -- | A record representing a widget of the _Float class from IPython
defaultFloatWidget :: FieldType S.ViewName -> Rec Attr FloatClass defaultFloatWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr FloatClass
defaultFloatWidget viewName = defaultDOMWidget viewName <+> intAttrs defaultFloatWidget viewName modelName = defaultDOMWidget viewName modelName <+> intAttrs
where where
intAttrs = (FloatValue =:: 0) intAttrs = (FloatValue =:: 0)
:& (Disabled =:: False) :& (Disabled =:: False)
...@@ -748,8 +743,8 @@ defaultFloatWidget viewName = defaultDOMWidget viewName <+> intAttrs ...@@ -748,8 +743,8 @@ defaultFloatWidget viewName = defaultDOMWidget viewName <+> intAttrs
:& RNil :& RNil
-- | A record representing a widget of the _BoundedFloat class from IPython -- | A record representing a widget of the _BoundedFloat class from IPython
defaultBoundedFloatWidget :: FieldType S.ViewName -> Rec Attr BoundedFloatClass defaultBoundedFloatWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr BoundedFloatClass
defaultBoundedFloatWidget viewName = defaultFloatWidget viewName <+> boundedFloatAttrs defaultBoundedFloatWidget viewName modelName = defaultFloatWidget viewName modelName <+> boundedFloatAttrs
where where
boundedFloatAttrs = (StepFloat =:+ 1) boundedFloatAttrs = (StepFloat =:+ 1)
:& (MinFloat =:: 0) :& (MinFloat =:: 0)
...@@ -757,8 +752,8 @@ defaultBoundedFloatWidget viewName = defaultFloatWidget viewName <+> boundedFloa ...@@ -757,8 +752,8 @@ defaultBoundedFloatWidget viewName = defaultFloatWidget viewName <+> boundedFloa
:& RNil :& RNil
-- | A record representing a widget of the _BoundedFloat class from IPython -- | A record representing a widget of the _BoundedFloat class from IPython
defaultFloatRangeWidget :: FieldType S.ViewName -> Rec Attr FloatRangeClass defaultFloatRangeWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr FloatRangeClass
defaultFloatRangeWidget viewName = defaultFloatWidget viewName <+> rangeAttrs defaultFloatRangeWidget viewName modelName = defaultFloatWidget viewName modelName <+> rangeAttrs
where where
rangeAttrs = (FloatPairValue =:: (25, 75)) rangeAttrs = (FloatPairValue =:: (25, 75))
:& (LowerFloat =:: 0) :& (LowerFloat =:: 0)
...@@ -766,8 +761,8 @@ defaultFloatRangeWidget viewName = defaultFloatWidget viewName <+> rangeAttrs ...@@ -766,8 +761,8 @@ defaultFloatRangeWidget viewName = defaultFloatWidget viewName <+> rangeAttrs
:& RNil :& RNil
-- | A record representing a widget of the _BoundedFloatRange class from IPython -- | A record representing a widget of the _BoundedFloatRange class from IPython
defaultBoundedFloatRangeWidget :: FieldType S.ViewName -> Rec Attr BoundedFloatRangeClass defaultBoundedFloatRangeWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr BoundedFloatRangeClass
defaultBoundedFloatRangeWidget viewName = defaultFloatRangeWidget viewName <+> boundedFloatRangeAttrs defaultBoundedFloatRangeWidget viewName modelName = defaultFloatRangeWidget viewName modelName <+> boundedFloatRangeAttrs
where where
boundedFloatRangeAttrs = (StepFloat =:+ 1) boundedFloatRangeAttrs = (StepFloat =:+ 1)
:& (MinFloat =:: 0) :& (MinFloat =:: 0)
...@@ -775,20 +770,18 @@ defaultBoundedFloatRangeWidget viewName = defaultFloatRangeWidget viewName <+> b ...@@ -775,20 +770,18 @@ defaultBoundedFloatRangeWidget viewName = defaultFloatRangeWidget viewName <+> b
:& RNil :& RNil
-- | A record representing a widget of the _Box class from IPython -- | A record representing a widget of the _Box class from IPython
defaultBoxWidget :: FieldType S.ViewName -> Rec Attr BoxClass defaultBoxWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr BoxClass
defaultBoxWidget viewName = domAttrs <+> boxAttrs defaultBoxWidget viewName modelName = defaultDOMWidget viewName modelName <+> intAttrs
where where
defaultDOM = defaultDOMWidget viewName intAttrs = (Children =:: [])
domAttrs = rput (ModelName =:: "BoxModel") defaultDOM
boxAttrs = (Children =:: [])
:& (OverflowX =:: DefaultOverflow) :& (OverflowX =:: DefaultOverflow)
:& (OverflowY =:: DefaultOverflow) :& (OverflowY =:: DefaultOverflow)
:& (BoxStyle =:: DefaultBox) :& (BoxStyle =:: DefaultBox)
:& RNil :& RNil
-- | A record representing a widget of the _SelectionContainer class from IPython -- | A record representing a widget of the _SelectionContainer class from IPython
defaultSelectionContainerWidget :: FieldType S.ViewName -> Rec Attr SelectionContainerClass defaultSelectionContainerWidget :: FieldType S.ViewName -> FieldType S.ModelName -> Rec Attr SelectionContainerClass
defaultSelectionContainerWidget viewName = defaultBoxWidget viewName <+> selAttrs defaultSelectionContainerWidget viewName modelName = defaultBoxWidget viewName modelName <+> selAttrs
where where
selAttrs = (Titles =:: []) selAttrs = (Titles =:: [])
:& (SelectedIndex =:: 0) :& (SelectedIndex =:: 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment