pyreon

@pyreon/ui-core provides the foundation for Pyreon's UI system. It includes the init() function to configure the CSS engine, shared context providers, and utility functions used by other UI packages.

@pyreon/ui-corestable

Installation

npm install @pyreon/ui-core
bun add @pyreon/ui-core
pnpm add @pyreon/ui-core
yarn add @pyreon/ui-core

Overview

UI Core is the shared foundation that all other Pyreon UI packages (@pyreon/attrs, @pyreon/rocketstyle, @pyreon/elements, etc.) depend on. It handles three responsibilities:

  1. CSS engine initialization -- the init() function connects a CSS engine (e.g., @pyreon/styler) so that styled components can inject styles.

  2. Context providers -- shared context for theme state, breakpoints, and configuration that flows through the component tree.

  3. Shared utilities -- pure helper functions (merge, omit, pick, get, set, throttle, isEqual, isEmpty) and component composition tools (compose, hoistNonReactStatics, render).

Initialization

Call init() at your app's entry point to connect the CSS engine before rendering any UI components:

import { init } from '@pyreon/ui-core'
import { styled, css } from '@pyreon/styler'

init({
  styled,
  css,
  // other CSS engine hooks as needed
})

This must happen before any @pyreon/rocketstyle or @pyreon/elements components render, as they rely on the configured engine to generate and inject styles.

Theme Mode Provider

Context and Provider

UI Core provides a shared context and Provider component for distributing configuration through the component tree:

import { Provider, context } from '@pyreon/ui-core'

;<Provider value={{ breakpoints: { sm: 576, md: 768, lg: 992, xl: 1200 } }}>
  <App />
</Provider>

Utilities

Object Helpers

import { merge, omit, pick, get, set } from '@pyreon/ui-core'

merge({ a: 1 }, { b: 2 }) // { a: 1, b: 2 }
omit({ a: 1, b: 2, c: 3 }, ['b']) // { a: 1, c: 3 }
pick({ a: 1, b: 2, c: 3 }, ['a']) // { a: 1 }
get({ a: { b: 1 } }, 'a.b') // 1
set({}, 'a.b', 1) // { a: { b: 1 } }

Comparison Helpers

import { isEqual, isEmpty } from '@pyreon/ui-core'

isEqual({ a: 1 }, { a: 1 }) // true
isEmpty({}) // true
isEmpty({ a: 1 }) // false

Component Composition

import { compose, hoistNonReactStatics } from '@pyreon/ui-core'

// compose applies a chain of higher-order components
const EnhancedComponent = compose(withAuth, withTheme, withLogger)(BaseComponent)

// hoistNonReactStatics copies statics from source to target
hoistNonReactStatics(WrappedComponent, OriginalComponent)

Other

import { throttle, useStableValue } from '@pyreon/ui-core'

const throttled = throttle(handleResize, 100)

HTML Tag Constants

UI Core exports lists of valid HTML tags used by other UI packages for prop filtering and element creation:

import { HTML_TAGS, HTML_TEXT_TAGS } from '@pyreon/ui-core'

API Reference

ExportTypeDescription
initFunctionConfigures the CSS engine connector
configObjectCurrent CSS engine configuration
ProviderComponentShared context provider
contextContextRaw Pyreon context object
composeFunctionHOC composition utility
renderFunctionComponent render helper
hoistNonReactStaticsFunctionCopies static properties between components
mergeFunctionDeep merge objects
omitFunctionOmit keys from an object
pickFunctionPick keys from an object
getFunctionGet nested value by path
setFunctionSet nested value by path
throttleFunctionThrottle a function
isEqualFunctionDeep equality check
isEmptyFunctionCheck if a value is empty
useStableValueHookReturns a stable reference for a value
HTML_TAGSArrayList of all valid HTML tag names
HTML_TEXT_TAGSArrayList of HTML tags that contain text content

Types

TypeDescription
CSSEngineConnectorInterface for connecting a CSS engine to UI Core
BreakpointsBreakpoint size map (e.g., &#123; sm: 576, md: 768 &#125;)
BreakpointKeysString union of breakpoint names
HTMLTagsUnion type of all valid HTML tag names
HTMLTextTagsUnion type of text-content HTML tags
RenderRender function type

Key Features

  • init() configures the CSS engine at app startup

  • Shared context provider for theme and breakpoint state

  • Pure utility functions for object manipulation and comparison

  • HOC composition and static hoisting tools

  • HTML tag constants for prop filtering

  • Foundation package for @pyreon/attrs, @pyreon/rocketstyle, and @pyreon/elements

UI Core