new TableSorter
Provides methods to sort table instances.
Methods
Links
new BaseTable(...)
The shared functionality of all `o-table` variants.
Methods
-
updateRows
- (instance) Update the o-table instance with rows added or removed dynamically from
the table. Applies any existing sort and filter to new rows.
-
renderRowUpdates
- (instance) Updates the dom to account for row updates, including when their sort
order changes, or any filter is applied. E.g. changes the dom order,
applies aria-labels to hidden rows, updates the table height to
efficiently hide them.
Note this does not calculate which rows should be sorted or filtered,
and does not look for new rows added to the dom. See `updateRows`.
-
filter(headerIndex, filter)
- (instance) Filter the table and render the result.
-
getTableHeader(columnIndex)
- (instance) Gets a table header for a given column index.
-
sortRowsByColumn(columnIndex, sortOrder)
- (instance) Sort the table.
-
addSortButtons
- (instance) Add sort buttons to the DOM within the table header.
-
sorted(...)
- (instance) Indicate that the table has been sorted after intercepting the sorting event.
-
destroy
- (instance) Gets the instance ready for deletion.
Removes event listeners that were added during instatiation of the component.
Links
new BasicTable(...)
Initialises an `o-table` component without responsive behaviour.
Links
new FlatTable(...)
Initialises an `o-table` component with "flat" responsive behaviour.
Methods
-
updateRows
- (instance) Update the o-table instance with rows added dynamically to the table.
Links
new OverflowTable(...)
Initialises an `o-table` component with "overflow" responsive behaviour.
Methods
-
filter(headerIndex, filter)
- (instance) Filter the table.
-
isExpanded
- (instance) Check if the table is expanded (true) or collapsed (false).
-
isContracted
- (instance) Check if the table is collapsed (true) or expanded (false).
-
canExpand
- (instance) Check if the table supports the expand/contract feature.
-
renderRowUpdates
- (instance) Updates the dom to account for row updates.
-
contractTable
- (instance) Hides table rows if the table can be expanded.
-
expandTable
- (instance) Expands the table, revealing hidden table rows, if it can be expanded and has been contracted.
Links
new Count(countEl, opts)
Class constructor.
Methods
Links
new Message(messageElement, options)
Initialises an `o-message` component.
Methods
-
render
- (instance) Render the message.
-
open
- (instance) Open the message.
-
close
- (instance) Close the message.
-
getDataAttributes(messageElement)
- (static) Get the data attributes from the messageElement. If the message is being set up
declaratively, this method is used to extract the data attributes from the DOM.
-
init(rootElement, opts)
- (static) Initialise message component.
Examples
Example #1
To construct all elements on the page with the `data-o-component="o-message"` attribute.
Message.init();
Example #2
To construct a specifc o-message on the page.
const myMessageElement = document.querySelector('.my-message');
const myMessage = new Message(myMessageElement, {});
Example #3
To construct a message which does not already exist on the page.
const errorAlert = new Message(null, {
type: 'alert',
state: 'error',
content: {
highlight: 'Something has gone wrong.',
detail: 'The quick brown fox did not jump over the lazy dogs.'
}
});
Links
new OTable(rootEl, opts)
Constructs an o-table component.
Methods
Links
new Stream(streamEl, opts)
Class constructor.
Methods
Links
MessageOptions
An object of options to configure a message instance.
Properties
-
type
- (type: string)
The o-message type e.g. 'action', 'alert' and 'notice'.
-
state
- (type: string)
The o-message state e.g. `success`, `neutral`, `error`, `inform-inverse`.
-
autoOpen
- (type: boolean)
[true] - Whether to show the message automatically.
-
parentElement
- (type: string)
[null] - The element to append the message to. If none is declared it will leave any existing message elements in place or append to the body when creating a new message element.
-
content
- (type: object)
Configuration for the message copy.
-
content.detail
- (type: string)
Copy for of the message e.g "Thing saved to the place you requested.".
-
content.highlight
- (type: string)
[null] - Highlighted copy to prepend the main message copy "Success!".
-
content.additionalInfo
- (type: string)
[null] - More copy with additional information – only applies to a message with an `inner` layout.
-
actions
- (type: Object)
Links to display on the message.
-
actions.primary
- (type: Object)
Show a link in the style of a primary button within the message.
-
actions.primary.text
- (type: string)
The copy for the link.
-
actions.primary.url
- (type: string)
The url for the link.
-
actions.primary.openInNewWindow
- (type: boolean)
[false] - Opens in a new tab/window when set to `true`.
-
actions.secondary
- (type: Object)
Show a link with less emphasis that the primary action.
-
actions.secondary.text
- (type: string)
The copy for the link.
-
actions.secondary.url
- (type: string)
The url for the link.
-
actions.secondary.openInNewWindow
- (type: boolean)
[false] - Opens in a new tab/window when set to `true`.
-
close
- (type: boolean)
[true] - Whether or not to display a close button.
Type
object
Links
OTableOptions
Table options.
Properties
-
sortable
- (type: boolean)
[true] - Disable the table's sort feature.
-
expanded
- (types: undefined | types: boolean)
[Undefined] - Allow the "OverflowTable" to hide results behind a "show more" button. The table is expanded by default when "true", contracted when "false", or not expandable if not set.
-
minimumRowCount
- (type: number)
[20] - When the `expanded` option is set, the number of rows to show when the table is not expanded.
Type
object
Links
TableSorter#sortRowsByColumn(...)
Instance Method
Sort the given table.
Returns
Links
BaseTable#updateRows
Instance Method
Update the o-table instance with rows added or removed dynamically from
the table. Applies any existing sort and filter to new rows.
Returns
Links
BaseTable#renderRowUpdates
Instance Method
Updates the dom to account for row updates, including when their sort
order changes, or any filter is applied. E.g. changes the dom order,
applies aria-labels to hidden rows, updates the table height to
efficiently hide them.
Note this does not calculate which rows should be sorted or filtered,
and does not look for new rows added to the dom. See updateRows
.
Returns
Links
BaseTable#filter(headerIndex, filter)
Instance Method
Filter the table and render the result.
Returns
Links
BaseTable#sortRowsByColumn(columnIndex, sortOrder)
Instance Method
Sort the table.
Returns
Links
<anonymous>~defaultSort
Inner Property
Fires an "oTable.sorting" event. The sorting event can be cancelled to
provide a totally custom method of sorting the table.
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent
Links
BaseTable#sorted(...)
Instance Method
Indicate that the table has been sorted after intercepting the sorting event.
Links
BaseTable#destroy
Instance Method
Gets the instance ready for deletion.
Removes event listeners that were added during instatiation of the component.
Returns
Links
FlatTable#updateRows
Instance Method
Update the o-table instance with rows added dynamically to the table.
Returns
Links
OverflowTable#filter(headerIndex, filter)
Instance Method
Filter the table.
Returns
Links
OverflowTable#isExpanded
Instance Method
Check if the table is expanded (true) or collapsed (false).
Returns
-
boolean
- is the table expanded?
Links
OverflowTable#isContracted
Instance Method
Check if the table is collapsed (true) or expanded (false).
Returns
-
boolean
- is the table contracted?
Links
OverflowTable#canExpand
Instance Method
Check if the table supports the expand/contract feature.
Returns
-
boolean
- can the table expand and contract?
Links
OverflowTable#renderRowUpdates
Instance Method
Updates the dom to account for row updates.
Returns
Links
OverflowTable#contractTable
Instance Method
Hides table rows if the table can be expanded.
Returns
Links
OverflowTable#expandTable
Instance Method
Expands the table, revealing hidden table rows, if it can be expanded and has been contracted.
Returns
Links
module.exports.message()
Static Method
Build a full message element. Used when there is no message element in the DOM.
Returns
-
HTMLElement
- Returns the new message element
Links
CookieMessage#shouldShowCookieMessage
Instance Method
Checks whether cookie is set
Returns
-
boolean
- - should the cookie message be shown
Links
CookieMessage#showCookieMessage
Instance Method
Displays cookie message banner, based on existing cookies.
Returns
Links
CookieMessage#removeCookieMessage
Instance Method
Removes cookie message banner.
Returns
Links
CookieMessage#destroy
Instance Method
Undo theme and event listeners set on init.
Returns
Links
CookieMessage.getOptionsFromDom(cookieMessageElement)
Static Method
Get the data attributes from the cookieMessageElement. If the cookie message is being set up
declaratively, this method is used to extract the data attributes from the DOM.
Returns
-
Object.<string, any>
- - The options
Links
CookieMessage.init(rootElement, options)
Static Method
Initialise cookie message components.
Returns
-
CookieMessage | Array.<CookieMessage>
- - The newly instantiated CookieMessage (or CookieMessages, if rootElement was not a banner)
Links
Count.getCountLabel(count)
Static Method
Get the aria-label for the count element.
Returns
-
string
- The string that should be used as the aria-label
Links
Message#render
Instance Method
Render the message.
Returns
Links
Message#open
Instance Method
Open the message.
Returns
Links
Message#close
Instance Method
Close the message.
Returns
Links
Message.getDataAttributes(messageElement)
Static Method
Get the data attributes from the messageElement. If the message is being set up
declaratively, this method is used to extract the data attributes from the DOM.
Returns
-
object
- - An object of options defined via data attributes on the message element
Links
Message.init(rootElement, opts)
Static Method
Initialise message component.
Returns
-
Message | Array.<Message>
- The newly constructed message component or components
Links
OTable.init(el, opts)
Static Method
Constructs all o-table components inside the element passed as the first parameter.
Returns
-
Array.<(FlatTable|ScrollTable|OverflowTable|BasicTable)> | FlatTable | ScrollTable | OverflowTable | BasicTable
- - A table instance or array of table instances.
Links
Stream#publishEvent(...)
Instance Method
Emits events that have a valid o-comment event name.
Returns
Links
new OTable(rootEl, opts)
Constructs an o-table component.
Methods
Links
Comments.getDataAttributes(rootEl)
Static Method
Get the data attributes from the element. If the component is being set up declaratively, this method is used to extract the data attributes from the DOM.
Returns
Links