Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const sketch = function (rawSpec) {
const navigateEvent = 'navigateEvent';
const wrapperAdhocEvents = 'serializer-wrapper-events';
const formAdhocEvents = 'form-events';
const schema = ValueSchema.objOf([
FieldSchema.strict('fields'),
// Used for when datafields are present.
FieldSchema.defaulted('maxFieldIndex', rawSpec.fields.length - 1),
FieldSchema.strict('onExecute'),
FieldSchema.strict('getInitialValue'),
FieldSchema.state('state', function () {
return {
dialogSwipeState: Singleton.value(),
currentScreen: Cell(0)
};
})
]);
const spec = ValueSchema.asRawOrDie('SerialisedDialog', schema, rawSpec);
const navigationButton = function (direction, directionName, enabled) {
return Button.sketch({
dom: UiDomFactory.dom('<span class="${prefix}-icon-' + directionName + ' ${prefix}-icon"></span>'),
action (button) {
AlloyTriggers.emitWith(button, navigateEvent, { direction });
},
initGroups: [],
getSink: spec.getSink,
backstage: spec.backstage,
moreDrawerData: {
lazyToolbar: spec.lazyToolbar,
lazyMoreButton: spec.lazyMoreButton,
lazyHeader: spec.lazyHeader
}
};
return renderer(toolbarSpec);
}
},
name: 'toolbar',
schema: [
FieldSchema.strict('dom'),
FieldSchema.strict('onEscape'),
FieldSchema.strict('getSink')
]
});
const partHeader = Composite.partType.optional({
factory: {
sketch: renderHeader
},
name: 'header',
schema: [
FieldSchema.strict('dom')
]
});
const partSocket = Composite.partType.optional({
// factory: Fun.identity,
return CommonBehaviour.create(value.fields, value.name, value.active, value.apis, value.extra, value.state);
};
export interface BehaviourModeSpec {
branchKey: string;
branches: Record;
name: string;
active?: any;
apis?: { };
extra?: { };
state?: { };
}
const modeSchema: Processor = ValueSchema.objOfOnly([
FieldSchema.strict('branchKey'),
FieldSchema.strict('branches'),
FieldSchema.strict('name'),
FieldSchema.defaulted('active', { }),
FieldSchema.defaulted('apis', { }),
FieldSchema.defaulted('state', NoState),
FieldSchema.defaulted('extra', { })
]);
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 revoke = Fun.constant(undefined);
detail.onAction(comp);
}
})
),
apis
};
};
export const Notification = Sketcher.single({
name: 'Notification',
factory,
configFields: [
FieldSchema.option('level'),
FieldSchema.strict('progress'),
FieldSchema.strict('icon'),
FieldSchema.strict('onAction'),
FieldSchema.strict('text'),
FieldSchema.strict('iconProvider'),
FieldSchema.strict('translationProvider'),
],
apis: {
updateProgress: (apis: NotificationSketchApis, comp: AlloyComponent, percent: number) => {
apis.updateProgress(comp, percent);
},
updateText: (apis: NotificationSketchApis, comp: AlloyComponent, text: string) => {
apis.updateText(comp, text);
}
}
}) as NotificationSketcher;
import * as Behaviour from '../../api/behaviour/Behaviour';
import { Focusing } from '../../api/behaviour/Focusing';
import { Keying } from '../../api/behaviour/Keying';
import { Toggling } from '../../api/behaviour/Toggling';
import { Toolbar } from '../../api/ui/Toolbar';
import * as SplitToolbarBase from '../common/SplitToolbarBase';
import * as Fields from '../../data/Fields';
import * as PartType from '../../parts/PartType';
import { SplitFloatingToolbarDetail } from '../types/SplitFloatingToolbarTypes';
import * as AlloyParts from '../../parts/AlloyParts';
import * as ToolbarSchema from './ToolbarSchema';
const schema: () => FieldProcessorAdt[] = Fun.constant([
Fields.markers([ 'overflowToggledClass' ]),
FieldSchema.strict('getAnchor'),
FieldSchema.strict('lazySink')
].concat(
SplitToolbarBase.schema()
));
const parts: () => PartType.PartTypeAdt[] = Fun.constant([
PartType.required({
factory: Toolbar,
schema: ToolbarSchema.schema(),
name: 'primary'
}),
PartType.external({
factory: Toolbar,
schema: ToolbarSchema.schema(),
name: 'overflow',
overrides (detail: SplitFloatingToolbarDetail) {
};
export interface BehaviourModeSpec {
branchKey: string;
branches: Record;
name: string;
active?: any;
apis?: { };
extra?: { };
state?: { };
}
const modeSchema: Processor = ValueSchema.objOfOnly([
FieldSchema.strict('branchKey'),
FieldSchema.strict('branches'),
FieldSchema.strict('name'),
FieldSchema.defaulted('active', { }),
FieldSchema.defaulted('apis', { }),
FieldSchema.defaulted('state', NoState),
FieldSchema.defaulted('extra', { })
]);
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 revoke = Fun.constant(undefined);
const noActive = Fun.constant({ });
action: (comp) => {
detail.onAction(comp);
}
})
),
apis
};
};
export const Notification = Sketcher.single({
name: 'Notification',
factory,
configFields: [
FieldSchema.option('level'),
FieldSchema.strict('progress'),
FieldSchema.strict('icon'),
FieldSchema.strict('onAction'),
FieldSchema.strict('text'),
FieldSchema.strict('iconProvider'),
FieldSchema.strict('translationProvider'),
],
apis: {
updateProgress: (apis: NotificationSketchApis, comp: AlloyComponent, percent: number) => {
apis.updateProgress(comp, percent);
},
updateText: (apis: NotificationSketchApis, comp: AlloyComponent, text: string) => {
apis.updateText(comp, text);
}
}
}) as NotificationSketcher;
}],
action: (comp) => {
detail.onAction(comp);
}
})
),
apis
};
};
export const Notification = Sketcher.single({
name: 'Notification',
factory,
configFields: [
FieldSchema.option('level'),
FieldSchema.strict('progress'),
FieldSchema.strict('icon'),
FieldSchema.strict('onAction'),
FieldSchema.strict('text'),
FieldSchema.strict('iconProvider'),
FieldSchema.strict('translationProvider'),
],
apis: {
updateProgress: (apis: NotificationSketchApis, comp: AlloyComponent, percent: number) => {
apis.updateProgress(comp, percent);
},
updateText: (apis: NotificationSketchApis, comp: AlloyComponent, text: string) => {
apis.updateText(comp, text);
}
}
}) as NotificationSketcher;
const value = ValueSchema.asRawOrDie('Creating behaviour: ' + data.name, simpleSchema, data);
return CommonBehaviour.create(value.fields, value.name, value.active, value.apis, value.extra, value.state);
};
export interface BehaviourModeSpec {
branchKey: string;
branches: Record;
name: string;
active?: any;
apis?: { };
extra?: { };
state?: { };
}
const modeSchema: Processor = ValueSchema.objOfOnly([
FieldSchema.strict('branchKey'),
FieldSchema.strict('branches'),
FieldSchema.strict('name'),
FieldSchema.defaulted('active', { }),
FieldSchema.defaulted('apis', { }),
FieldSchema.defaulted('state', NoState),
FieldSchema.defaulted('extra', { })
]);
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
);
};
})
),
apis
};
};
export const Notification = Sketcher.single({
name: 'Notification',
factory,
configFields: [
FieldSchema.option('level'),
FieldSchema.strict('progress'),
FieldSchema.strict('icon'),
FieldSchema.strict('onAction'),
FieldSchema.strict('text'),
FieldSchema.strict('iconProvider'),
FieldSchema.strict('translationProvider'),
],
apis: {
updateProgress: (apis: NotificationSketchApis, comp: AlloyComponent, percent: number) => {
apis.updateProgress(comp, percent);
},
updateText: (apis: NotificationSketchApis, comp: AlloyComponent, text: string) => {
apis.updateText(comp, text);
}
}
}) as NotificationSketcher;