74 Commits

Author SHA1 Message Date
Kaede Hoshikawa
c5b7790949
Remove IntoComponent (#2579)
* Make Function Component to Implement BaseComponent.

* Remove IntoComponent.

* Inline some methods.

* Move some logic out of proc macro.

* Move position of the self generics.

* Discourage direct implementation `FunctionComponent` & `#[doc(hidden)]`.
2022-04-16 00:44:39 +02:00
Kaede Hoshikawa
6fb547339f
Fix some Hook edge cases (#2592)
* Fix a couple edge cases.

* no implicit prelude.
2022-04-16 01:47:04 +05:00
Kaede Hoshikawa
6d07ba3b90
Fix generic with impl trait. (#2589) 2022-04-07 19:45:26 +05:00
Muhammad Hamza
2f3b90ce2c
Fix macro hygine issues (#2585)
* no_implicit_prelude in macro tests

* #[automatically_derived] and #[doc(hidden)]

* Span::call_site() -> Span::mixed_site()
2022-04-07 01:14:00 +05:00
WorldSEnder
8978baa45d
Fix casing of dynamic tags (#2578)
* fix casing of dynamic tags
* add test case for unknown tag names
* add lint for non-normalized tags
2022-04-05 19:07:31 +02:00
Finn Bear
ea8a530454
Fix #2553 - automatically convert closure to callback for component properties (#2554)
* Fix #2553 - automatically convert closure to callback for component properties.

* Support F -> Option<Callback<_>> too.

* test stderr.
2022-03-28 00:43:53 +02:00
Kaede Hoshikawa
8bc2212716
#[cfg(feature = "render")] and yew::Renderer (#2498)
* Bring changes to this branch.

* Bring changes to this branch.

* Add feature render and renderer.

* Bring changes to this branch.

* Migrate examples to Renderer.

* Satisfy no any render.

* Satisfy ssr.

* Satisfy feature render.

* Lint feature soundness.

* Suppress tests.

* Fix pr-flow, update docs.

* Add a notice.

* Adjust visibility.

* Correctly feature gate tests.

* make test scope available under feature render.

* Fix CI.

* Fix CI.

* Restore tests module to its original place as well.

* Make bundles crate private.

* Make most bundle APIs private.

* Adjust docs.

* Adjust debug implementation.

* Replace start_app with Renderer.

* Adjust documentation.

* Remove unused lint.

* Remove start_app from docs.

* DomBundle -> ReconcileTarget.

* Adjust documentation.

* Once render, now csr.

* Fix docs as well.
2022-03-20 00:48:47 +09:00
Kaede Hoshikawa
51238fb0e3
Better Function Component in docs + Macro-based Hooks (#2478)
* Fix const function component.

* Show Properties on the function definition.

* Filter certain doc attributes to be applied to type alias. More precise warnings.

* Implement macro-based hook.

* Add fail case.

* Function Component no longer a type alias.

* Clippy!

* Force 'static on generics.

* Fix clippy!

* Fix clippy and trybuild.

* Fix clippy and trybuild.

* Fix clippy.

* BaseComponent was not sealed properly.

* Adjust prelude.

* Public API should use IntoComponent for better ergonomics.

* Fix race condition.

* Fix trybuild.
2022-03-08 18:03:40 +05:00
Kaede Hoshikawa
fc067ab56c
Fix Call Generics & FnOnce macro hygiene (#2437)
* Fix Call Generics & FnOnce macro hygiene.

* Add a failure case as well.

* Remove a unused struct in test case.

* Update packages/yew-macro/tests/hook_attr/hook-const-generic-pass.rs

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
2022-02-12 18:26:23 +05:00
Kaede Hoshikawa
485a1b8c4a
Function Components & Hooks V2 (#2401)
* Make a use_hook hook with the new Hook trait.

* Implement Lifetime.

* Rewrites function signature.

* Only apply lifetime if there're other lifetimes.

* Cleanup signature rewrite logic.

* Rewrite hook body.

* Port some built-in hooks.

* Finish porting all built-in hooks.

* Port tests.

* Fix tests.

* Migrate to macro-based hooks.

* Fix HookContext, add tests on non-possible locations.

* Fix stderr for trybuild.

* Add 1 more test case.

* Adjust doc location.

* Pretty print hook signature.

* Fix Items & std::ops::Fn*.

* Add use_memo.

* Optimise Implementation of hooks.

* Use Box to capture function value only.

* Detect whether needs boxing.

* Add args if boxing not needed.

* Enforce hook number.

* Deduplicate use_effect.

* Optimise Implementation.

* Update documentation.

* Fix website test. Strip BoxedHook implementation from it.

* Allow doc string.

* Workaround doc tests.

* Optimise codebase & documentation.

* Fix website test.

* Reduce implementation complexity.

* Destructor is no more.

* Documentation and macros.

* Reduce heap allocation and hook complexity.

* Remove Queue as well.

* Prefer Generics.

* Fix typo.

* Remove more allocations.

* Add comments.

* Remove outdated comment.

* Bare Function Pointer for better code size.
2022-01-28 11:51:37 +02:00
Muhammad Hamza
f05ba4152c
Update to edition 2021 (#2354)
* cargo fix --edition

* change edition="2018" to edition="2021" in Cargo.toml
2022-01-12 16:22:00 +02:00
dependabot[bot]
3677930fc4
Update gloo requirement from 0.4 to 0.6 (#2337)
* Update gloo requirement from 0.4 to 0.6

Updates the requirements on [gloo](https://github.com/rustwasm/gloo) to permit the latest version.
- [Release notes](https://github.com/rustwasm/gloo/releases)
- [Commits](https://github.com/rustwasm/gloo/commits)

---
updated-dependencies:
- dependency-name: gloo
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix ci

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: voidpumpkin <32368314+voidpumpkin@users.noreply.github.com>
2022-01-10 23:17:13 +02:00
Muhammad Hamza
b456636111
Bump minimal supported rust version (MSRV) to 1.56 (#2334)
* Bump MSRV to 1.54

* add rust version to Cargo.toml

* update macro test stderr

* 1.56 go brrrr

* 1.56 go brrrr: part 2 electric boogaloo
2022-01-06 19:32:48 +02:00
Kaede Hoshikawa
ac3af0a9bc
Suspense Support (#2212)
* Make Html a Result.

* Fix tests.

* Implement Suspense.

* Schedule render when suspension is resumed.

* Shift children into a detached node.

* styled example.

* Update wording a little bit.

* Move hint to hint.

* Add some tests.

* Fix clippy.

* Add docs.

* Add to sidebar.

* Fix syntax highlight.

* Component -> BaseComponent.

* Html -> VNode, HtmlResult = RenderResult<Html>.

* Suspendible Function Component.

* Add a method to create suspension from futures.

* Revert extra changes.

* Fix tests.

* Update documentation.

* Switch to custom trait to make test reliable.

* Fix file permission.

* Fix docs.

* Remove log.

* Fix file permission.

* Fix component name error.

* Make Suspension a future.
2022-01-05 18:16:34 +05:00
Muhammad Hamza
73b5f6b4c1
Allow function_component creation based on function name (#2292)
* function_component without name

* fmt

* fc

* update docs

* remove fc
2021-12-23 13:30:17 +01:00
Zachary Stewart
a166815b88
Implement IntoPropValue for Rc<str> (#2285)
* add IntoPropValue implementations for Rc<str>

* add test

* update test logs which record the new impls
2021-12-22 01:42:26 +05:00
Kaede Hoshikawa
5b0bbd55c9
Fix defaulted type parameter. (#2284)
* Fix defaulted type parameter.

* Add test.
2021-12-19 16:46:32 +05:00
WorldSEnder
f5b921984a
Silence some warnings from derive(Properties) (#2266)
* silence some warnings from derive(Properties)

* for consistency preserve [#deny(..)]

* preserve some attributes on the struct def

adds a test case to check for several warnings

* add #[deny] in test cases to error instead of warning on failure

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>
2021-12-16 14:38:53 +05:00
Matt
1ef364ffda
Add braces when html_nested used on html element (#2270)
* add braces when html_nested used on html element

* run rustfmt
2021-12-15 22:56:24 +01:00
WorldSEnder
c2d39d7d48
Raw field names in property structs (#2273)
* raw property names

* add component test
2021-12-15 22:55:34 +01:00
GitHub Action
4d96d3d87d (cargo-release) version yew-macro-v0.19.3 2021-12-11 19:44:22 +00:00
Julius Lungys
457e98682d
Fix failed release (#2261)
* Revert "(cargo-release) version yew-v0.19.2"

This reverts commit feb45d81bc4ac7f5c6966622cb87286a1fa46d4e.

* (cargo-release) version yew-macro-v0.19.2

* remove publish = false
2021-12-11 21:31:34 +02:00
Cecile Tonglet
63eb95ca44 (cargo-release) version yew-macro-v0.19.1 2021-12-07 19:23:47 +01:00
Julius Lungys
d3d4b1dae6
(cargo-release) version yew-macro-v0.19.0 (#2245) 2021-12-06 15:33:32 +01:00
Julius Lungys
1c49e89450
Automatic publishing actions v2 (#2241) 2021-12-06 11:47:47 +01:00
Cecile Tonglet
3858aededd
Add the ability to add child nodes conditionally in html! (#1609)
* Initial commit

Forked at: 66d506e13329a06f7dce0b55a9427972b8aad3ff
Parent branch: origin/master

* Add the ability to add child nodes conditionally in html!

* WIP

Forked at: 66d506e13329a06f7dce0b55a9427972b8aad3ff
Parent branch: origin/master

* CLEANUP

Forked at: 66d506e13329a06f7dce0b55a9427972b8aad3ff
Parent branch: origin/master

* Experiment

* Failing test

* More tests

* More tests

* Add new HtmlIterable with syntax `for {...}` instead of `{for ...}`

* Remove HtmlIf from HtmlRoot (already done in HtmlTree)

* WIP

* WIP

* WIP

* WIP

* Revert

* CLEANUP

* WIP

* CLEANUP

* Remove IterableNew

* Renamed HtmlBranch to HtmlRootBraced and moved to mod.rs

* Update yew-macro/tests/html_macro/html-if-pass.rs

Co-authored-by: Simon <simon@siku2.io>

* Suggestion

* Oops

* Added ToNodeIterator to HtmlIf

* Improve error spans

* More html!()

* Move tests to not use browser

* Multiple children in if-expr

* Clippy fix

* Clippy fix again

* Re-trigger CI

* Apply suggestions from code review

Co-authored-by: Simon <simon@siku2.io>

* Replacing ParseResult by syn::Result everywhere

* Remove unnecessary &mut

* Attempt to add test on ToNodeIterator

* Clippy fixes

* Still works for some reason

* Revert "Attempt to add test on ToNodeIterator"

This reverts commit 75b1a85c28df36ad8bf61344eef56e06667da3b6.

* fix CI

* add docs on website

* Apply suggestions from code review

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>

* apparently I can't hide lines on website

* update stderr file

* will this work?

* fix bug where conditions can't be expressions

* better error message

* clippy & fmt

Co-authored-by: Simon <simon@siku2.io>
Co-authored-by: Hamza <muhammadhamza1311@gmail.com>
Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
2021-11-22 20:13:03 +02:00
Matt
4c3d6934a8
Remove extra braces in html_nested macro (#2169)
* removed unused braces from html_nested marco

* allow specifying test name

* also fix for html! macro

* also fix for html! macro

* remove misplaced #[allow(unused_braces)]
2021-11-21 17:09:30 +02:00
Teymour Aldridge
7e2542cbf8
Add basic lints to the HTML macro. (#1748)
* Add basic lints to the HTML macro.

* f

* Fix the examples.

* Fix nightly warning message tests.

* apply code review suggestions

* update error message

* rebase onto master

* remove unused props

* remove console log

* remove js void

* fix according to PR comments

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>
2021-11-21 19:54:49 +05:00
Jonas Platte
39886d4675
Allow Classes properties to be created from string literals (#2141)
* Allow Classes properties to be created from string literals

* Update test output
2021-11-11 22:02:05 +02:00
Muhammad Hamza
2f47b09da4
Add custom type for attribute values (#1994)
* Add custom type for attribute values

* fix tests/example

* Remove `PartialEq<String>` and it's usage

* `ReferenceCounted` -> `Rc`

* fucking fake

* please CI, just turn green
2021-11-08 18:11:22 +01:00
mc1098
77b46bfa40
Fix trybuild (#2103) 2021-10-08 01:57:24 +01:00
mc1098
e503c9acda
Remove web_sys re-export (#2084)
* Remove `web_sys` re-export

Removes re-exporting the `web_sys` dependency from the yew crate and
removes some `web_sys` features that were only enabled for re-exporting.

* re-export events through yew::events
2021-09-27 02:07:38 +02:00
Xavientois
97498cdfcd
Use into_prop_value to convert str prop to Option<String> (#2080) 2021-09-24 09:00:39 +02:00
mc1098
adb3fcfce1
Update dependencies (#2064)
General review of dependencies, removing ones that are not used and
bumping up minor versions to avoid breakage.

Consistent use of caret so that we use the most recent minor/patch
version of a dependency when building Yew crates.
2021-09-19 11:14:08 +02:00
mc1098
c4dee74e4a
Add support for missing boolean attributes (#2051) 2021-09-12 20:03:03 +01:00
mc1098
4c6da9aab3
Add fully qualified primitives in proc macro (#2037)
* Add primitive shadowing in macro tests

* Fix primitive types to be fully qualified
2021-09-07 09:40:09 +02:00
Xavientois
eeddcb95be
Add "struct update" syntax to pass props to component (..props instead of with props) (#2024)
* Reword to use double-dot syntax instead of "with"

* Implement double-dot syntax for props in components

* Update documentation with new syntax

* Update forgotten doc

* Add descriptive comments

* Check props and base expression

* Make compatible with 1.49.0 by removing then

* Fix website tests

* Update error output

* Implicitly convert string literals to String if they are listed as props

* Remove unused keyword

* Rename function for checking if string literal

* Fix weird formatting

* Update code based on review

* Update website/docs/concepts/html/components.md

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>

* Base expression span includes dot2 now

* Improve specificity of error message

* Chain together error messages

* Add an example failure case to illustrate combined error message

* Update based on review comments

* Fix missing clones

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
2021-09-06 06:41:51 +01:00
mc1098
58753d9607
Add no_implicit_prelude to proc macro tests (#2033)
* Add no_implicit_prelude to derive_props test

* Add no_implicit_prelude to html_macro tests

* Fix function_component macro tests

function_component macro tests weren't being run by try build due to
change in dir name. Imports corrected now that function_component is now
in yew.

Adds no_implicit_prelude to *-pass tests

* Add no_implicit_prelude to props_macro tests

* fix typo in comment
2021-09-05 23:33:30 +01:00
mc1098
c307f07fb8
Fix IntoEventCallback over IntoPropValue (#2025)
PR #1542 didn't merge in the changes from #1989 correctly, this is fixed
in this commit.
2021-08-31 12:10:28 +01:00
Janis Petersons
68d2fdbc59
Dev/listener multiplexer (#1542)
* yew: partial event listener multiplexer

web_sys implementaion compiles but the std_web implementation is unfinished. Keeping this only to commit curretn progress before reverting std_web.

* yew: partial event listener multiplexer

Feature parity with master, except for bubbling.

* yew/listener: fix and test synchronous listeners

* yew/listener: add placeholder comments

* yew/listener: passive listener test

* yew: extend and fix APIs and docs

* yew/listener: event bubbling

* clippy: ignore warning

* Update yew/src/callback.rs

Co-authored-by: Simon <simon@siku2.io>

* Update yew/src/html/listener/listener_stdweb.rs

Co-authored-by: Simon <simon@siku2.io>

* Apply suggestions from code review

Co-authored-by: Simon <simon@siku2.io>

* Apply suggestions from code review

Co-authored-by: Simon <simon@siku2.io>

* yew/listner: remove redundant function

* yew/listner: restore delibarate formatting

* yew/callback: make Flags a newtype

* yew/listener: use utility function

* yew/listener: deferred listeners

* yew/listner: input and change tests

* yew/listener: optimize listener registration

* yew/listener: remove benchmark placeholders

Seems easybench-wasm does not support specifying a module path.

* yew/callback: revert CallbackOnce -> Once

* yew: convert listener_tests to a build flag

* Apply suggestions from code review

Co-authored-by: Simon <simon@siku2.io>

* yew: fix doc comments

* yew: simplify iteration

* yew/remove unneeded default passive listeners

* yew/listeners: DRY some more

* yew/listener: fix clippy warnings

* yew/listeners: remove legacy comment

* yew/listeners: document stopping propagation

* yew/listeners: update tests

* ci: see how test run on stable

* ci: let's find the new MSRV

* ci: try to run integration tests only on stable

* yew/test: clean up residual dirty state

* yew/listeners: minor doc string and inline fixes

* yew/listener: document reasonning for function

Co-authored-by: Simon <simon@siku2.io>
2021-08-28 18:56:03 +02:00
Muhammad Hamza
f50c8c3cba
Components v2 (2) (#1961)
* Start rewrite

* Rc > cloning props

* fmt + rm useless file

* move props inside `Context`

* router compiles

* fix boids example

* fix counter example

* fix crm example

* fix dyn_create_destroy_apps example

* fix file_upload example

* fix futures example

* fix game_of_life example

* fix inner_html example

* fix js_callback example

* fix mount_point example

* fix keyed_list example

* fix web_gl example

* fix two_apps example

* fix todomvc example

* fix timer example

* fix store example

* fix nested_list example

* fix node_refs example

* fix pub_sub example

* fix multi_thread example

* don't call `changed` if props weren't changed

* formatting

* fix doc tests, remove neq_assign

* update router example, fix neq_assign compile errors

* fix macro/rest of doc tests

* start updating documentation

* `Component`'s documentation

* Apply suggestions from code review

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>

* Apply suggestions from code review (part 2)

* Apply suggestions from code review (part 3)

* fix context

* clippy

* post merge fixes

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
2021-08-25 13:11:39 +01:00
mc1098
f574c2fce3
Fix onsubmit handler to take Event (#2009)
onsubmit takes a `SubmitEvent` which is not available in web_sys.
`SubmitEvent` does not inherit from `FocusEvent` so
`FocusEvent::related_target` panics too!

As with onformdata onsubmit will use `Event` to remain safe and requires
users to define their own type or use Reflect api.

Trybuild change because of the new comment.
2021-08-22 00:16:28 +02:00
Karlitos
855de12313
Fix rust-analyzer #[derive(Properties)] warnings (#2007)
Fix #2006
2021-08-18 19:57:15 +02:00
mc1098
c6099cf875
Remove InputData & ChangeData (#2000) 2021-08-16 18:02:14 +02:00
Muhammad Hamza
c6458f124a
Allow taking Fn(EVENT) for callbacks too (#1989)
* Allow taking `Fn(EVENT)` for callbacks too

* fix bad test

* fmt

* add tests
2021-08-09 17:53:49 +02:00
Maciej Hirsz
47550292d5
Support const generics in #[derive(Properties)] (#1978)
* Support const generics in #[derive(Properties)]

* Test and tweak comment
2021-07-31 23:09:57 +02:00
Xavientois
c1226a2813
Add shorthand syntax for props (#1970)
* Allow shortened prop syntax

* Use new syntax where appropriate

* Apply suggestions from code review

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>

* Add tests to hit newly added error messages

* Fix clippy lints

* Re-trigger CI

* Revert error text

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
2021-07-31 23:01:02 +02:00
bakape
8fbb1a24cc
Static attribute lists (#1962)
* yew-macro: optimize VTag construction in html! macro

* yew/vtag: decrease VTag memory footpting and construction args

* yew,yew-macro: optimize VTag contruction, memory footprint and diffing

* yew/vlist: revert to VTag boxing

* yew-macro: add clippy allow for nightly rust

* yew-macro:  fix allow namespace

* *: bump MSRV to 1.49.0

* yew/attributes: static attribute keys and values

* yew/attributes: use boxed slices and inline dynamic class construction

* Update packages/yew/src/virtual_dom/vtag.rs

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>

* yew/vnode: revert mismerge

* yew/classes: add safety explanation comment

* Update packages/yew/src/utils/mod.rs

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
2021-07-31 23:00:10 +02:00
Xavientois
c9deba05f1
Fix clippy lints from 1.54.0 (#1976)
* Fix clippy lints from 1.54.0

* Format fixed code
2021-07-30 17:21:45 +02:00
Xavientois
26d42ba2a9
Remove unused punct field from props (#1969) 2021-07-25 14:52:04 +02:00