From d8da94af01fe1a4ed6f4a94d506fccfd9609fb9f Mon Sep 17 00:00:00 2001 From: Marek Mihok Date: Wed, 6 Mar 2024 13:55:38 +0100 Subject: [PATCH] feat: add width support for copyable text #2282 --- py/h2o_lightwave/h2o_lightwave/types.py | 10 ++++++++++ py/h2o_lightwave/h2o_lightwave/ui.py | 3 +++ py/h2o_wave/h2o_wave/types.py | 10 ++++++++++ py/h2o_wave/h2o_wave/ui.py | 3 +++ r/R/ui.R | 8 ++++++-- .../src/main/resources/templates/wave-components.xml | 3 ++- tools/vscode-extension/component-snippets.json | 2 +- ui/src/copyable_text.tsx | 2 ++ 8 files changed, 37 insertions(+), 4 deletions(-) diff --git a/py/h2o_lightwave/h2o_lightwave/types.py b/py/h2o_lightwave/h2o_lightwave/types.py index 9067bddc3f..186a0263d3 100644 --- a/py/h2o_lightwave/h2o_lightwave/types.py +++ b/py/h2o_lightwave/h2o_lightwave/types.py @@ -7113,12 +7113,14 @@ def __init__( name: Optional[str] = None, multiline: Optional[bool] = None, height: Optional[str] = None, + width: Optional[str] = None, ): _guard_scalar('CopyableText.value', value, (str,), False, False, False) _guard_scalar('CopyableText.label', label, (str,), False, False, False) _guard_scalar('CopyableText.name', name, (str,), False, True, False) _guard_scalar('CopyableText.multiline', multiline, (bool,), False, True, False) _guard_scalar('CopyableText.height', height, (str,), False, True, False) + _guard_scalar('CopyableText.width', width, (str,), False, True, False) self.value = value """Text to be displayed inside the component.""" self.label = label @@ -7129,6 +7131,8 @@ def __init__( """True if the component should allow multi-line text entry.""" self.height = height """Custom height in px (e.g. '200px') or '1' to fill the remaining card space. Requires `multiline` to be set.""" + self.width = width + """The width of the copyable text , e.g. '100px'.""" def dump(self) -> Dict: """Returns the contents of this object as a dict.""" @@ -7137,12 +7141,14 @@ def dump(self) -> Dict: _guard_scalar('CopyableText.name', self.name, (str,), False, True, False) _guard_scalar('CopyableText.multiline', self.multiline, (bool,), False, True, False) _guard_scalar('CopyableText.height', self.height, (str,), False, True, False) + _guard_scalar('CopyableText.width', self.width, (str,), False, True, False) return _dump( value=self.value, label=self.label, name=self.name, multiline=self.multiline, height=self.height, + width=self.width, ) @staticmethod @@ -7158,17 +7164,21 @@ def load(__d: Dict) -> 'CopyableText': _guard_scalar('CopyableText.multiline', __d_multiline, (bool,), False, True, False) __d_height: Any = __d.get('height') _guard_scalar('CopyableText.height', __d_height, (str,), False, True, False) + __d_width: Any = __d.get('width') + _guard_scalar('CopyableText.width', __d_width, (str,), False, True, False) value: str = __d_value label: str = __d_label name: Optional[str] = __d_name multiline: Optional[bool] = __d_multiline height: Optional[str] = __d_height + width: Optional[str] = __d_width return CopyableText( value, label, name, multiline, height, + width, ) diff --git a/py/h2o_lightwave/h2o_lightwave/ui.py b/py/h2o_lightwave/h2o_lightwave/ui.py index 4d9c0cb45b..462e993a2e 100644 --- a/py/h2o_lightwave/h2o_lightwave/ui.py +++ b/py/h2o_lightwave/h2o_lightwave/ui.py @@ -2632,6 +2632,7 @@ def copyable_text( name: Optional[str] = None, multiline: Optional[bool] = None, height: Optional[str] = None, + width: Optional[str] = None, ) -> Component: """Create a copyable text component. Use this component when you want to enable your users to quickly copy paste sections of text. @@ -2642,6 +2643,7 @@ def copyable_text( name: An identifying name for this component. multiline: True if the component should allow multi-line text entry. height: Custom height in px (e.g. '200px') or '1' to fill the remaining card space. Requires `multiline` to be set. + width: The width of the copyable text , e.g. '100px'. Returns: A `h2o_wave.types.CopyableText` instance. """ @@ -2651,6 +2653,7 @@ def copyable_text( name, multiline, height, + width, )) diff --git a/py/h2o_wave/h2o_wave/types.py b/py/h2o_wave/h2o_wave/types.py index 9067bddc3f..186a0263d3 100644 --- a/py/h2o_wave/h2o_wave/types.py +++ b/py/h2o_wave/h2o_wave/types.py @@ -7113,12 +7113,14 @@ def __init__( name: Optional[str] = None, multiline: Optional[bool] = None, height: Optional[str] = None, + width: Optional[str] = None, ): _guard_scalar('CopyableText.value', value, (str,), False, False, False) _guard_scalar('CopyableText.label', label, (str,), False, False, False) _guard_scalar('CopyableText.name', name, (str,), False, True, False) _guard_scalar('CopyableText.multiline', multiline, (bool,), False, True, False) _guard_scalar('CopyableText.height', height, (str,), False, True, False) + _guard_scalar('CopyableText.width', width, (str,), False, True, False) self.value = value """Text to be displayed inside the component.""" self.label = label @@ -7129,6 +7131,8 @@ def __init__( """True if the component should allow multi-line text entry.""" self.height = height """Custom height in px (e.g. '200px') or '1' to fill the remaining card space. Requires `multiline` to be set.""" + self.width = width + """The width of the copyable text , e.g. '100px'.""" def dump(self) -> Dict: """Returns the contents of this object as a dict.""" @@ -7137,12 +7141,14 @@ def dump(self) -> Dict: _guard_scalar('CopyableText.name', self.name, (str,), False, True, False) _guard_scalar('CopyableText.multiline', self.multiline, (bool,), False, True, False) _guard_scalar('CopyableText.height', self.height, (str,), False, True, False) + _guard_scalar('CopyableText.width', self.width, (str,), False, True, False) return _dump( value=self.value, label=self.label, name=self.name, multiline=self.multiline, height=self.height, + width=self.width, ) @staticmethod @@ -7158,17 +7164,21 @@ def load(__d: Dict) -> 'CopyableText': _guard_scalar('CopyableText.multiline', __d_multiline, (bool,), False, True, False) __d_height: Any = __d.get('height') _guard_scalar('CopyableText.height', __d_height, (str,), False, True, False) + __d_width: Any = __d.get('width') + _guard_scalar('CopyableText.width', __d_width, (str,), False, True, False) value: str = __d_value label: str = __d_label name: Optional[str] = __d_name multiline: Optional[bool] = __d_multiline height: Optional[str] = __d_height + width: Optional[str] = __d_width return CopyableText( value, label, name, multiline, height, + width, ) diff --git a/py/h2o_wave/h2o_wave/ui.py b/py/h2o_wave/h2o_wave/ui.py index 4d9c0cb45b..462e993a2e 100644 --- a/py/h2o_wave/h2o_wave/ui.py +++ b/py/h2o_wave/h2o_wave/ui.py @@ -2632,6 +2632,7 @@ def copyable_text( name: Optional[str] = None, multiline: Optional[bool] = None, height: Optional[str] = None, + width: Optional[str] = None, ) -> Component: """Create a copyable text component. Use this component when you want to enable your users to quickly copy paste sections of text. @@ -2642,6 +2643,7 @@ def copyable_text( name: An identifying name for this component. multiline: True if the component should allow multi-line text entry. height: Custom height in px (e.g. '200px') or '1' to fill the remaining card space. Requires `multiline` to be set. + width: The width of the copyable text , e.g. '100px'. Returns: A `h2o_wave.types.CopyableText` instance. """ @@ -2651,6 +2653,7 @@ def copyable_text( name, multiline, height, + width, )) diff --git a/r/R/ui.R b/r/R/ui.R index 12e0bc22b5..e7035d33de 100644 --- a/r/R/ui.R +++ b/r/R/ui.R @@ -3066,6 +3066,7 @@ ui_facepile <- function( #' @param name An identifying name for this component. #' @param multiline True if the component should allow multi-line text entry. #' @param height Custom height in px (e.g. '200px') or '1' to fill the remaining card space. Requires `multiline` to be set. +#' @param width The width of the copyable text , e.g. '100px'. #' @return A CopyableText instance. #' @export ui_copyable_text <- function( @@ -3073,18 +3074,21 @@ ui_copyable_text <- function( label, name = NULL, multiline = NULL, - height = NULL) { + height = NULL, + width = NULL) { .guard_scalar("value", "character", value) .guard_scalar("label", "character", label) .guard_scalar("name", "character", name) .guard_scalar("multiline", "logical", multiline) .guard_scalar("height", "character", height) + .guard_scalar("width", "character", width) .o <- list(copyable_text=list( value=value, label=label, name=name, multiline=multiline, - height=height)) + height=height, + width=width)) 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 8d7acbd1aa..bfb91b73b1 100644 --- a/tools/intellij-plugin/src/main/resources/templates/wave-components.xml +++ b/tools/intellij-plugin/src/main/resources/templates/wave-components.xml @@ -1249,12 +1249,13 @@