Skip to content

Loader for JSON Form library, for loading dependencies via JS.

License

Notifications You must be signed in to change notification settings

theopenwebjp/jsonform-loader

Repository files navigation

Description

Loads dependencies by array of keys.
Followng are always loaded because required: css, jquery, underscore
Check ./index.html for a simple demo. The dependencies required depend on what functionality is needed. Therefore, I created this demo to load the dependencies programmatically.

Reason for making

In the Github issue on jsonform below, I inquired about an npm module. Although there is an npm module(jsonform) available, the dependencies are not loaded together.

Usage

npm install @theopenweb/jsonform-loader

Install dependencies: npm install

Place jsonform into lib directory. Default settings work when jsonform is cloned into lib. Otherwise, use lib from node_modules.

Script is in ./dist/bundle.js
To build use npm run build.

// Sets options(mainly urls if using setting non-standard format.)
// const BASE = `../lib/jsonform` // libの場合
const BASE = `../node_modules/jsonform` // node_modulesの場合
const options = {
    depsUrl: `${BASE}/jsonform/deps/`, // deps directory url
    jsonFormUrl: `${BASE}/jsonform/lib/jsonform.js` // jsonform.js url
}
JsonFormSchema.setOptions(options)

// Get array of available keys to set dependencies.
const keys = JsonFormSchema.getKeys()
console.log('available keys', keys)

// Load without any optional dependencies.
JsonFormSchema.load().then(()=>{
    // CAN USE JsonForm here
})

// Load with optional dependencies.
JsonFormSchema.load(keys).then(()=>{
    // CAN USE JsonForm with dependencies in keys loaded
})

Test

Example can be tested via below:

npx http-server ./
# Go to http://localhost:8080/examples

About

Loader for JSON Form library, for loading dependencies via JS.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published