Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
The useCurrentValue
hook allows associating a value with current
based on its parameter, equivalent to:
With the useCurrentValue
hook
series of useful hooks for creating webcomponents
use-current-value
the useReflectEvent hook reflects the event from the reference origin to the reference destination
the useReflectEvent hook reflects the event from the reference origin to the reference destination, the captured event will be canceled
One of the possibilities of this hook is to reflect the events inside shadowDOM to lightDOM, example when using forms
useRefectEvent will listen for the eventType of refFrom, to reflect it on refTo
Reflects on an element the given event
The usesClickCoordinates hook is for capturing click coordinates, this is useful when positioning a tooptip or creating visual effects
The useClickPress hook will allow you to execute a callback with acceleration according to the click time, for example in the input type number we have 2 buttons by default, an up arrow and a down arrow, these allow us to modify the input value, either:
Increase the value before a click in a unit.
Increase the value by more than one unit according to the click pressure time.
Share values from the scope via setter and getters
Create reactive templates that interact with the state of your webcomponent
Communicate the component with external forms.
If the webcomponent is nested within a form tag, this hook will return that form tag as a reference.
If the webcomponent is nested within a form tag, you will be able to listen to events from that tag through useFormListener.
el hook renderiza un input hidden en el lightDOM cuyo name y value del input seran los parametros que el hook resiva
One of the difficult inputs to standardize when working with shadowDOM is the radio input, thanks to this hook you will be able to create and observe a radio input synchronized with the form and its webcomponent.
This hook requires the definition of the properties in its webcomponent:
You can work with the input from the component logic, example:
Your component will automatically be reactive to the change of the states of the radio input
creates a bottleneck to the definition of a state, limits concurrency.
this hook is similar to useState, but the purpose of this hook is to bottleneck the state at update time
mode differences
fps:
if delay is set to 1, the update is executed for each cycle of requestAnimationFrame(60fps),
if delay is defined as 2, the update is executed for every 2 cycle of requestAnimationFrame(30fps)
timeout: the delay will be the milliseconds for setTimeout
idle : the delay will be the milliseconds for requestIdleCallback
matches
: Optional string, allows to change the search of the parent tag fieldset for another tag or selector compatible with .
Inject CSS into the shadowRoot
Inject tag style into shadowRoot with content given as parameter to use CSS.
This hook was not created as a replacement for component.styles, it is rather a utility that seeks to facilitate the integration of css from a customHook, either by defining a state or another action.
Declare a state based on a responsive expression similar to using the tag img[srcset].
Where:
state
: String
, Current state according to the comparison between experiment and matchMedia.
expression
: String
, An expression that declares the serialized states.
Where:
defaultState
: Default state this cannot contain the use of commas ", "
.
caseState
: Status to show if matchMedia match.
size: size expression to observe, example:
"1080px": (min-width: 1080px)
"1080x720px": (min-width: 1080px) and (min-height: 720px)
"50rem": (min-width: 50rem)
"50em": (min-width: 50em)
The following example shows the use of useResponsiveState, to display a message based on the mediaquery.
rect
: Object
, the return of DOMRectReadOnly.toJSON()
, documentation of
rect
: Object
, the return of DOMRectReadOnly.toJSON()
, documentation of
selector
: String
, Selector to be used by when searching for the parent.
Retrieves the nodes assigned to a slot.
The usePromise hook consumes an asynchronous function is ideal for using fetch or other asynchronous tasks.
Where :
result
: Retorno de la promesa
status
: Estado de la promesa:
""
: Without executing.
"pending"
: In action.
"fulfilled"
: Successfully executed.
"rejected"
: Executed with error.
asyncFunction
: asynchronous function.
runFunction
: Booleano
, if true
it will execute the promise and define the status.
optionalArguments
: Optional any[]
, allows to regenerate the promise through arguments.
useProxySlot allows you to observe the nodes assigned to a slot and reassign them to another slot dynamically, example:
Input: Suppose we have a component that observe the slot[name="slide"] node
output: thanks to useProxySlot you will be able to modify the assignment of the list nodes without losing the nodes in the process as normally happens with useSlot, example:
All redirected hooks must exist under a slot
create connection between components to share internal states
Now, Atomico includes a context API as part of its core. We recommend implementing it as an alternative to using useChannel
.
An alternative to React's context but solely based on hooks.
Where :
channel
: String
, defines the name of the event to be used to generate the channel.
parentValue
: Value inherited by the parent component.
setChildValue
: Callback
, defines a value for nested components.
This hook is used by @atomico/components/router
share your style sheets between LightDOM and ShadowDOM
Hooks to work with routes in the browser
Hook to handle routes based on expressions according to the https://github.com/uppercod/exp-route library, this hook is used by @atomico/components/router****
Where:
view
: return of the last function executed according to the route match.
path
: string, represents the prop of the last path that consists of the path match.
params
: parameters captured according to the path
search
: parameters captured from the path
Share the return from useRouter
Captures all nodes not created by the webcomponent render, ideal for apply slot polyfill in LightDOM.
Where :
childNodes
: List of nodes that do not belong to the webcomponent render.
update
: Callback that forces a new childNodes
scan.
From the example we can highlight that the webcomponent will use all the children not created by the h1
type and will associate the onclick handler with them.
AController
: ReactiveController
, A with property a
.
Allows forcing the rendering of the webcomponent without the need to be tied to a state or property
Since the version of atomico@1.14.* there is the useUpdate hook, with the same functionality but in the core of Atomico.
Where:
forceRender
: Callback
to force rendering of the webcomponent.
Sometimes the rendering of the webcomponent does not depend on a state or property of this, to reflect these changes you can use useForceRender
to regenerate the DOM, example: