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

@kensoni/mui-quantity-control

v1.0.1

Published

Quantity control with MUI

Downloads

2

Readme

@kensoni/mui-quantity-control

Changelog

1.0.1

  • Fix required props

Installation

Install packages dependency:

# Install via npm
npm install @emotion/react @emotion/styled @mui/material

# Install via yarn
yarn add @emotion/react @emotion/styled @mui/material

Install component:

# Install via npm
npm i @kensoni/mui-quantity-control

# Install via yarn
yarn add @kensoni/mui-quantity-control

Using

import { ChangeEvent, MouseEvent, useState } from 'react';
import QuantityControl from '@kensoni/mui-quantity-control';

export default function App(){

  const [ value, setValue ] = useState(1);

  const onChange = (e: ChangeEvent<HTMLInputElement>, newValue: number) => {
    setValue(newValue);
  }

  const onClickMinus = (e: MouseEvent<HTMLButtonElement>, newValue: number) => {
    console.log('Clicked minus', newValue)
  }

  const onClickPlus = (e: MouseEvent<HTMLButtonElement>, newValue: number) => {
    console.log('Clicked plus', newValue)
  }

  return (
    <div className="App">
      <QuantityControl 
        value={ 1 } 
        onChange={ onChange }
        onClickMinus={ onClickMinus }
        onClickPlus={ onClickPlus }
      />
    </div>
  )
}

If onClickMinus and onClickPlus functions don't call e.preventDefault(), there's no need to update the value again. Inside QuantityComponent component will call the onChange function.

Props APIs.

1. value

  • Type: number
  • Required: false
  • Default:
  • Description: Current value for QuantityControl.

2. onChange

  • Type: (e: ChangeEvent<HTMLInputElement>, newValue: number) => void
  • Required: false
  • Default:
  • Description: Handle event when value of QuantityControl change. If If onClickMinus and onClickPlus functions don't call e.preventDefault(), this function will be called.

3. onClickMinus

  • Type: (e: MouseEvent<HTMLButtonElement>, newValue: number) => void
  • Required: false
  • Default:
  • Description: Handle event when minus button clicked. If this function don't call e.preventDefault(), inside QuantityComponent component will call the onChange function.

4. onClickMinus

  • Type: (e: MouseEvent<HTMLButtonElement>, newValue: number) => void
  • Required: false
  • Default:
  • Description: Handle event when plus button clicked. If this function don't call e.preventDefault(), inside QuantityComponent component will call the onChange function.

5. className

  • Type: string
  • Required: false
  • Default:
  • Description: HTML class attribute value on div element wrapper of input.

6. sx

  • Type: SxProps<Theme>
  • Required: false
  • Default:
  • Description: Custom styles for div element wrapper of input. See more

7. minusIcon

  • Type: ReactNode
  • Required: false
  • Default: "-"
  • Description: Custom component for minus icon.

8. plusIcon

  • Type: ReactNode
  • Required: false
  • Default: "+"
  • Description: Custom component for plus icon.

9. InputProps

  • Type: Omit<InputProps, keyof InputNumberProps>
  • Required: false
  • Default:
  • Description: All props for Mui Input without prop's InputNumber.

10. ButtonProps

  • Type: { minus?: ButtonProps; plus?: ButtonProps }
  • Required: false
  • Default:
  • Description: ButtonProps for minus and plus buttons.

11. format

  • Type: boolean
  • Required: false
  • Default: false
  • Description: Format value when render value into input.

12. comma

  • Type: boolean
  • Required: false
  • Default: false
  • Description: Format value with separator between integer and decimal is comma (,).

13. formatOnlyBlur

  • Type: boolean
  • Required: false
  • Default: false
  • Description: Only format input number when focus out input.

HTML Props

All props of DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>

With NextJS

Temporarily, SSR is not supported yet, so it can be used with NextJS as follows.

import dynamic from 'next/dynamic';

const QuantityControl = dynamic(
  () => import('@kensoni/mui-quantity-control'),
  { ssr: false }
);

export default function App(){

  return (
    <div className="App">
      <QuantityControl />
    </div>
  )
}