mirror of
https://github.com/rio-labs/rio.git
synced 2026-01-23 14:00:59 -06:00
deprecate width and height
This commit is contained in:
@@ -28,7 +28,7 @@ export type ComponentState = {
|
||||
// Explicit size request, if any
|
||||
_min_size_?: [number, number];
|
||||
// Maximum size, if any
|
||||
_max_size_?: [number | null, number | null];
|
||||
// MAX-SIZE-BRANCH _max_size_?: [number | null, number | null];
|
||||
// Alignment of the component within its parent, if any
|
||||
_align_?: [number | null, number | null];
|
||||
// Scrolling behavior
|
||||
@@ -119,9 +119,9 @@ export abstract class ComponentBase {
|
||||
this.element.style.minHeight = `${deltaState._min_size_[1]}rem`;
|
||||
}
|
||||
|
||||
if (deltaState._max_size_ !== undefined) {
|
||||
this._updateMaxSize(deltaState._max_size_);
|
||||
}
|
||||
// MAX-SIZE-BRANCH if (deltaState._max_size_ !== undefined) {
|
||||
// MAX-SIZE-BRANCH this._updateMaxSize(deltaState._max_size_);
|
||||
// MAX-SIZE-BRANCH }
|
||||
|
||||
if (deltaState._align_ !== undefined) {
|
||||
this._updateAlign(deltaState._align_);
|
||||
|
||||
@@ -59,9 +59,18 @@ export class ImageComponent extends ComponentBase {
|
||||
deltaState.imageUrl !== undefined &&
|
||||
imgElement.src !== deltaState.imageUrl
|
||||
) {
|
||||
// imgElement.classList.add('rio-content-loading');
|
||||
// this.element.classList.add('rio-content-loading');
|
||||
imgElement.src = deltaState.imageUrl;
|
||||
|
||||
// Until the image is loaded and we get access to its resolution,
|
||||
// let it fill the entire space. This is the correct size for all
|
||||
// `fill_mode`s except `"fit"` anyway, so there's no harm in setting
|
||||
// it now rather than later. (SVGs might temporarily render content
|
||||
// outside of the viewbox, but the only way to prevent that would be
|
||||
// to make the image invisible until loaded.)
|
||||
this.imageElement.style.width = '100%';
|
||||
this.imageElement.style.height = '100%';
|
||||
|
||||
// If we're currently displaying an error icon, remove it
|
||||
if (this.element.firstElementChild !== imgElement) {
|
||||
this.element.firstElementChild!.remove();
|
||||
@@ -89,7 +98,7 @@ export class ImageComponent extends ComponentBase {
|
||||
}
|
||||
|
||||
private _onLoad(): void {
|
||||
this.imageElement.classList.remove('rio-content-loading');
|
||||
// this.element.classList.remove('rio-content-loading');
|
||||
this._updateSize();
|
||||
}
|
||||
|
||||
@@ -128,7 +137,7 @@ export class ImageComponent extends ComponentBase {
|
||||
}
|
||||
|
||||
private _onError(event: string | Event): void {
|
||||
this.imageElement.classList.remove('rio-content-loading');
|
||||
this.element.classList.remove('rio-content-loading');
|
||||
|
||||
applyIcon(this.element, 'material/broken_image');
|
||||
|
||||
|
||||
@@ -158,6 +158,7 @@ class ComponentMeta(RioDataclassMeta):
|
||||
deprecations._remap_kwargs(
|
||||
cls.__name__, kwargs, cls._deprecated_parameter_names_
|
||||
)
|
||||
deprecations.remap_width_and_height(kwargs)
|
||||
|
||||
component: C = object.__new__(cls)
|
||||
|
||||
|
||||
@@ -217,11 +217,8 @@ class Component(abc.ABC, metaclass=ComponentMeta):
|
||||
min_width: float | None = None
|
||||
min_height: float | None = None
|
||||
|
||||
max_width: float | None = None
|
||||
max_height: float | None = None
|
||||
|
||||
width: float | Literal["grow", "natural"] | None = None
|
||||
height: float | Literal["grow", "natural"] | None = None
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None
|
||||
|
||||
grow_x: bool = False
|
||||
grow_y: bool = False
|
||||
@@ -825,7 +822,7 @@ class Component(abc.ABC, metaclass=ComponentMeta):
|
||||
# Separator
|
||||
rio.Rectangle(
|
||||
fill=self.session.theme.primary_color,
|
||||
height=0.2,
|
||||
min_height=0.2,
|
||||
),
|
||||
# Content
|
||||
wrapped_content,
|
||||
@@ -951,7 +948,7 @@ class Component(abc.ABC, metaclass=ComponentMeta):
|
||||
title,
|
||||
style="heading2",
|
||||
wrap=True,
|
||||
width="grow",
|
||||
grow_x=True,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -968,7 +965,7 @@ class Component(abc.ABC, metaclass=ComponentMeta):
|
||||
main_column.add(
|
||||
rio.Rectangle(
|
||||
fill=self.session.theme.primary_color,
|
||||
height=0.2,
|
||||
min_height=0.2,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import tempfile
|
||||
from collections.abc import Iterable
|
||||
from dataclasses import field
|
||||
from pathlib import Path
|
||||
from typing import Literal, Sequence
|
||||
from typing import Sequence
|
||||
|
||||
import rio
|
||||
|
||||
@@ -47,10 +47,8 @@ class DevelComponent(FundamentalComponent):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -69,10 +67,8 @@ class DevelComponent(FundamentalComponent):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from collections.abc import Mapping, Sequence
|
||||
from dataclasses import KW_ONLY, dataclass
|
||||
from typing import Any, Generic, Literal, TypeVar, final
|
||||
from typing import Any, Generic, TypeVar, final
|
||||
|
||||
from uniserde import JsonDoc
|
||||
|
||||
@@ -149,10 +149,8 @@ class Dropdown(FundamentalComponent, Generic[T]):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -174,10 +172,8 @@ class Dropdown(FundamentalComponent, Generic[T]):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -75,10 +75,8 @@ class FlowContainer(FundamentalComponent):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -99,10 +97,8 @@ class FlowContainer(FundamentalComponent):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
import math
|
||||
from collections.abc import Iterable
|
||||
from dataclasses import KW_ONLY, dataclass
|
||||
from typing import Literal, final
|
||||
from typing import final
|
||||
|
||||
from typing_extensions import Self
|
||||
from uniserde import JsonDoc
|
||||
@@ -115,10 +115,8 @@ class Grid(FundamentalComponent):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -137,10 +135,8 @@ class Grid(FundamentalComponent):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -119,10 +119,8 @@ class Icon(FundamentalComponent):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = 1.3,
|
||||
min_height: float | None = 1.3,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -141,10 +139,8 @@ class Icon(FundamentalComponent):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -130,10 +130,8 @@ class Image(FundamentalComponent):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = 2,
|
||||
min_height: float | None = 2,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -152,10 +150,8 @@ class Image(FundamentalComponent):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from collections.abc import Mapping
|
||||
from dataclasses import field
|
||||
from typing import Literal, final
|
||||
from typing import final
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
@@ -59,10 +59,8 @@ class LabeledColumn(Component):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -81,10 +79,8 @@ class LabeledColumn(Component):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -133,10 +133,8 @@ class Row(_LinearContainer):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -155,10 +153,8 @@ class Row(_LinearContainer):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
@@ -291,10 +287,8 @@ class Column(_LinearContainer):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -313,10 +307,8 @@ class Column(_LinearContainer):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Literal, final
|
||||
from typing import final
|
||||
|
||||
from uniserde import JsonDoc
|
||||
|
||||
@@ -68,10 +68,8 @@ class Link(FundamentalComponent):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -97,10 +95,8 @@ class Link(FundamentalComponent):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -178,10 +178,8 @@ class SimpleListItem(Component):
|
||||
on_press: rio.EventHandler[[]] = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
# SCROLLING-REWORK scroll_x: Literal["never", "auto", "always"] = "never",
|
||||
@@ -190,10 +188,8 @@ class SimpleListItem(Component):
|
||||
super().__init__(
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
# SCROLLING-REWORK scroll_x=scroll_x,
|
||||
@@ -348,10 +344,8 @@ class CustomListItem(FundamentalComponent):
|
||||
on_press: rio.EventHandler[[]] = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
# SCROLLING-REWORK scroll_x: Literal["never", "auto", "always"] = "never",
|
||||
@@ -360,10 +354,8 @@ class CustomListItem(FundamentalComponent):
|
||||
super().__init__(
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
# SCROLLING-REWORK scroll_x=scroll_x,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Literal, final
|
||||
from typing import final
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
@@ -108,10 +108,8 @@ class ListView(FundamentalComponent):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -130,10 +128,8 @@ class ListView(FundamentalComponent):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pathlib
|
||||
from typing import Literal, final
|
||||
from typing import final
|
||||
|
||||
from uniserde import JsonDoc
|
||||
|
||||
@@ -117,10 +117,8 @@ class MediaPlayer(KeyboardFocusableFundamentalComponent):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -139,10 +137,8 @@ class MediaPlayer(KeyboardFocusableFundamentalComponent):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -39,10 +39,8 @@ class NodeInput(FundamentalComponent):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
# SCROLLING-REWORK scroll_x: Literal["never", "auto", "always"] = "never",
|
||||
@@ -62,10 +60,8 @@ class NodeInput(FundamentalComponent):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
# SCROLLING-REWORK scroll_x=scroll_x,
|
||||
|
||||
@@ -39,10 +39,8 @@ class NodeOutput(FundamentalComponent):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
# SCROLLING-REWORK scroll_x: Literal["never", "auto", "always"] = "never",
|
||||
@@ -62,10 +60,8 @@ class NodeOutput(FundamentalComponent):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
# SCROLLING-REWORK scroll_x=scroll_x,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
from typing import TYPE_CHECKING, Literal, cast, final
|
||||
from typing import TYPE_CHECKING, cast, final
|
||||
|
||||
from uniserde import JsonDoc
|
||||
|
||||
@@ -92,10 +92,8 @@ class Plot(FundamentalComponent):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -114,10 +112,8 @@ class Plot(FundamentalComponent):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -72,10 +72,8 @@ class ProgressBar(FundamentalComponent):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -107,10 +105,8 @@ class ProgressBar(FundamentalComponent):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import math
|
||||
from dataclasses import dataclass
|
||||
from typing import Literal, final
|
||||
from typing import final
|
||||
|
||||
from uniserde import JsonDoc
|
||||
|
||||
@@ -123,10 +123,8 @@ class Slider(FundamentalComponent):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = 1.3,
|
||||
min_height: float | None = 1.3,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -145,10 +143,8 @@ class Slider(FundamentalComponent):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from dataclasses import KW_ONLY
|
||||
from datetime import timedelta
|
||||
from typing import Literal, final
|
||||
from typing import final
|
||||
|
||||
from uniserde import JsonDoc
|
||||
|
||||
@@ -73,10 +73,8 @@ class Slideshow(FundamentalComponent):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -98,10 +96,8 @@ class Slideshow(FundamentalComponent):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -42,18 +42,18 @@ class Spacer(class_container.ClassContainer):
|
||||
*,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = True,
|
||||
grow_y: bool = True,
|
||||
key: str | int | None = None,
|
||||
):
|
||||
"""
|
||||
## Parameters
|
||||
width: How much space the spacer should take up horizontally.
|
||||
height: How much space the spacer should take up vertically.
|
||||
|
||||
`width`: How much space the spacer should take up horizontally.
|
||||
|
||||
`height`: How much space the spacer should take up vertically.
|
||||
"""
|
||||
|
||||
super().__init__(
|
||||
@@ -62,10 +62,8 @@ class Spacer(class_container.ClassContainer):
|
||||
key=key,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Literal, final
|
||||
from typing import final
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
@@ -75,10 +75,8 @@ class Stack(FundamentalComponent):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -97,10 +95,8 @@ class Stack(FundamentalComponent):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -152,10 +152,8 @@ class SwitcherBar(FundamentalComponent, Generic[T]):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -179,10 +177,8 @@ class SwitcherBar(FundamentalComponent, Generic[T]):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -75,10 +75,8 @@ class Tooltip(FundamentalComponent):
|
||||
margin_bottom: float | None = None,
|
||||
min_width: float | None = None,
|
||||
min_height: float | None = None,
|
||||
max_width: float | None = None,
|
||||
max_height: float | None = None,
|
||||
width: float | Literal["grow", "natural"] | None = None,
|
||||
height: float | Literal["grow", "natural"] | None = None,
|
||||
# MAX-SIZE-BRANCH max_width: float | None = None,
|
||||
# MAX-SIZE-BRANCH max_height: float | None = None,
|
||||
grow_x: bool = False,
|
||||
grow_y: bool = False,
|
||||
align_x: float | None = None,
|
||||
@@ -97,10 +95,8 @@ class Tooltip(FundamentalComponent):
|
||||
margin_bottom=margin_bottom,
|
||||
min_width=min_width,
|
||||
min_height=min_height,
|
||||
max_width=max_width,
|
||||
max_height=max_height,
|
||||
width=width,
|
||||
height=height,
|
||||
# MAX-SIZE-BRANCH max_width=max_width,
|
||||
# MAX-SIZE-BRANCH max_height=max_height,
|
||||
grow_x=grow_x,
|
||||
grow_y=grow_y,
|
||||
align_x=align_x,
|
||||
|
||||
@@ -5,13 +5,23 @@ from typing import *
|
||||
from .component_meta import ComponentMeta
|
||||
from .warnings import *
|
||||
|
||||
__all__ = ["deprecated", "parameters_renamed", "_remap_kwargs"]
|
||||
__all__ = [
|
||||
"deprecated",
|
||||
"parameters_renamed",
|
||||
"_remap_kwargs",
|
||||
"warn",
|
||||
"remap_width_and_height",
|
||||
]
|
||||
|
||||
|
||||
C = TypeVar("C", bound=Union[Callable, ComponentMeta])
|
||||
F = TypeVar("F", bound=Callable)
|
||||
|
||||
|
||||
def warn(message: str) -> None:
|
||||
warnings.warn(message, RioDeprecationWarning)
|
||||
|
||||
|
||||
@overload
|
||||
def deprecated(*, since: str, replacement: Callable | str): ...
|
||||
|
||||
@@ -106,11 +116,10 @@ def parameters_remapped(since: str, **params: Callable[[Any], dict[str, Any]]):
|
||||
[[new_name, new_value]] = remap_func(old_value).items()
|
||||
kwargs[new_name] = new_value
|
||||
|
||||
warnings.warn(
|
||||
warn(
|
||||
f"The {old_name!r} parameter of rio.{func.__qualname__}"
|
||||
f" is deprecated; please use the {new_name!r} parameter"
|
||||
f" from now on",
|
||||
RioDeprecationWarning,
|
||||
f" from now on"
|
||||
)
|
||||
|
||||
return func(*args, **kwargs)
|
||||
@@ -131,7 +140,44 @@ def _remap_kwargs(
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
warnings.warn(
|
||||
f"The {old_name!r} parameter of rio.{func_name} is deprecated; it has been renamed to {new_name!r}",
|
||||
RioDeprecationWarning,
|
||||
warn(
|
||||
f"The {old_name!r} parameter of rio.{func_name} is deprecated;"
|
||||
f" it has been renamed to {new_name!r}",
|
||||
)
|
||||
|
||||
|
||||
def remap_width_and_height(kwargs):
|
||||
width: float | Literal["grow", "natural"] | None = kwargs.pop("width", None)
|
||||
height: float | Literal["grow", "natural"] | None = kwargs.pop(
|
||||
"height", None
|
||||
)
|
||||
|
||||
if width is None:
|
||||
pass
|
||||
else:
|
||||
warn(
|
||||
"The `width` parameter/attribute of `rio.Component` is deprecated;"
|
||||
" it has been superseded by `min_width` and `grow_x`"
|
||||
)
|
||||
|
||||
if width == "natural":
|
||||
pass
|
||||
elif width == "grow":
|
||||
kwargs["grow_x"] = True
|
||||
else:
|
||||
kwargs["min_width"] = width
|
||||
|
||||
if height is None:
|
||||
pass
|
||||
else:
|
||||
warn(
|
||||
"The `height` parameter/attribute of `rio.Component` is deprecated;"
|
||||
" it has been superseded by `min_height` and `grow_y`"
|
||||
)
|
||||
|
||||
if height == "natural":
|
||||
pass
|
||||
elif height == "grow":
|
||||
kwargs["grow_y"] = True
|
||||
else:
|
||||
kwargs["min_height"] = height
|
||||
|
||||
@@ -96,29 +96,12 @@ def serialize_and_host_component(component: rio.Component) -> JsonDoc:
|
||||
min_width = component.min_width
|
||||
min_height = component.min_height
|
||||
|
||||
max_width = component.max_width
|
||||
max_height = component.max_height
|
||||
# MAX-SIZE-BRANCH max_width = component.max_width
|
||||
# MAX-SIZE-BRANCH max_height = component.max_height
|
||||
|
||||
grow_x = component.grow_x
|
||||
grow_y = component.grow_y
|
||||
|
||||
width: float | Literal["grow", "natural"] | None = component.width # type: ignore
|
||||
height: float | Literal["grow", "natural"] | None = component.height # type: ignore
|
||||
|
||||
if width is None or width == "natural":
|
||||
pass
|
||||
elif width == "grow":
|
||||
grow_x = True
|
||||
else:
|
||||
min_width = width
|
||||
|
||||
if height is None or height == "natural":
|
||||
pass
|
||||
elif height == "grow":
|
||||
grow_y = True
|
||||
else:
|
||||
min_height = height
|
||||
|
||||
margin_x = component.margin_x
|
||||
margin_y = component.margin_y
|
||||
margin = component.margin
|
||||
@@ -141,10 +124,10 @@ def serialize_and_host_component(component: rio.Component) -> JsonDoc:
|
||||
_float_or_zero(min_width),
|
||||
_float_or_zero(min_height),
|
||||
)
|
||||
result["_max_size_"] = (
|
||||
_float_if_not_none(max_width),
|
||||
_float_if_not_none(max_height),
|
||||
)
|
||||
# MAX-SIZE-BRANCH result["_max_size_"] = (
|
||||
# MAX-SIZE-BRANCH _float_if_not_none(max_width),
|
||||
# MAX-SIZE-BRANCH _float_if_not_none(max_height),
|
||||
# MAX-SIZE-BRANCH )
|
||||
result["_align_"] = (
|
||||
component.align_x,
|
||||
component.align_y,
|
||||
|
||||
Reference in New Issue
Block a user