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

@servicenow/ui-core

Package Overview
Dependencies
Maintainers
4
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@servicenow/ui-core

Core package of the Now Experience UI Framework

  • 18.2.5
  • paris
  • npm
  • Socket score

Version published
Weekly downloads
102
increased by148.78%
Maintainers
4
Weekly downloads
 
Created
Source

@servicenow/ui-core

createCustomElement

Define a custom element.

ParamTypeDescription
elementNamestringThe tag name of the custom element.
configObjectThe custom element configuration.
[config.initialState]ObjectThe initial state for a component.
[config.properties]ObjectThe properties used by a custom element.
config.properties.nameObjectThe name of the property.
[config.properties.name.default]*The default value of the property.
[config.properties.name.computed]functionA function that computes the property value.
config.properties.name.computed.stateObjectThe custom element state.
[config.properties.name.onChange]functionA function that will be called with the new property value, the previous value, and the dispatch function.
[config.properties.name.reflect]booleanReflect property change to corresponding attribute.
[config.properties.name.unstableParse]booleanParse attribute values when corresponding properties are set.
[config.properties.name.readOnly]booleanProperty cannot be externally set.
[config.actions]ObjectThe actions the custom element dispatches.
config.actions.typeObjectThe action type, name.
[config.actions.private]booleanIndicates if the action is visible outside of the custom element.
[config.actions.handlers]ArrayEffect handlers to run when the action type is dispatched.
config.rendererObjectThe renderer to be used by the custom element.
config.renderer.typefunctionThe library that renders the view.
config.renderer.viewfunctionA function that is executed by onStateChange.
[config.renderer.transformState]functionA function that executes before a component's state is passed to the handler.
[config.onDisconnect]functionA function that executes when the custom element is disconnected.
[config.onConnect]functionA function that executes when the custom element is connected.
[config.behaviors]ArrayBehaviors to applied to the custom element.

Example

import {createCustomElement} from '@servicenow/ui-core';
import snabbdom from '@servicenow/ui-renderer-snabbdom';

createCustomElement('sn-hello-world', {
  properties: {
    name: {
      default: 'Fred'
    }
  },
  renderer: {
    type: snabbdom,
    transformState({properties}) { return properties; },
    view: ({name}) => { return <p>Hello {name}!</p>; }
  }
});

Action Routing

Actions will "bubble" up the component hierarchy unless they are explictly stopped by dispatch meta data, {stopPropagtion: true}, or part of the stopPropagtion configuration for a component definition.

dispatch('SOMETHING_HAPPENED', {somethingHappened: true}, {stopPropagtion: true});

OR

createCustomElement('sn-foo', () => null, {
  stopPropagtion: ['SOMETHING_HAPPENED']
});

FAQs

Package last updated on 15 Sep 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