@apia/api 3.0.9 → 3.0.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/dist/index.d.ts +135 -8
- package/dist/index.js +533 -23
- package/dist/index.js.map +1 -1
- package/package.json +11 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { AxiosResponse, AxiosRequestConfig } from 'axios';
|
|
4
|
-
import
|
|
4
|
+
import * as _apia_util from '@apia/util';
|
|
5
|
+
import { TApiaFilter, TModify, TApiaLoad, TApiaFormElement, TApiaFilterOption, TApiaFunction, TApiaFunctionPageInfo } from '@apia/util';
|
|
5
6
|
import { TNotificationMessage, notify } from '@apia/notifications';
|
|
6
|
-
import { TModal } from '@apia/components';
|
|
7
|
+
import { TModal, TOpenModal, ApiaUtilModalHandler } from '@apia/components';
|
|
7
8
|
import QueryString from 'qs';
|
|
8
|
-
import { TResponsiveTableColumn } from '@apia/table';
|
|
9
|
+
import { TResponsiveTableColumn, TResponsiveTableContextProps, TResponsiveTableRow, TResponsiveTableRowsSelectionEvent, TResponsiveTableSortChangeEvent } from '@apia/table';
|
|
10
|
+
import * as lodash from 'lodash';
|
|
11
|
+
import * as theme_ui from 'theme-ui';
|
|
9
12
|
|
|
10
13
|
declare function getConfig<LoadType>(outerBehaveConfig?: IApiaApiRequestConfig<LoadType>): IApiaApiRequestConfig<unknown> & IApiaApiRequestConfig<LoadType> & Partial<IApiaApiRequestConfig<unknown>>;
|
|
11
14
|
type TApiaApiAxiosResponse<LoadType> = AxiosResponse<LoadType | null> & {
|
|
@@ -245,14 +248,14 @@ type TApiaApiMethodHandler = {
|
|
|
245
248
|
reset: () => void;
|
|
246
249
|
setError: typeof notify;
|
|
247
250
|
setMessage: (message: Record<string, unknown>) => unknown;
|
|
248
|
-
setState: React.Dispatch<React.SetStateAction<IApiaApiHandlerState>>;
|
|
251
|
+
setState: React$1.Dispatch<React$1.SetStateAction<IApiaApiHandlerState>>;
|
|
249
252
|
state: IApiaApiHandlerState;
|
|
250
253
|
setValue: (name: string, value: string) => void;
|
|
251
254
|
};
|
|
252
255
|
type TApiaApiMethod = (handler: TApiaApiMethodHandler, props: TMethod['props']) => Promise<void> | void;
|
|
253
256
|
type TApiaApiField = TApiaApiMethodHandler & {
|
|
254
257
|
element: TModify<TApiaFormElement, {
|
|
255
|
-
onChange: React.ChangeEventHandler;
|
|
258
|
+
onChange: React$1.ChangeEventHandler;
|
|
256
259
|
}>;
|
|
257
260
|
};
|
|
258
261
|
type TStoredApiaApiMethod = (props?: TMethod['props']) => unknown;
|
|
@@ -277,7 +280,7 @@ interface IApiaApiHandlerState {
|
|
|
277
280
|
errors: Record<string, string>;
|
|
278
281
|
windowIndex: number;
|
|
279
282
|
}
|
|
280
|
-
declare const ApiaApiHandler: React.MemoExoticComponent<() => React.JSX.Element>;
|
|
283
|
+
declare const ApiaApiHandler: React$1.MemoExoticComponent<() => React$1.JSX.Element>;
|
|
281
284
|
|
|
282
285
|
declare global {
|
|
283
286
|
interface Window {
|
|
@@ -294,5 +297,129 @@ declare global {
|
|
|
294
297
|
* */
|
|
295
298
|
declare const getModal: (path: string) => React__default.LazyExoticComponent<React__default.ComponentType<TApiaApiField>>;
|
|
296
299
|
|
|
297
|
-
|
|
300
|
+
type TFilter = {
|
|
301
|
+
avoidLabel?: boolean;
|
|
302
|
+
column?: string;
|
|
303
|
+
errorMessage?: string;
|
|
304
|
+
id: string;
|
|
305
|
+
isAdditional?: boolean;
|
|
306
|
+
isHidden?: boolean;
|
|
307
|
+
onChange?: (queryController: QueryController) => unknown;
|
|
308
|
+
options?: TApiaFilterOption[];
|
|
309
|
+
placeholder?: string;
|
|
310
|
+
readonly?: boolean;
|
|
311
|
+
required?: boolean;
|
|
312
|
+
runAutomatically?: boolean;
|
|
313
|
+
title?: string;
|
|
314
|
+
tooltip?: string;
|
|
315
|
+
type?: 'date' | 'D' | 'S' | 'number' | 'N' | 'apiaNumber' | 'triple' | 'dateHour';
|
|
316
|
+
value: any;
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
type FilterState = TFilter;
|
|
320
|
+
declare class Filter {
|
|
321
|
+
filterState: FilterState;
|
|
322
|
+
constructor(properties: TFilter);
|
|
323
|
+
Component: (({ filter }: {
|
|
324
|
+
filter: TApiaFilter;
|
|
325
|
+
}) => React$1.JSX.Element) & {
|
|
326
|
+
displayName: string;
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
type TableControllerState = {
|
|
331
|
+
columns: Map<string, TResponsiveTableColumn>;
|
|
332
|
+
filters: Map<string | number, Filter>;
|
|
333
|
+
pagination: {
|
|
334
|
+
currentPage: number;
|
|
335
|
+
totalPages: number;
|
|
336
|
+
totalRecords: number;
|
|
337
|
+
};
|
|
338
|
+
props: Omit<TResponsiveTableContextProps, 'FiltersRenderer' | 'SelectionHandler' | 'filters' | 'columns' | 'rows' | keyof TableControllerEvents>;
|
|
339
|
+
rows: TResponsiveTableRow[];
|
|
340
|
+
};
|
|
341
|
+
type TableControllerEvents = {
|
|
342
|
+
onChangeSelection: TResponsiveTableRowsSelectionEvent;
|
|
343
|
+
onFilterBlur: TApiaFilter;
|
|
344
|
+
onFilterChange: TApiaFilter;
|
|
345
|
+
onFilterPressEnter: TApiaFilter;
|
|
346
|
+
onPage: number;
|
|
347
|
+
onRefresh: null;
|
|
348
|
+
onRowClick: TResponsiveTableRowsSelectionEvent[number];
|
|
349
|
+
onSelectRows: TResponsiveTableRowsSelectionEvent;
|
|
350
|
+
onSortChange: TResponsiveTableSortChangeEvent;
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
declare class TableController {
|
|
354
|
+
private emitter;
|
|
355
|
+
private tableName;
|
|
356
|
+
private tableSelectionController;
|
|
357
|
+
private controllerComponent;
|
|
358
|
+
state: TableControllerState;
|
|
359
|
+
constructor(initialState?: Partial<TableControllerState>);
|
|
360
|
+
Context: (({ children }: {
|
|
361
|
+
children: React.ReactNode;
|
|
362
|
+
}) => React$1.JSX.Element) & {
|
|
363
|
+
displayName: string;
|
|
364
|
+
};
|
|
365
|
+
getTableName(): string;
|
|
366
|
+
Pagination: (() => React$1.JSX.Element) & {
|
|
367
|
+
displayName: string;
|
|
368
|
+
};
|
|
369
|
+
Table: React$1.MemoExoticComponent<React$1.ForwardRefExoticComponent<theme_ui.BoxProps & React$1.RefAttributes<HTMLDivElement>>>;
|
|
370
|
+
on<K extends keyof TableControllerEvents>(ev: K, cb: (e: TableControllerEvents[K]) => unknown): _apia_util.UnSubscriber;
|
|
371
|
+
updateState(newState: Partial<TableControllerState> | ((currentState: TableControllerState) => void)): void;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
type QueryControllerStructure = {
|
|
375
|
+
columns: TResponsiveTableColumn[];
|
|
376
|
+
description: string;
|
|
377
|
+
filters: TFilter[];
|
|
378
|
+
hasAdditionalInformation: boolean;
|
|
379
|
+
isDynamic: boolean;
|
|
380
|
+
openFiltersAutomatically: boolean;
|
|
381
|
+
runFiltersAutomatically: boolean;
|
|
382
|
+
title: string;
|
|
383
|
+
};
|
|
384
|
+
declare abstract class QueryController {
|
|
385
|
+
ajaxUrl: string;
|
|
386
|
+
private hasInited;
|
|
387
|
+
private initializing;
|
|
388
|
+
structure: QueryControllerStructure | null;
|
|
389
|
+
tableController: TableController;
|
|
390
|
+
constructor(ajaxUrl: string);
|
|
391
|
+
private initEvents;
|
|
392
|
+
protected getLoadStructureParameters(): Record<string, unknown>;
|
|
393
|
+
protected getPageParameters(): Record<string, unknown>;
|
|
394
|
+
protected getRefreshParameters(): Record<string, unknown>;
|
|
395
|
+
protected getSortParameters(): Record<string, unknown>;
|
|
396
|
+
protected parseLoadStructureResponse(response: Record<string, unknown>): QueryControllerStructure;
|
|
397
|
+
protected parseRefreshResponse(response?: TApiaFunction | null): void;
|
|
398
|
+
protected getStructure(): Promise<QueryControllerStructure>;
|
|
399
|
+
protected parseStructure(structure: QueryControllerStructure): void;
|
|
400
|
+
protected updatePageState(pageInfo?: TApiaFunctionPageInfo): void;
|
|
401
|
+
protected updateRows(rows: TResponsiveTableRow[]): void;
|
|
402
|
+
initialLoad(): Promise<void>;
|
|
403
|
+
page(num: number): Promise<void>;
|
|
404
|
+
protected executeRefresh: lodash.DebouncedFunc<() => Promise<void>>;
|
|
405
|
+
refresh(): Promise<void | undefined>;
|
|
406
|
+
sort(column: string): Promise<void>;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
type QueryModalControllerEvents = Pick<TableControllerEvents, 'onSelectRows'>;
|
|
410
|
+
declare class QueryModalController {
|
|
411
|
+
private emitter;
|
|
412
|
+
protected queryController: QueryController;
|
|
413
|
+
private modalHandler;
|
|
414
|
+
private currentSelection;
|
|
415
|
+
private additionalFiltersController;
|
|
416
|
+
constructor(queryController: QueryController);
|
|
417
|
+
protected getModalDefinition(): TOpenModal;
|
|
418
|
+
getQueryController(): QueryController;
|
|
419
|
+
on<K extends keyof QueryModalControllerEvents>(ev: K, cb: (e: QueryModalControllerEvents[K]) => unknown): _apia_util.UnSubscriber;
|
|
420
|
+
openModal: (properties?: TOpenModal) => Promise<void>;
|
|
421
|
+
getModalHandler(): ApiaUtilModalHandler | null;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export { ApiaApi, ApiaApiHandler, type IApiaApiRequestConfig, QueryController, type QueryControllerStructure, QueryModalController, type TApiaApiAxiosResponse, type TApiaApiMethod, type TApiaApiResult, type TFilter, getFunction, getModal, makeApiaUrl };
|
|
298
425
|
//# sourceMappingURL=index.d.ts.map
|