Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
promptText = 'Please fill out and submit the form below',
submitText = 'Submit',
inputs = [{ name: 'lorem', type: 'text', placeholder: 'Example Input' }],
action = data => console.log('Submitted', data),
errorText = '',
links = []
}) =>
h('form', {
key,
oncreate: e => e.elements[0].focus(),
onsubmit: e => {
e.preventDefault()
return action(parseFormInputs(e.target))
}
},[
h('header', {}, [
h('h3', {}, titleText),
h('p', {}, promptText),
]),
inputs.map(props => h('label', { style: { display: props.type === 'hidden' ? 'none' : false }}, h('input', props))),
errorText && h('error-', {}, errorText),
h('button', { type: 'submit' }, submitText),
h('footer', {}, links.map(x =>
h('a', { href: '#', onclick: e => e.preventDefault() || x.action() }, x.text)
)),
])
const view = (state, actions) => (props, children) => {
const orientation = props.orientation || 'vertical';
return h(Element, {
orientation,
class: 'osjs-gui-panes-inner'
}, panes(state, actions, children, orientation));
};
const Button = ({ label, action, disabled = false }) => h(
'button',
{ onclick: action, disabled: disabled },
label
);
export const Lifecycle = (elementName, props, children) => {
const fn = (method, eventName) => function (el) {
const event = new CustomEvent(eventName, { detail: el })
setTimeout(() => el.parentElement.dispatchEvent(event))
return Object.getPrototypeOf(this)[method].call(this, el)
}
return h(
elementName,
{
appendChild: fn('appendChild', 'create'),
removeChild: fn('removeChild', 'remove'),
...props
},
children
)
}
export default ({ node = "div", content, ...props }) =>
h(node, {
...props,
oncreate: setInnerHTML(memoMarked(content))
});
}, (fieldProps) => h('label', {
}, [
h('input', fieldProps),
h('span', {
class: 'osjs-toggle-input'
}),
h('span', {
class: 'osjs-toggle-label'
}, [
props.label || '',
...children
])
]), ev => [props.type === 'radio'
? parseValue(ev.target.value)
export const FirebaseAuthDialog = (state, actions) =>
state.checked &&
!state.authed &&
h(
'dialog',
{
key: 'firebase-auth-dialog',
},
[
!state.user.email
? Identity(state, actions)
: state.hasIdentity.length
? Signin(state, actions)
: Signup(state, actions),
]
)
return function (props, children) {
return typeof props === "object" && !Array.isArray(props)
? h(name, mergeProps(props, additionalProps), children)
: h(name, additionalProps, props)
}
}
value: 'svg',
checked: props.exportType === 'svg',
id: 'exportTypeSvg',
name: 'exportType',
onchange: props.updateExportType
}),
h('label', { for: 'exportTypeSvg', class: styles.exportOptLabel }, 'SVG'),
h('input', {
type: 'radio',
value: 'html',
checked: props.exportType === 'html',
id: 'exportTypeHtml',
name: 'exportType',
onchange: props.updateExportType
}),
h('label', { for: 'exportTypeHtml', class: styles.exportOptLabel }, 'HTML'),
h('input', {
type: 'radio',
value: 'gif',
checked: props.exportType === 'gif',
id: 'exportTypeGif',
name: 'exportType',
onchange: props.updateExportType
}),
h('label', { for: 'exportTypeGif', class: styles.exportOptLabel }, [
'GIF',
h('span', { class: styles.alpha }, '(alpha)')
]),
h('div', { class: styles.exportActions }, [
h('button', { onclick: props.export }, props.isExporting ? 'Exporting...' : 'Export')
])
])
export const terminalView = props =>
h(
'div',
{
class: [styles.terminalContainer, props.background && styles.terminalBackground].filter(Boolean).join(' '),
style: {
width: props.width + 'px',
height: props.height + 'px',
backgroundImage: props.background ? `linear-gradient(${props.bgColor1}, ${props.bgColor2})` : null
}
},
[h('div', { class: styles.terminal }, [h(terminalTitleView, props), h(terminalContentView, props)])]
)