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

tableschema-ui

v1.3.0

Published

UI components for tableschema

Downloads

3

Readme

tableschema-ui

Travis Coveralls NPM Github Gitter

A web UI for creating, editing and validating Table Schemas.

Features

  • render - framework-agnostic component render
  • List of components:
    • EditorSchema - table schema editor widget

Contents

Getting Started

You could use this components in plain JavaScript code or mixing with any modern framework (with native support for React). To render EditorSchema you have use tableschemaUI.render(tableschemaUI.<Component>, props, element) function.

First add bootstrap styles and scripts:

<!-- Styles -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Scripts -->
<script src="//code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

Installation

NPM

Install the package in your terminal $ npm install --save tableschema-ui

The package could be used as tableschema-ui package from NPM:

const tableschemaUI = require('tableschema-ui')

const props = '<YOUR-PROPS>'
const element = document.getElementById('component')
tableschemaUI.render(tableschemaUI.Component, {...props}, element)

CDN

The package could be used as pluggable script from CDN:

<div id="component"></div>
<script src="//unpkg.com/tableschema-ui/dist/tableschema-ui.min.js"></script>
<script>
  var props = '<YOUR-PROPS>'
  var element = document.getElementById('component')
  tableschemaUI.render(tableschemaUI.Component, {...props}, element)
</script>

Documentation

React

You could use presented components as native React component (import from tableschema-ui/lib to get native React support):

const React = require('react')
const ReactDOM = require('react-dom')
const tableschemaUI = require('tableschema-ui/lib')

const props = '<YOUR-PROPS>'
const element = document.getElementById('component')
ReactDOM.render(<tableschemaUI.Component ...props />, element)

Angular

The package's components could be used as angular component:

const {Component, Input} = require('@angular/core')
const tableschemaUI = require('tableschema-ui')

@Component({
  selector: 'component',
  template: '<div id="component"></div>'
})
class Report {
  @Input() <YOUR_PROPS>: any;
  ngAfterViewInit() {
    const element = document.getElementById('component')
    tableschemaUI.render(tableschemaUI.Component, {...this.props}, element)
  }
}

Vue

The package's components could be used as vue component:

const tableschemaUI = require('tableschema-ui')

const Report = {
  props: [<YOUR_PROPS>],
  template: '<div id="component"></div>',
  mounted() {
    const element = document.getElementById('component')
    tableschemaUI.render(tableschemaUI.Report, {...this.props}, element)
  },
}

Working with Render

To render one of the provided component render function should be used. Let's see on the basic usage example:

// Render
const props = {key: value}
const element = document.getElementById('component')
const component = tableschemaUI.render(tableschemaUI.Component, {...props}, element)

// Dispose
component.dispose()

Working with EditorSchema

This component provides a simple Table Schema editor. Let's see on the basic usage example:

// Render
const props = {
    source: 'http://example.com/data.csv',
    schema: '{"fields": []}',
    onSave: (schema, error) => {
        handleError(error)
        handleSchema(schema)
        component.dispose()
    },
}
const element = document.getElementById('schema-editor')
const component = tableschemaUI.render(tableschemaUI.EditorSchema, {...props}, element)

If data source is provided and data schema is not provided than it will be inferred from the data. The component support various options to provide the source/schema including URL and File object.

API Referencer

render(source, schema, onSave, disablePreview)

Render tableschema editor

| Param | Type | Description | | --- | --- | --- | | source | Array.<URL/File/Array> | data source | | schema | URL/File/String/Object | data schema | | onSave | function | callback executed on the save button click | | disablePreview | boolean | if true the preview tab will not be shown |

Contributing

The project follows the Open Knowledge International coding standards. There are common commands to work with the project:

$ npm run dev
$ npm run build
$ npm run test

Statefull components use redux combined with immer (see src/store.js). Instead of classical initialState/actionCreators/reducers there are:

  • initial - initial store state
  • handlers - callbacks available in components to dispatch actions
  • mutations - immer based state reducers. The same as redux reducers but it allows us to change state in-place preserving immutability on the system level (see redux-box)
  • processor - a mutation which is called after every state change

Changelog

Here described only breaking and the most important changes. The full changelog and documentation for all released versions could be found in nicely formatted commit history.

v1.3

  • Moved react to peer dependencies

v1.2

  • Rebased on redux@4

v1.1

  • Enabled csv sniffing (#8)

v1.0

  • Initial version