Socket
Socket
Sign inDemoInstall

@highlight-ui/utils-commons

Package Overview
Dependencies
5
Maintainers
10
Versions
91
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @highlight-ui/utils-commons

A collection of helpers, global constants, shared types used by UI-components in Personio


Version published
Weekly downloads
3.3K
increased by0.46%
Maintainers
10
Install size
398 kB
Created
Weekly downloads
 

Readme

Source

@highlight-ui/utils-commons

Installation

yarn add @highlight-ui/utils-commons

Usage

import utils from '@highlight-ui/utils-commons';

Exported Types

NameDescription
FontFamilyValid FontAwesome family variants
LocaleUsed for internationalization
SizeAllowed size variants
DirectionUsed for positioning elements
ComponentMetadataUsed for specifying required data-attributes for e2e tests
ParsedMetadataSame as ComponentMetadata but every attribute is prefixed with data-*
PropsWithMetadataUtility type for adding metadata to a component's props
OutlineVariantAllowed outlines on input elements
ValidationStatusUsed for specifying validations status for a message or a file

Exported Functions

parseMetadata()

Takes an object and converts all of its properties to valid HTML data attributes.

import utils from '@highlight-ui/utils-commons';

const metadata = {
  firstAttribute: '1',
  secondAttribute: '2',
};

const parsedMetadata = utils.parseMetadata(metadata);

console.log(parsedMetadata);
/*
  Output:
 {
  'data-first-attribute': '1',
  'data-second-attribute': '2',
  }
*/

forkHandlers()

Receives an array of callbacks and returns a function that accepts an event argument that will be passed to every callback in the array.

import utils from '@highlight-ui/utils-commons';

const MyComponent = () => {
  const handleClick = utils.forkHandlers([
    () => {
      console.log('first handler');
    },
    () => {
      console.log('second handler');
    },
    (event) => {
      event.preventDefault();
      console.log('third handler');
    },
  ]);

  return <div onClick={handleClick}>Click Me</div>;
};

withDeprecationWarning()

Higher order component that can be used to show a deprecation message as a warning in the console, with optional further information on how to use a replacement.

PropTypeRequiredDefaultDescription
WrappedComponentReactComponentYesComponent to display console warning about deprecation - when used
migrationGuideLinkstringNonullValid link to a migration guide from deprecated component to alternative
withDeprecationWarning(
  ADeprecatedComponent,
  'https://optional-link-to-a-migration-guide.com',
);

This will show as a warning on the console:

⚠️ Deprecation Warning: ADeprecatedComponent is now deprecated. See https://optional-link-to-a-migration-guide.com for migration guidance.

FAQs

Last updated on 06 Dec 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc