
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
ontime-layout
Advanced tools
ontime-layout is used to generate any layouts from JSON using React components
The library is used to create any layouts or forms from JSON configuration.
// npm
npm install ontime-layout
// yarn
yarn add ontime-layout
Please see the storybook page where you are able to see and test all components with documentation and examples.
ontime-layout is library to create and manage UI for React 16.
Register components, functions etc for using
You are able to register only - component, function, class, object, exec
You should use pipeline only as an array. Where the first argument must be 'pipeline' and other arguments must be registered functions, objects etc.
// pipeline example
props: {
onClick: ['pipeline', ['function/fn1', {a: 1}], 'function/fn2', 'function/fn3']
}
When the user clicks on the element then the function 'function/fn1' will be called and the first argument will be an onClick event (Proxy) and the second argument will be an object {a: 1}. Result of the first function will be passed to the function 'function/fn2' and so on. All functions will be called like async functions.
Register components, functions and abjects etc
import { Row, Input, Button } from 'ontime-components';
import { config } from 'ontime-layout';
import i18n from 'i18n';
config.set('component', 'Row', Row);
config.set('component', 'Input', Input);
config.set('component', 'Button', Button);
config.set('function', 'populateSelect', async () => ['John Snow', 'Rob Stark']);
config.set('exec', 'translate', (key, options) => i18n.t(key, options));
Register translating function for validator
If you want to use ontime-layout validator and see correct errors. You shloud register translating function. Please see below example how to do.
import { config } from 'ontime-layout';
import i18n from 'i18n';
config.setI18n((key, options) => i18n.t(key, options));
How to use registered components, function etc in JSON configuration
import { Layout } from 'ontime-layout';
const data = [
{
component: 'Row',
children: [
{
component: 'Input',
props: {
name: 'name',
label: ['exec/translate', 'user.name'],
leftIcon: 'user'
}
},
{
component: 'Select',
props: {
name: 'region',
label: ['exec/translate', 'user.alias'],
dataSource: 'function/populateSelect'
}
}
]
},
{
component: 'Row',
children: [
{
component: 'Button',
props: {
type: 'submit',
label: ['exec/translate', 'save'],
primary: true
}
},
{
component: 'Button',
props: {
label: ['exec/translate', 'cancel']
}
}
]
}
];
<Layout data={ data } />
For From details please see ontime-layout/storybook/form
For Layout details please see ontime-layout/storybook/layout
How to use validator
import { validator } from 'ontime-layout';
// Create rules
const rules = {
name: {
req: true,
maxLen: 100
},
email: {
req: true,
email: true
}
};
// Create data
const data = {
name: '',
email: '111'
};
// create validate function for rules
const validate = validator(rules);
// validate
try {
await validate(data);
} catch (err) {
console.error(err);
}
// if need to validate only one field
try {
await validate(data, 'email');
} catch (err) {
console.error(err);
}
// Use validate into Form
<Form
data={ data }
validate={ validate }
/>
List of predefined rules
MIT
FAQs
ontime-layout is used to generate any layouts from JSON using React components
We found that ontime-layout demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.

Security News
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.