Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const contextToggleButtonSchema = ValueSchema.objOf(baseToolbarToggleButtonFields.concat([
FieldSchema.defaulted('type', 'contextformbutton'),
FieldSchema.defaulted('primary', false),
FieldSchema.strictFunction('onAction'),
FieldSchema.state('original', Fun.identity)
]));
const launchButtonSchema = ValueSchema.objOf(baseToolbarButtonFields.concat([
FieldSchema.defaulted('type', 'contextformbutton')
]));
const launchToggleButtonSchema = ValueSchema.objOf(baseToolbarToggleButtonFields.concat([
FieldSchema.defaulted('type', 'contextformtogglebutton')
]));
const toggleOrNormal = ValueSchema.choose('type', {
contextformbutton: contextButtonSchema,
contextformtogglebutton: contextToggleButtonSchema
});
const contextFormSchema = ValueSchema.objOf([
FieldSchema.defaulted('type', 'contextform'),
FieldSchema.defaultedFunction('initValue', () => ''),
FieldSchema.optionString('label'),
FieldSchema.strictArrayOf('commands', toggleOrNormal),
FieldSchema.optionOf('launch', ValueSchema.choose('type', {
contextformbutton: launchButtonSchema,
contextformtogglebutton: launchToggleButtonSchema
}))
].concat(contextBarFields));
const contextToolbarSchema = ValueSchema.objOf([
const createModes = (data: BehaviourModeSpec): AlloyBehaviour => {
const value: BehaviourModeSpec = ValueSchema.asRawOrDie('Creating behaviour: ' + data.name, modeSchema, data);
return CommonBehaviour.createModes(
ValueSchema.choose(value.branchKey, value.branches),
value.name, value.active, value.apis, value.extra, value.state
);
};
const normalButtonFields = [
FieldSchema.strictStringEnum('type', ['submit', 'cancel', 'custom']),
...dialogButtonFields
];
const menuButtonFields = [
FieldSchema.strictStringEnum('type', ['menu']),
FieldSchema.optionString('text'),
FieldSchema.optionString('tooltip'),
FieldSchema.optionString('icon'),
FieldSchema.strictArrayOf('items', dialogToggleMenuItemSchema),
FieldSchema.defaultedFunction('onSetup', () => Fun.noop),
...baseButtonFields
];
export const dialogButtonSchema = ValueSchema.choose(
'type',
{
submit: normalButtonFields,
cancel: normalButtonFields,
custom: normalButtonFields,
menu: menuButtonFields
}
);
const launchToggleButtonSchema = ValueSchema.objOf(baseToolbarToggleButtonFields.concat([
FieldSchema.defaulted('type', 'contextformtogglebutton')
]));
const toggleOrNormal = ValueSchema.choose('type', {
contextformbutton: contextButtonSchema,
contextformtogglebutton: contextToggleButtonSchema
});
const contextFormSchema = ValueSchema.objOf([
FieldSchema.defaulted('type', 'contextform'),
FieldSchema.defaultedFunction('initValue', () => ''),
FieldSchema.optionString('label'),
FieldSchema.strictArrayOf('commands', toggleOrNormal),
FieldSchema.optionOf('launch', ValueSchema.choose('type', {
contextformbutton: launchButtonSchema,
contextformtogglebutton: launchToggleButtonSchema
}))
].concat(contextBarFields));
const contextToolbarSchema = ValueSchema.objOf([
FieldSchema.defaulted('type', 'contexttoolbar'),
FieldSchema.strictString('items')
].concat(contextBarFields));
export const createContextToolbar = (spec: ContextToolbarApi): Result> => {
return ValueSchema.asRaw('ContextToolbar', contextToolbarSchema, spec);
};
export const createContextForm = (spec: ContextFormApi): Result> => {
return ValueSchema.asRaw('ContextForm', contextFormSchema, spec);