Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const onLeftOrRightInMenu = (comp: AlloyComponent, se: SimulatedEvent) => {
// The originating dropdown is stored on the sandbox itself.
const dropdown: AlloyComponent = Representing.getValue(comp);
// Focus the dropdown. Current workaround required to make flow recognise the current focus
Focusing.focus(dropdown);
AlloyTriggers.emitWith(dropdown, 'keydown', {
raw: se.event().raw()
});
// Close the dropdown
AlloyDropdown.close(dropdown);
return Option.some(true);
};validate: (input) => {
const inputValue = Representing.getValue(input);
// Consider empty strings valid colours
if (inputValue.length === 0) {
return Future.pure(Result.value(true));
} else {
const span = Element.fromTag('span');
Css.set(span, 'background-color', inputValue);
const res = Css.getRaw(span, 'background-color').fold(
// TODO: Work out what we want to do here.
() => Result.error('blah'),
(_) => Result.value(inputValue)
);
return Future.pure(res);
}
}const updateHistory = (component: AlloyComponent): void => {
const urlEntry = Representing.getValue(component);
urlBackstage.addToHistory(urlEntry.value, spec.filetype);
};const optHex = optRgbForm.bind((rgbForm) => {
const formValues = Representing.getValue(rgbForm);
return formValues.hex as Option;
}) ;
return optHex.map((hex) => '#' + hex).getOr('');const getItems = (fileType: 'image' | 'media' | 'file', input: AlloyComponent, urlBackstage: UiFactoryBackstageForUrlInput) => {
const urlInputValue = Representing.getValue(input);
const term = urlInputValue.meta.text !== undefined ? urlInputValue.meta.text : urlInputValue.value;
const info = urlBackstage.getLinkInformation();
return info.fold(
() => [],
(linkInfo) => {
const history = filterByQuery(term, historyTargets(urlBackstage.getHistory(fileType)));
return fileType === 'file' ? joinMenuLists([
history,
filterByQuery(term, headerTargets(linkInfo)),
filterByQuery(term, Arr.flatten([
anchorTargetTop(linkInfo),
anchorTargets(linkInfo),
anchorTargetBottom(linkInfo)
]))
])
: history;validate(input) {
const v = Representing.getValue(input);
const result = vl.validator(v);
return Future.pure(result === true ? Result.value(v) : Result.error(result));
},
validateOnLoad: vl.validateOnLoadComposing.getCurrent(comp).each((field) => {
const urlData = Representing.getValue(field);
optUrlPicker.each((picker) => {
picker(urlData).get((chosenData) => {
Representing.setValue(field, chosenData);
AlloyTriggers.emitWith(comp, formChangeEvent, { name: spec.name });
});
});
});
};memSize.getOpt(button).each((sizeInput) => {
const value = Representing.getValue(sizeInput);
const width = parseInt(value.width, 10);
const height = parseInt(value.height, 10);
const transform = makeResizeTransform(width, height);
emitTransformApply(button, transform);
});
}, false, true)greenOpt.each((green) => {
const r = Representing.getValue(red).x() / 100;
const g = Representing.getValue(green).x() / 100;
const b = Representing.getValue(blue).x() / 100;
const transform = makeColorTransform(r, g, b);
emitTransform(slider, transform);
});
});