Skip to content

[Live][Stimulus] Prepping the LiveComponent Stable Release 🚀 #1419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/LiveComponent/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# Live Components

**EXPERIMENTAL** This component is currently experimental and is
likely to change, or even change drastically.

Live components work with the [TwigComponent](https://symfony.com/bundles/ux-twig-component/current/index.html)
library to give you the power to automatically update your
Twig components on the frontend as the user interacts with them.
Inspired by [Livewire](https://laravel-livewire.com/) and
[Phoenix LiveView](https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html).

Want a demo? Check out https://github.com/weaverryan/live-demo.
Want a demo? Check out https://ux.symfony.com/live-component.

**This repository is a READ-ONLY sub-tree split**. See
https://github.com/symfony/ux to create issues or submit pull requests.
Expand Down
6 changes: 3 additions & 3 deletions src/LiveComponent/assets/dist/live_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1374,9 +1374,9 @@ function executeMorphdom(rootFromElement, rootToElement, modifiedFieldElements,
if (modifiedFieldElements.includes(fromEl)) {
setValueOnElement(toEl, getElementValue(fromEl));
}
if (fromEl === document.activeElement
&& fromEl !== document.body
&& null !== getModelDirectiveFromElement(fromEl, false)) {
if (fromEl === document.activeElement &&
fromEl !== document.body &&
null !== getModelDirectiveFromElement(fromEl, false)) {
setValueOnElement(toEl, getElementValue(fromEl));
}
const elementChanges = externalMutationTracker.getChangedElement(fromEl);
Expand Down
7 changes: 4 additions & 3 deletions src/LiveComponent/assets/src/morphdom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ export function executeMorphdom(
// We skip this for non-model elements and allow this to either
// maintain the value if changed (see code above) or for the
// morphing process to update it to the value from the server.
if (fromEl === document.activeElement
&& fromEl !== document.body
&& null !== getModelDirectiveFromElement(fromEl, false)
if (
fromEl === document.activeElement &&
fromEl !== document.body &&
null !== getModelDirectiveFromElement(fromEl, false)
) {
setValueOnElement(toEl, getElementValue(fromEl));
}
Expand Down
12 changes: 4 additions & 8 deletions src/LiveComponent/doc/index.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
Live Components
===============

.. caution::

This component is currently experimental and is likely to change, or even
change drastically.

Live components builds on top of the `TwigComponent`_ library
to give you the power to automatically update your Twig components on
the frontend as the user interacts with them. Inspired by
Expand Down Expand Up @@ -3528,8 +3523,10 @@ This bundle aims at following the same Backward Compatibility promise as
the Symfony framework:
https://symfony.com/doc/current/contributing/code/bc.html

However it is currently considered `experimental`_, meaning it is not
bound to Symfony's BC policy for the moment.
For JavaScript files, the public API (i.e. documented features and exports
from the main JavaScript file) is protected by the backward compatibility
promise. However, any internal implementation in the JavaScript files
(i.e. exports from internal files) is not protected.

.. _`TwigComponent`: https://symfony.com/bundles/ux-twig-component/current/index.html
.. _TwigComponent documentation: https://symfony.com/bundles/ux-twig-component/current/index.html
Expand All @@ -3538,7 +3535,6 @@ bound to Symfony's BC policy for the moment.
.. _`Twig Component`: https://symfony.com/bundles/ux-twig-component/current/index.html
.. _`Twig Component mount documentation`: https://symfony.com/bundles/ux-twig-component/current/index.html#the-mount-method
.. _`Symfony form`: https://symfony.com/doc/current/forms.html
.. _`experimental`: https://symfony.com/doc/current/contributing/code/experimental.html
.. _`dependent form fields`: https://ux.symfony.com/live-component/demos/dependent-form-fields
.. _StimulusBundle configured in your app: https://symfony.com/bundles/StimulusBundle/current/index.html
.. _`attributes variable`: https://symfony.com/bundles/ux-twig-component/current/index.html#component-attributes
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/Attribute/AsLiveComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
* @see https://symfony.com/bundles/ux-live-component
*
* @author Kevin Bond <kevinbond@gmail.com>
*
* @experimental
*/
#[\Attribute(\Attribute::TARGET_CLASS)]
final class AsLiveComponent extends AsTwigComponent
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/Attribute/LiveAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
* An attribute to register a LiveAction method.
*
* @see https://symfony.com/bundles/ux-live-component/current/index.html#actions
*
* @experimental
*/
#[\Attribute(\Attribute::TARGET_METHOD)]
class LiveAction
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/Attribute/LiveArg.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
* @see https://symfony.com/bundles/ux-live-component/current/index.html#actions-arguments
*
* @author Tomas Norkūnas <norkunas.tom@gmail.com>
*
* @experimental
*/
#[\Attribute(\Attribute::TARGET_PARAMETER)]
final class LiveArg
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/Attribute/LiveListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
* method and re-render the component.
*
* @see https://symfony.com/bundles/ux-live-component/current/index.html#listeners
*
* @experimental
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class LiveListener extends LiveAction
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/Attribute/LiveProp.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
* An attribute to mark a property as a "LiveProp".
*
* @see https://symfony.com/bundles/ux-live-component/current/index.html#liveprops-stateful-component-properties
*
* @experimental
*/
#[\Attribute(\Attribute::TARGET_PROPERTY)]
final class LiveProp
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/Attribute/PostHydrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

/**
* An attribute to register a PostHydrate hook.
*
* @experimental
*/
#[\Attribute(\Attribute::TARGET_METHOD)]
final class PostHydrate
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/Attribute/PreDehydrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

/**
* An attribute to register a PreDehydrate hook.
*
* @experimental
*/
#[\Attribute(\Attribute::TARGET_METHOD)]
final class PreDehydrate
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/Attribute/PreReRender.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
*
* This hook ONLY happens when rendering via HTTP: it does
* not happen during the initial render of a component.
*
* @experimental
*/
#[\Attribute(\Attribute::TARGET_METHOD)]
final class PreReRender
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/ComponentToolsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
* Trait with shortcut methods useful for live components.
*
* @author Ryan Weaver <ryan@symfonycasts.com>
*
* @experimental
*/
trait ComponentToolsTrait
{
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/ComponentValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
/**
* @author Ryan Weaver <ryan@symfonycasts.com>
*
* @experimental
*
* @internal
*/
class ComponentValidator implements ComponentValidatorInterface, ServiceSubscriberInterface
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/ComponentValidatorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

/**
* @author Ryan Weaver <ryan@symfonycasts.com>
*
* @experimental
*/
interface ComponentValidatorInterface
{
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/ComponentWithFormTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

/**
* @author Ryan Weaver <ryan@symfonycasts.com>
*
* @experimental
*/
trait ComponentWithFormTrait
{
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/DefaultActionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

/**
* @author Kevin Bond <kevinbond@gmail.com>
*
* @experimental
*/
trait DefaultActionTrait
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
/**
* @author Kevin Bond <kevinbond@gmail.com>
*
* @experimental
*
* @internal
*/
final class ComponentDefaultActionPass implements CompilerPassInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
/**
* @author Kevin Bond <kevinbond@gmail.com>
*
* @experimental
*
* @internal
*/
final class OptionalDependencyPass implements CompilerPassInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
/**
* @author Kevin Bond <kevinbond@gmail.com>
*
* @experimental
*
* @internal
*/
final class LiveComponentExtension extends Extension implements PrependExtensionInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
*
* @author Kevin Bond <kevinbond@gmail.com>
*
* @experimental
*
* @internal
*/
final class AddLiveAttributesSubscriber implements EventSubscriberInterface, ServiceSubscriberInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
use Symfony\UX\TwigComponent\Event\PostMountEvent;
use Symfony\UX\TwigComponent\Event\PreRenderEvent;

/**
* Handles the "defer" key, which causes the component to be rendered asynchronously.
*
* @internal
*/
final class DeferLiveComponentSubscriber implements EventSubscriberInterface
{
private const DEFAULT_LOADING_TAG = 'div';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
*
* @author Ryan Weaver <ryan@symfonycasts.com>
*
* @experimental
*
* @internal
*/
class InterceptChildComponentRenderSubscriber implements EventSubscriberInterface, ServiceSubscriberInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
* @author Kevin Bond <kevinbond@gmail.com>
* @author Ryan Weaver <ryan@symfonycasts.com>
*
* @experimental
*
* @internal
*/
class LiveComponentSubscriber implements EventSubscriberInterface, ServiceSubscriberInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
/**
* @author Nicolas Rigaud <squrious@protonmail.com>
*
* @experimental
*
* @internal
*/
class QueryStringInitializeSubscriber implements EventSubscriberInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
*
* @author Ryan Weaver <ryan@symfonycasts.com>
*
* @experimental
*
* @internal
*/
final class ResetDeterministicIdSubscriber implements EventSubscriberInterface
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/Exception/HydrationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
*
* @author Ryan Weaver <ryan@symfonycasts.com>
*
* @experimental
*
* @internal
*/
class HydrationException extends BadRequestHttpException
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/Form/Type/LiveCollectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

/**
* @author Gábor Egyed <gabor.egyed@gmail.com>
*
* @experimental
*/
final class LiveCollectionType extends AbstractType
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Persistence\ObjectManager;

/**
* Handles hydration of Doctrine entities.
*
* @internal
*/
class DoctrineEntityHydrationExtension implements HydrationExtensionInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

namespace Symfony\UX\LiveComponent\Hydration;

/**
* Interface for custom hydration of objects.
*/
interface HydrationExtensionInterface
{
/**
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/LiveCollectionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

/**
* @author Gábor Egyed <gabor.egyed@gmail.com>
*
* @experimental
*/
trait LiveCollectionTrait
{
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/LiveComponentBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

/**
* @author Kevin Bond <kevinbond@gmail.com>
*
* @experimental
*/
final class LiveComponentBundle extends Bundle
{
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/LiveComponentHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
/**
* @author Kevin Bond <kevinbond@gmail.com>
*
* @experimental
*
* @internal
*/
final class LiveComponentHydrator
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/LiveResponder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
namespace Symfony\UX\LiveComponent;

/**
* @experimental
*
* @author Ryan Weaver <ryan@symfonycasts.com>
*/
final class LiveResponder
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/Metadata/LiveComponentMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
/**
* @author Ryan Weaver <ryan@symfonycasts.com>
*
* @experimental
*
* @internal
*/
class LiveComponentMetadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
/**
* @author Ryan Weaver <ryan@symfonycasts.com>
*
* @experimental
*
* @internal
*/
class LiveComponentMetadataFactory implements ResetInterface
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/Metadata/LivePropMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
/**
* @author Kevin Bond <kevinbond@gmail.com>
*
* @experimental
*
* @internal
*/
final class LivePropMetadata
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/Twig/DeterministicTwigIdCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
/**
* @author Ryan Weaver <ryan@symfonycasts.com>
*
* @experimental
*
* @internal
*/
class DeterministicTwigIdCalculator
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/Twig/LiveComponentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
/**
* @author Kevin Bond <kevinbond@gmail.com>
*
* @experimental
*
* @internal
*/
final class LiveComponentExtension extends AbstractExtension
Expand Down
Loading