Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const factory = (newSpec: { uid: string }) => {
return NavigableObject.craft(
{
// We need to use the part uid or the label and field won't be linked with ARIA
uid: newSpec.uid,
dom: {
tag: 'iframe',
attributes
},
behaviours: Behaviour.derive([
Tabstopping.config({ }),
Focusing.config({ }),
RepresentingConfigs.withComp(Option.none(), sourcing.getValue, sourcing.setValue)
])
}
);
};export const renderColorInput = (spec: ColorInputSpec, sharedBackstage: UiFactoryBackstageShared, colorInputBackstage: UiFactoryBackstageForColorInput): SimpleSpec => {
const pField = FormField.parts().field({
factory: Input,
inputClasses: ['tox-textfield'],
onSetValue: (c) => Invalidating.run(c).get(() => { }),
inputBehaviours: Behaviour.derive([
Tabstopping.config({ }),
Invalidating.config({
invalidClass: 'tox-textbox-field-invalid',
getRoot: (comp) => {
return Traverse.parent(comp.element());
},
notify: {
onValid: (comp) => {
// onValid should pass through the value here
// We need a snapshot of the value validated.
const val = Representing.getValue(comp);
AlloyTriggers.emitWith(comp, colorInputChangeEvent, {
color: val
});
}
},
validator: {useEnter: spec.multiline !== true,
useControlEnter: spec.multiline === true,
execute: (comp) => {
AlloyTriggers.emit(comp, formSubmitEvent);
return Option.some(true);
},
}),
AddEventsBehaviour.config('textfield-change', [
AlloyEvents.run(NativeEvents.input(), (component, _) => {
AlloyTriggers.emitWith(component, formChangeEvent, { name: spec.name } );
}),
AlloyEvents.run(SystemEvents.postPaste(), (component, _) => {
AlloyTriggers.emitWith(component, formChangeEvent, { name: spec.name } );
})
]),
Tabstopping.config({})
];
const validatingBehaviours = spec.validation.map((vl) => {
return Invalidating.config({
getRoot(input) {
return Traverse.parent(input.element());
},
invalidClass: 'tox-invalid',
validator: {
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.validateOnLoad
}useEnter: spec.multiline !== true,
useControlEnter: spec.multiline === true,
execute: (comp) => {
AlloyTriggers.emit(comp, formSubmitEvent);
return Option.some(true);
},
}),
AddEventsBehaviour.config('textfield-change', [
AlloyEvents.run(NativeEvents.input(), (component, _) => {
AlloyTriggers.emitWith(component, formChangeEvent, { name: spec.name } );
}),
AlloyEvents.run(SystemEvents.postPaste(), (component, _) => {
AlloyTriggers.emitWith(component, formChangeEvent, { name: spec.name } );
})
]),
Tabstopping.config({})
];
const validatingBehaviours = spec.validation.map((vl) => {
return Invalidating.config({
getRoot(input) {
return Traverse.parent(input.element());
},
invalidClass: 'tox-invalid',
validator: {
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.validateOnLoad
}const renderCommonSpec = (spec, actionOpt: Option<(comp: AlloyComponent) => void>, extraBehaviours = [], dom, components) => {
const action = actionOpt.fold(() => {
return {};
}, (action) => {
return {
action
};
});
const common = {
buttonBehaviours: Behaviour.derive([
DisablingConfigs.button(spec.disabled),
Tabstopping.config({}),
AddEventsBehaviour.config('button press', [
AlloyEvents.preventDefault('click'),
AlloyEvents.preventDefault('mousedown')
])
].concat(extraBehaviours)),
eventOrder: {
click: ['button press', 'alloy.base.behaviour'],
mousedown: ['button press', 'alloy.base.behaviour']
},
...action
};
const domFinal = Merger.deepMerge(common, { dom });
return Merger.deepMerge(domFinal, { components });
};const getFieldPart = (isField1) => AlloyFormField.parts().field({
factory: AlloyInput,
inputClasses: ['tox-textfield'],
inputBehaviours: Behaviour.derive([
Disabling.config({ disabled: spec.disabled }),
Tabstopping.config({}),
AddEventsBehaviour.config('size-input-events', [
AlloyEvents.run(NativeEvents.focusin(), function (component, simulatedEvent) {
AlloyTriggers.emitWith(component, ratioEvent, { isField1 });
}),
AlloyEvents.run(NativeEvents.change(), function (component, simulatedEvent) {
AlloyTriggers.emitWith(component, formChangeEvent, { name: spec.name });
})
])
]),
selectOnFocus: false
});tag: 'button',
innerHtml: providersBackstage.translate('Browse for an image'),
styles: {
position: 'relative'
},
classes: [ 'tox-button', 'tox-button--secondary']
},
components: [
memInput.asSpec()
],
action: (comp) => {
const inputComp = memInput.get(comp);
inputComp.element().dom().click();
},
buttonBehaviours: Behaviour.derive([
Tabstopping.config({ })
])
})
]
}
]
};
};components: [
AlloyTabSection.parts().tabbar({
dom: {
tag: 'div',
classes: [ 'tox-dialog__body-nav' ]
},
components: [
AlloyTabbar.parts().tabs({ })
],
markers: {
tabClass: 'tox-tab',
selectedClass: 'tox-dialog__body-nav-item--active'
},
tabbarBehaviours: Behaviour.derive([
Tabstopping.config({ })
])
}),
AlloyTabSection.parts().tabview({
dom: {
tag: 'div',
classes: [ 'tox-dialog__body-content' ]
}
})
],
selectFirst: tabMode.selectFirst,
tabSectionBehaviours: Behaviour.derive([
AddEventsBehaviour.config('tabpanel', tabMode.extraEvents),
Keying.config({
mode: 'acyclic']
});
const renderTd = (text: string) => ({ dom: { tag: 'td', innerHtml: providersBackstage.translate(text) } });
const renderTr = (row: string[]) => ({ dom: { tag: 'tr' }, components: Arr.map(row, renderTd) });
const renderRows = (rows: string[][]) => ({ dom: { tag: 'tbody' }, components: Arr.map(rows, renderTr) });
return {
dom: {
tag: 'table',
classes: [ 'tox-dialog__table' ]
},
components: [
renderHeader(spec.header),
renderRows(spec.cells)
],
behaviours: Behaviour.derive([
Tabstopping.config({ }),
Focusing.config({ })
])
};
};components: [
AlloyTabSection.parts().tabbar({
dom: {
tag: 'div',
classes: [ 'tox-dialog__body-nav' ]
},
components: [
AlloyTabbar.parts().tabs({ })
],
markers: {
tabClass: 'tox-tab',
selectedClass: 'tox-dialog__body-nav-item--active'
},
tabbarBehaviours: Behaviour.derive([
Tabstopping.config({ })
])
}),
AlloyTabSection.parts().tabview({
dom: {
tag: 'div',
classes: [ 'tox-dialog__body-content' ]
}
})
],
selectFirst: tabMode.selectFirst,
tabSectionBehaviours: Behaviour.derive([
AddEventsBehaviour.config('tabpanel', tabMode.extraEvents),
Keying.config({
mode: 'acyclic'