ContentSelectorElement
ContentSelectorElement is a custom HTML element that displays a modal dialog for browsing,
opening, and saving SAS Viya content. The dialog is hidden until it is opened with the open
method. This element extends
HTMLElement.
Custom Element Tag
<button id="openButton">Choose a report</button>
<sas-content-selector
id="selector"
url="http://my-viya-server.com"
mode="open"
></sas-content-selector>
const selector = document.getElementById('selector');
document.getElementById('openButton').onclick = () => selector.open();
selector.onCommit = (context) => {
console.log(context.selection);
};
Attributes
mode: string
Specify the behavior of the dialog, which determines the available actions and what the user is able
to commit. The default is open.
Values
open
Browse and select a file to open.
save
Choose a folder and a name to save a file.
selectItem
Select a single content item.
selectLocation
Select a folder location only.
selectAny
Select any content item or folder.
addToLocation
Select a folder to add content into.
manage
Browse and manage content without a commit action.
title: string
The title of the dialog. If it is not specified, a localized default that is based on the mode is
used.
default-save-name: string
The name that is prefilled in the name field when mode="save".
disable-trash: boolean
Specify whether the Recycle Bin should be suppressed in the dialog. Since HTML attributes don't support booleans, only the presence of this attribute is required to enable it.
multi-select: boolean
Specify whether multiple items can be committed at once. Since HTML attributes don't support booleans, only the presence of this attribute is required to enable it.
url
See url.
authentication-type
See authenticationType.
Properties
isOpen: boolean
Whether the dialog is currently open. Setting this property shows or hides the dialog, and is
equivalent to calling the open and close methods.
onSelect: (selections: Item[]) => void
A callback function that can be used to respond to the selection changing within the dialog. This is called as the user browses, before the selection is committed.
Arguments
selections: Item[]
The Items that are currently selected.
onCommit: (context) => void
A callback function that is called when the user confirms the dialog, such as by choosing Open or Save.
Arguments
context.selection?: Item
The primary selected Item, if there is one.
context.selections: Item[]
All of the selected Items.
context.location?: Item
The Item representing the folder that the selection was made in. In save mode, this is
the target folder.
context.name: string
The name of the selected item, or the name that was entered in save mode.
context.type: string | undefined
The SAS content type of the committed item.
onDismiss: () => void
A callback function that is called when the user cancels the dialog. If it is not supplied, the
dialog closes itself. If you supply a handler, you are responsible for closing the dialog by calling
close.
Methods
open: () => void
Opens the dialog.
close: () => void
Closes the dialog.