Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

panel

Package Overview
Dependencies
Maintainers
7
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

panel - npm Package Compare versions

Comparing version 4.0.2 to 5.0.0

121

lib/index.d.ts

@@ -52,69 +52,46 @@ // Type definitions for panel

declare namespace Component {
interface Helpers {
[helper: string]: any;
}
export interface PanelHelpers {
[helper: string]: any;
}
interface Hooks<State> {
/** Function called before an update is applied */
preUpdate?: (stateUpdate: Partial<State>) => void;
export interface PanelHooks<State> {
/** Function called before an update is applied */
preUpdate?: (stateUpdate: Partial<State>) => void;
/** Function called after an update is applied */
postUpdate?: (stateUpdate: Partial<State>) => void;
/** Function called after an update is applied */
postUpdate?: (stateUpdate: Partial<State>) => void;
[hookName: string]: (params: any) => void;
}
[hookName: string]: (params: any) => void;
}
interface HookHelpers {
delayedAttrRemove: (attr: string, value: string, waitMs?: number) => void;
}
export interface ConfigOptions<StateT, AppStateT = unknown> {
/** Function transforming state object to virtual dom tree */
template(scope?: StateT): VNode;
interface TemplateScope<State, AppState = {}, Attrs = AnyAttrs> {
/** AppState of the root panel component */
$app: AppState;
/** Component-specific Shadow DOM stylesheet */
css?: string;
/** Attributes parsed from component's html attributes using attrsSchema */
$attr<A extends keyof Attrs>(attr: A): Attrs[A];
/** An initial default value for the component's state property */
defaultState?: StateT;
/** A reference to the component itself */
$component: Component<State, AppState, unknown, Attrs>;
/**
* A state object to share with nested descendant components. If not set, root component
* shares entire state object with all descendants. Only applicable to app root components.
*/
appState?: AppStateT;
/** Helpers defined in component config */
$helpers: Helpers;
/** Properties and functions injected automatically into template state object */
helpers?: PanelHelpers;
/** Hook helpers for snabbdom hooks module */
$hooks: HookHelpers;
}
/** Extra rendering/lifecycle callbacks */
hooks?: PanelHooks<StateT>;
interface ConfigOptions<State, AppState, Attrs> {
/** Function transforming state object to virtual dom tree */
template(scope: TemplateScope<State, AppState, Attrs> & State): VNode;
/** Object mapping string route expressions to handler functions */
routes?: {[route: string]: Function};
/** Component-specific Shadow DOM stylesheet */
css?: string;
/** Whether to apply updates to DOM immediately, instead of batching to one update per frame */
updateSync?: boolean;
/** An initial default value for the component's state property */
defaultState?: State;
/**
* A state object to share with nested descendant components. If not set, root component
* shares entire state object with all descendants. Only applicable to app root components.
*/
appState?: AppState;
/** Properties and functions injected automatically into template state object */
helpers?: Helpers;
/** Extra rendering/lifecycle callbacks */
hooks?: Hooks<State>;
/** Object mapping string route expressions to handler functions */
routes?: {[route: string]: Function};
/** Whether to apply updates to DOM immediately, instead of batching to one update per frame */
updateSync?: boolean;
/** Whether to use Shadow DOM */
useShadowDom?: boolean;
}
/** Whether to use Shadow DOM */
useShadowDom?: boolean;
}

@@ -153,5 +130,3 @@

export type ConfigOptions<State, AppState = {}, Attrs = AnyAttrs> = Component.ConfigOptions<State, AppState, Attrs>;
export class Component<State, AppState = {}, App = unknown, Attrs = AnyAttrs> extends WebComponent {
export class Component<StateT, AttrsT = AnyAttrs, AppStateT = unknown, AppT = unknown> extends WebComponent {
/** The first Panel Component ancestor in the DOM tree; null if this component is the root */

@@ -167,6 +142,6 @@ $panelParent: Component<unknown>;

/** A reference to the top-level component */
app: App;
app: AppT;
/** State object to share with nested descendant components */
appState: AppState;
appState: AppStateT;

@@ -180,6 +155,6 @@ /** Refers to the outer-most element in the template file for shadow DOM components. Otherwise, el refers to the component itself. */

/** Defines the state of the component, including all the properties required for rendering */
state: State;
state: StateT;
/** Defines standard component configuration */
config: ConfigOptions<State, AppState, Attrs>;
config: ConfigOptions<StateT, AppStateT>;

@@ -193,6 +168,6 @@ /**

/** Gets the attribute value. Throws an error if attr not defined in attrsSchema */
attr<A extends keyof Attrs>(attr: A): Attrs[A];
attr<A extends keyof AttrsT>(attr: A): AttrsT[A];
/** Attributes parsed from component's html attributes using attrsSchema */
attrs(): Attrs;
attrs(): AttrsT;

@@ -215,4 +190,7 @@ /**

*/
getConfig<K extends keyof ConfigOptions<State, AppState>>(key: K): ConfigOptions<State, AppState>[K];
getConfig<K extends keyof ConfigOptions<StateT, AppStateT>>(key: K): this['config'][K];
/** Sets a value in the component's configuration map after element initialization */
setConfig<K extends keyof ConfigOptions<StateT, AppStateT>>(key: K, val: ConfigOptions<StateT, AppStateT>[K]): void;
/**

@@ -222,7 +200,7 @@ * Executes the route handler matching the given URL fragment, and updates

*/
navigate(fragment: string, stateUpdate?: Partial<State>): void;
navigate(fragment: string, stateUpdate?: Partial<StateT>): void;
/** Run a user-defined hook with the given parameters */
runHook: (
hookName: keyof ConfigOptions<State, AppState>['hooks'],
hookName: keyof ConfigOptions<StateT, AppStateT>['hooks'],
options: {cascade: boolean; exclude: Component<any, any>},

@@ -232,5 +210,2 @@ params: any,

/** Sets a value in the component's configuration map after element initialization */
setConfig<K extends keyof ConfigOptions<State, AppState>>(key: K, val: ConfigOptions<State, AppState>[K]): void;
/**

@@ -242,3 +217,3 @@ * To be overridden by subclasses, defining conditional logic for whether

*/
shouldUpdate(state: State): boolean;
shouldUpdate(state: StateT): boolean;

@@ -251,3 +226,3 @@ /**

*/
updateApp(stateUpdate?: Partial<AppState>): void;
updateApp(stateUpdate?: Partial<AppStateT>): void;

@@ -259,3 +234,3 @@ /**

*/
update(stateUpdate?: Partial<State> | ((state: State) => Partial<State>)): void;
update(stateUpdate?: Partial<StateT> | ((state: StateT) => Partial<StateT>)): void;
}
{
"name": "panel",
"version": "4.0.2",
"version": "5.0.0",
"description": "Web Components with Virtual DOM: lightweight composable web apps",

@@ -5,0 +5,0 @@ "main": "build/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc