2.0.0 • Published 4 years ago

spfx-async-dropdown v2.0.0

Weekly downloads
12
License
MIT
Repository
github
Last release
4 years ago

spfx-async-dropdown

CI Status npm version

Asynchronous dropdown component for the SPFx property pane

Screenshot

Installation

npm install spfx-async-dropdown
import { PropertyPaneAsyncDropdown } from "spfx-async-dropdown"

Examples

Get lists that are in the root web using pnpjs

new PropertyPaneAsyncDropdown("list", {
    label: "List",
    onLoad: async () => {
        const lists = await sp.site.rootWeb.lists.select("Id", "Title").get();
        return lists.map(list => {
            return {
                key: list.Id,
                text: list.Title
            }
        })
    },
    onPropertyChange: (property: string, newValue: any) => {
        const oldValue = get(this.properties, property);
        update(this.properties, property, () => newValue);
        this.onPropertyPaneFieldChanged(property, oldValue, newValue);
        this.render();
    },
    selectedKey: this.properties.list,
    required: true,
    tooltip: {
        content: "Testing Tooltip",
        iconName: "List"
    },
    placeholder: "Select an item...",
    description: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua"
})

Props

PropType
label(required)string
onLoad(required)() => Promise<IDropdownOption[]>
onPropertyChange(required)(property: string, newValue: any) => void
selectedKey(required)string or number
disabledboolean
requiredboolean
tooltipIToolTip ({ content: string, iconName: string}). iconName is a Fabric icon
placeholderstring
descriptionstring