@ichicraft/widgets-widget-base 1.8.9 → 1.8.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,6 +9,14 @@ All notable changes to this project will be documented here.
9
9
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
10
10
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
11
11
 
12
+ ## 1.8.11 - 2023-04-03
13
+
14
+ - Changed `openFilePicker` function to return more details of the picked file in the shape of `FilePickerFileProps`
15
+
16
+ ## 1.8.10 - 2023-03-30
17
+
18
+ - Changed `openFilePicker` function to accept `options`, to support configuration of picker behavior
19
+
12
20
  ## 1.8.9 - 2023-03-06
13
21
 
14
22
  - Added `registerCustomCommandBarItems` function to the `instance` object of the `WidgetContext` interface, to support multiple custom buttons in the widget header.
@@ -95,7 +95,7 @@ export interface WidgetContext {
95
95
  }) => void;
96
96
  };
97
97
  /**
98
- * Metadata and functions in the context of a widget's definition. A widget definition is
98
+ * Metadata and functions in the context of a widget's variant (fka definition). A widget variant is
99
99
  * a widget that's been installed by an administrator from within the board administration.
100
100
  */
101
101
  definition: {
@@ -116,13 +116,12 @@ export interface WidgetContext {
116
116
  };
117
117
  /**
118
118
  * Metadata and functions in the context of a widget's manifest. A widget manifest contains
119
- * all information of the originally installed widget. If multiple instances of the same widget 'type'
120
- * exist in a widget board configuration, they share this manifest.
121
- * We use the term 'definition' to distinguish each instance of a manifest.
119
+ * all information of the originally installed widget. Multiple `variants` of the same widget `manifest`
120
+ * can exist in a widget board configuration.
122
121
  */
123
122
  manifest: {
124
123
  /**
125
- * Unique id of a widget 'type', also used in the widget manifest in the original script source manifest file.
124
+ * Unique id of a widget 'type', also used in the widget manifest config file in the original script source manifest file.
126
125
  * If this is a 'single instance widget', which means that no more than one instance of this
127
126
  * widget can be installed in the widget board, the id of the definition is the same as the id of the manifest.
128
127
  */
@@ -286,8 +285,10 @@ export interface WidgetContext {
286
285
  loadScript?: <TModule>(url: string, options?: any) => Promise<TModule>;
287
286
  /**
288
287
  * Functionality offered by the widget board to open a File Picker panel to select files.
288
+ * @param onFilePicked Function that's called when a file was picked. Returns the url of the picked file.
289
+ * @param options Options to change the behavior of the file picker
289
290
  */
290
- openFilePicker?: (onFilePicked: (fileUrl: string) => void, onCancel?: () => void) => void;
291
+ openFilePicker?: (onFilePicked: (fileUrl: string, fileProps: FilePickerFileProps) => void, options?: FilePickerOptions) => void;
291
292
  /**
292
293
  * Functionality offered by the widget board to open a url in an iframe dialog.
293
294
  * @param url The url to open in a dialog.
@@ -348,7 +349,7 @@ export interface WidgetManifestConfig {
348
349
  */
349
350
  manifestVersion: number;
350
351
  /**
351
- * Unique id (Guid) to identify the widget
352
+ * Unique id to identify the widget
352
353
  */
353
354
  id: string;
354
355
  /**
@@ -593,5 +594,50 @@ export interface IFrameDialogOptions {
593
594
  */
594
595
  onDismissed?: () => void;
595
596
  }
597
+ /**
598
+ * Options to pass to openFilePicker function
599
+ */
600
+ export interface FilePickerOptions {
601
+ /**
602
+ * Array of file extensions that will be used to filter the files in the picker.
603
+ * @default ['.gif', '.jpg', '.jpeg', '.png']
604
+ */
605
+ extensions?: string[];
606
+ /**
607
+ * Maximum number of files to show in a folder
608
+ * @default 100
609
+ */
610
+ itemsCountQueryLimit?: number;
611
+ /**
612
+ * Whether or not to hide the organisational site files tab
613
+ * @default false
614
+ */
615
+ hideOrganisationalAssetTab?: boolean;
616
+ /**
617
+ * Whether or not to hide the site files tab
618
+ * @default false
619
+ */
620
+ hideSiteFilesTab?: boolean;
621
+ /**
622
+ * Whether or not to hide the upload tab
623
+ * @default false
624
+ */
625
+ hideLocalUploadTab?: boolean;
626
+ /**
627
+ * Function that's called when user closes file picker without picking a file
628
+ * @default undefined
629
+ */
630
+ onCancel?: () => void;
631
+ }
632
+ export interface FilePickerFileProps {
633
+ /**
634
+ * Unique identifier of the file item in SharePoint, in the shape of a Guid.
635
+ */
636
+ uniqueId: string;
637
+ /**
638
+ * Unique identifier of the site in SharePoint, in the shape of a Guid.
639
+ */
640
+ siteId: string;
641
+ }
596
642
  export declare type BoardType = 'shared' | 'personal';
597
643
  export declare type UserRole = 'administrator' | 'board-owner';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ichicraft/widgets-widget-base",
3
- "version": "1.8.9",
3
+ "version": "1.8.11",
4
4
  "description": "Part of the Widget Development Kit for building widgets for Ichicraft Boards",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",