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

@kleeen/core-react

Package Overview
Dependencies
Maintainers
5
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kleeen/core-react

kleeen-core-react

  • 0.1.0-alpha.0
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by33.33%
Maintainers
5
Weekly downloads
 
Created
Source

kleeen-core-react

Travis npm package Coveralls

Access Control

Description

Component to show/hide elements according the user role.

Functions

setAccessControl:

Set the user permissions in the redux state.

Properties
TypeNameDescription
objectaccessControlSettingsSettings for the accessControl
objectaccessControlSettings.permissionsPermissions json base
stringaccessControlSettings.setPathToRoleOnStatePath to the rol property on state
functioncustomRenderViewFunction to eval the render of the AccessControl
functioncustomAccessControlCheckerFunction to eval the permissions

Example

const permissions = {
  WORKBENCH: {
    CHILDREN: {
      ACTIONS: {
        PERMISSIONS: {
          ADMIN: 'SHOW',
          GUEST: 'HIDE',
        },
      }
    }
  }
};

setAccessControl({ permissions, pathToRoleOnState: 'user.role' });

Properties

TypeNameDescription
stringidPermission id to be evaluated with all permissions
stringroleGet current role from redux state
nodechildrenAccording to the permssions it is shown/hidden
functionchildrenExecute the function with the user's permission to be used as the user requires

Example

<AccessControl id="LAYOUT.SEARCH_BOX">
  <input type="text" />
</AccessControl>

<AccessControl id="LAYOUT.HEALTH_SPARKLINE">
  {({ permission }) => (
    permission === 'SHOW'
      ? <input type="text" />
      : null
    )
  }
</AccessControl>

Icon Registry Provider

Description

Provider for the use of icons defined in a file with the following structure (iconRegistry):

{
  name: { path: './path.svg', alt: 'Icon name' }
}

Properties

TypeNameDefault Values
jsoniconRegistry{ }

Init provider

IconRegistryProvider({ iconRegistry })

Usage

import { IconRegistryConsumer } from '@kleeen/core-react';

<IconRegistryConsumer>
  {({ getIcon }) => (
    <img className="icon" src={getIcon(kuiIcon).path} alt={getIcon(kuiIcon).alt} />
  )}
</IconRegistryConsumer>

Theming Provider

Description

Provider to change the theme of the application by adding or modifying the classes of the html tag.

Properties

TypeNameDefault Values
StringinitialTheme

Init Provider

ThemingProvider({ themeName })

Usage

import { ThemingConsumer } from '@kleeen/core-react';

<ThemingConsumer>
  {({ setTheme }) => (
    {setTheme('newThemeName')}
  )}
</ThemingConsumer>

Translation Provider

Description

Provider for the internationalization of the application defined in a file with the following structure (localeData):

{
  "en": {
    "textKey": "English translation!"
  },
  "es": {
    "textKey": "¡Traducción español!"
  }
}

Properties

TypeNameDefault Values
StringlocaleNavigator Languaje
ArraylanguageToSupport[ es , en , fr , it ]
JsonlocaleData{ }

Init Provider

TranslationProvider({ localeData, locale: 'en' })

Use for language change

import { ThemingConsumer } from '@kleeen/core-react';

<ThemingConsumer>
  {({ setLocale }) => (
    select onChange={e => setLocale(e.target.value)}>
      <option value="en">Ingles</option>
      <option value="es">Español</option>
    </select>
  )}
</ThemingConsumer>

Use for translation

<Translate defaultMessage="content only for Admin">{'App.adminText'}</Translate>

KUIConnect

It allows to add the consumers of the combine consumer to a component to pass the props and these can be used from that component.

Example

import { KUIConnect } from '@kleeen/core-react';

const App = (props) => {
  render (
    const { translate, getIcon, setLocale } = props;
    return  (
     <div>
       ...
     </div>
    );
  );
};

compose(
  connect(state => state, ({ logIn })),
  KUIConnect(state => state),
)(App);

Combine Providers

Component that combines several providers, allows consuming components to subscribe to context changes. The properties for this function are children and providers.

Example

<KUICombineProviders providers = {[
    TranslationProvider({ localeData, locale: 'en' }),
    ReduxProvider,
    IconRegistryProvider({ iconRegistry }),
  ]}
>

Combine Consumers

Function that subscribes to context changes. The properties for this function are children and consumers.

Example

KUICombineConsumers({
  children,
  consumers: {
    theming: ThemingConsumer,
    icons: IconRegistryConsumer,
    translation: TranslationConsumer,
  },
});

Keywords

FAQs

Package last updated on 01 Mar 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