SignaturePad.BASELINE
const · packages/mixins-ui/src/signaturePad.ts:307
const BASELINE: 0.72Where the line is, as a share of the pad's height from its top; the recipe draws it there too.
Mixins / foldkit-mixins-ui
namespace · packages/mixins-ui/src/signaturePad.ts:1
export * as SignaturePad from './signaturePad.js'SignaturePad.BASELINEconst · packages/mixins-ui/src/signaturePad.ts:307
const BASELINE: 0.72Where the line is, as a share of the pad's height from its top; the recipe draws it there too.
SignaturePad.ExportPngconst · packages/mixins-ui/src/signaturePad.ts:335
const ExportPng: Command.CommandDefinitionWithArgs<
'SignaturePad.ExportPng',
{
model: Schema.Struct<{
readonly id: Schema.String
readonly pen: Schema.Struct<{
readonly size: Schema.Number
readonly thinning: Schema.Number
readonly smoothing: Schema.Number
}>
readonly space: Schema.OptionFromNullOr<
Schema.Struct<{
readonly width: Schema.Number
readonly height: Schema.Number
}>
>
readonly strokes: Schema.$Array<
Schema.Struct<{
readonly points: Schema.$Array<
Schema.Struct<{
readonly x: Schema.Number
readonly y: Schema.Number
readonly pressure: Schema.Number
}>
>
readonly pressure: Schema.Boolean
}>
>
readonly undone: Schema.$Array<
Schema.Struct<{
readonly points: Schema.$Array<
Schema.Struct<{
readonly x: Schema.Number
readonly y: Schema.Number
readonly pressure: Schema.Number
}>
>
readonly pressure: Schema.Boolean
}>
>
readonly pointers: Schema.$Array<
Schema.Literals<readonly ['mouse', 'pen', 'touch']>
>
readonly drawing: Schema.OptionFromNullOr<
Schema.Struct<{
readonly points: Schema.$Array<
Schema.Struct<{
readonly x: Schema.Number
readonly y: Schema.Number
readonly pressure: Schema.Number
}>
>
readonly pressure: Schema.Boolean
}>
>
readonly typed: Schema.String
}>
scale: Schema.Number
background: Schema.OptionFromNullOr<Schema.String>
},
Effect.Effect<
| { readonly _tag: 'FailedExport'; readonly reason: string }
| {
readonly _tag: 'ExportedPng'
readonly url: string
readonly width: number
readonly height: number
},
never,
never
>
>Draws the signature on a canvas scale times the pad's size, in the
colour and face the pad shows it in (read from the elements the view drew,
found by id), over background if given.
SignaturePad.initfunction · packages/mixins-ui/src/signaturePad.ts:123
function init(options: {
readonly id: string
readonly pen?: Partial<Pen> | undefined
readonly pointers?: ReadonlyArray<PointerKind> | undefined
}): ModelSignaturePad.isEmptyfunction · packages/mixins-ui/src/signaturePad.ts:140
function isEmpty(model: Model): booleanWhether there is nothing to sign with: no stroke drawn and no name typed.
SignaturePad.Messageconst · packages/mixins-ui/src/signaturePad.ts:146
const Message: MessageUnion<{
readonly Measured: { width: Schema.Number; height: Schema.Number }
readonly Began: {
readonly point: Schema.Struct<{
readonly x: Schema.Number
readonly y: Schema.Number
readonly pressure: Schema.Number
}>
readonly pointerType: Schema.String
readonly width: Schema.Number
readonly height: Schema.Number
}
readonly Extended: {
readonly points: Schema.$Array<
Schema.Struct<{
readonly x: Schema.Number
readonly y: Schema.Number
readonly pressure: Schema.Number
}>
>
readonly width: Schema.Number
readonly height: Schema.Number
}
readonly Ended: {}
readonly Undid: {}
readonly Redid: {}
readonly Cleared: {}
readonly Typed: { readonly text: Schema.String }
readonly RequestedPng: {
readonly scale: Schema.Number
readonly background: Schema.OptionFromNullOr<Schema.String>
}
readonly ExportedPng: {
readonly url: Schema.String
readonly width: Schema.Number
readonly height: Schema.Number
}
readonly FailedExport: { readonly reason: Schema.String }
}>SignaturePad.Modelconst · packages/mixins-ui/src/signaturePad.ts:105
const Model: Schema.Struct<{
readonly id: Schema.String
readonly pen: Schema.Struct<{
readonly size: Schema.Number
readonly thinning: Schema.Number
readonly smoothing: Schema.Number
}>
readonly space: Schema.OptionFromNullOr<
Schema.Struct<{
readonly width: Schema.Number
readonly height: Schema.Number
}>
>
readonly strokes: Schema.$Array<
Schema.Struct<{
readonly points: Schema.$Array<
Schema.Struct<{
readonly x: Schema.Number
readonly y: Schema.Number
readonly pressure: Schema.Number
}>
>
readonly pressure: Schema.Boolean
}>
>
readonly undone: Schema.$Array<
Schema.Struct<{
readonly points: Schema.$Array<
Schema.Struct<{
readonly x: Schema.Number
readonly y: Schema.Number
readonly pressure: Schema.Number
}>
>
readonly pressure: Schema.Boolean
}>
>
readonly pointers: Schema.$Array<
Schema.Literals<readonly ['mouse', 'pen', 'touch']>
>
readonly drawing: Schema.OptionFromNullOr<
Schema.Struct<{
readonly points: Schema.$Array<
Schema.Struct<{
readonly x: Schema.Number
readonly y: Schema.Number
readonly pressure: Schema.Number
}>
>
readonly pressure: Schema.Boolean
}>
>
readonly typed: Schema.String
}>SignaturePad.OutMessageconst · packages/mixins-ui/src/signaturePad.ts:174
const OutMessage: MessageUnion<{
readonly ExportedPng: {
readonly url: Schema.String
readonly width: Schema.Number
readonly height: Schema.Number
}
readonly FailedExport: { readonly reason: Schema.String }
}>What Bundles.SignaturePad reports: the answer to a PNG the application asked for.
SignaturePad.pathOffunction · packages/mixins-ui/src/signaturePad.ts:291
function pathOf(stroke: Stroke, pen: Pen): stringA stroke's outline as SVG path data, to fill.
SignaturePad.Penconst · packages/mixins-ui/src/signaturePad.ts:91
const Pen: Schema.Struct<{
readonly size: Schema.Number
readonly thinning: Schema.Number
readonly smoothing: Schema.Number
}>How strokes are drawn: their width, how much pressure thins them, and how much they are smoothed.
SignaturePad.Pointconst · packages/mixins-ui/src/signaturePad.ts:80
const Point: Schema.Struct<{
readonly x: Schema.Number
readonly y: Schema.Number
readonly pressure: Schema.Number
}>A point of a stroke in the pad's coordinates, and the pen's pressure there, 0 to 1.
SignaturePad.PointerKindconst · packages/mixins-ui/src/signaturePad.ts:102
const PointerKind: Schema.Literals<readonly ['mouse', 'pen', 'touch']>What a pointer is, as the browser's pointerType names it.
SignaturePad.SignaturePadSlotsconst · packages/mixins-ui/src/signaturePad.ts:34
const SignaturePadSlots: Slots.Contract<{ readonly root: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly [Attr.AttrToken<"role">], readonly Slot.RequirementName[], boolean>; readonly label: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly control: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly [Attr.AttrToken<"role">, Attr.AttrToken<"aria-label">], readonly Slot.RequirementName[], boolean>; readonly segments: Slot.UnnamedSlot<Capability.Capability<"Base", readonly []>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly stroke: Slot.UnnamedSlot<Capability.Capability<"Base", readonly []>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly guide: Slot.UnnamedSlot<Capability.Capability<"Base", readonly []>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly placeholder: Slot.UnnamedSlot<Capability.Capability<"Base", readonly []>, r …;A signature pad after Zag's: strokes drawn with a pointer on a control
above a dashed guide and a "Sign here" placeholder, undo and clear, and
a text field where a name can be typed instead, for whoever cannot draw.
The strokes are data in a small Model of this module's: each a list of
points with the pen's pressure, in the pad's own coordinates (its size
when first measured; a pad drawn larger later scales what it is sent into
them). A pen's pressure is used as the browser reports it; a mouse or a
finger reports none worth reading, so the stroke thins as it speeds up
instead. Each stroke is drawn as the outline of a variable-width line,
smoothed, after perfect-freehand's method: pathOf gives its SVG path
data, toSvg the whole drawing as an SVG document, and ExportPng draws
it on a canvas as a PNG data URL.
The signature is the drawing, or, while nothing is drawn, the typed name, which the pad shows on its line in the recipe's script face and both exports write. The control is an image to assistive technology, named by what it holds; the typed field is the way to sign by keyboard.
SignaturePad.SignaturePadViewinterface · packages/mixins-ui/src/signaturePad.ts:543
interface SignaturePadView<Message> {
readonly model: Model
readonly onMessage: (message: typeof Message.Type) => NoInfer<Message>
readonly label: string
readonly fallback?: boolean | undefined
readonly name?: string | undefined
readonly words?: Partial<SignaturePadWords> | undefined
readonly disabled?: boolean | undefined
readonly style?: NamedStyle<typeof SignaturePadSlots> | undefined
readonly mixins?: MixinList<Message> | undefined
}SignaturePad.SignaturePadWordsinterface · packages/mixins-ui/src/signaturePad.ts:512
interface SignaturePadWords {
readonly placeholder: string
readonly undo: string
readonly redo: string
readonly clear: string
readonly fallback: string
readonly empty: string
readonly drawnOne: string
readonly drawn: string
readonly typed: string
}The words a pad says; each has an English default.
SignaturePad.Strokeconst · packages/mixins-ui/src/signaturePad.ts:83
const Stroke: Schema.Struct<{
readonly points: Schema.$Array<
Schema.Struct<{
readonly x: Schema.Number
readonly y: Schema.Number
readonly pressure: Schema.Number
}>
>
readonly pressure: Schema.Boolean
}>SignaturePad.toSvgfunction · packages/mixins-ui/src/signaturePad.ts:314
function toSvg(
model: Model,
options?: {
readonly color?: string | undefined
readonly font?: string | undefined
},
): Option.Option<string>The signature as an SVG document in the pad's coordinates, its strokes
filled with color (default black), or the typed name on the line in
font's family; none while the pad is empty or unmeasured.
SignaturePad.updatefunction · packages/mixins-ui/src/signaturePad.ts:382
function update(model: Model, message: Message): Return<Model, Message>The pad after message; the same Model when nothing changes.
SignaturePad.viewfunction · packages/mixins-ui/src/signaturePad.ts:565
function view<Outer>(
options: SignaturePadView<Outer>,
h: HtmlBuilder<Outer>,
): HtmlSignaturePad.wordsconst · packages/mixins-ui/src/signaturePad.ts:531
const words = {
placeholder,
undo,
redo,
clear,
fallback,
empty,
drawnOne,
drawn,
typed,
}The words a pad starts from; words overrides them one at a time.