WrapperComponent
Extends the base component interface to allow for the
construction of interesting compound interfaces (using JHTML.Compound).
Takes a dict of wrappers naming the successive levels of the interface
along with a theme that provides style declarations for each level.
Used primarily to create Bootstrap-based interfaces.
wrappers: dict
theme: dict
__init__(self, items: Union[str, Mapping, McUtils.Jupyter.Apps.types.HTMLableType, McUtils.Jupyter.Apps.types.WidgetableType, McUtils.Jupyter.Apps.types.IPyHTMLableType, McUtils.Jupyter.Apps.types.ImageableType, Tuple[Union[str, Mapping, McUtils.Jupyter.Apps.types.HTMLableType, McUtils.Jupyter.Apps.types.WidgetableType, McUtils.Jupyter.Apps.types.IPyHTMLableType, McUtils.Jupyter.Apps.types.ImageableType], Mapping], NoneType, Iterable[Union[str, Mapping, McUtils.Jupyter.Apps.types.HTMLableType, McUtils.Jupyter.Apps.types.WidgetableType, McUtils.Jupyter.Apps.types.IPyHTMLableType, McUtils.Jupyter.Apps.types.ImageableType, Tuple[Union[str, Mapping, McUtils.Jupyter.Apps.types.HTMLableType, McUtils.Jupyter.Apps.types.WidgetableType, McUtils.Jupyter.Apps.types.IPyHTMLableType, McUtils.Jupyter.Apps.types.ImageableType], Mapping]]]], wrappers=None, theme=None, extend_base_theme=True, **attrs):
LLM Docstring
A component that renders its items inside one or more themed wrapper elements (the basis for Bootstrap interfaces).
items:Anythe wrapped items
wrappers:dict | Nonethe named wrapper element classes
theme:dict | Nonethe per-wrapper style theme
extend_base_theme:boolmerge with the class’s base theme
attrs:Anyextra attributes (merged into the outer wrapper’s theme)
handle_variants(self, theme):
LLM Docstring
Expand a theme’s variant/base-cls shorthand into the concrete
base-cls-variant CSS class.
theme:dictthe theme
:returns:dictthe expanded theme
manage_theme(self, theme, extend_base_theme=True):
LLM Docstring
Resolve the effective theme, optionally merging it over the class’s base theme.
theme:Anythe supplied theme (the class theme if
None)extend_base_theme:boolmerge with the base theme
:returns:dictthe resolved theme
@classmethod
merge_themes(cls, theme: 'None|dict', attrs: dict, merge_keys=('cls',)):
Needs to handle cases where a theme is provided
which includes things like cls declarations and then the
attrs may also include cls declarations and the attrs
declarations get appended to the theme
@classmethod
manage_items(cls, items, attrs):
LLM Docstring
Normalize the items spec into a (items_list, attrs) pair, pulling out any
attribute dict (from a dict body or a (items, opts) pair) and wrapping a scalar
item in a list.
items:Anythe items spec
attrs:dictthe base attributes
:returns:tuple(items_list, attrs)
get_child(self, key):
LLM Docstring
Get a wrapped item by index.
key:Anythe item index
:returns:_the item
set_child(self, which, new):
LLM Docstring
Set a wrapped item by index.
which:Anythe item index
new:Anythe new item
insert_child(self, where, child):
LLM Docstring
Insert a wrapped item at a position (appending if where is None).
where:Anythe index
child:Anythe item
wrap_items(self, items):
LLM Docstring
Render the items inside the wrapper element(s), applying the themed attributes.
items:Anythe items to wrap
:returns:_the wrapper element
to_jhtml(self, parent=None):
LLM Docstring
Render the component by wrapping its items.
parent:Anythe parent component
:returns:_the JHTML element