Releases: atomicojs/atomico
Add support for fragments and improve the use of props
Add support for fragments
You can now use the <></>
fragment tag through jsx-runtime.
Improve the use of props
Previously null values were kept as null, this did not favor the use of default parameters when destructing the props object or defining a default prop when using a callback as a value reducer, example:
function component({ value = 100 }: Props<typeof component>) {
return <host>{value}</host>;
}
component.props = { value: Number };
If prop is defined as null, value will be equal to null. but since [email protected] any value declared as null will be defined as undefined in the component's prop object, so value will be defined as undefined
Fix TS types for useProp
1.62.4 Fix TS types for useProp
Fix at typescript level for setState and useProp
Fix type errors at Ts level for useProp and useCallback
Fixes types for TS with erroneous behavior from version 1.62.0. Bug reference: #90
Fix context synchronization by non-parallel mount
This context synchronization error occurs when mounting the components directly in the HTML, now atomico synchronizes the contexts in non-parallel mounting situations.
[email protected] 🎉, welcome to the new context api
The new Context api is introduced and internal and external improvements are added at the type level
- rewrite Atomico virtualDOM and hook types for better internal maintainability: Now Atomico's internal api shares the exposed type api, which improves maintainability as they are now directly related.
- Now the pipeline before test validates Atomico typing internally, externally and tsx through Typescript.
- Add context as part of the core.
New context api
This new api facilitates communication between components, example:
Paso 1: declarar el contexto y consumirlo.
import { createContext, useContext, c } from "atomico";
export const Provider = createContext({ value: 0 });
function component() {
const { value } = useContext(Provider);
return <host>{value}</host>;
}
export const Component = c(component);
Paso 2: Instantiate the context, The <Provider>
component allows to define the value for the components nested inside the <Provider/>
import { Provider, Component } from "./component";
<Provider value={{ value: "New value!" }}>
<div>
<div>
<Component></Component>
</div>
</div>
</Provider>;
Fix meta props when using Component type (TS)
This fixes type validation when using the Component type, correctly completing meta props
New feature for TS
Now the Component type allows, through a second parameter, to define meta types, such as methods and events:
import { Component, useEvent } from "atomico";
interface Props {
checked: boolean;
}
interface MetaProps {
onChange: Event;
}
const myComponent: Component<Props, MetaProps> = ({ checked }) => {
const dispatchChange = useEvent("Change");
return (
<host>
<input checked={checked} onchange={dispatchChange} />
</host>
);
};
myComponent.props = {
checked: Boolean,
};
export const MyComponent = c(myComponent);
Meta Props are only declared for JSX(Atomico, Preact and React), example:
<MyComponent onChange={(event)=>{
event.currentTarget.checked // TS: boolean
}}/>
fix ssr mode detection
1.60.3 fix ssr mode detection
Fix path SSR
1.60.2 fix path