diff --git a/ihaskell-display/ihaskell-widgets/MsgSpec.md b/ihaskell-display/ihaskell-widgets/MsgSpec.md index 3bf9a6f7..465de5cd 100644 --- a/ihaskell-display/ihaskell-widgets/MsgSpec.md +++ b/ihaskell-display/ihaskell-widgets/MsgSpec.md @@ -1,8 +1,9 @@ # IPython widget messaging specification version 2 -The model implemented is the Model State v8, for ipywidgets 7.4., @jupyter-widgets/base 1.1., and @jupyter-widgets/controls 1.4.*. +The model implemented is the Model State v8, for ipywidgets 8.0., @jupyter-widgets/base 2.0.0, and @jupyter-widgets/controls 2.0.0. -> Largely based on: https://github.com/jupyter-widgets/ipywidgets/blob/master/packages/schema/messages.md +> Largely based on: https://github.com/jupyter-widgets/ipywidgets/blob/main/packages/schema/jupyterwidgetmodels.v8.md +> and https://github.com/jupyter-widgets/ipywidgets/blob/master/packages/schema/messages.md > The messaging specification as detailed is riddled with assumptions the IHaskell widget > implementation makes. It works for us, so it should work for everyone. diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs index 80955fa7..d745f8bb 100644 --- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs +++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs @@ -56,6 +56,8 @@ pattern Width = S.SWidth pattern Height = S.SHeight -- | Description of the control pattern Description = S.SDescription +-- | Allow html in description +pattern DescriptionAllowHtml = S.SDescriptionAllowHtml -- | Method to be called on click pattern ClickHandler = S.SClickHandler -- | Method to be called on submit @@ -68,6 +70,8 @@ pattern StringValue = S.SStringValue pattern Placeholder = S.SPlaceholder -- | Tooltip for the description pattern Tooltip = S.STooltip +-- | Is the widget tabbable? +pattern Tabbable = S.STabbable -- | The font-awesome icon without the fa- pattern Icon = S.SIcon -- | Predefined styling for the button @@ -190,8 +194,20 @@ pattern Buttons = S.SButtons pattern Axes = S.SAxes -- | Color of the button pattern ButtonColor = S.SButtonColor +-- | The font family of the text +pattern FontFamily = S.SFontFamily -- | The font weight of the text +pattern FontSize = S.SFontSize +-- | The font style of the text +pattern FontStyle = S.SFontStyle +-- | The font variant of the text +pattern FontVariant = S.SFontVariant +-- | The text color of the text pattern FontWeight = S.SFontWeight +-- | The font size of the text +pattern TextColor = S.STextColor +-- | The text decoration of the text +pattern TextDecoration = S.STextDecoration -- | Width of the description to the side of the control pattern DescriptionWidth = S.SDescriptionWidth -- | Color of the progress bar diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/Common.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/Common.hs index 5dbaf67a..cc55cb57 100644 --- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/Common.hs +++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/Common.hs @@ -18,7 +18,10 @@ import qualified IHaskell.Display.Widgets.Singletons as S pattern AlignContent = S.SLAlignContent pattern AlignItems = S.SLAlignItems pattern AlignSelf = S.SLAlignSelf -pattern Border = S.SLBorder +pattern BorderBottom = S.SLBorderBottom +pattern BorderLeft = S.SLBorderLeft +pattern BorderRight = S.SLBorderRight +pattern BorderTop = S.SLBorderTop pattern Bottom = S.SLBottom pattern Display = S.SLDisplay pattern Flex = S.SLFlex @@ -42,10 +45,10 @@ pattern MaxHeight = S.SLMaxHeight pattern MaxWidth = S.SLMaxWidth pattern MinHeight = S.SLMinHeight pattern MinWidth = S.SLMinWidth +pattern ObjectFit = S.SLObjectFit +pattern ObjectPosition = S.SLObjectPosition pattern Order = S.SLOrder pattern Overflow = S.SLOverflow -pattern OverflowX = S.SLOverflowX -pattern OverflowY = S.SLOverflowY pattern Padding = S.SLPadding pattern Right = S.SLRight pattern Top = S.SLTop @@ -67,4 +70,4 @@ gridAutoFlowProps = ["column", "row", "row dense", "column dense"] ++ cssProps justifyContentProps = ["flex-start", "flex-end", "center", "space-between", "space-around"] ++ cssProps justifyItemsProps = ["flex-start", "flex-end", "center"] ++ cssProps overflowProps = ["visible", "hidden", "scroll", "auto"] ++ cssProps -visibilityProps = ["visible", "hidden"] ++ cssProps \ No newline at end of file +visibilityProps = ["visible", "hidden"] ++ cssProps diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/Types.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/Types.hs index e2c55995..0bc4bf11 100644 --- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/Types.hs +++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/Types.hs @@ -42,7 +42,10 @@ type LayoutClass = [ 'S.ModelModule , 'S.LAlignContent , 'S.LAlignItems , 'S.LAlignSelf - , 'S.LBorder + , 'S.LBorderBottom + , 'S.LBorderLeft + , 'S.LBorderRight + , 'S.LBorderTop , 'S.LBottom , 'S.LDisplay , 'S.LFlex @@ -66,10 +69,10 @@ type LayoutClass = [ 'S.ModelModule , 'S.LMaxWidth , 'S.LMinHeight , 'S.LMinWidth + , 'S.LObjectFit + , 'S.LObjectPosition , 'S.LOrder , 'S.LOverflow - , 'S.LOverflowX - , 'S.LOverflowY , 'S.LPadding , 'S.LRight , 'S.LTop @@ -80,7 +83,10 @@ type LayoutClass = [ 'S.ModelModule type instance FieldType 'S.LAlignContent = Maybe String type instance FieldType 'S.LAlignItems = Maybe String type instance FieldType 'S.LAlignSelf = Maybe String -type instance FieldType 'S.LBorder = Maybe String +type instance FieldType 'S.LBorderBottom = Maybe String +type instance FieldType 'S.LBorderLeft = Maybe String +type instance FieldType 'S.LBorderRight = Maybe String +type instance FieldType 'S.LBorderTop = Maybe String type instance FieldType 'S.LBottom = Maybe String type instance FieldType 'S.LDisplay = Maybe String type instance FieldType 'S.LFlex = Maybe String @@ -104,10 +110,10 @@ type instance FieldType 'S.LMaxHeight = Maybe String type instance FieldType 'S.LMaxWidth = Maybe String type instance FieldType 'S.LMinHeight = Maybe String type instance FieldType 'S.LMinWidth = Maybe String +type instance FieldType 'S.LObjectFit = Maybe String +type instance FieldType 'S.LObjectPosition = Maybe String type instance FieldType 'S.LOrder = Maybe String type instance FieldType 'S.LOverflow = Maybe String -type instance FieldType 'S.LOverflowX = Maybe String -type instance FieldType 'S.LOverflowY = Maybe String type instance FieldType 'S.LPadding = Maybe String type instance FieldType 'S.LRight = Maybe String type instance FieldType 'S.LTop = Maybe String @@ -120,15 +126,18 @@ type instance WidgetFields 'LayoutType = LayoutClass -- | A record representing a widget of the Layour class from IPython defaultLayoutWidget :: Rec Attr LayoutClass defaultLayoutWidget = (S.SModelModule =:! "@jupyter-widgets/base") - :& (S.SModelModuleVersion =:! "1.1.0") + :& (S.SModelModuleVersion =:! "2.0.0") :& (S.SModelName =:! "LayoutModel") :& (S.SViewModule =:! "@jupyter-widgets/base") - :& (S.SViewModuleVersion =:! "1.1.0") + :& (S.SViewModuleVersion =:! "2.0.0") :& (S.SViewName =:! "LayoutView") :& (AlignContent =:. (Nothing, venum alignContentProps)) :& (AlignItems =:. (Nothing, venum alignItemProps)) :& (AlignSelf =:. (Nothing, venum alignSelfProps)) - :& (Border =:: Nothing) + :& (BorderBottom =:: Nothing) + :& (BorderLeft =:: Nothing) + :& (BorderRight =:: Nothing) + :& (BorderTop =:: Nothing) :& (Bottom =:: Nothing) :& (Display =:: Nothing) :& (Flex =:: Nothing) @@ -152,10 +161,10 @@ defaultLayoutWidget = (S.SModelModule =:! "@jupyter-widgets/base") :& (MaxWidth =:: Nothing) :& (MinHeight =:: Nothing) :& (MinWidth =:: Nothing) + :& (ObjectFit =:: Nothing) + :& (ObjectPosition =:: Nothing) :& (Order =:: Nothing) :& (Overflow =:. (Nothing, venum overflowProps)) - :& (OverflowX =:. (Nothing, venum overflowProps)) - :& (OverflowY =:. (Nothing, venum overflowProps)) :& (Padding =:: Nothing) :& (Right =:: Nothing) :& (Top =:: Nothing) diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Singletons.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Singletons.hs index 416c33da..b4562713 100644 --- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Singletons.hs +++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Singletons.hs @@ -48,12 +48,14 @@ singletons | Width | Height | Description + | DescriptionAllowHtml | ClickHandler | SubmitHandler | Disabled | StringValue | Placeholder | Tooltip + | Tabbable | Icon | ButtonStyle | BSValue @@ -115,7 +117,13 @@ singletons | Buttons | Axes | ButtonColor + | FontFamily + | FontStyle + | FontSize + | FontVariant | FontWeight + | TextColor + | TextDecoration | DescriptionWidth | BarColor | HandleColor @@ -131,7 +139,10 @@ singletons | LAlignContent | LAlignItems | LAlignSelf - | LBorder + | LBorderBottom + | LBorderLeft + | LBorderRight + | LBorderTop | LBottom | LDisplay | LFlex @@ -155,10 +166,10 @@ singletons | LMaxWidth | LMinHeight | LMinWidth + | LObjectFit + | LObjectPosition | LOrder | LOverflow - | LOverflowX - | LOverflowY | LPadding | LRight | LTop @@ -182,12 +193,14 @@ promote toKey Width = "width" toKey Height = "height" toKey Description = "description" + toKey DescriptionAllowHtml = "description_allow_html" toKey ClickHandler = "" -- Not sent to the frontend toKey SubmitHandler = "" -- Not sent to the frontend toKey Disabled = "disabled" toKey StringValue = "value" toKey Placeholder = "placeholder" toKey Tooltip = "tooltip" + toKey Tabbable = "tabbable" toKey Icon = "icon" toKey ButtonStyle = "button_style" toKey BSValue = "value" @@ -224,7 +237,7 @@ promote toKey ChangeHandler = "" -- Not sent to the frontend toKey Children = "children" toKey BoxStyle = "box_style" - toKey Titles = "_titles" + toKey Titles = "titles" toKey SelectedIndex = "selected_index" toKey ReadOutMsg = "readout" toKey Indent = "indent" @@ -250,7 +263,13 @@ promote toKey Axes = "axes" toKey Layout = "layout" toKey ButtonColor = "button_color" + toKey FontFamily = "font_family" + toKey FontSize = "font_size" + toKey FontStyle = "font_style" + toKey FontVariant = "font_variant" toKey FontWeight = "font_weight" + toKey TextColor = "text_color" + toKey TextDecoration = "text_decoration" toKey DescriptionWidth = "description_width" toKey BarColor = "bar_color" toKey HandleColor = "handle_color" @@ -263,7 +282,10 @@ promote toKey LAlignContent = "align_content" toKey LAlignItems = "align_items" toKey LAlignSelf = "align_self" - toKey LBorder = "border" + toKey LBorderBottom = "border_bottom" + toKey LBorderLeft = "border_left" + toKey LBorderRight = "border_right" + toKey LBorderTop = "border_top" toKey LBottom = "bottom" toKey LDisplay = "display" toKey LFlex = "flex" @@ -287,10 +309,10 @@ promote toKey LMaxWidth = "max_width" toKey LMinHeight = "min_height" toKey LMinWidth = "min_width" + toKey LObjectFit = "object_fit" + toKey LObjectPosition = "object_position" toKey LOrder = "order" toKey LOverflow = "overflow" - toKey LOverflowX = "overflow_x" - toKey LOverflowY = "overflow_y" toKey LPadding = "padding" toKey LRight = "right" toKey LTop = "top" diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/ButtonStyle.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/ButtonStyle.hs index b7a3235d..9f5235b7 100644 --- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/ButtonStyle.hs +++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/ButtonStyle.hs @@ -36,7 +36,13 @@ mkButtonStyle = do let stl = defaultStyleWidget "ButtonStyleModel" but = (ButtonColor =:: Nothing) + :& (FontFamily =:: Nothing) + :& (FontSize =:: Nothing) + :& (FontStyle =:: Nothing) + :& (FontVariant =:: Nothing) :& (FontWeight =:: DefaultWeight) + :& (TextColor =:: Nothing) + :& (TextDecoration =:: Nothing) :& RNil btnStlState = WidgetState (stl <+> but) diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs index 51d8b5c8..8a9f1fed 100644 --- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs +++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs @@ -130,11 +130,11 @@ type (a :++ b) = a ++ b -- Classes from IPython's widget hierarchy. Defined as such to reduce code duplication. type CoreWidgetClass = ['S.ViewModule, 'S.ViewModuleVersion, 'S.ModelModule, 'S.ModelModuleVersion ] -type DOMWidgetClass = ['S.ModelName, 'S.ViewName, 'S.DOMClasses, 'S.Tooltip, 'S.Layout, 'S.DisplayHandler] +type DOMWidgetClass = ['S.ModelName, 'S.ViewName, 'S.DOMClasses, 'S.Tabbable, 'S.Tooltip, 'S.Layout, 'S.DisplayHandler] type StyleWidgetClass = ['S.ModelName, 'S.ViewName] :++ CoreWidgetClass -type DescriptionWidgetClass = CoreWidgetClass :++ DOMWidgetClass :++ ['S.Description,'S.Style] +type DescriptionWidgetClass = CoreWidgetClass :++ DOMWidgetClass :++ ['S.Description,'S.DescriptionAllowHtml,'S.Style] type StringClass = DescriptionWidgetClass :++ ['S.StringValue, 'S.Placeholder] @@ -191,11 +191,13 @@ type instance FieldType 'S.DOMClasses = [Text] type instance FieldType 'S.Width = PixCount type instance FieldType 'S.Height = PixCount type instance FieldType 'S.Description = Text +type instance FieldType 'S.DescriptionAllowHtml = Maybe Bool type instance FieldType 'S.ClickHandler = IO () type instance FieldType 'S.SubmitHandler = IO () type instance FieldType 'S.Disabled = Bool type instance FieldType 'S.StringValue = Text type instance FieldType 'S.Placeholder = Text +type instance FieldType 'S.Tabbable = Maybe Bool type instance FieldType 'S.Tooltip = Maybe Text type instance FieldType 'S.Icon = Text type instance FieldType 'S.ButtonStyle = ButtonStyleValue @@ -258,7 +260,13 @@ type instance FieldType 'S.Timestamp = Double type instance FieldType 'S.Buttons = [IPythonWidget 'ControllerButtonType] type instance FieldType 'S.Axes = [IPythonWidget 'ControllerAxisType] type instance FieldType 'S.ButtonColor = Maybe String +type instance FieldType 'S.FontFamily = Maybe String +type instance FieldType 'S.FontSize = Maybe String +type instance FieldType 'S.FontStyle = Maybe String +type instance FieldType 'S.FontVariant = Maybe String type instance FieldType 'S.FontWeight = FontWeightValue +type instance FieldType 'S.TextColor = Maybe String +type instance FieldType 'S.TextDecoration = Maybe String type instance FieldType 'S.DescriptionWidth = String type instance FieldType 'S.BarColor = Maybe String type instance FieldType 'S.HandleColor = Maybe String @@ -452,8 +460,7 @@ type instance WidgetFields 'ControllerAxisType = CoreWidgetClass :++ DOMWidgetCl type instance WidgetFields 'ControllerButtonType = CoreWidgetClass :++ DOMWidgetClass :++ [ 'S.FloatValue, 'S.Pressed, 'S.ChangeHandler ] type instance WidgetFields 'LinkType = LinkClass type instance WidgetFields 'DirectionalLinkType = LinkClass - -type instance WidgetFields 'ButtonStyleType = StyleWidgetClass :++ ['S.ButtonColor, 'S.FontWeight] +type instance WidgetFields 'ButtonStyleType = StyleWidgetClass :++ ['S.ButtonColor, 'S.FontFamily, 'S.FontSize, 'S.FontStyle, 'S.FontVariant, 'S.FontWeight, 'S.TextColor, 'S.TextDecoration] type instance WidgetFields 'DescriptionStyleType = DescriptionStyleClass type instance WidgetFields 'ProgressStyleType = DescriptionStyleClass :++ '[ 'S.BarColor ] type instance WidgetFields 'SliderStyleType = DescriptionStyleClass :++ '[ 'S.HandleColor ] @@ -565,9 +572,9 @@ reflect = fromSing -- | A record representing a Widget class from IPython from the controls modules defaultCoreWidget :: Rec Attr CoreWidgetClass defaultCoreWidget = (ViewModule =:! "@jupyter-widgets/controls") - :& (ViewModuleVersion =:! "1.4.0") + :& (ViewModuleVersion =:! "2.0.0") :& (ModelModule =:! "@jupyter-widgets/controls") - :& (ModelModuleVersion =:! "1.4.0") + :& (ModelModuleVersion =:! "2.0.0") :& RNil -- | A record representing an object of the DOMWidget class from IPython @@ -575,6 +582,7 @@ defaultDOMWidget :: FieldType 'S.ViewName -> FieldType 'S.ModelName -> IPythonWi defaultDOMWidget viewName modelName layout = (ModelName =:! modelName) :& (ViewName =:! viewName) :& (DOMClasses =:: []) + :& (Tabbable =:: Nothing) :& (Tooltip =:: Nothing) :& (Layout =:: layout) :& (DisplayHandler =:: return ()) @@ -589,6 +597,7 @@ defaultDescriptionWidget :: FieldType 'S.ViewName defaultDescriptionWidget v m l d = defaultCoreWidget <+> defaultDOMWidget v m l <+> descriptionAttrs where descriptionAttrs = (Description =:: "") + :& (DescriptionAllowHtml =:: Nothing) :& (Style =:: d) :& RNil @@ -821,9 +830,9 @@ defaultStyleWidget :: FieldType 'S.ModelName -> Rec Attr StyleWidgetClass defaultStyleWidget modelName = (ModelName =:! modelName) :& (ViewName =:! "StyleView") :& (ViewModule =:! "@jupyter-widgets/base") - :& (ViewModuleVersion =:! "1.1.0") + :& (ViewModuleVersion =:! "2.0.0") :& (ModelModule =:! "@jupyter-widgets/controls") - :& (ModelModuleVersion =:! "1.4.0") + :& (ModelModuleVersion =:! "2.0.0") :& RNil -- | A record representing a widget of the DescriptionStyle class from IPython