Socket
Socket
Sign inDemoInstall

@rjsf/utils

Package Overview
Dependencies
Maintainers
2
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rjsf/utils

Utility functions for @rjsf/core


Version published
Weekly downloads
236K
decreased by-10.72%
Maintainers
2
Created
Weekly downloads
 

Package description

What is @rjsf/utils?

@rjsf/utils is a utility library for React JSON Schema Form (RJSF). It provides a set of helper functions and utilities to work with JSON schemas, form data, and UI schemas. This package is designed to simplify the process of creating and managing forms using JSON schema definitions.

What are @rjsf/utils's main functionalities?

Schema Validation

This feature allows you to validate form data against a JSON schema. The `validateFormData` function takes form data and a schema as inputs and returns validation errors if any.

const { validateFormData } = require('@rjsf/utils');
const schema = { type: 'object', properties: { name: { type: 'string' } } };
const formData = { name: 'John Doe' };
const result = validateFormData(formData, schema);
console.log(result.errors);

Schema Merging

This feature allows you to merge multiple JSON schemas into one. The `mergeSchemas` function takes two or more schemas and combines them into a single schema.

const { mergeSchemas } = require('@rjsf/utils');
const schema1 = { type: 'object', properties: { name: { type: 'string' } } };
const schema2 = { type: 'object', properties: { age: { type: 'number' } } };
const mergedSchema = mergeSchemas(schema1, schema2);
console.log(mergedSchema);

Form Data Manipulation

This feature allows you to manipulate form data based on a schema. The `getDefaultFormState` function takes a schema and form data as inputs and returns the default form state.

const { getDefaultFormState } = require('@rjsf/utils');
const schema = { type: 'object', properties: { name: { type: 'string' }, age: { type: 'number' } } };
const formData = { name: 'John Doe' };
const defaultFormData = getDefaultFormState(schema, formData);
console.log(defaultFormData);

Other packages similar to @rjsf/utils

Changelog

Source

5.4.0

@rjsf/antd

  • Added the ability to use a tooltip for a description
  • Updated ObjectFieldTemplate to hide the titles and descriptions when displayLabel is true (including globally), fixing #3231
  • Updated CheckboxWidget to show the description using the DescriptionFieldTemplate, fixing #2791
  • Updated CheckboxesWidget and SelectWidget to show the label using the TitleFieldTemplate, fixing #2134

@rjsf/bootstrap-4

  • Updated ObjectFieldTemplate to hide the titles and descriptions when displayLabel is true (including globally), fixing #3231
  • Updated CheckboxWidget to show the description using the DescriptionFieldTemplate, fixing #2791
  • Updated RangeWidget to fix the label hiding bug using labelValue()

@rjsf/chakra-ui

  • Fix: MUI radio widget initializes as uncontrolled when schema has no default value, fixing #3511
  • Updated ObjectFieldTemplate to hide the titles and descriptions when displayLabel is true (including globally), fixing #3231
  • Updated CheckboxesWidget, CheckboxWidget, RadioWidget and SelectWidget to hide labels when hideLabel is true using the new labelValue() helper (including globally)
  • Updated CheckboxWidget to show the description using the DescriptionFieldTemplate, fixing #2791

@rjsf/core

  • Updated FileWidget to show a preview of images and a download link for non-images when the filePreview options is set to true in the UiSchema
  • Updated ArrayField, BooleanField, MultiSelectField and StringField to pass label (read from uiSchema.title || schema.title || name) and hideLabel down to all of the Widgets they render, fixing #827, #2636, #2399 and #3531
  • Updated ObjectField, ObjectFieldTemplate, ArrayFieldDescriptionTemplate, ArrayFieldTitleTemplate and CheckboxWidget to hide the titles and descriptions when hideLabel is true using the new labelValue() helper (including globally), fixing #3231
  • Updated CheckboxWidget to use the labelValue() function for hiding labels

@rjsf/fluent-ui

  • Updated FieldTemplate and ObjectFieldTemplate to hide the titles and descriptions when displayLabel is true (including globally), fixing #3231
  • Updated BaseInputTemplate, CheckboxesWidget, CheckboxWidget, ColorWidget, DateWidget, RadioWidget, RangeWidget, SelectWidget and UpDownWidget to hide labels when hideLabel is true using the new labelValue() helper (including globally)
    • Also extracted a new FluentLabel component out of CheckboxesWidget, ColorWidget, RangeWidget and UpDownWidget
  • Updated CheckboxWidget to show the description using the DescriptionFieldTemplate, fixing #2791

@rjsf/material-ui

  • Fix: MUI radio widget initializes as uncontrolled when schema has no default value, fixing #3511
  • Updated ObjectFieldTemplate to hide the titles and descriptions when displayLabel is true (including globally), fixing #3231
  • Updated BaseInputTemplate, CheckboxesWidget, CheckboxWidget, RadioWidget, RangeWidget and SelectWidget to hide labels when hideLabel is true using the new labelValue() helper (including globally)
  • Updated CheckboxWidget to show the description using the DescriptionFieldTemplate, fixing #2791

@rjsf/mui

  • Fix: MUI radio widget initializes as uncontrolled when schema has no default value, fixing #3511
  • Updated ObjectFieldTemplate to hide the titles and descriptions when displayLabel is true (including globally), fixing #3231
  • Updated BaseInputTemplate, CheckboxesWidget, CheckboxWidget, RadioWidget, RangeWidget and SelectWidget to hide labels when hideLabel is true using the new labelValue() helper (including globally)
  • Updated CheckboxWidget to show the description using the DescriptionFieldTemplate, fixing #2791

@rjsf/semantic-ui

  • Updated ObjectFieldTemplate to hide the titles and descriptions when displayLabel is true (including globally), fixing #3231
  • Updated BaseInputTemplate, CheckboxesWidget, CheckboxWidget, SelectWidget and TextareaWidget to hide labels when hideLabel is true using the new labelValue() helper (including globally)
  • Updated CheckboxWidget to show the description using the DescriptionFieldTemplate, fixing #2791

@rjsf/utils

  • Updated the UiSchema to support the optional filePreview?: boolean option and to add a new TranslatableString.PreviewLabel to the enums
  • Updated the WidgetProps to add an optional hideLabel?: boolean field to better support hiding labels
  • Added a new labelValue() helper function to better support hiding labels

@rjsf/validator-ajv8

  • Improve toErrorList() and unwrapErrorHandler() by ensuring objects before recursing

Dev / docs / playground

  • Added a new AntD Customization documentation with references to it in the form-props and uiSchema documentation
  • Updated the uiSchema documentation to add the filePreview option
  • Updated the widgets documentation to add the new, optional hideLabel prop
  • Updated the utility-functions documentation to add the new labelValue() function

Readme

Source

Build Status npm npm downloads Contributors Apache 2.0 License


Logo

@rjsf/utils

Utility functions for react-jsonschema-form.
Explore the docs »

View Playground · Report Bug · Request Feature

Table of Contents

About The Project

Exports utils functions for react-jsonschema-form.

Built With

Getting Started

Installation

yarn add @rjsf/utils

Usage

import * as Utils from '@rjsf/utils';

Documentation

Utility function documentation

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Read our contributors' guide to get started.

Contact

rjsf team: https://github.com/orgs/rjsf-team/people

GitHub repository: https://github.com/rjsf-team/react-jsonschema-form

Keywords

FAQs

Package last updated on 24 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc