🤖 Merge PR #62164 [filestack-react]: New definition by @philting

* added filestack-react definitions

* fixed dt-header error

* changed export syntax for filestack-js
This commit is contained in:
Phil Ting
2022-09-10 21:37:34 -07:00
committed by GitHub
parent 6ed6d08ebe
commit 2e539bf761
5 changed files with 122 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
import * as React from 'react';
import { PickerInline, PickerOverlay, PickerDropPane, client } from 'filestack-react';
import type { ClientOptions, PickerFileMetadata, PickerOptions } from 'filestack-js';
const mockClientOptions: ClientOptions = {};
const mockPickerOptions: PickerOptions = {};
const mockApiKey = 'API_KEY';
const mockAction = (result: PickerFileMetadata) => {
/* do nothing */
};
export const MockInline = () => (
<PickerInline
apikey={mockApiKey}
pickerOptions={mockPickerOptions}
clientOptions={mockClientOptions}
onSuccess={mockAction}
onUploadDone={mockAction}
onError={mockAction}
/>
);
export const MockOverlay = () => (
<PickerOverlay
apikey={mockApiKey}
pickerOptions={mockPickerOptions}
clientOptions={mockClientOptions}
onSuccess={mockAction}
onUploadDone={mockAction}
onError={mockAction}
/>
);
export const MockDropPane = () => (
<PickerDropPane
apikey={mockApiKey}
pickerOptions={mockPickerOptions}
clientOptions={mockClientOptions}
onSuccess={mockAction}
onUploadDone={mockAction}
onError={mockAction}
/>
);
client.init(mockApiKey); // $ExpectType Client

44
types/filestack-react/index.d.ts vendored Normal file
View File

@@ -0,0 +1,44 @@
// Type definitions for filestack-react 4.0
// Project: https://github.com/filestack/filestack-react
// Definitions by: Phil Ting <https://github.com/philting>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as React from 'react';
import { ClientOptions, PickerFileMetadata, PickerOptions } from 'filestack-js';
export * as client from 'filestack-js';
interface PickerBaseProps {
/**
* Filestack api key
*/
apikey: string;
/**
* https://filestack.github.io/filestack-js/interfaces/clientoptions.html
*/
pickerOptions?: PickerOptions;
/**
* https://filestack.github.io/filestack-js/interfaces/pickeroptions.html
*/
clientOptions?: ClientOptions;
/**
* A function to be called after successful completed action
* @deprecated
*/
onSuccess?: (result: PickerFileMetadata) => void;
/**
* Called when all files have been uploaded
*/
onUploadDone?: (result: PickerFileMetadata) => void;
/**
* A function to be called when error occurs
*/
onError?: (error: PickerFileMetadata) => void;
}
export type PickerInlineProps = PickerBaseProps;
export type PickerOverlayProps = PickerBaseProps;
export type PickerDropPaneProps = PickerBaseProps;
export const PickerInline: React.FC<PickerInlineProps>;
export const PickerOverlay: React.FC<PickerOverlayProps>;
export const PickerDropPane: React.FC<PickerDropPaneProps>;

View File

@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"filestack-js": "^3.20.0"
}
}

View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react"
},
"files": [
"index.d.ts",
"filestack-react-tests.tsx"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }