#![allow(non_snake_case)]
use events::EventHandler;
use crate::*;
pub(crate) fn element(tag: &'static str) -> HtmlNode {
HtmlNode::create_element(tag.into())
}
pub(crate) fn svg_element(tag: &'static str) -> HtmlNode {
HtmlNode::create_element_ns("http://www.w3.org/2000/svg", tag.into())
}
pub struct CustomElement(HtmlNode);
pub fn custom_element(tag: &'static str) -> CustomElement {
CustomElement(element(tag))
}
impl From<CustomElement> for View {
fn from(el: CustomElement) -> Self {
View::from_node(el.0)
}
}
impl AsHtmlNode for CustomElement {
fn as_html_node(&mut self) -> &mut HtmlNode {
&mut self.0
}
}
impl GlobalProps for CustomElement {}
impl HtmlGlobalAttributes for CustomElement {}
macro_rules! impl_attribute {
($(#[$attr:meta])* $v:vis $ident:ident: $ty:ty) => {
impl_attribute!($(#[$attr])* $v $ident (stringify!($ident)): $ty);
};
($(#[$attr:meta])* $v:vis $ident:ident ($name:expr): $ty:ty) => {
$(#[$attr])*
$v fn $ident(mut self, value: $ty) -> Self {
self.set_attribute($name, value.into());
self
}
}
}
macro_rules! impl_attributes {
($(
$(#[$attr:meta])*
$v:vis $ident:ident $(($name:literal))?: $ty:ty,
)*) => {
$(
impl_attribute!($(#[$attr])* $v $ident $(($name))*: $ty);
)*
};
}
macro_rules! impl_element {
(
$(#[$attr:meta])*
$name:ident {
$(
$(#[$prop_attr:meta])*
$prop:ident $(($prop_name:literal))?: $ty:ty,
)*
}
) => {
impl_element!($(#[$attr])* $name (stringify!($name)) {
$(
$(#[$prop_attr])*
$prop $(($prop_name))*: $ty,
)*
});
};
(
$(#[$attr:meta])*
$name:ident ($tag:expr) {
$(
$(#[$prop_attr:meta])*
$prop:ident $(($prop_name:literal))?: $ty:ty,
)*
}
) => {
paste::paste! {
#[doc = "The `<" $name ">` HTML element. This can be created by calling [`" $name "()`]."]
pub struct [<Html $name:camel>] (HtmlNode);
#[doc = "Create a `<" $name ">` element."]
#[doc = ""]
$(#[$attr])*
pub fn $name() -> [<Html $name:camel>] {
[<Html $name:camel>](element($tag))
}
impl From<[<Html $name:camel>]> for View {
fn from(el: [<Html $name:camel>]) -> Self {
View::from_node(el.0)
}
}
impl AsHtmlNode for [<Html $name:camel>] {
fn as_html_node(&mut self) -> &mut HtmlNode {
&mut self.0
}
}
impl GlobalProps for [<Html $name:camel>] {}
impl HtmlGlobalAttributes for [<Html $name:camel>] {}
#[doc = "Trait that provides attributes for the `<" $name ">` HTML element."]
pub trait [<Html $name:camel Attributes>]: SetAttribute + Sized {
impl_attributes! {
$(
$(#[$prop_attr])*
$prop $(($prop_name))*: $ty,
)*
}
}
impl [<Html $name:camel Attributes>] for [<Html $name:camel>] {}
}
};
}
macro_rules! impl_elements {
($(
$(#[$attr:meta])*
$name:ident $(($tag:expr))? {
$(
$(#[$prop_attr:meta])*
$prop:ident $(($prop_name:literal))?: $ty:ty,
)*
},
)*) => {
$(
impl_element!($(#[$attr])* $name $(($tag))* {
$(
$(#[$prop_attr])*
$prop $(($prop_name))*: $ty,
)*
});
)*
pub mod html_attributes {
paste::paste! {
pub use super::{$([<Html $name:camel Attributes>]),*};
}
}
};
}
macro_rules! impl_svg_element {
(
$(#[$attr:meta])*
$name:ident {
$(
$(#[$prop_attr:meta])*
$prop:ident $(($prop_name:literal))?: $ty:ty,
)*
}
) => {
impl_svg_element!($(#[$attr])* $name (stringify!($name)) {
$(
$(#[$prop_attr])*
$prop $(($prop_name))*: $ty,
)*
});
};
(
$(#[$attr:meta])*
$name:ident ($tag:expr) {
$(
$(#[$prop_attr:meta])*
$prop:ident $(($prop_name:literal))?: $ty:ty,
)*
}
) => {
paste::paste! {
#[doc = "The `<" $name ">` SVG element. This can be created by calling [`" $name "()`]."]
pub struct [<Svg $name:camel>] (HtmlNode);
#[doc = "Create a `<" $name ">` element."]
#[doc = ""]
$(#[$attr])*
pub fn $name() -> [<Svg $name:camel>] {
[<Svg $name:camel>](svg_element($tag))
}
impl From<[<Svg $name:camel>]> for View {
fn from(el: [<Svg $name:camel>]) -> Self {
View::from_node(el.0)
}
}
impl AsHtmlNode for [<Svg $name:camel>] {
fn as_html_node(&mut self) -> &mut HtmlNode {
&mut self.0
}
}
impl GlobalProps for [<Svg $name:camel>] {}
impl SvgGlobalAttributes for [<Svg $name:camel>] {}
#[doc = "Trait that provides attributes for the `<" $name ">` SVG element."]
pub trait [<Svg $name:camel Attributes>]: SetAttribute + Sized {
impl_attributes! {
$(
$(#[$prop_attr])*
$prop $(($prop_name))*: $ty,
)*
}
}
impl [<Svg $name:camel Attributes>] for [<Svg $name:camel>] {}
}
};
}
macro_rules! impl_svg_elements {
($(
$(#[$attr:meta])*
$name:ident $(($tag:expr))? {
$(
$(#[$prop_attr:meta])*
$prop:ident $(($prop_name:literal))?: $ty:ty,
)*
},
)*) => {
$(
impl_svg_element!($(#[$attr])* $name $(($tag))* {
$(
$(#[$prop_attr])*
$prop $(($prop_name))*: $ty,
)*
});
)*
pub mod svg_attributes {
paste::paste! {
pub use super::{$([<Svg $name:camel Attributes>]),*};
}
}
};
}
pub mod tags {
use super::*;
impl_elements! {
a {
download: impl Into<StringAttribute>,
href: impl Into<StringAttribute>,
hreflang: impl Into<StringAttribute>,
target: impl Into<StringAttribute>,
r#type("type"): impl Into<StringAttribute>,
ping: impl Into<StringAttribute>,
rel: impl Into<StringAttribute>,
},
abbr {},
address {},
area {
alt: impl Into<StringAttribute>,
coords: impl Into<StringAttribute>,
download: impl Into<StringAttribute>,
href: impl Into<StringAttribute>,
hreflang: impl Into<StringAttribute>,
media: impl Into<StringAttribute>,
referrerpolicy: impl Into<StringAttribute>,
ping: impl Into<StringAttribute>,
rel: impl Into<StringAttribute>,
shape: impl Into<StringAttribute>,
target: impl Into<StringAttribute>,
r#type("type"): impl Into<StringAttribute>,
},
article {},
aside {},
audio {
autoplay: impl Into<MaybeDyn<bool>>,
controls: impl Into<MaybeDyn<bool>>,
crossorigin: impl Into<StringAttribute>,
muted: impl Into<MaybeDyn<bool>>,
preload: impl Into<StringAttribute>,
src: impl Into<StringAttribute>,
r#loop("loop"): impl Into<MaybeDyn<bool>>,
},
b {},
base {
href: impl Into<StringAttribute>,
target: impl Into<StringAttribute>,
},
bdi {},
bdo {},
blockquote {
cite: impl Into<StringAttribute>,
},
body {},
br {},
button {
autofocus: impl Into<MaybeDyn<bool>>,
disabled: impl Into<MaybeDyn<bool>>,
form: impl Into<StringAttribute>,
formaction: impl Into<StringAttribute>,
formenctype: impl Into<StringAttribute>,
formmethod: impl Into<StringAttribute>,
formnovalidate: impl Into<MaybeDyn<bool>>,
formtarget: impl Into<StringAttribute>,
name: impl Into<StringAttribute>,
r#type("type"): impl Into<StringAttribute>,
value: impl Into<StringAttribute>,
},
canvas {
height: impl Into<StringAttribute>, width: impl Into<StringAttribute>, },
caption {},
cite {},
code {
language: impl Into<StringAttribute>,
},
col {
span: impl Into<StringAttribute>, },
colgroup {
span: impl Into<StringAttribute>, },
data {
value: impl Into<StringAttribute>,
},
datalist {},
dd {},
del {
cite: impl Into<StringAttribute>,
datetime: impl Into<StringAttribute>,
},
details {
open: impl Into<MaybeDyn<bool>>,
},
dfn {},
dialog {},
div {},
dl {},
dt {},
em {},
embed {
height: impl Into<StringAttribute>,
src: impl Into<StringAttribute>,
r#type("type"): impl Into<StringAttribute>,
width: impl Into<StringAttribute>, },
fieldset {},
figcaption {},
figure {},
footer {},
form {
acceptcharset: impl Into<StringAttribute>,
action: impl Into<StringAttribute>,
autocomplete: impl Into<StringAttribute>,
enctype: impl Into<StringAttribute>,
method: impl Into<StringAttribute>,
name: impl Into<StringAttribute>,
novalidate: impl Into<MaybeDyn<bool>>,
target: impl Into<StringAttribute>,
},
head {},
header {},
hgroup {},
h1 {},
h2 {},
h3 {},
h4 {},
h5 {},
h6 {},
hr {},
html {},
i {},
iframe {
allow: impl Into<StringAttribute>,
allowfullscreen: impl Into<MaybeDyn<bool>>,
allowpaymentrequest: impl Into<MaybeDyn<bool>>,
height: impl Into<StringAttribute>,
loading: impl Into<StringAttribute>,
name: impl Into<StringAttribute>,
referrerpolicy: impl Into<StringAttribute>,
sandbox: impl Into<MaybeDyn<bool>>,
src: impl Into<StringAttribute>,
srcdoc: impl Into<StringAttribute>,
width: impl Into<StringAttribute>,
},
img {
alt: impl Into<StringAttribute>,
crossorigin: impl Into<StringAttribute>,
decoding: impl Into<StringAttribute>,
height: impl Into<StringAttribute>,
ismap: impl Into<MaybeDyn<bool>>,
loading: impl Into<StringAttribute>,
referrerpolicy: impl Into<StringAttribute>,
sizes: impl Into<StringAttribute>,
src: impl Into<StringAttribute>,
srcset: impl Into<StringAttribute>,
usemap: impl Into<StringAttribute>,
width: impl Into<StringAttribute>,
},
input {
accept: impl Into<StringAttribute>,
alt: impl Into<StringAttribute>,
autocomplete: impl Into<StringAttribute>,
autofocus: impl Into<MaybeDyn<bool>>,
capture: impl Into<StringAttribute>,
checked: impl Into<MaybeDyn<bool>>,
directory: impl Into<StringAttribute>,
disabled: impl Into<MaybeDyn<bool>>,
form: impl Into<StringAttribute>,
formaction: impl Into<StringAttribute>,
formenctype: impl Into<StringAttribute>,
formmethod: impl Into<StringAttribute>,
formnovalidate: impl Into<MaybeDyn<bool>>,
formtarget: impl Into<StringAttribute>,
height: impl Into<StringAttribute>, initial_checked: impl Into<MaybeDyn<bool>>,
initial_value: impl Into<StringAttribute>,
list: impl Into<StringAttribute>,
max: impl Into<StringAttribute>,
maxlength: impl Into<StringAttribute>, min: impl Into<StringAttribute>,
minlength: impl Into<StringAttribute>, multiple: impl Into<MaybeDyn<bool>>,
name: impl Into<StringAttribute>,
pattern: impl Into<StringAttribute>,
placeholder: impl Into<StringAttribute>,
readonly: impl Into<MaybeDyn<bool>>,
required: impl Into<MaybeDyn<bool>>,
size: impl Into<StringAttribute>, spellcheck: impl Into<MaybeDyn<bool>>,
src: impl Into<StringAttribute>,
step: impl Into<StringAttribute>,
tabindex: impl Into<StringAttribute>, r#type("type"): impl Into<StringAttribute>,
value: impl Into<StringAttribute>,
width: impl Into<StringAttribute>, },
ins {
cite: impl Into<StringAttribute>,
datetime: impl Into<StringAttribute>,
},
kbd {},
keygen {},
label {
form: impl Into<StringAttribute>,
r#for("for"): impl Into<StringAttribute>,
},
legend {},
li {
value: impl Into<StringAttribute>, },
link {
r#as("as"): impl Into<StringAttribute>,
crossorigin: impl Into<StringAttribute>,
href: impl Into<StringAttribute>,
hreflang: impl Into<StringAttribute>,
media: impl Into<StringAttribute>,
rel: impl Into<StringAttribute>,
sizes: impl Into<StringAttribute>,
title: impl Into<StringAttribute>,
r#type("type"): impl Into<StringAttribute>,
integrity: impl Into<StringAttribute>,
},
main {},
map {
name: impl Into<StringAttribute>,
},
mark {},
menu {},
menuitem {},
meta {
charset: impl Into<StringAttribute>,
content: impl Into<StringAttribute>,
http_equiv("http-equiv"): impl Into<StringAttribute>,
name: impl Into<StringAttribute>,
},
meter {
value: impl Into<StringAttribute>, min: impl Into<StringAttribute>, max: impl Into<StringAttribute>, low: impl Into<StringAttribute>, high: impl Into<StringAttribute>, optimum: impl Into<StringAttribute>, form: impl Into<StringAttribute>,
},
nav {},
noscript {},
object {
data: impl Into<StringAttribute>,
form: impl Into<StringAttribute>,
height: impl Into<StringAttribute>, name: impl Into<StringAttribute>,
r#type("type"): impl Into<StringAttribute>,
typemustmatch: impl Into<MaybeDyn<bool>>,
usemap: impl Into<StringAttribute>,
width: impl Into<StringAttribute>,
},
ol {
reversed: impl Into<MaybeDyn<bool>>,
start: impl Into<StringAttribute>, r#type("type"): impl Into<StringAttribute>,
},
optgroup {
disabled: impl Into<MaybeDyn<bool>>,
label: impl Into<StringAttribute>,
},
option {
disabled: impl Into<MaybeDyn<bool>>,
initial_selected: impl Into<MaybeDyn<bool>>,
label: impl Into<StringAttribute>,
selected: impl Into<MaybeDyn<bool>>,
value: impl Into<StringAttribute>,
},
output {
r#for("for"): impl Into<StringAttribute>,
form: impl Into<StringAttribute>,
name: impl Into<StringAttribute>,
},
p {},
param {
name: impl Into<StringAttribute>,
value: impl Into<StringAttribute>,
},
picture {},
pre {},
progress {
value: impl Into<StringAttribute>, max: impl Into<StringAttribute>, },
q {
cite: impl Into<StringAttribute>,
},
rp {},
rt {},
ruby {},
s {},
samp {},
script {
r#async: impl Into<MaybeDyn<bool>>,
crossorigin: impl Into<StringAttribute>,
defer: impl Into<MaybeDyn<bool>>,
integrity: impl Into<StringAttribute>,
nomodule: impl Into<MaybeDyn<bool>>,
nonce: impl Into<StringAttribute>,
src: impl Into<StringAttribute>,
script: impl Into<StringAttribute>,
text: impl Into<StringAttribute>,
r#type("type"): impl Into<StringAttribute>,
},
section {},
select {
autocomplete: impl Into<StringAttribute>,
autofocus: impl Into<MaybeDyn<bool>>,
disabled: impl Into<MaybeDyn<bool>>,
form: impl Into<StringAttribute>,
multiple: impl Into<MaybeDyn<bool>>,
name: impl Into<StringAttribute>,
required: impl Into<MaybeDyn<bool>>,
size: impl Into<StringAttribute>, value: impl Into<StringAttribute>,
},
small {},
source {
src: impl Into<StringAttribute>,
r#type("type"): impl Into<StringAttribute>,
},
span {},
strong {},
style {
media: impl Into<StringAttribute>,
nonce: impl Into<StringAttribute>,
title: impl Into<StringAttribute>,
r#type("type"): impl Into<StringAttribute>,
},
sub {},
summary {},
sup {},
table {},
tbody {},
td {
colspan: impl Into<StringAttribute>, headers: impl Into<StringAttribute>,
rowspan: impl Into<StringAttribute>, },
template {},
textarea {
autocomplete: impl Into<StringAttribute>,
autofocus: impl Into<MaybeDyn<bool>>,
cols: impl Into<StringAttribute>, disabled: impl Into<MaybeDyn<bool>>,
form: impl Into<StringAttribute>,
initial_value: impl Into<StringAttribute>,
maxlength: impl Into<StringAttribute>, minlength: impl Into<StringAttribute>, name: impl Into<StringAttribute>,
placeholder: impl Into<StringAttribute>,
readonly: impl Into<MaybeDyn<bool>>,
required: impl Into<MaybeDyn<bool>>,
rows: impl Into<StringAttribute>, spellcheck: impl Into<MaybeDyn<bool>>,
r#type("type"): impl Into<StringAttribute>,
value: impl Into<StringAttribute>,
wrap: impl Into<StringAttribute>,
},
tfoot {},
th {
abbr: impl Into<StringAttribute>,
colspan: impl Into<StringAttribute>, headers: impl Into<StringAttribute>,
rowspan: impl Into<StringAttribute>, scope: impl Into<StringAttribute>,
},
thead {},
time {
datetime: impl Into<StringAttribute>,
},
title {},
tr {},
track {
default: impl Into<MaybeDyn<bool>>,
kind: impl Into<StringAttribute>,
label: impl Into<StringAttribute>,
src: impl Into<StringAttribute>,
srclang: impl Into<StringAttribute>,
},
u {},
ul {},
var {},
video {
autoplay: impl Into<MaybeDyn<bool>>,
controls: impl Into<MaybeDyn<bool>>,
crossorigin: impl Into<StringAttribute>,
height: impl Into<StringAttribute>, r#loop("loop"): impl Into<MaybeDyn<bool>>,
muted: impl Into<MaybeDyn<bool>>,
playsinline: impl Into<MaybeDyn<bool>>,
poster: impl Into<StringAttribute>,
preload: impl Into<StringAttribute>,
src: impl Into<StringAttribute>,
width: impl Into<StringAttribute>, },
wbr {},
}
impl_svg_elements! {
svg {
xmlns: impl Into<StringAttribute>,
},
svg_a("a") {},
animate {},
animateMotion {},
animateTransform {},
circle {},
clipPath {},
defs {},
desc {},
discard {},
ellipse {},
feBlend {},
feColorMatrix {},
feComponentTransfer {},
feComposite {},
feConvolveMatrix {},
feDiffuseLighting {},
feDisplacementMap {},
feDistantLight {},
feDropShadow {},
feFlood {},
feFuncA {},
feFuncB {},
feFuncG {},
feFuncR {},
feGaussianBlur {},
feImage {},
feMerge {},
feMergeNode {},
feMorphology {},
feOffset {},
fePointLight {},
feSpecularLighting {},
feSpotLight {},
feTile {},
feTurbulence {},
filter {},
foreignObject {},
g {},
hatch {},
hatchpath {},
image {},
line {},
linearGradient {},
marker {},
mask {},
metadata {},
mpath {},
path {},
pattern {},
polygon {},
polyline {},
radialGradient {},
rect {},
svg_script("script") {},
set {},
stop {},
svg_style("style") {},
switch {},
symbol {},
text {},
textPath {},
svg_title("title") {},
tspan {},
r#use("use") {},
view {},
}
}
pub trait HtmlGlobalAttributes: SetAttribute + Sized {
impl_attributes! {
accesskey: impl Into<StringAttribute>,
autocapitalize: impl Into<StringAttribute>,
autofocus: impl Into<MaybeDyn<bool>>,
class: impl Into<StringAttribute>,
contenteditable: impl Into<StringAttribute>,
dir: impl Into<StringAttribute>,
draggable: impl Into<StringAttribute>,
enterkeyhint: impl Into<StringAttribute>,
exportparts: impl Into<StringAttribute>,
hidden: impl Into<MaybeDyn<bool>>,
id: impl Into<StringAttribute>,
inert: impl Into<MaybeDyn<bool>>,
inputmode: impl Into<StringAttribute>,
is: impl Into<StringAttribute>,
itemid: impl Into<StringAttribute>,
itemprop: impl Into<StringAttribute>,
itemref: impl Into<StringAttribute>,
itemscope: impl Into<MaybeDyn<bool>>,
itemtype: impl Into<StringAttribute>,
lang: impl Into<StringAttribute>,
nonce: impl Into<StringAttribute>,
part: impl Into<StringAttribute>,
popover: impl Into<StringAttribute>,
role: impl Into<StringAttribute>,
slot: impl Into<StringAttribute>,
spellcheck: impl Into<StringAttribute>,
style: impl Into<StringAttribute>,
tabindex: impl Into<StringAttribute>,
title: impl Into<StringAttribute>,
translate: impl Into<StringAttribute>,
virtualkeyboardpolicy: impl Into<StringAttribute>,
}
}
pub trait SvgGlobalAttributes: SetAttribute + Sized {
impl_attributes! {
accentHeight("accent-height"): impl Into<StringAttribute>,
accumulate: impl Into<StringAttribute>,
additive: impl Into<StringAttribute>,
alignmentBaseline("alignment-baseline"): impl Into<StringAttribute>,
alphabetic: impl Into<StringAttribute>,
amplitude: impl Into<StringAttribute>,
arabicForm("arabic-form"): impl Into<StringAttribute>,
ascent: impl Into<StringAttribute>,
attributeName("attributeName"): impl Into<StringAttribute>,
attributeType("attributeType"): impl Into<StringAttribute>,
azimuth: impl Into<StringAttribute>,
baseFrequency("baseFrequency"): impl Into<StringAttribute>,
baselineShift("baseline-shift"): impl Into<StringAttribute>,
baseProfile("baseProfile"): impl Into<StringAttribute>,
bbox: impl Into<StringAttribute>,
begin: impl Into<StringAttribute>,
bias: impl Into<StringAttribute>,
by: impl Into<StringAttribute>,
calcMode("calcMode"): impl Into<StringAttribute>,
capHeight("cap-height"): impl Into<StringAttribute>,
class: impl Into<StringAttribute>,
clipPathUnits("clipPathUnits"): impl Into<StringAttribute>,
clipPath("clip-path"): impl Into<StringAttribute>,
clipRule("clip-rule"): impl Into<StringAttribute>,
color: impl Into<StringAttribute>,
colorInterpolation("color-interpolation"): impl Into<StringAttribute>,
colorInterpolationFilters("color-interpolation-filters"): impl Into<StringAttribute>,
colorProfile("color-profile"): impl Into<StringAttribute>,
colorRendering("color-rendering"): impl Into<StringAttribute>,
crossorigin: impl Into<StringAttribute>,
cursor: impl Into<StringAttribute>,
cx: impl Into<StringAttribute>,
cy: impl Into<StringAttribute>,
d: impl Into<StringAttribute>,
decelerate: impl Into<StringAttribute>,
descent: impl Into<StringAttribute>,
diffuseConstant("diffuseConstant"): impl Into<StringAttribute>,
direction: impl Into<StringAttribute>,
display: impl Into<StringAttribute>,
divisor: impl Into<StringAttribute>,
dominantBaseline("dominant-baseline"): impl Into<StringAttribute>,
dur: impl Into<StringAttribute>,
dx: impl Into<StringAttribute>,
dy: impl Into<StringAttribute>,
edgeMode("edgeMode"): impl Into<StringAttribute>,
elevation: impl Into<StringAttribute>,
enableBackground("enable-background"): impl Into<StringAttribute>,
end: impl Into<StringAttribute>,
exponent: impl Into<StringAttribute>,
fill: impl Into<StringAttribute>,
fillOpacity("fill-opacity"): impl Into<StringAttribute>,
fillRule("fill-rule"): impl Into<StringAttribute>,
filter: impl Into<StringAttribute>,
filterUnits("filterUnits"): impl Into<StringAttribute>,
floodColor("flood-color"): impl Into<StringAttribute>,
floodOpacity("flood-opacity"): impl Into<StringAttribute>,
fontFamily("font-family"): impl Into<StringAttribute>,
fontSize("font-size"): impl Into<StringAttribute>,
fontSizeAdjust("font-size-adjust"): impl Into<StringAttribute>,
fontStretch("font-stretch"): impl Into<StringAttribute>,
fontStyle("font-style"): impl Into<StringAttribute>,
fontVariant("font-variant"): impl Into<StringAttribute>,
fontWeight("font-weight"): impl Into<StringAttribute>,
format: impl Into<StringAttribute>,
from: impl Into<StringAttribute>,
fr: impl Into<StringAttribute>,
fx: impl Into<StringAttribute>,
fy: impl Into<StringAttribute>,
g1: impl Into<StringAttribute>,
g2: impl Into<StringAttribute>,
glyphName("glyph-name"): impl Into<StringAttribute>,
glyphOrientationHorizontal("glyph-orientation-horizontal"): impl Into<StringAttribute>,
glyphOrientationVertical("glyph-orientation-vertical"): impl Into<StringAttribute>,
glyphRef: impl Into<StringAttribute>,
gradientTransform("gradientTransform"): impl Into<StringAttribute>,
gradientUnits("gradientUnits"): impl Into<StringAttribute>,
hanging: impl Into<StringAttribute>,
height: impl Into<StringAttribute>,
href: impl Into<StringAttribute>,
hreflang: impl Into<StringAttribute>,
horizAdvX("horiz-adv-x"): impl Into<StringAttribute>,
horizOriginX("horiz-origin-x"): impl Into<StringAttribute>,
id: impl Into<StringAttribute>,
ideographic: impl Into<StringAttribute>,
imageRendering("image-rendering"): impl Into<StringAttribute>,
in_: impl Into<StringAttribute>,
in2: impl Into<StringAttribute>,
intercept: impl Into<StringAttribute>,
k: impl Into<StringAttribute>,
k1: impl Into<StringAttribute>,
k2: impl Into<StringAttribute>,
k3: impl Into<StringAttribute>,
k4: impl Into<StringAttribute>,
kernelMatrix("kernelMatrix"): impl Into<StringAttribute>,
kernelUnitLength("kernelUnitLength"): impl Into<StringAttribute>,
kerning: impl Into<StringAttribute>,
keyPoints("keyPoints"): impl Into<StringAttribute>,
keySplines("keySplines"): impl Into<StringAttribute>,
keyTimes("keyTimes"): impl Into<StringAttribute>,
lang: impl Into<StringAttribute>,
lengthAdjust("lengthAdjust"): impl Into<StringAttribute>,
letterSpacing("letter-spacing"): impl Into<StringAttribute>,
lightingColor("lighting-color"): impl Into<StringAttribute>,
limitingConeAngle("limitingConeAngle"): impl Into<StringAttribute>,
local: impl Into<StringAttribute>,
markerEnd("marker-end"): impl Into<StringAttribute>,
markerMid("marker-mid"): impl Into<StringAttribute>,
markerStart("marker-start"): impl Into<StringAttribute>,
markerHeight("markerHeight"): impl Into<StringAttribute>,
markerUnits("markerUnits"): impl Into<StringAttribute>,
markerWidth("markerWidth"): impl Into<StringAttribute>,
mask: impl Into<StringAttribute>,
maskContentUnits("maskContentUnits"): impl Into<StringAttribute>,
maskUnits("maskUnits"): impl Into<StringAttribute>,
mathematical: impl Into<StringAttribute>,
max: impl Into<StringAttribute>,
media: impl Into<StringAttribute>,
method: impl Into<StringAttribute>,
min: impl Into<StringAttribute>,
mode: impl Into<StringAttribute>,
name: impl Into<StringAttribute>,
numOctaves("numOctaves"): impl Into<StringAttribute>,
offset: impl Into<StringAttribute>,
opacity: impl Into<StringAttribute>,
operator: impl Into<StringAttribute>,
order: impl Into<StringAttribute>,
orient: impl Into<StringAttribute>,
orientation: impl Into<StringAttribute>,
origin: impl Into<StringAttribute>,
overflow: impl Into<StringAttribute>,
overlinePosition("overline-position"): impl Into<StringAttribute>,
overlineThickness("overline-thickness"): impl Into<StringAttribute>,
panose1("panose-1"): impl Into<StringAttribute>,
paintOrder("paint-order"): impl Into<StringAttribute>,
path: impl Into<StringAttribute>,
pathLength("pathLength"): impl Into<StringAttribute>,
patternContentUnits("patternContentUnits"): impl Into<StringAttribute>,
patternTransform("patternTransform"): impl Into<StringAttribute>,
patternUnits("patternUnits"): impl Into<StringAttribute>,
ping: impl Into<StringAttribute>,
pointerEvents("pointer-events"): impl Into<StringAttribute>,
points: impl Into<StringAttribute>,
pointsAtX("pointsAtX"): impl Into<StringAttribute>,
pointsAtY("pointsAtY"): impl Into<StringAttribute>,
pointsAtZ("pointsAtZ"): impl Into<StringAttribute>,
preserveAlpha("preserveAlpha"): impl Into<StringAttribute>,
preserveAspectRatio("preserveAspectRatio"): impl Into<StringAttribute>,
primitiveUnits("primitiveUnits"): impl Into<StringAttribute>,
r: impl Into<StringAttribute>,
radius: impl Into<StringAttribute>,
referrerPolicy("referrerPolicy"): impl Into<StringAttribute>,
refX("refX"): impl Into<StringAttribute>,
refY("refY"): impl Into<StringAttribute>,
rel: impl Into<StringAttribute>,
renderingIntent("rendering-intent"): impl Into<StringAttribute>,
repeatCount("repeatCount"): impl Into<StringAttribute>,
repeatDur("repeatDur"): impl Into<StringAttribute>,
requiredExtensions("requiredExtensions"): impl Into<StringAttribute>,
requiredFeatures("requiredFeatures"): impl Into<StringAttribute>,
restart: impl Into<StringAttribute>,
result: impl Into<StringAttribute>,
rotate: impl Into<StringAttribute>,
rx: impl Into<StringAttribute>,
ry: impl Into<StringAttribute>,
scale: impl Into<StringAttribute>,
seed: impl Into<StringAttribute>,
shapeRendering("shape-rendering"): impl Into<StringAttribute>,
slope: impl Into<StringAttribute>,
spacing: impl Into<StringAttribute>,
specularConstant("specularConstant"): impl Into<StringAttribute>,
specularExponent("specularExponent"): impl Into<StringAttribute>,
speed: impl Into<StringAttribute>,
spreadMethod("spreadMethod"): impl Into<StringAttribute>,
startOffset("startOffset"): impl Into<StringAttribute>,
stdDeviation("stdDeviation"): impl Into<StringAttribute>,
stemh: impl Into<StringAttribute>,
stemv: impl Into<StringAttribute>,
stitchTiles("stitchTiles"): impl Into<StringAttribute>,
stopColor("stop-color"): impl Into<StringAttribute>,
stopOpacity("stop-opacity"): impl Into<StringAttribute>,
strikethroughPosition("strikethrough-position"): impl Into<StringAttribute>,
strikethroughThickness("strikethrough-thickness"): impl Into<StringAttribute>,
string: impl Into<StringAttribute>,
stroke: impl Into<StringAttribute>,
strokeDasharray("stroke-dasharray"): impl Into<StringAttribute>,
strokeDashoffset("stroke-dashoffset"): impl Into<StringAttribute>,
strokeLinecap("stroke-linecap"): impl Into<StringAttribute>,
strokeLinejoin("stroke-linejoin"): impl Into<StringAttribute>,
strokeMiterlimit("stroke-miterlimit"): impl Into<StringAttribute>,
strokeOpacity("stroke-opacity"): impl Into<StringAttribute>,
strokeWidth("stroke-width"): impl Into<StringAttribute>,
style: impl Into<StringAttribute>,
surfaceScale("surfaceScale"): impl Into<StringAttribute>,
systemLanguage("systemLanguage"): impl Into<StringAttribute>,
tabindex: impl Into<StringAttribute>,
tableValues("tableValues"): impl Into<StringAttribute>,
target: impl Into<StringAttribute>,
targetX("targetX"): impl Into<StringAttribute>,
targetY("targetY"): impl Into<StringAttribute>,
textAnchor("text-anchor"): impl Into<StringAttribute>,
textDecoration("text-decoration"): impl Into<StringAttribute>,
textRendering("text-rendering"): impl Into<StringAttribute>,
textLength("textLength"): impl Into<StringAttribute>,
to: impl Into<StringAttribute>,
transform: impl Into<StringAttribute>,
transformOrigin("transform-origin"): impl Into<StringAttribute>,
type_: impl Into<StringAttribute>,
u1: impl Into<StringAttribute>,
u2: impl Into<StringAttribute>,
underlinePosition("underline-position"): impl Into<StringAttribute>,
underlineThickness("underline-thickness"): impl Into<StringAttribute>,
unicode: impl Into<StringAttribute>,
unicodeBidi("unicode-bidi"): impl Into<StringAttribute>,
unicodeRange("unicode-range"): impl Into<StringAttribute>,
unitsPerEm("units-per-em"): impl Into<StringAttribute>,
vAlphabetic("v-alphabetic"): impl Into<StringAttribute>,
vHanging("v-hanging"): impl Into<StringAttribute>,
vIdeographic("v-ideographic"): impl Into<StringAttribute>,
vMathematical("v-mathematical"): impl Into<StringAttribute>,
values: impl Into<StringAttribute>,
vectorEffect("vector-effect"): impl Into<StringAttribute>,
version: impl Into<StringAttribute>,
vertAdvY("vert-adv-y"): impl Into<StringAttribute>,
vertOriginX("vert-origin-x"): impl Into<StringAttribute>,
vertOriginY("vert-origin-y"): impl Into<StringAttribute>,
viewBox: impl Into<StringAttribute>,
visibility: impl Into<StringAttribute>,
width: impl Into<StringAttribute>,
widths: impl Into<StringAttribute>,
wordSpacing("word-spacing"): impl Into<StringAttribute>,
writingMode("writing-mode"): impl Into<StringAttribute>,
x: impl Into<StringAttribute>,
xHeight("x-height"): impl Into<StringAttribute>,
x1: impl Into<StringAttribute>,
x2: impl Into<StringAttribute>,
xChannelSelector("xChannelSelector"): impl Into<StringAttribute>,
xmlBase("xml:base"): impl Into<StringAttribute>,
xmlLang("xml:lang"): impl Into<StringAttribute>,
xmlSpace("xml:space"): impl Into<StringAttribute>,
y: impl Into<StringAttribute>,
y1: impl Into<StringAttribute>,
y2: impl Into<StringAttribute>,
yChannelSelector("yChannelSelector"): impl Into<StringAttribute>,
zoomAndPan("zoomAndPan"): impl Into<StringAttribute>,
}
}
pub trait GlobalAttributes: SetAttribute + Sized {
/// Set attribute `name` with `value`.
fn attr(mut self, name: &'static str, value: impl Into<StringAttribute>) -> Self {
self.set_attribute(name, value.into());
self
}
fn bool_attr(mut self, name: &'static str, value: impl Into<MaybeDyn<bool>>) -> Self {
self.set_attribute(name, value.into());
self
}
fn prop(mut self, name: &'static str, value: impl Into<MaybeDyn<JsValue>>) -> Self {
self.set_attribute(name, value.into());
self
}
/// Set an event handler with `name`.
fn on<E: events::EventDescriptor, R>(
mut self,
_: E,
mut handler: impl EventHandler<E, R>,
) -> Self {
let scope = use_current_scope(); // Run handler inside the current scope.
let handler = move |ev: web_sys::Event| scope.run_in(|| handler.call(ev.unchecked_into()));
self.set_event_handler(E::NAME, handler);
self
}
fn bind<E: bind::BindDescriptor>(mut self, _: E, signal: Signal<E::ValueTy>) -> Self {
let scope = use_current_scope(); let handler = move |ev: web_sys::Event| {
scope.run_in(|| {
let value =
js_sys::Reflect::get(&ev.current_target().unwrap(), &E::TARGET_PROPERTY.into())
.unwrap();
signal.set(E::CONVERT_FROM_JS(&value).expect("failed to convert value from js"));
})
};
self.set_event_handler(<E::Event as events::EventDescriptor>::NAME, handler);
self.prop(E::TARGET_PROPERTY, move || signal.get_clone().into())
}
}
impl<T: GlobalProps> GlobalAttributes for T {}
pub trait GlobalProps: GlobalAttributes + AsHtmlNode + Sized {
fn dangerously_set_inner_html(mut self, inner_html: impl Into<Cow<'static, str>>) -> Self {
self.as_html_node().set_inner_html(inner_html.into());
self
}
fn children(mut self, children: impl Into<View>) -> Self {
self.as_html_node().append_view(children.into());
self
}
fn r#ref(mut self, noderef: NodeRef) -> Self {
if is_not_ssr!() {
noderef.set(Some(self.as_html_node().as_web_sys().clone()));
}
self
}
fn spread(mut self, attributes: Attributes) -> Self {
attributes.apply_self(self.as_html_node());
self
}
}