@lynx-json/jsua-lynx
v0.5.1
Published
JSUA extensions for the Lynx media type.
Readme
jsua-lynx (PRELIMINARY DOCUMENTATION)
Extensions to the jsua package for the Lynx JSON media type.
building.build accepts content and then:
- parses
content.blobas Lynx JSON and assigns it to thecontent.documentproperty - passes the
contentobject tobuilding.documentViewBuilder
builders.nodeViewBuilder accepts result and then:
- finds (see
building.register) the builder that matches the most specific hint - passes the
resultobject to the builder
building.register registers a view builder (for a Lynx JSON node) function that accepts the following params:
hint- the hint to build views forbuilder- the builder function with signature f(node) -> view || Promisecondition- a function that accepts a Lynx node param and returnstrueif the builder will build a view for the node orfalseif the builder will not
building.registrations returns the registrations added via building.register
building.setNodeViewBuilder sets the default nodeViewBuilder, accepting a function with signature f(node) -> view || Promise
View Attributes
A view representing a Lynx JSON document may have the following attributes:
data-content-url- the document's URLdata-content-type- the document's content type (application/lynx+json)data-lynx-realm- the document's realm URIdata-lynx-context- the document's context URIdata-lynx-focus- the document's focus namedata-transfer-started-at- the start date/time of the transfer that the view represents (see ECMASCript Date.prototype.valueOf()).
A view representing a node of a Lynx JSON document may have the following attributes:
data-lynx-visibility- the node'svisibilitydata-lynx-hints- the node'shintsdata-lynx-name- the node'snamedata-lynx-labeled-by- the node'slabeledByproperty valuedata-lynx-scope- the node'sscope(containernodes)href- the node'shrefproperty value (linknodes)type- the node'stypeproperty value (linknodes)data-lynx-input- the node's input name for form data submissiondata-lynx-submitter- the node'ssubmitterproperty value (formand input nodes)formaction- the node'sactionproperty value (submitnodes)data-lynx-submit-method- the node'smethodproperty value (submitnodes)data-lynx-submit-enctype- the node'senctypeproperty value (submitnodes)data-lynx-send- the node'ssendproperty value (submitnodes)data-lynx-embedded-view- the view for the node'ssrcordataproperty value (contentnodes)alt- the node'saltproperty value (contentnodes)title- the node'saltproperty value (imagenodes)data-lynx-height- the node'sheightproperty value (imagenodes)data-lynx-width- the node'swidthproperty value (imagenodes)data-lynx-container-input-add- the control used to add a new value to acontainerinput nodedata-lynx-container-input-value- the view for the value of an item in thecontainerinput nodedata-lynx-container-input-remove- the control used to remove a value from acontainerinput nodedata-lynx-container-input-item- contains thedata-lynx-container-input-valueview and its associateddata-lynx-container-input-removecontroldata-lynx-validation-state- the current validation state of the viewdata-lynx-visibility-conceal- the control used to toggle a view'sdata-lynx-visibilitybetweenrevealedandconcealeddata-lynx-options-name- the node'soptionsproperty value (input nodes)data-lynx-options-connected- the input view is connected to its source of options (input nodes)data-lynx-options-role=options- the view is a source of options for an input viewdata-lynx-option-selected- the current option selected state of the viewdata-lynx-var-*- lynx data (unspecified) properties are added with this namespace
View Functions
A view representing a node of a Lynx JSON document may have the following methods/functions:
lynxGetVisibility- gets the visibility of a viewlynxSetVisibility- sets the visibility of a viewlynxGetValue- gets the value of a view (text, content, text input, content input, container input, option, and option value views)lynxSetValue- sets the value of an input viewlynxHasValue- tests an input view's value and returns a Promise for a booleanlynxClearValue- clears an input view's valuelynxAddValue- adds a value to a container input viewlynxRemoveValue- removes a value from a container input viewlynxValidateValue- if the view can be validated, performs the validationlynxGetValidationState- if the view can be validated, gets the validation state of the viewlynxGetValidationConstraintSetObject- gets the normalized validation constraint set of a viewlynxGetConcealView- gets the view that represents the conceal action of a viewlynxSetConcealView- sets the view that represents the conceal action of a viewlynxGetRevealView- gets the view that represents the reveal action of a viewlynxSetRevealView- sets the view that represents the reveal action of a viewlynxConnectOptions- connects an input view that has options with its source of options (if found)lynxDisconnectOptions- disconnects an input view from its source of options (if connected)lynxGetInputView- gets the input view for an options viewlynxGetOptionsView- gets the options view for an input viewlynxSetEmbeddedView- sets both the view and the value (Blob) for a content viewlynxGetFocusableView- optional function to get the element from a view that is an appropriate focus target (i.e., an input control)
View Events
A view representing a node of a Lynx JSON document may emit the following events:
change- emitted when an input view's value changeslynx-visibility-change- emitted when the view'sdata-lynx-visibilityvalue changeslynx-validation-state-change- emitted when the view'sdata-lynx-validation-statevalue changes. The event object will have avalidationproperty whose value is an object (conforming to Lynx JSON's "Validation Constraint Set Object" interface) with the following additional properties:state- the overall validation state for the view after considering the state of all constraintspriorState- the overall validation state for the view prior to the changeconstraints- an array of the validation constraints (conforming Lynx JSON's "Validation Constraint Object" interface) for the view also with their ownstateandpriorStatepropertieschanges- an array of references to the validation constraints that have changed state
lynx-options-connected- emitted when a view that provides options to an input view is connected to the input viewlynx-options-disconnected- emitted when a view that provides options to an input view is disconnected from the input viewlynx-option-attached- emitted when an option view has been added to an options viewlynx-option-selected- emitted when a view that provides a value to an input view is selectedlynx-option-deselected- emitted when a view that provides a value to an input view is deselectedlynx-marker-here- emitted when a marker view determines the current view contains the content it markslynx-marker-there- emitted when a marker view determines the current view does not contain the content it marks
