mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-02-02 10:54:15 -05:00
updated to latest version of web_sys
This commit is contained in:
parent
5d1d8ad28f
commit
294cbaf222
7 changed files with 36 additions and 39 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "leptos-use"
|
||||
version = "0.11.4"
|
||||
version = "0.11.5"
|
||||
edition = "2021"
|
||||
authors = ["Marc-Stefan Cassola"]
|
||||
categories = ["gui", "web-programming"]
|
||||
|
@ -37,7 +37,7 @@ wasm-bindgen = "0.2.92"
|
|||
wasm-bindgen-futures = "0.4"
|
||||
|
||||
[dependencies.web-sys]
|
||||
version = "0.3"
|
||||
version = ">=0.3.70"
|
||||
features = [
|
||||
"AddEventListenerOptions",
|
||||
"BinaryType",
|
||||
|
|
|
@ -79,10 +79,9 @@ pub fn use_clipboard_with_options(
|
|||
let update_text = move |_| {
|
||||
if is_supported.get() {
|
||||
spawn_local(async move {
|
||||
if let Some(clipboard) = window().navigator().clipboard() {
|
||||
if let Ok(text) = js_fut!(clipboard.read_text()).await {
|
||||
set_text.set(text.as_string());
|
||||
}
|
||||
let clipboard = window().navigator().clipboard();
|
||||
if let Ok(text) = js_fut!(clipboard.read_text()).await {
|
||||
set_text.set(text.as_string());
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -102,12 +101,11 @@ pub fn use_clipboard_with_options(
|
|||
let value = value.to_owned();
|
||||
|
||||
spawn_local(async move {
|
||||
if let Some(clipboard) = window().navigator().clipboard() {
|
||||
if js_fut!(clipboard.write_text(&value)).await.is_ok() {
|
||||
set_text.set(Some(value));
|
||||
set_copied.set(true);
|
||||
start(());
|
||||
}
|
||||
let clipboard = window().navigator().clipboard();
|
||||
if js_fut!(clipboard.write_text(&value)).await.is_ok() {
|
||||
set_text.set(Some(value));
|
||||
set_copied.set(true);
|
||||
start(());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -235,11 +235,11 @@ impl UseEventListenerOptions {
|
|||
passive,
|
||||
} = self;
|
||||
|
||||
let mut options = web_sys::AddEventListenerOptions::new();
|
||||
options.capture(*capture);
|
||||
options.once(*once);
|
||||
let options = web_sys::AddEventListenerOptions::new();
|
||||
options.set_capture(*capture);
|
||||
options.set_once(*once);
|
||||
if let Some(passive) = passive {
|
||||
options.passive(*passive);
|
||||
options.set_passive(*passive);
|
||||
}
|
||||
|
||||
options
|
||||
|
|
|
@ -183,8 +183,8 @@ where
|
|||
return;
|
||||
}
|
||||
|
||||
let mut event_src_opts = web_sys::EventSourceInit::new();
|
||||
event_src_opts.with_credentials(with_credentials);
|
||||
let event_src_opts = web_sys::EventSourceInit::new();
|
||||
event_src_opts.set_with_credentials(with_credentials);
|
||||
|
||||
let es = web_sys::EventSource::new_with_event_source_init_dict(&url, &event_src_opts)
|
||||
.unwrap_throw();
|
||||
|
|
|
@ -214,20 +214,20 @@ impl From<UseMutationObserverOptions> for web_sys::MutationObserverInit {
|
|||
character_data_old_value,
|
||||
} = val;
|
||||
|
||||
let mut init = Self::new();
|
||||
let init = Self::new();
|
||||
|
||||
init.subtree(subtree)
|
||||
.child_list(child_list)
|
||||
.attributes(attributes)
|
||||
.attribute_old_value(attribute_old_value)
|
||||
.character_data_old_value(character_data_old_value);
|
||||
init.set_subtree(subtree);
|
||||
init.set_child_list(child_list);
|
||||
init.set_attributes(attributes);
|
||||
init.set_attribute_old_value(attribute_old_value);
|
||||
init.set_character_data_old_value(character_data_old_value);
|
||||
|
||||
if let Some(attribute_filter) = attribute_filter {
|
||||
let array = js_sys::Array::from_iter(attribute_filter.into_iter().map(JsValue::from));
|
||||
init.attribute_filter(array.unchecked_ref());
|
||||
init.set_attribute_filter(array.unchecked_ref());
|
||||
}
|
||||
if let Some(character_data) = character_data {
|
||||
init.character_data(character_data);
|
||||
init.set_character_data(character_data);
|
||||
}
|
||||
|
||||
init
|
||||
|
|
|
@ -171,8 +171,8 @@ pub struct UseResizeObserverOptions {
|
|||
|
||||
impl From<UseResizeObserverOptions> for web_sys::ResizeObserverOptions {
|
||||
fn from(val: UseResizeObserverOptions) -> Self {
|
||||
let mut options = web_sys::ResizeObserverOptions::new();
|
||||
options.box_(
|
||||
let options = web_sys::ResizeObserverOptions::new();
|
||||
options.set_box(
|
||||
val.box_
|
||||
.unwrap_or(web_sys::ResizeObserverBoxOptions::ContentBox),
|
||||
);
|
||||
|
|
|
@ -318,32 +318,31 @@ impl Default for UseWebNotificationOptions {
|
|||
|
||||
impl From<&UseWebNotificationOptions> for web_sys::NotificationOptions {
|
||||
fn from(options: &UseWebNotificationOptions) -> Self {
|
||||
let mut web_sys_options = Self::new();
|
||||
let web_sys_options = Self::new();
|
||||
|
||||
web_sys_options
|
||||
.dir(options.direction.into())
|
||||
.require_interaction(options.require_interaction)
|
||||
.renotify(options.renotify)
|
||||
.silent(options.silent);
|
||||
web_sys_options.set_dir(options.direction.into());
|
||||
web_sys_options.set_require_interaction(options.require_interaction);
|
||||
web_sys_options.set_renotify(options.renotify);
|
||||
web_sys_options.set_silent(options.silent);
|
||||
|
||||
if let Some(body) = &options.body {
|
||||
web_sys_options.body(body);
|
||||
web_sys_options.set_body(body);
|
||||
}
|
||||
|
||||
if let Some(icon) = &options.icon {
|
||||
web_sys_options.icon(icon);
|
||||
web_sys_options.set_icon(icon);
|
||||
}
|
||||
|
||||
if let Some(image) = &options.image {
|
||||
web_sys_options.image(image);
|
||||
web_sys_options.set_image(image);
|
||||
}
|
||||
|
||||
if let Some(language) = &options.language {
|
||||
web_sys_options.lang(language);
|
||||
web_sys_options.set_lang(language);
|
||||
}
|
||||
|
||||
if let Some(tag) = &options.tag {
|
||||
web_sys_options.tag(tag);
|
||||
web_sys_options.set_tag(tag);
|
||||
}
|
||||
|
||||
web_sys_options
|
||||
|
|
Loading…
Add table
Reference in a new issue