Cell - Widget Component
Frontend infrastructure that @celljs/react builds on. Applications rarely depend on it directly; installing @celljs/react brings it in.
- Frontend target. Its
package.jsondeclarescell.targets: ["frontend"], which is what makes the toolchain build a frontend when a UI package is installed. - Widgets.
@Widget(area)or@Widget({ area, priority, component, id, rebind })registers a component for a named area;WidgetManager.get(area)/render(area)return them ordered by priority (<Slot area>of@celljs/reactrenders them). Widgets can also be declared in configuration underwidget.widgets, keyed by widget id (area,priority,visible,props;${...}inpropsis evaluated at each render). The id defaults to the name of the decorated class (LogoWidgetbelow). AWidgetFactoryrenders the models whosetypeequals its owntype. - Themes.
Themecomponents and theThemeManager, configured bywidget.themes. The id of the current theme is kept inlocalStorage; on load it selects that theme, elsedefault, else the first one. - Locales.
Localecomponents and theLocaleManager, configured bywidget.locales. The language of the current locale is kept inlocalStorage; on load it selects that one, else the browser's, else the first one.
Both managers have current, setCurrent(value) (which also saves it) and onCurrentChanged(listener), an Event of @celljs/core that returns a Disposable. useLocale() of @celljs/react reads and changes the locale in a component.
ts
import { Widget } from '@celljs/widget';
@Widget({ area: 'header', priority: 100, component: Logo })
export class LogoWidget {}All exports are frontend-only (@celljs/widget resolves to lib/browser).