Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve findDOMElement and UIPluginOptions types #4946

Merged
merged 7 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/@uppy/audio/src/Audio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import locale from './locale.ts'
import packageJson from '../package.json'

interface AudioOptions extends UIPluginOptions {
target?: HTMLElement | string
showAudioSourceDropdown?: boolean
}
interface AudioState {
Expand Down
13 changes: 8 additions & 5 deletions packages/@uppy/core/src/UIPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,14 @@ function debounce<T extends (...args: any[]) => any>(
}
}

export interface UIPluginOptions extends PluginOpts {
replaceTargetContent?: boolean
direction?: 'ltr' | 'rtl'
}

/**
* UIPlugin is the extended version of BasePlugin to incorporate rendering with Preact.
* Use this for plugins that need a user interface.
*
* For plugins without an user interface, see BasePlugin.
*/
class UIPlugin<
// eslint-disable-next-line no-use-before-define
Opts extends UIPluginOptions,
M extends Meta,
B extends Body,
Expand Down Expand Up @@ -91,6 +87,7 @@ class UIPlugin<
): HTMLElement {
const callerPluginName = plugin.id

// eslint-disable-next-line no-use-before-define
Murderlon marked this conversation as resolved.
Show resolved Hide resolved
const targetElement = findDOMElement(target)

if (targetElement) {
Expand Down Expand Up @@ -204,3 +201,9 @@ export type PluginTarget<M extends Meta, B extends Body> =
| typeof BasePlugin
| typeof UIPlugin
| BasePlugin<any, M, B>

export interface UIPluginOptions extends PluginOpts {
target?: PluginTarget<any, any>
replaceTargetContent?: boolean
direction?: 'ltr' | 'rtl'
}
2 changes: 1 addition & 1 deletion packages/@uppy/core/src/Uppy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import locale from './locale.ts'

import type BasePlugin from './BasePlugin.ts'
import type UIPlugin from './UIPlugin.ts'

Check warning on line 45 in packages/@uppy/core/src/Uppy.ts

View workflow job for this annotation

GitHub Actions / Lint JavaScript/TypeScript

'UIPlugin' is defined but never used
import type { Restrictions } from './Restricter.ts'

type Processor = (fileIDs: string[], uploadID: string) => Promise<void> | void
Expand Down Expand Up @@ -1910,7 +1910,7 @@
* Passes messages to a function, provided in `opts.logger`.
* If `opts.logger: Uppy.debugLogger` or `opts.debug: true`, logs to the browser console.
*/
log(message: string | Record<string, unknown> | Error, type?: string): void {
log(message: string | Record<any, any> | Error, type?: string): void {
const { logger } = this.opts
switch (type) {
case 'error':
Expand Down
1 change: 0 additions & 1 deletion packages/@uppy/image-editor/src/ImageEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ declare module '@uppy/core' {
}

interface Opts extends UIPluginOptions {
target?: string | HTMLElement
quality?: number
cropperOptions?: Cropper.Options & {
croppedCanvasOptions?: Cropper.GetCroppedCanvasOptions
Expand Down
1 change: 0 additions & 1 deletion packages/@uppy/status-bar/src/StatusBarOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { UIPluginOptions } from '@uppy/core/lib/UIPlugin'
import type StatusBarLocale from './locale.ts'

export interface StatusBarOptions extends UIPluginOptions {
target?: HTMLElement | string
showProgressDetails?: boolean
hideUploadButton?: boolean
hideAfterFinish?: boolean
Expand Down