npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

solid-resizable-panels

v0.5.4

Published

Solid-js components for making resizable panels

Downloads

85

Readme

Solid-resizable-panels

version npm

A collection of components for building resizable panels.

https://solid-resizable-panels.vercel.app/

Usage

import { PanelGroup, Panel, ResizeHandle } from "solid-resizable-panels";
// Don't forget to import styles!
import "solid-resizable-panels/styles.css";

const TestApp = () => {
  return (
    <PanelGroup direction="row">
      <Panel
        id="1"
        collapsible
        minSize={20}
        onCollapse={() => console.log("collapsed")}
        onExpand={() => console.log("expanded")}
      >
        hi!
      </Panel>
      <ResizeHandle />
      <Panel id="2">hi 2!</Panel>
    </PanelGroup>
  );
};

Types

import { ParentComponent } from "solid-js";

export declare type Direction = "row" | "column" | "row-reverse" | "column-reverse";

export declare type LayoutItem = {
  id: string;
  size?: number;
  /** A number from 0 to 100 */
  minSize: number;
  /** A number from 0 to 100 */
  maxSize: number;
  collapsible: boolean;
};

export declare interface Logger {
  warn(message: string): void;
  error(message: string): void;
}

export declare const Panel: ParentComponent<PanelProps>;

export declare const PanelGroup: ParentComponent<PanelGroupProps>;

export declare type PanelGroupAPI = {
  /**
   * Returns the current layout of the panels
   */
  getLayout(): number[];
  /**
   * Set the layout of the panels
   * The layout should be aligned with configuration of the panels (minSize, maxSize, collapsible and etc.)
   */
  setLayout(layout: number[]): void;
  /**
   * Trying to collapse the panel to it's minSize
   */
  collapse(panelId: string): void;
  /**
   * Expand the panel to its maximum possible size
   * You can also pass the size to expand the panel to
   * (it should be between minSize and maxSize)
   */
  expand(panelId: string, expandSize?: number): void;
};

export declare interface PanelGroupProps {
  /**
   * A flex-direction property applied to the element
   * @default "row"
   */
  direction?: Direction;
  /**
   * If the parent element has CSS zoom property
   * The zoom value should be passed to eliminate visual bugs during resizing
   */
  zoom?: number;
  /**
   * If the parent element has CSS scale property
   * The scale value should be passed to eliminate visual bugs during resizing
   */
  scale?: number;
  /**
   * Rendered HTML tag
   * @default "div"
   */
  tag?: string;
  /**
   * Extra class passed to panel DOM element.
   */
  class?: string;
  /**
   * A logger to be used for diagnostic messages
   */
  logger?: Logger;
  /**
   * API setter for the parent component
   * You can use this API to get and set the layout of the panels
   */
  setAPI?: (api: PanelGroupAPI) => void;
  /**
   * A callback called during resize
   */
  onLayoutChange?: (sizes: number[]) => void;
  /**
   * You can pass custom resize algorithm and implemenent custom resize logic
   * This algorithm is called every time on items resize (mousemove or touchmove)
   * So it should return the final state of the items
   *
   * @returns The sizes of the items on the current resize event (mousemove or touchmove)
   */
  resizeAlgorithm?: ResizeAlgorithm;
}

export declare interface PanelProps {
  id: string;
  /**
   * Index of the panel within panel group.
   * Should be passed when conditional panels used.
   * @default undefined
   */
  index?: number;
  /**
   * Rendered HTML tag
   * @default "div"
   */
  tag?: string;
  /**
   * Initial size of the panel in percent.
   * @default computed according to layout
   */
  initialSize?: number;
  /**
   * Minimum size of the panel in percent.
   * @default 0
   */
  minSize?: number;
  /**
   * Maximum size of the panel in percent.
   * @default 100
   */
  maxSize?: number;
  /**
   * Is panel collapsible
   * @default false
   */
  collapsible?: boolean;
  /**
   * Extra class passed to panel DOM element.
   */
  class?: string;
  /** A callback called when the panel becomes collapsed */
  onCollapse?: VoidFunction;
  /** A callback called when the panel becomes expanded */
  onExpand?: VoidFunction;
  /** A callback called when size changes */
  onResize?: (newSize: number) => void;
}

export declare type ResizeAlgorithm = (
  /** Current state of layout */
  resolvedLayout: ResolvedLayoutItem[],
  sizesOnResizeStart: number[],
  resizableItemIndex: number,
  /**
   * Delta size is computed from the initial size (before resize) and current state
   */
  deltaSize: number
) => number[];

export declare const ResizeHandle: ParentComponent<ResizeHandleProps>;

export declare interface ResizeHandleProps {
  /**
   * Disables the handle
   * @default false
   */
  disabled?: boolean;
  /**
   * Rendered HTML tag
   * @default "button"
   */
  tag?: string;
  /**
   * Extra class passed to panel DOM element.
   */
  class?: string;
}

export declare type ResolvedLayoutItem = Required<LayoutItem>;