Skip to content

Commit

Permalink
Moved option types to a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
paulosabayomi committed Mar 6, 2024
1 parent a952ccf commit ac80597
Show file tree
Hide file tree
Showing 13 changed files with 423 additions and 1,041 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 1.1.1 (2024-03-05)

- New: Moved the option types to a new file
- New: Added option types to the `setOptions` method

## 1.1.0 (2024-03-05)

- New: CustUp now extends `EventTarget` and it can now trigger events, and events triggered by CustUp can be listened for by calling the `addEventListener` or the `on` method
Expand Down
3 changes: 2 additions & 1 deletion __test__/custup.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import CustUp from '../src/custup'
import {ICustUpOptions} from '../types/types'

const instance1 = new CustUp({} as ICustUpOptions);
const instance2 = new CustUp({autoInitialize: false} as ICustUpOptions);

expectType<CustUp>(instance1);
expectType<CustUp | undefined>(instance1.initializeUI());
expectType<CustUp | undefined>(instance2.initializeUI());
391 changes: 7 additions & 384 deletions core/custupCore.d.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/custupCore.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

132 changes: 7 additions & 125 deletions core/custupCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,130 +352,9 @@ export default class CustUpCore extends EventTarget {
/**
* Pass parameters
*
* @param {{
* _custupDefaultUploadSentence?: string;
* disable_scrollbar?: boolean;
* persist_default_ui?: boolean;
* use_default_file_display_ui?: boolean;
* show_preview_file_btn?: boolean;
* autoInitialize?: boolean;
* show_file_remove_btn?: boolean;
* show_file_details_container?: boolean;
* file_source_icons?: {[key in 'video_camera' | 'capture_image' | 'record_audio' | 'record_screen' | 'url_source' | 'google_drive_source' | 'dropbox_source' | 'box_source' | 'openai_dalle_source']: any};
* css_font_link?: string;
* css_font_name?: string;
* external_source_style_override?: typeof external_sources_ui_styles;
* media_capture_source_style_override?: typeof media_capture_ui_styles;
* default_styles_override?: typeof ui_styles;
* persist_styles_override_across_instances?: boolean;
* default_icons_override?: typeof icons;
* allowed_file_types?: (keyof file_types)[];
* targetRootElement: string;
* maxNumberOfFiles?: number;
* minNumberOfFiles?: number;
* minimumAllowedFileSize?: number;
* maximumAllowedFileSize?: number;
* ui_type?: 'default' | 'resumeUploaderUI' | 'bare' | 'detached' | 'profilePicture' | 'elegant';
* display_ui_tools?: boolean;
* disable_drag_n_drop?: boolean;
* disable_select_files_from_device?: boolean;
* allowed_tools?: Array<'upload' | 'add_file' | 'added_files_count' | 'clear_files'>;
* position_container?: "before" | "after" | "overwrite" | {"beforeEl": string};
* file_preview_animation_types?: Array<'slideInRight' | 'slideInTop' | 'slideInLeft' | 'slideInBottom' | 'zoomIn' | 'fadeIn'>;
* allowMultipleUpload?: boolean;
* file_upload_settings?: {
* endpoint_url: string;
* files_field_name: string;
* form_field?: HTMLFormElement | string;
* additional_data?: object;
* axios_settings: {
* headers: {};
* configs: {};
* };
* chunk_size: number;
* should_chunk: boolean;
* };
* allowed_sources?: Array<'record_video' | 'capture_image' | 'record_audio' | 'record_screen' | 'link_source' | 'google_drive_source' | 'dropbox_source' | 'box_source' | 'openai_dalle_source'>;
* display_file_sources?: boolean;
* upload_automatically?: boolean;
* show_upload_error_overlay?: boolean;
* show_upload_progress_bar?: boolean;
* file_source_config?: {
* video_recording: {
* video_only: boolean;
* show_image_capture_btn: boolean;
* };
* capture_image: {
* };
* record_audio: {
* };
* record_screen: {
* };
* url_source: {
* };
* google_drive_source: {
* authConfig: {
* client_id: string;
* api_key: string;
* app_id: string;
* scopes: string;
* };
* };
* dropbox_source: {
* authConfig: {
* appKey: string;
* };
* options: {
* cancel: Function;
* };
* };
* box_source: {
* authConfig: {
* developerToken: string;
* cssLink: string;
* jsLink: string;
* folder_id: string;
* };
* pickerConfig: {
* chooseButtonLabel?: string;
* sortBy?: 'name' | 'date';
* sortDirection?: 'ASC' | 'DESC';
* logoUrl?: string;
* canUpload?: boolean;
* canSetShareAccess?: boolean;
* canCreateNewFolder?: boolean;
* sharedLink?: string;
* sharedLinkPassword?: string;
* modal?: string;
* size?: 'large' | 'small';
* isTouch?: boolean;
* autoFocus?: boolean;
* defaultView?: 'files' | 'recents';
* cancelButtonLabel?: string;
* requestInterceptor?: Function;
* responseInterceptor?: Function;
* }
* };
* openai_dalle_source: {
* endpoint: string;
* api_key: string;
* size: "1024x1024" | "1024x1792" | "1792x1024";
* n: number;
* model: "dall-e-3" | "dall-e-2";
* quality: "standard" | "hd";
* };
* };
* default_files?: Array<{file: string | File | Blob; isUploadable: boolean; headers: any}>;
* count_default_files?: boolean;
* instance_attach?: Array<object>;
* single_upload?: boolean;
* persist_files?: boolean;
* persist_type?: 'soft' | 'hard';
* alert_timeout_time?: number;
* messages?: {
* timeout?: number;
* };
* }} passedOptions
* @typedef {import('../types/types-jsdoc.js').TCustupOptions} TCustupOptions
*
* @param {TCustupOptions} passedOptions
*
* @param autoInitialize - Whether to automatically initialize the library
*
Expand Down Expand Up @@ -622,7 +501,8 @@ export default class CustUpCore extends EventTarget {

/**
* @public @method setOptions
* @param {Object} option - The option(s) to update
* @typedef {import('../types/types-jsdoc.js').TCustupOptions} TCustupOptions
* @param {TCustupOptions} option - The option(s) to update
* @param {boolean} [no_update=false] - To set whether the function that needs to be called for some options to be updated should be called, the functions are called by default
* @returns {void}
*/
Expand All @@ -648,6 +528,8 @@ export default class CustUpCore extends EventTarget {
this.load_default_files();
}else if (key === 'default_icons_override') {
this.map_override_icons_to_default_icons();
}else if (key === '_custupDefaultUploadSentence') {
this.uploadSentenceEl.innerHTML = this.options._custupDefaultUploadSentence;
}else if (key === "default_styles_override" || key === "persist_styles_override_across_instances") {
this.map_override_styles_to_default_styles();
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "custup",
"version": "1.1.0",
"version": "1.1.1",
"description": "Highly customisable file upload library with zero dependencies",
"main": "src/custup.min.js",
"scripts": {
Expand Down
Loading

0 comments on commit ac80597

Please sign in to comment.