0.1.2 • Published 10 months ago

@googleworkspace/drive-picker-element v0.1.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
10 months ago

npm.io

npm Test Release

Description

A Web Component for Google Drive Picker.

Install

Install using NPM or similar.

npm i @googleworkspace/drive-picker-element
yarn add @googleworkspace/drive-picker-element
pnpm add @googleworkspace/drive-picker-element

Usage

import "@googleworkspace/drive-picker-element";
<drive-picker client-id="YOUR_CLIENT_ID" app-id="YOUR_APP_ID">
  <drive-picker-docs-view
    mime-types="application/json"
    label="JSON"
  ></drive-picker-docs-view>
  <drive-picker-docs-view owned-by-me="" label="Mine"></drive-picker-docs-view>
  <drive-picker-docs-view starred="" label="Starred"></drive-picker-docs-view>
</drive-picker>

See the components and the official reference documentation for more details:

StatusComponentReference Docs
\<drive-picker/>PickerBuilder API Reference
\<drive-picker-docs-view/>DocsView API Reference
❌ - ToDo\<drive-picker-docs-upload-view/>DocsUploadView API Reference

To report issues or feature requests for the underlying Drive Picker, please use the issue tracker.

drive-picker

The drive-picker web component provides a convenient way to integrate the Google Picker API into your web applications. The Google Picker API is a JavaScript API that allows users to select or upload Google Drive files. This component acts as a "File Open" dialog for accessing and interacting with files stored on Google Drive.

Features:

  • Provides a similar look-and-feel to the Google Drive UI.
  • Offers several views showing previews and thumbnail images of Drive files.
  • Displays as an inline, modal window, ensuring users never leave the main application.

Note: The Google Picker API does not support file organization, moving, or copying. For these operations, you should use either the Google Drive API or the Drive UI.

Example

<drive-picker
  app-id="675807958095"
  client-id="675807958095-nsptdcn5qdb6pl44cge1c6ghact9t5q0.apps.googleusercontent.com"
>
  <drive-picker-docs-view></drive-picker-docs-view>
</drive-picker>

Properties

PropertyAttributeTypeDefaultDescription
appIdapp-idstringThe Google Drive app ID.
clientIdclient-idstringThe Google API client ID.
developerKeydeveloperKeystring \| undefinedThe Google API developer key.
heightheightnumber \| undefinedThe height of the picker dialog.
hideTitleBarhide-title-barboolean \| undefinedWhether to hide the title bar of the picker dialog.
localelocalestring \| undefinedThe locale of the picker dialog.
maxItemsmax-itemsnumber \| undefinedThe maximum number of items that the user can select.
multiselectmultiselectboolean \| undefinedWhether the user can select multiple items.
oauthTokenoauth-tokenstring \| undefinedThe OAuth token to authenticate the user.
originoriginstring \| undefinedThe origin of the picker dialog.
relayUrlrelay-urlstring \| undefinedThe relay URL to use for cross-origin communication.
scopescopestring"https://www.googleapis.com/auth/drive.file"The scope of the OAuth token.
titletitlestring""The title of the picker dialog.
visiblevisiblebooleantrueWhether the picker dialog is visible.
widthwidthnumber \| undefinedThe width of the picker dialog.

Methods

MethodType
addEventListener(type: "cancel" \| "picked", listener: (ev: CustomEvent<ResponseObject>): void, options?: boolean \| AddEventListenerOptions \| undefined) => void
removeEventListener(type: "cancel" \| "picked", listener: (ev: CustomEvent<ResponseObject>): void, options?: boolean \| EventListenerOptions \| undefined) => void

Events

EventTypeDescription
cancelCustomEvent<google.picker.ResponseObject>Triggered when the user cancels the picker dialog.
pickedCustomEvent<google.picker.ResponseObject>Triggered when the user picks one or more items.

Slots

NameDescription
The View elements to display in the picker. Each View element should implement a property view of type google.picker.View.

drive-picker-docs-view

The drive-picker-docs-view element is used to define a view for the Google Drive Picker.

Example

<drive-picker-docs-view ownedByMe=""></drive-picker-docs-view>

Properties

PropertyAttributeModifiersTypeDefaultDescription
enableDrivesenable-drivesboolean \| undefinedIndicates whether to enable drives in the view.
includeFoldersinclude-foldersboolean \| undefinedIndicates whether to include folders in the view.
labellabelstring \| undefinedThe label of the view.
mimeTypesmime-typesstring \| undefinedThe MIME types to filter the view by.
modemode"GRID" \| "LIST""GRID"The mode of the view. This should be one of the values of the google.picker.DocsViewMode enum.
ownedByMeowned-by-meboolean \| undefinedIndicates whether to show only files owned by the user in the view.
parentparentstring \| undefinedThe ID of the parent folder to restrict the view to.
queryquerystring \| undefinedThe query string to filter the view by.
selectFolderEnabledselect-folder-enabledboolean \| undefinedIndicates whether selecting folders is enabled in the view.
starredstarredboolean \| undefinedIndicates whether to show only starred files in the view.
viewreadonlyDocsViewGets the Google Drive Picker view based on the current property values.
viewIdview-id"DOCS" \| "DOCS_IMAGES" \| "DOCS_IMAGES_AND_VIDEOS" \| "DOCS_VIDEOS" \| "DOCUMENTS" \| "DRAWINGS" \| "FOLDERS" \| "FORMS" \| "IMAGE_SEARCH" \| "PDFS" \| "PHOTO_ALBUMS" \| "PHOTO_UPLOAD" \| ... 6 more ... \| "YOUTUBE""DOCS"The ID of the view. This should be one of the values of thegoogle.picker.ViewId enum.Note: The default value is DOCS which corresponds to thegoogle.picker.ViewId.DOCS enum value in the Google Drive Picker API andcorresponsds to all Google Drive document types.

Development

pnpm install
pnpm build
pnpm serve
pnpm storybook
0.1.2

10 months ago

0.1.1

10 months ago

0.1.0

11 months ago

0.0.0

11 months ago