DevactionUI.SignatureField (devaction_ui v0.1.0)

Copy Markdown View Source

A field to sign: draw with the mouse, the finger or the pen, or type the name; clear and start again. It writes what was signed into hidden inputs for the form: the method, the typed name or the SVG of the stroke (DevactionUI.Signature hook, exportSvg). The SVG is the drawing only, in its own coordinates, so it can be kept and drawn back at any size. A drawing is accepted by the server only after safe_path?/1.

Summary

Functions

Whether a path is only path commands and numbers, so it can be drawn back without being trusted.

The SVG of a stroke, nil for one that is not safe.

Functions

safe_path?(path)

@spec safe_path?(term()) :: boolean()

Whether a path is only path commands and numbers, so it can be drawn back without being trusted.

signature_field(assigns)

Attributes

  • id (:string) (required)
  • name (:string) (required) - the form field: name[method], name[typed] and name[path].
  • mode (:atom) - Defaults to :draw. Must be one of :draw, or :type.
  • typed (:string) - Defaults to "".
  • label (:string) (required)
  • mode_event (:string) (required) - sent with phx-value-mode by the two buttons.
  • draw_label (:string) (required)
  • type_label (:string) (required)
  • clear_label (:string) (required)
  • hint (:string) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • target (:any) - a phx-target (a @myself) when used inside a LiveComponent. Defaults to nil.
  • Global attributes are accepted.

to_svg(path)

@spec to_svg(String.t()) :: String.t() | nil

The SVG of a stroke, nil for one that is not safe.