New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@sequenia/react-material-fields

Package Overview
Dependencies
Maintainers
4
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sequenia/react-material-fields

React fields with Material-UI design

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-87.5%
Maintainers
4
Weekly downloads
 
Created
Source

@sequenia/react-material-fields

React custom component with Material-UI design

NPM JavaScript Style Guide

Demo

https://sequenia.github.io/react-material-fields/

Requirements

React v16.0.0 and above, @material-ui/core v4.9.0 and above

Install

npm install --save @sequenia/react-material-fields

Usage

List of common properties for all fields:

nametypedefaultdescription
classNamestringyour custom css (or jss) className
disableAutoCompletebooleanfalsedisbaling/enabling standart autocomplete
displayNamestringtitle of this field
displayNamePositionstring"inside"position of title: "inside" by default prop and "above"
hasErrorbooleanfalseerror highlight
onChangefunctiononChange event callback function
readOnlybooleanfalsefield disabling
variantstring"outlined"variants of styling: "outlined", "filled" and "standard"
valuefield's value (string, number, array or object)
aboveLabelClassNamestringif displayNamePosition = "above" , this is label className prop

TextField

It's a simple text, email, or number input field.

nametypedefaultdescription
typestring"text"type of input: "text", "number" or "email"
capitalizationstring"none"text capitalization for field: "uppercase", "lowercase", "capitalize", "none" by default prop
multilinebooleanfalseconvert field to textarea
rowsnumber5number of rows if multiline is true
import React, { Component } from 'react'
import { TextField } from '@sequenia/react-material-fields'

class Example extends Component {
  render() {
    return <TextField displayName = { "Text field" }
                      disableAutoComplete = { true }
                      type = { "email" } />          
  }
}

PhoneField

Text field with number mask

nametypeis requireddescription
maskarrayyesnumber mask array
import React, { Component } from 'react'
import { PhoneField } from '@sequenia/react-material-fields'

class Example extends Component {
  render() {
    return <PhoneField displayName = { "Phone field" }
                       mask = { ['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/] } />             
  }
}

PasswordField

Password field with toggle password visibility.

nametypedefaultdescription
disableShowPasswordbooleanfalsedisables visibility toggling
iconClassNamestringclassName props for iconButton
import React, { Component } from 'react'
import { PasswordField } from '@sequenia/react-material-fields'

class Example extends Component {
  render() {
    return <PasswordField displayName = { "Password field" }/>               
  }
}

DecimalField

Number field with special formatting. It has two number options: precision (length of number) and scale (length after point). Also you can set decimal separator, thousand separator and prefix/suffix string.

nametypedefaultdescription
prefixstringstring prefix
suffixstringstring suffix
precisionnumber10length of number before point
scalenumber2length after point
decimalSeparatorstring","separator symbol
thousandSeparatorstring"."separator symbol
import React, { Component } from 'react'
import { DecimalField } from '@sequenia/react-material-fields'

class Example extends Component {
  render() {
    return <DecimalField displayName = { "Decimal field" }
                         suffix = { "$" } />
  }        
}

DateTimeField

Simple datepicker field. You can set format, locale, utcOffset, minDate, maxDate, serverDateFormat, serverDateTimeFormat.

nametypedefaultdescription
formatstring"DD.MM.YYYY"date-month-year format
localestring"en"language
utcOffsetnumber0UTC Universal Time offset, 0 by default
minDatetext"1900-01-01"min date (year-month-day)
maxDatetext"2100-12-31"max date (year-month-day)
maxDatetext"2100-12-31"max date (year-month-day)
serverDateFormattext"YYYY-MM-DD"date format from backend
serverDateTimeFormattext"YYYY-MM-DDTHH:mm:ss"date and time format from backend
iconClassNamestringclassName props for iconButton
import React, { Component } from 'react'
import { DateTimeField } from '@sequenia/react-material-fields'

class Example extends Component {
  render() {
    return <DateTimeField displayName = { "Datetime field" }/>               
  }
}

Checkbox

Simple checkbox. NOTE: checkbox element recieve only these props: displayName, checked, placement

nametypedefaultdescription
placementstring"end"placement of title, "start" or "end"
checkedbooleanfalsechecked status
import React, { Component } from 'react'
import { Checkbox } from '@sequenia/react-material-fields'

class Example extends Component {
  render() {
    return <Checkbox displayName = { "Checkbox" } /> 
  }
}

SelectField and RemoteSelectField

Custom select element. RemoteSelectField is a custom select with remote data and searching field.

nametypedefaultis requireddescription
dataarrayyesArray of objects. Every object should have "key" and "value". "Key" is a visible string of dropdown option. "Value" is a value of option.
multiplebooleanfalsemultiple choosing
allowClearbooleanfalseshowing "all" option
clearItemstring"all"text of "all" option
import React, { Component } from 'react'
import { SelectField, RemoteSelectField } from '@sequenia/react-material-fields'

class Example extends Component {

  /* data examples */
  const selectData = [
    {
      key: "One",
      value: "1"
    },
    {
      key: "Two",
      value: "2"
    }
  ];

  const singleSelectValue = {
    "id":2,
    "email":"janet.weaver@reqres.in",
    "first_name":"Janet",
    "last_name":"Weaver",
    "avatar":"https://s3.amazonaws.com/uifaces/faces/twitter/josephstein/128.jpg"
  };
  const multipleSelectValue = [
    {
      "id":2,
      "email":"janet.weaver@reqres.in",
      "first_name":"Janet",
      "last_name":"Weaver",
      "avatar":"https://s3.amazonaws.com/uifaces/faces/twitter/josephstein/128.jpg"
    },
    {
      "id":3,
      "email":"emma.wong@reqres.in",
      "first_name":"Emma",
      "last_name":"Wong",
      "avatar":"https://s3.amazonaws.com/uifaces/faces/twitter/olegpogodaev/128.jpg"
    }
  ];

  render() {
    return <React.Fragment>
      <SelectField data = { selectData }
                   displayName = { "Select field" } 
                   multiple = { true }
                   allowClear = { true }
      />
      <RemoteSelectField optionDisplayName = { (option) => {
                           const { first_name, last_name } = option;
                           return `${first_name} ${last_name}`;
                         }}
                         value = { singleSelectValue }
                        //  value = { multipleSelectValue } for multiple choosing
                        //  multiple = { true } // boolean, for multiple choosing,
                         onChange = { (value) => {
                           console.log(value)
                         }}
                         downloader = { (searchQuery, selectedValueIds) => {
                           const params = {
                             query: searchQuery,
                             valueIds: selectedValueIds
                           }
                           const url = new URL("https://reqres.in/api/users");
                           Object.keys(params).forEach(key => url.searchParams.append(key, encodeURIComponent(params[key])));

                             return fetch(url).then((response) => response.json())
                                              .then((response) => {
                                                const { data } = response;
                                                return data;
                             });
                           }}
      />
    </React.Fragment>  
  }
}

FileField and ImageField

File and image uploader

nametypedefaultis requireddescription
uploaderfunctionyesuploader is a function, that should return promise
accepttext"*/*"file types
deleteTextstring"Delete"button text
notUploadedTextstring"Not uploaded"button text
uploadingTextstring"Uploading"button text
buttonClassNamestringclassName property
import React, { Component } from 'react'
import { FileField, ImageField } from '@sequenia/react-material-fields'

render() {
    return <React.Fragment>
      <FileField uploader = {() => Promise.resolve() } /> 
      <ImageField uploader = {() => Promise.resolve() } />
    </React.Fragment>

License

MIT © sequenia

Keywords

FAQs

Package last updated on 27 Oct 2020

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