diff --git a/py/h2o_lightwave/h2o_lightwave/types.py b/py/h2o_lightwave/h2o_lightwave/types.py index 83f7cccdebd..f19533c0e6d 100644 --- a/py/h2o_lightwave/h2o_lightwave/types.py +++ b/py/h2o_lightwave/h2o_lightwave/types.py @@ -2571,6 +2571,85 @@ def load(__d: Dict) -> 'ColorPicker': ) +class ButtonCommand: + """No documentation available. + """ + def __init__( + self, + name: str, + label: Optional[str] = None, + caption: Optional[str] = None, + icon: Optional[str] = None, + value: Optional[str] = None, + path: Optional[str] = None, + ): + _guard_scalar('ButtonCommand.name', name, (str,), True, False, False) + _guard_scalar('ButtonCommand.label', label, (str,), False, True, False) + _guard_scalar('ButtonCommand.caption', caption, (str,), False, True, False) + _guard_scalar('ButtonCommand.icon', icon, (str,), False, True, False) + _guard_scalar('ButtonCommand.value', value, (str,), False, True, False) + _guard_scalar('ButtonCommand.path', path, (str,), False, True, False) + self.name = name + """An identifying name for this component. If the name is prefixed with a '#', the command sets the location hash to the name when executed.""" + self.label = label + """The text displayed for this command.""" + self.caption = caption + """The caption for this command (typically a tooltip).""" + self.icon = icon + """The icon to be displayed for this command.""" + self.value = value + """Data associated with this command, if any.""" + self.path = path + """The path or URL to link to. If specified, the `name` is ignored. The URL is opened in a new browser window or tab.""" + + def dump(self) -> Dict: + """Returns the contents of this object as a dict.""" + _guard_scalar('ButtonCommand.name', self.name, (str,), True, False, False) + _guard_scalar('ButtonCommand.label', self.label, (str,), False, True, False) + _guard_scalar('ButtonCommand.caption', self.caption, (str,), False, True, False) + _guard_scalar('ButtonCommand.icon', self.icon, (str,), False, True, False) + _guard_scalar('ButtonCommand.value', self.value, (str,), False, True, False) + _guard_scalar('ButtonCommand.path', self.path, (str,), False, True, False) + return _dump( + name=self.name, + label=self.label, + caption=self.caption, + icon=self.icon, + value=self.value, + path=self.path, + ) + + @staticmethod + def load(__d: Dict) -> 'ButtonCommand': + """Creates an instance of this class using the contents of a dict.""" + __d_name: Any = __d.get('name') + _guard_scalar('ButtonCommand.name', __d_name, (str,), True, False, False) + __d_label: Any = __d.get('label') + _guard_scalar('ButtonCommand.label', __d_label, (str,), False, True, False) + __d_caption: Any = __d.get('caption') + _guard_scalar('ButtonCommand.caption', __d_caption, (str,), False, True, False) + __d_icon: Any = __d.get('icon') + _guard_scalar('ButtonCommand.icon', __d_icon, (str,), False, True, False) + __d_value: Any = __d.get('value') + _guard_scalar('ButtonCommand.value', __d_value, (str,), False, True, False) + __d_path: Any = __d.get('path') + _guard_scalar('ButtonCommand.path', __d_path, (str,), False, True, False) + name: str = __d_name + label: Optional[str] = __d_label + caption: Optional[str] = __d_caption + icon: Optional[str] = __d_icon + value: Optional[str] = __d_value + path: Optional[str] = __d_path + return ButtonCommand( + name, + label, + caption, + icon, + value, + path, + ) + + class Button: """Create a button. @@ -2603,6 +2682,7 @@ def __init__( visible: Optional[bool] = None, tooltip: Optional[str] = None, path: Optional[str] = None, + commands: Optional[List[ButtonCommand]] = None, ): _guard_scalar('Button.name', name, (str,), True, False, False) _guard_scalar('Button.label', label, (str,), False, True, False) @@ -2616,6 +2696,7 @@ def __init__( _guard_scalar('Button.visible', visible, (bool,), False, True, False) _guard_scalar('Button.tooltip', tooltip, (str,), False, True, False) _guard_scalar('Button.path', path, (str,), False, True, False) + _guard_vector('Button.commands', commands, (ButtonCommand,), False, True, False) self.name = name """An identifying name for this component. If the name is prefixed with a '#', the button sets the location hash to the name when clicked.""" self.label = label @@ -2640,6 +2721,8 @@ def __init__( """An optional tooltip message displayed when a user clicks the help icon to the right of the component.""" self.path = path """The path or URL to link to. If specified, the `name` is ignored. The URL is opened in a new browser window or tab.""" + self.commands = commands + """The menu with button actions.""" def dump(self) -> Dict: """Returns the contents of this object as a dict.""" @@ -2655,6 +2738,7 @@ def dump(self) -> Dict: _guard_scalar('Button.visible', self.visible, (bool,), False, True, False) _guard_scalar('Button.tooltip', self.tooltip, (str,), False, True, False) _guard_scalar('Button.path', self.path, (str,), False, True, False) + _guard_vector('Button.commands', self.commands, (ButtonCommand,), False, True, False) return _dump( name=self.name, label=self.label, @@ -2668,6 +2752,7 @@ def dump(self) -> Dict: visible=self.visible, tooltip=self.tooltip, path=self.path, + commands=None if self.commands is None else [__e.dump() for __e in self.commands], ) @staticmethod @@ -2697,6 +2782,8 @@ def load(__d: Dict) -> 'Button': _guard_scalar('Button.tooltip', __d_tooltip, (str,), False, True, False) __d_path: Any = __d.get('path') _guard_scalar('Button.path', __d_path, (str,), False, True, False) + __d_commands: Any = __d.get('commands') + _guard_vector('Button.commands', __d_commands, (dict,), False, True, False) name: str = __d_name label: Optional[str] = __d_label caption: Optional[str] = __d_caption @@ -2709,6 +2796,7 @@ def load(__d: Dict) -> 'Button': visible: Optional[bool] = __d_visible tooltip: Optional[str] = __d_tooltip path: Optional[str] = __d_path + commands: Optional[List[ButtonCommand]] = None if __d_commands is None else [ButtonCommand.load(__e) for __e in __d_commands] return Button( name, label, @@ -2722,6 +2810,7 @@ def load(__d: Dict) -> 'Button': visible, tooltip, path, + commands, ) diff --git a/py/h2o_lightwave/h2o_lightwave/ui.py b/py/h2o_lightwave/h2o_lightwave/ui.py index 06ad23b6fe4..e0d3d33d1b3 100644 --- a/py/h2o_lightwave/h2o_lightwave/ui.py +++ b/py/h2o_lightwave/h2o_lightwave/ui.py @@ -985,6 +985,36 @@ def color_picker( )) +def button_command( + name: str, + label: Optional[str] = None, + caption: Optional[str] = None, + icon: Optional[str] = None, + value: Optional[str] = None, + path: Optional[str] = None, +) -> ButtonCommand: + """No documentation available. + + Args: + name: An identifying name for this component. If the name is prefixed with a '#', the command sets the location hash to the name when executed. + label: The text displayed for this command. + caption: The caption for this command (typically a tooltip). + icon: The icon to be displayed for this command. + value: Data associated with this command, if any. + path: The path or URL to link to. If specified, the `name` is ignored. The URL is opened in a new browser window or tab. + Returns: + A `h2o_wave.types.ButtonCommand` instance. + """ + return ButtonCommand( + name, + label, + caption, + icon, + value, + path, + ) + + def button( name: str, label: Optional[str] = None, @@ -998,6 +1028,7 @@ def button( visible: Optional[bool] = None, tooltip: Optional[str] = None, path: Optional[str] = None, + commands: Optional[List[ButtonCommand]] = None, ) -> Component: """Create a button. @@ -1029,6 +1060,7 @@ def button( visible: True if the component should be visible. Defaults to True. tooltip: An optional tooltip message displayed when a user clicks the help icon to the right of the component. path: The path or URL to link to. If specified, the `name` is ignored. The URL is opened in a new browser window or tab. + commands: The menu with button actions. Returns: A `h2o_wave.types.Button` instance. """ @@ -1045,6 +1077,7 @@ def button( visible, tooltip, path, + commands, )) diff --git a/py/h2o_wave/h2o_wave/types.py b/py/h2o_wave/h2o_wave/types.py index 83f7cccdebd..f19533c0e6d 100644 --- a/py/h2o_wave/h2o_wave/types.py +++ b/py/h2o_wave/h2o_wave/types.py @@ -2571,6 +2571,85 @@ def load(__d: Dict) -> 'ColorPicker': ) +class ButtonCommand: + """No documentation available. + """ + def __init__( + self, + name: str, + label: Optional[str] = None, + caption: Optional[str] = None, + icon: Optional[str] = None, + value: Optional[str] = None, + path: Optional[str] = None, + ): + _guard_scalar('ButtonCommand.name', name, (str,), True, False, False) + _guard_scalar('ButtonCommand.label', label, (str,), False, True, False) + _guard_scalar('ButtonCommand.caption', caption, (str,), False, True, False) + _guard_scalar('ButtonCommand.icon', icon, (str,), False, True, False) + _guard_scalar('ButtonCommand.value', value, (str,), False, True, False) + _guard_scalar('ButtonCommand.path', path, (str,), False, True, False) + self.name = name + """An identifying name for this component. If the name is prefixed with a '#', the command sets the location hash to the name when executed.""" + self.label = label + """The text displayed for this command.""" + self.caption = caption + """The caption for this command (typically a tooltip).""" + self.icon = icon + """The icon to be displayed for this command.""" + self.value = value + """Data associated with this command, if any.""" + self.path = path + """The path or URL to link to. If specified, the `name` is ignored. The URL is opened in a new browser window or tab.""" + + def dump(self) -> Dict: + """Returns the contents of this object as a dict.""" + _guard_scalar('ButtonCommand.name', self.name, (str,), True, False, False) + _guard_scalar('ButtonCommand.label', self.label, (str,), False, True, False) + _guard_scalar('ButtonCommand.caption', self.caption, (str,), False, True, False) + _guard_scalar('ButtonCommand.icon', self.icon, (str,), False, True, False) + _guard_scalar('ButtonCommand.value', self.value, (str,), False, True, False) + _guard_scalar('ButtonCommand.path', self.path, (str,), False, True, False) + return _dump( + name=self.name, + label=self.label, + caption=self.caption, + icon=self.icon, + value=self.value, + path=self.path, + ) + + @staticmethod + def load(__d: Dict) -> 'ButtonCommand': + """Creates an instance of this class using the contents of a dict.""" + __d_name: Any = __d.get('name') + _guard_scalar('ButtonCommand.name', __d_name, (str,), True, False, False) + __d_label: Any = __d.get('label') + _guard_scalar('ButtonCommand.label', __d_label, (str,), False, True, False) + __d_caption: Any = __d.get('caption') + _guard_scalar('ButtonCommand.caption', __d_caption, (str,), False, True, False) + __d_icon: Any = __d.get('icon') + _guard_scalar('ButtonCommand.icon', __d_icon, (str,), False, True, False) + __d_value: Any = __d.get('value') + _guard_scalar('ButtonCommand.value', __d_value, (str,), False, True, False) + __d_path: Any = __d.get('path') + _guard_scalar('ButtonCommand.path', __d_path, (str,), False, True, False) + name: str = __d_name + label: Optional[str] = __d_label + caption: Optional[str] = __d_caption + icon: Optional[str] = __d_icon + value: Optional[str] = __d_value + path: Optional[str] = __d_path + return ButtonCommand( + name, + label, + caption, + icon, + value, + path, + ) + + class Button: """Create a button. @@ -2603,6 +2682,7 @@ def __init__( visible: Optional[bool] = None, tooltip: Optional[str] = None, path: Optional[str] = None, + commands: Optional[List[ButtonCommand]] = None, ): _guard_scalar('Button.name', name, (str,), True, False, False) _guard_scalar('Button.label', label, (str,), False, True, False) @@ -2616,6 +2696,7 @@ def __init__( _guard_scalar('Button.visible', visible, (bool,), False, True, False) _guard_scalar('Button.tooltip', tooltip, (str,), False, True, False) _guard_scalar('Button.path', path, (str,), False, True, False) + _guard_vector('Button.commands', commands, (ButtonCommand,), False, True, False) self.name = name """An identifying name for this component. If the name is prefixed with a '#', the button sets the location hash to the name when clicked.""" self.label = label @@ -2640,6 +2721,8 @@ def __init__( """An optional tooltip message displayed when a user clicks the help icon to the right of the component.""" self.path = path """The path or URL to link to. If specified, the `name` is ignored. The URL is opened in a new browser window or tab.""" + self.commands = commands + """The menu with button actions.""" def dump(self) -> Dict: """Returns the contents of this object as a dict.""" @@ -2655,6 +2738,7 @@ def dump(self) -> Dict: _guard_scalar('Button.visible', self.visible, (bool,), False, True, False) _guard_scalar('Button.tooltip', self.tooltip, (str,), False, True, False) _guard_scalar('Button.path', self.path, (str,), False, True, False) + _guard_vector('Button.commands', self.commands, (ButtonCommand,), False, True, False) return _dump( name=self.name, label=self.label, @@ -2668,6 +2752,7 @@ def dump(self) -> Dict: visible=self.visible, tooltip=self.tooltip, path=self.path, + commands=None if self.commands is None else [__e.dump() for __e in self.commands], ) @staticmethod @@ -2697,6 +2782,8 @@ def load(__d: Dict) -> 'Button': _guard_scalar('Button.tooltip', __d_tooltip, (str,), False, True, False) __d_path: Any = __d.get('path') _guard_scalar('Button.path', __d_path, (str,), False, True, False) + __d_commands: Any = __d.get('commands') + _guard_vector('Button.commands', __d_commands, (dict,), False, True, False) name: str = __d_name label: Optional[str] = __d_label caption: Optional[str] = __d_caption @@ -2709,6 +2796,7 @@ def load(__d: Dict) -> 'Button': visible: Optional[bool] = __d_visible tooltip: Optional[str] = __d_tooltip path: Optional[str] = __d_path + commands: Optional[List[ButtonCommand]] = None if __d_commands is None else [ButtonCommand.load(__e) for __e in __d_commands] return Button( name, label, @@ -2722,6 +2810,7 @@ def load(__d: Dict) -> 'Button': visible, tooltip, path, + commands, ) diff --git a/py/h2o_wave/h2o_wave/ui.py b/py/h2o_wave/h2o_wave/ui.py index 06ad23b6fe4..e0d3d33d1b3 100644 --- a/py/h2o_wave/h2o_wave/ui.py +++ b/py/h2o_wave/h2o_wave/ui.py @@ -985,6 +985,36 @@ def color_picker( )) +def button_command( + name: str, + label: Optional[str] = None, + caption: Optional[str] = None, + icon: Optional[str] = None, + value: Optional[str] = None, + path: Optional[str] = None, +) -> ButtonCommand: + """No documentation available. + + Args: + name: An identifying name for this component. If the name is prefixed with a '#', the command sets the location hash to the name when executed. + label: The text displayed for this command. + caption: The caption for this command (typically a tooltip). + icon: The icon to be displayed for this command. + value: Data associated with this command, if any. + path: The path or URL to link to. If specified, the `name` is ignored. The URL is opened in a new browser window or tab. + Returns: + A `h2o_wave.types.ButtonCommand` instance. + """ + return ButtonCommand( + name, + label, + caption, + icon, + value, + path, + ) + + def button( name: str, label: Optional[str] = None, @@ -998,6 +1028,7 @@ def button( visible: Optional[bool] = None, tooltip: Optional[str] = None, path: Optional[str] = None, + commands: Optional[List[ButtonCommand]] = None, ) -> Component: """Create a button. @@ -1029,6 +1060,7 @@ def button( visible: True if the component should be visible. Defaults to True. tooltip: An optional tooltip message displayed when a user clicks the help icon to the right of the component. path: The path or URL to link to. If specified, the `name` is ignored. The URL is opened in a new browser window or tab. + commands: The menu with button actions. Returns: A `h2o_wave.types.Button` instance. """ @@ -1045,6 +1077,7 @@ def button( visible, tooltip, path, + commands, )) diff --git a/r/R/ui.R b/r/R/ui.R index 47451331e7c..f30d5317e5c 100644 --- a/r/R/ui.R +++ b/r/R/ui.R @@ -1171,6 +1171,40 @@ ui_color_picker <- function( return(.o) } +#' No documentation available. +#' +#' @param name An identifying name for this component. If the name is prefixed with a '#', the command sets the location hash to the name when executed. +#' @param label The text displayed for this command. +#' @param caption The caption for this command (typically a tooltip). +#' @param icon The icon to be displayed for this command. +#' @param value Data associated with this command, if any. +#' @param path The path or URL to link to. If specified, the `name` is ignored. The URL is opened in a new browser window or tab. +#' @return A ButtonCommand instance. +#' @export +ui_button_command <- function( + name, + label = NULL, + caption = NULL, + icon = NULL, + value = NULL, + path = NULL) { + .guard_scalar("name", "character", name) + .guard_scalar("label", "character", label) + .guard_scalar("caption", "character", caption) + .guard_scalar("icon", "character", icon) + .guard_scalar("value", "character", value) + .guard_scalar("path", "character", path) + .o <- list( + name=name, + label=label, + caption=caption, + icon=icon, + value=value, + path=path) + class(.o) <- append(class(.o), c(.wave_obj, "WaveButtonCommand")) + return(.o) +} + #' Create a button. #' #' Buttons are best used to enable a user to commit a change or complete steps in a task. @@ -1200,6 +1234,7 @@ ui_color_picker <- function( #' @param visible True if the component should be visible. Defaults to True. #' @param tooltip An optional tooltip message displayed when a user clicks the help icon to the right of the component. #' @param path The path or URL to link to. If specified, the `name` is ignored. The URL is opened in a new browser window or tab. +#' @param commands The menu with button actions. #' @return A Button instance. #' @export ui_button <- function( @@ -1214,7 +1249,8 @@ ui_button <- function( width = NULL, visible = NULL, tooltip = NULL, - path = NULL) { + path = NULL, + commands = NULL) { .guard_scalar("name", "character", name) .guard_scalar("label", "character", label) .guard_scalar("caption", "character", caption) @@ -1227,6 +1263,7 @@ ui_button <- function( .guard_scalar("visible", "logical", visible) .guard_scalar("tooltip", "character", tooltip) .guard_scalar("path", "character", path) + .guard_vector("commands", "WaveButtonCommand", commands) .o <- list(button=list( name=name, label=label, @@ -1239,7 +1276,8 @@ ui_button <- function( width=width, visible=visible, tooltip=tooltip, - path=path)) + path=path, + commands=commands)) class(.o) <- append(class(.o), c(.wave_obj, "WaveComponent")) return(.o) } diff --git a/tools/intellij-plugin/src/main/resources/templates/wave-components.xml b/tools/intellij-plugin/src/main/resources/templates/wave-components.xml index 218be7fab0c..c75862b4135 100644 --- a/tools/intellij-plugin/src/main/resources/templates/wave-components.xml +++ b/tools/intellij-plugin/src/main/resources/templates/wave-components.xml @@ -20,6 +20,12 @@