ReadonlycontextReadonlyenableTargets will be enabled if the target's rule matches the scoped form data, otherwise will be disabled.
ReadonlyhasTrue if there is at least one enable target, used to ensure rules do not run if not needed.
ReadonlyhasTrue if there is at least one show target, used to ensure rules do not run if not needed.
ReadonlymatchThe matching strategy to use for the rules, defaults to all and used as the fallback if not provided.
ReadonlyshowTargets will be shown if the target's rule matches the scoped form data, otherwise will be hidden with the hidden attribute.
StaticblessingsStaticoutletsStatictargetsStaticvaluesEffect handlers to first determine if the effect needs to be applied, if it does, it will return a function to apply the effect.
Effect targets grouped by effect type.
Cache the form element found on the controller to avoid DOM thrashing when multiple resolves happen.
Returns an object of match functions that will be used to match against the current state of the form data.
StaticshouldGet the match type for the specified target, effect or event so that the most specific match value can be used for this rules resolving.
First check the event for provided params, then the target element for attributes, finally the controller's match value with default and error handling for edge cases.
Finds & parses the rules for the provided target by the rules attribute,
which is determined via the identifier and the provided effect name,
(e.g. data-w-rules-enable). Falling back to the generic attribute
if not found (e.g. data-w-rules).
With the found rules, check the rules cache first, then parse the rules for caching if not found.
When parsing the rule, assume an Object.entries format or convert an
object to this format. Then ensure each value is an array of strings
for consistent comparison to FormData values.
Resolve the conditional targets based on the form data and the target(s) rule attributes and the controlled element's form data.
For each effect target, determine the match type to use, parse the rules, run the matchers and apply the effect if needed.
An effect event is dispatched before applying the effect,
which can be cancelled to prevent the effect from being applied.
Finally, a resolved event is dispatched after all effects have been processed.
Optionalevent: Event & { params?: { match?: Match } }Staticafter
Adds the ability for a controlled form element to conditionally enable or show targeted elements based on the data from the controlled form along with a set of rules to match against that data.
Example: - Enable a button if a specific value is chosen
Example: - Show an additional field when a select field value is chosen
Example