How to use the @create-figma-plugin/utilities/src/number.isValidNumericInput function in @create-figma-plugin/utilities

To help you get started, we’ve selected a few @create-figma-plugin/utilities examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yuanqing / create-figma-plugin / packages / ui / src / components / textbox / textbox-numeric / textbox-numeric.js View on Github external
nonDigitRegex.test(value) === true ? `${evaluatedValue}` : value
        )
        inputElementRef.current.value = formatSignificantFigures(
          newValue,
          significantFiguresCount
        )
        handleInput()
        handleFocus()
        return
      }
      if (event.ctrlKey === true || event.metaKey === true) {
        return
      }
      if (isKeyCodeCharacterGenerating(event.keyCode) === true) {
        const nextValue = computeNextValue(inputElementRef.current, event.key)
        if (isValidNumericInput(nextValue, isInteger) === false) {
          event.preventDefault()
          return
        }
        const evaluatedValue = evaluateNumericExpression(nextValue)
        if (evaluatedValue < minimum || evaluatedValue > maximum) {
          event.preventDefault()
        }
      }
    },
    [
github yuanqing / create-figma-plugin / packages / ui / src / components / textbox / textbox-numeric / textbox-numeric.js View on Github external
function (event) {
      const nextValue = computeNextValue(
        inputElementRef.current,
        event.clipboardData.getData('Text')
      )
      if (isValidNumericInput(nextValue, isInteger) === false) {
        event.preventDefault()
      }
    },
    [isInteger]

@create-figma-plugin/utilities

An extensive library of utility functions for common Figma/FigJam plugin/widget operations

MIT
Latest version published 6 days ago

Package Health Score

71 / 100
Full package analysis