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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@graviola/color-picker-renderer

v3.0.0

Published

A collection of color picker renderers for JSON Forms, providing intuitive color selection and formatting in the Graviola framework.

Readme

@graviola/color-picker-renderer

A collection of color picker renderers for JSON Forms, providing intuitive color selection and formatting in the Graviola framework.

Environment: Client

Overview

This package provides React components for rendering color picker controls in JSON Forms. It includes simple and advanced color picker renderers with support for various color formats (hex, rgb, rgba, hsl, hsla). The renderers use the react-color library to provide intuitive color selection interfaces.

Ecosystem Integration

Position in the Graviola Framework

The color-picker-renderer package extends the form rendering capabilities of the Graviola framework by providing specialized components for color selection. It works alongside other form renderer packages to create rich, interactive forms for editing JSON data with color properties.

Dependency Graph

flowchart TD
    A[graviola/color-picker-renderer] --> B[graviola/edb-core-utils]
    A --> C[next-i18next]
    A --> D[lodash-es]
    A --> E[react-color]

    style A fill:#f9f,stroke:#333,stroke-width:2px

Package Relationships

  • Dependencies:

    • @graviola/edb-core-utils: Provides utility functions used by the renderers
    • next-i18next: Used for internationalization of labels and messages
    • lodash-es: Provides utility functions for object manipulation
    • react-color: Provides the color picker components
  • Peer Dependencies:

    • @graviola/edb-state-hooks: For state management
    • @mui/material, @mui/icons-material, @mui/x-date-pickers: Material UI components
    • @jsonforms/material-renderers, @jsonforms/core, @jsonforms/react: JSON Forms library
    • react: React library

Installation

bun add @graviola/color-picker-renderer
# or
npm install @graviola/color-picker-renderer
# or
yarn add @graviola/color-picker-renderer

Features

  • ColorPickerRenderer: A simple color picker with a color preview and text input
  • AdvancedColorPickerRenderer: An advanced color picker with configurable picker types and additional features
  • Color Format Support: Support for hex, rgb, rgba, hsl, and hsla color formats
  • Ajv Integration: Custom format validators for color formats to use with Ajv
  • Multiple Picker Types: Support for various picker types from react-color (sketch, chrome, block, etc.)

Usage

Basic Usage

To use the color picker renderers, register them with the JSON Forms renderer registry:

import {
  ColorPickerRenderer,
  ColorPickerRendererTester,
  AdvancedColorPickerRenderer,
  AdvancedColorPickerRendererTester
} from '@graviola/color-picker-renderer';
import { JsonFormsRendererRegistryEntry } from '@jsonforms/core';

// Create a renderer registry
const renderers: JsonFormsRendererRegistryEntry[] = [
  // Register the simple color picker
  {
    tester: ColorPickerRendererTester,
    renderer: ColorPickerRenderer
  },
  // Register the advanced color picker
  {
    tester: AdvancedColorPickerRendererTester,
    renderer: AdvancedColorPickerRenderer
  }
];

// Use the renderers with JsonForms
import { JsonForms } from '@jsonforms/react';

const MyForm = ({ data, schema, uischema, onChange }) => (
  <JsonForms
    data={data}
    schema={schema}
    uischema={uischema}
    renderers={renderers}
    onChange={onChange}
  />
);

Schema Configuration

To use the color picker with specific color formats, define the format in your JSON Schema:

{
  "type": "object",
  "properties": {
    "primaryColor": {
      "type": "string",
      "format": "hex",
      "title": "Primary Color"
    },
    "secondaryColor": {
      "type": "string",
      "format": "rgba",
      "title": "Secondary Color"
    }
  }
}

Advanced Configuration

The AdvancedColorPickerRenderer supports different picker types through UI schema options:

{
  "type": "Control",
  "scope": "#/properties/primaryColor",
  "options": {
    "picker": {
      "component": "chrome",
      "props": {
        "disableAlpha": true
      }
    }
  }
}

Available picker components:

  • alpha: Alpha value slider
  • block: Simple block picker
  • chrome: Chrome-style picker with multiple tabs
  • circle: Circular color picker
  • compact: Compact color picker
  • github: GitHub-style picker
  • hue: Hue slider
  • photoshop: Photoshop-style picker
  • sketch: Sketch-style picker (default)
  • slider: Slider-based picker
  • swatches: Swatches picker
  • twitter: Twitter-style picker

Adding Color Format Validation

To add color format validation to Ajv:

import { addColorFormatsToAjv } from "@graviola/color-picker-renderer";
import Ajv from "ajv";

const ajv = new Ajv();
addColorFormatsToAjv(ajv);

// Now ajv can validate hex, rgb, rgba, hsl, and hsla formats

API Reference

ColorPickerRenderer

A simple color picker component with a color preview button and text input.

AdvancedColorPickerRenderer

An advanced color picker component with configurable picker type and additional features like form helper text and validation.

formatColor(color, format)

Formats a color object from react-color into a string representation in the specified format.

  • Parameters:
    • color: The color object from react-color
    • format: The target format ('hex', 'rgb', 'rgba', 'hsl', 'hsla')
  • Returns: A string representation of the color in the specified format

addColorFormatsToAjv(ajv)

Adds color format validators to an Ajv instance.

  • Parameters:
    • ajv: The Ajv instance to add the formats to

License

This package is part of the Graviola project.