quasar

Форк
0
/
utils.d.ts 
189 строк · 4.6 Кб
1
import { QUploader, LiteralUnion } from "quasar";
2
import {
3
  ComponentOptionsMixin,
4
  ComponentPropsOptions,
5
  ComponentPublicInstance,
6
  DefineComponent,
7
  EmitsOptions,
8
  ExtractPropTypes,
9
  Ref,
10
  SetupContext,
11
} from "vue";
12
import { MetaOptions } from "./meta";
13

14
export * from "./utils/colors";
15
export * from "./utils/date";
16
export * from "./utils/dom";
17
export * from "./utils/event";
18
export * from "./utils/format";
19
export * from "./utils/scroll";
20
export * from "./utils/is";
21
export * from "./utils/patterns";
22
export * from "./utils/run-sequential-promises";
23

24
import { BrandColor } from "./api/color";
25
import { VueStyleObjectProp } from "./api/vue-prop-types";
26

27
interface ExportFileOpts {
28
  mimeType?: string;
29
  byteOrderMark?: string | Uint8Array;
30
  encoding?: string;
31
}
32

33
// others utils
34
export function copyToClipboard(text: string): Promise<void>;
35

36
export function debounce<F extends (...args: any[]) => any>(
37
  fn: F,
38
  wait?: number,
39
  immediate?: boolean,
40
): ((this: ThisParameterType<F>, ...args: Parameters<F>) => void) & {
41
  cancel(): void;
42
};
43

44
export function frameDebounce<F extends (...args: any[]) => any>(
45
  fn: F,
46
): ((this: ThisParameterType<F>, ...args: Parameters<F>) => void) & {
47
  cancel(): void;
48
};
49

50
export function exportFile(
51
  fileName: string,
52
  rawData: string | ArrayBuffer | ArrayBufferView | Blob,
53
  opts?: string | ExportFileOpts,
54
): true | Error;
55

56
export function extend<R>(deep: boolean, target: any, ...sources: any[]): R;
57
export function extend<R>(target: object, ...sources: any[]): R;
58

59
export function openURL<F extends (...args: any[]) => any>(
60
  url: string,
61
  reject?: F,
62
  windowFeatures?: Object,
63
): void;
64

65
export function throttle<F extends (...args: any[]) => any>(
66
  fn: F,
67
  limit: number,
68
): F;
69

70
export function uid(): string;
71

72
interface MorphOptions {
73
  from: Element | string | (() => Element | null | undefined);
74
  to?: Element | string | (() => Element | null | undefined);
75
  onToggle?: () => void;
76
  waitFor?: number | "transitionend" | Promise<any>;
77

78
  duration?: number;
79
  easing?: string;
80
  delay?: number;
81
  fill?: string;
82

83
  style?: string | VueStyleObjectProp;
84
  classes?: string;
85

86
  resize?: boolean;
87
  useCSS?: boolean;
88
  hideFromClone?: boolean;
89
  keepToClone?: boolean;
90

91
  tween?: boolean;
92
  tweenFromOpacity?: number;
93
  tweenToOpacity?: number;
94

95
  onEnd?: (direction: "to" | "from", aborted: boolean) => void;
96
}
97

98
export function morph(options: MorphOptions): (abort?: boolean) => boolean;
99

100
export function getCssVar(
101
  varName: LiteralUnion<BrandColor>,
102
  element?: Element,
103
): string | null;
104

105
export function setCssVar(
106
  varName: LiteralUnion<BrandColor>,
107
  value: string,
108
  element?: Element,
109
): void;
110

111
interface Callbacks {
112
  [key: string]: (...args: any[]) => void;
113
}
114

115
export class EventBus<T extends Callbacks = Callbacks> {
116
  on<K extends keyof T>(
117
    event: K,
118
    callback: T[K],
119
    ...ctx: unknown extends ThisParameterType<T[K]>
120
      ? []
121
      : [ctx: ThisParameterType<T[K]>]
122
  ): this;
123
  once<K extends keyof T>(
124
    event: K,
125
    callback: T[K],
126
    ...ctx: unknown extends ThisParameterType<T[K]>
127
      ? []
128
      : [ctx: ThisParameterType<T[K]>]
129
  ): this;
130
  emit<K extends keyof T>(event: K, ...args: Parameters<T[K]>): this;
131
  off<K extends keyof T>(event: K, callback?: T[K]): this;
132
}
133

134
interface CreateMetaMixinContext extends ComponentPublicInstance {
135
  [index: string]: any;
136
}
137

138
export function createMetaMixin<
139
  CustomInstanceProperties extends Record<string, any> = {},
140
>(
141
  options:
142
    | MetaOptions
143
    | ((
144
        this: CreateMetaMixinContext & CustomInstanceProperties,
145
      ) => MetaOptions),
146
): ComponentOptionsMixin;
147

148
interface InjectPluginFnHelpers {
149
  queuedFiles: Ref<File[]>;
150
  uploadedFiles: Ref<File[]>;
151
  uploadedSize: Ref<number>;
152
  updateFileStatus: (
153
    file: File,
154
    status: "failed" | "idle" | "uploaded" | "uploading",
155
    uploadedSize?: number,
156
  ) => void;
157
  isAlive: () => boolean;
158
}
159

160
interface InjectPluginFnOptions<Props> {
161
  props: ExtractPropTypes<Props>;
162
  emit: SetupContext["emit"];
163
  helpers: InjectPluginFnHelpers;
164
  exposeApi: (api: Record<string, any>) => void;
165
}
166

167
interface InjectPluginFnReturn {
168
  isUploading: Ref<boolean>;
169
  isBusy: Ref<boolean>;
170
  abort: () => void;
171
  upload: () => void;
172
}
173

174
interface CreateUploaderComponentOptions<
175
  Props extends ComponentPropsOptions = {},
176
  Emits extends EmitsOptions = [],
177
> {
178
  name: string;
179
  props?: Props;
180
  emits?: Emits;
181
  injectPlugin(options: InjectPluginFnOptions<Props>): InjectPluginFnReturn;
182
}
183

184
export function createUploaderComponent<
185
  Props extends ComponentPropsOptions = {},
186
  Emits extends EmitsOptions = [],
187
>(
188
  options: CreateUploaderComponentOptions<Props, Emits>,
189
): QUploader & DefineComponent<Props, {}, {}, {}, {}, {}, {}, Emits>;
190

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.