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

@particles/configurable-field-set

Package Overview
Dependencies
Maintainers
27
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@particles/configurable-field-set

Functions to determine column visibility and requiredness.

  • 0.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
27
Created
Source

Configurable Field Set

Functions to determine column visibility and requiredness.

Usage

isVisible(Object)(Object)(String) => Boolean

A function for checking if a column is visible or not. Returns true if the item cannot be found.

isVisible = (
    // defines frontend names to match to the corresponding
    // backend configurable_field_set field names
    nameMapObj: { someName: 'field_set_name' },
  ) => (
    // the object of configurable_field_set field names
    sourceOfValuesObj: { field_set_name: { visible: Boolean } },
  ) => (
    'someName'
  ) =>
  returns Boolean

isRequired(Object)(Object)(String) => Boolean

A function for checking if a column is required or not. Returns false if the item cannot be found.

isRequired = (
    // defines frontend names to match to the corresponding
    // backend configurable_field_set field names
    nameMapObj: { someName: 'field_set_name' },
  ) => (
    // the object of configurable_field_set field names
    sourceOfValuesObj: { field_set_name: { required: Boolean } },
  ) => (
    'someName'
  ) =>
  returns Boolean

filterVisibleColumns(Object)(Object)(Array, String) => Array

A function for filtering an array of columns to only visible columns.

filterVisibleColumns = (
    // defines frontend names to match the corresponding
    // backend configurable_field_set field names
    nameMapObj: { someName: 'field_set_name' },
  ) => (
    // the object of configurable_field_set field names
    sourceOfValuesObj: { field_set_name: { visible: Boolean } },
  ) => (
    // some arbitrary array of columns
    columnsArr = [{ [colKey]: 'someName' }],
    colKey: 'key'  // defaults to 'key'
  ) =>
  returns []

aggregateVisibility(Array) => Object

A function that takes in an array of CFS fields objects and returns a new set of fields where the visibility of each field is set to true if ANY of the input fieldsets have that field set to "visible: true", otherwise set to false.

aggregateVisibility = (
    [
      { name: { visible: true }, status: { visible: true }, contact: { visible: false }},
      { name: { visible: true }, status: { visible: false }, contact: { visible: false }},
    ],
  ) =>
  returns {} // { name: { visible: true }, status: { visible: true }, contact: { visible: false } }

Change Log

0.3.2

  • Added aggregateVisibility() method

0.3.0

  • Breaking The second argument to the second function, 'visible', has been removed from isVisible()(undefined, 'visible')(). This is in order to determine keys sooner
  • Breaking The second argument to the first function, true, has been removed from isVisible(undefined, true)()(). This is in order to determine defaults for different keys sooner
  • Breaking The second argument to the second function, true, has been removed from filterVisibleColumns()(undefined, true)(). This is in order to determine defaults for different keys sooner
  • added isRequired

0.2.1

  • Breaking The names of functions switched. visibleColumns is now filterVisibleColumns, already knowing it's filter func. And filterVisibleColumns is now visibleColumns, needing a filter func
  • added isVisible function for non array checks

0.2.0

  • unpublished

0.1.1

  • Added false/empty visibleObj check to avoid filter call

0.1.0

  • Initial commit

FAQs

Package last updated on 19 Dec 2019

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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc