dotvvm-types 4.3.0-preview03-final → 4.3.0-preview05-final
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/package.json +1 -1
- package/types/index.d.ts +43 -17
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -5,8 +5,7 @@ declare module "shared-classes" {
|
|
|
5
5
|
constructor(reason: DotvvmPostbackErrorReason);
|
|
6
6
|
toString(): string;
|
|
7
7
|
}
|
|
8
|
-
export class CoerceError implements CoerceErrorType {
|
|
9
|
-
message: string;
|
|
8
|
+
export class CoerceError extends Error implements CoerceErrorType {
|
|
10
9
|
path: string;
|
|
11
10
|
isError: true;
|
|
12
11
|
wasCoerced: false;
|
|
@@ -19,6 +18,20 @@ declare module "shared-classes" {
|
|
|
19
18
|
declare module "utils/logging" {
|
|
20
19
|
type LogLevel = "normal" | "verbose";
|
|
21
20
|
export const level: LogLevel;
|
|
21
|
+
type ConsoleLogLevel = "warn" | "log" | "error" | "trace";
|
|
22
|
+
let logger: (level: ConsoleLogLevel, area: DotvvmLoggingArea, ...args: any) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Instead of calling console.log, console.warn or console.error, DotVVM will call this function instead.
|
|
25
|
+
* Please keep in mind that the exact wording of log messages is not DotVVM public API and may change without notice.
|
|
26
|
+
* @example
|
|
27
|
+
* dotvvm.log.setLogger((next, level, area, ...args) => {
|
|
28
|
+
* if (area == "validation" && /^This message should be an error$/.test(args[0])) {
|
|
29
|
+
* level = "error"
|
|
30
|
+
* }
|
|
31
|
+
* previous(level, area, ...args) // call the default logger
|
|
32
|
+
* })
|
|
33
|
+
*/
|
|
34
|
+
export function setLogger(newLogger: (next: typeof logger, level: ConsoleLogLevel, area: DotvvmLoggingArea, ...args: any) => void): void;
|
|
22
35
|
export type DotvvmLoggingArea = ("debug" | "configuration" | "postback" | "spa" | "static-command" | "binding-handler" | "resource-loader" | "coercer" | "state-manager" | "validation" | "events" | "rest-api");
|
|
23
36
|
export function logInfoVerbose(area: DotvvmLoggingArea, ...args: any[]): void;
|
|
24
37
|
export function logInfo(area: DotvvmLoggingArea, ...args: any[]): void;
|
|
@@ -117,7 +130,7 @@ declare module "utils/isNumber" {
|
|
|
117
130
|
export function isNumber(value: any): boolean;
|
|
118
131
|
}
|
|
119
132
|
declare module "metadata/enums" {
|
|
120
|
-
export function enumStringToInt(value: number | string, type: EnumTypeMetadata): number | null;
|
|
133
|
+
export function enumStringToInt(value: number | string | null | undefined, type: EnumTypeMetadata): number | null;
|
|
121
134
|
export function enumIntToString(value: number, type: EnumTypeMetadata): string | null;
|
|
122
135
|
export function tryCoerceEnum(value: any, type: EnumTypeMetadata): CoerceResult;
|
|
123
136
|
}
|
|
@@ -313,6 +326,7 @@ declare module "viewModules/viewModuleManager" {
|
|
|
313
326
|
export function initViewModule(name: string, viewIdOrElement: string | HTMLElement, rootElement: HTMLElement, properties?: object): ModuleContext;
|
|
314
327
|
export function callViewModuleCommand(viewIdOrElement: string | HTMLElement, commandName: string, args: any[], allowAsync?: boolean): any;
|
|
315
328
|
export function findComponent(viewIdOrElement: null | string | HTMLElement, name: string): [ModuleContext | null, DotvvmJsComponentFactory];
|
|
329
|
+
/** Registers a component to be used in any JsComponent, independent of view modules */
|
|
316
330
|
export function registerGlobalComponent(name: string, c: DotvvmJsComponentFactory): void;
|
|
317
331
|
export function registerNamedCommand(viewIdOrElement: string | HTMLElement, commandName: string, command: ModuleCommand, rootElement: HTMLElement): void;
|
|
318
332
|
export function unregisterNamedCommand(viewIdOrElement: string | HTMLElement, commandName: string): void;
|
|
@@ -647,6 +661,7 @@ declare module "validation/validation" {
|
|
|
647
661
|
* `dotvvm.validation.removeErrors("/Detail")` removes all errors from the object in property root.Detail */
|
|
648
662
|
removeErrors: typeof removeErrors;
|
|
649
663
|
};
|
|
664
|
+
export const runClientSideValidation: (validationTarget: any, options: PostbackOptions) => void;
|
|
650
665
|
export function init(): void;
|
|
651
666
|
export type ValidationErrorDescriptor = {
|
|
652
667
|
/** Error to be displayed to the user */
|
|
@@ -726,24 +741,22 @@ declare module "metadata/metadataHelper" {
|
|
|
726
741
|
}
|
|
727
742
|
declare module "translations/sortingHelper" {
|
|
728
743
|
type ElementType = string | number | boolean;
|
|
729
|
-
export const orderBy: <T>(array: T[], selector: (item: T) => ElementType, typeId: string) => T[];
|
|
730
|
-
export const orderByDesc: <T>(array: T[], selector: (item: T) => ElementType, typeId: string) => T[];
|
|
744
|
+
export const orderBy: <T>(array: T[], selector: (item: T) => ElementType, typeId: string | null) => T[];
|
|
745
|
+
export const orderByDesc: <T>(array: T[], selector: (item: T) => ElementType, typeId: string | null) => T[];
|
|
731
746
|
}
|
|
732
747
|
declare module "translations/arrayHelper" {
|
|
733
748
|
import { orderBy, orderByDesc } from "translations/sortingHelper";
|
|
734
|
-
export { add, addOrUpdate, addRange, clear, distinct, contains,
|
|
749
|
+
export { add, addOrUpdate, addRange, clear, distinct, contains, insert, insertRange, max, min, orderBy, orderByDesc, removeAll, removeAt, removeFirst, removeLast, removeRange, reverse, setItem };
|
|
735
750
|
function add<T>(observable: any, element: T): void;
|
|
736
751
|
function addOrUpdate<T>(observable: any, element: T, matcher: (e: T) => boolean, updater: (e: T) => T): void;
|
|
737
752
|
function addRange<T>(observable: any, elements: T[]): void;
|
|
738
753
|
function clear(observable: any): void;
|
|
739
754
|
function distinct<T>(array: T[]): T[];
|
|
740
755
|
function contains<T>(array: T[], value: T): boolean;
|
|
741
|
-
function firstOrDefault<T>(array: T[], predicate: (s: T) => boolean): T | null;
|
|
742
756
|
function insert<T>(observable: any, index: number, element: T): void;
|
|
743
757
|
function insertRange<T>(observable: any, index: number, elements: T[]): void;
|
|
744
|
-
function
|
|
745
|
-
function
|
|
746
|
-
function min<T>(array: T[], selector: (item: T) => number, throwIfEmpty: boolean): number | null;
|
|
758
|
+
function max<T>(array: T[], selector: (item: T) => number): number | null;
|
|
759
|
+
function min<T>(array: T[], selector: (item: T) => number): number | null;
|
|
747
760
|
function removeAt<T>(observable: any, index: number): void;
|
|
748
761
|
function removeAll<T>(observable: any, predicate: (s: T) => boolean): void;
|
|
749
762
|
function removeRange<T>(observable: any, index: number, length: number): void;
|
|
@@ -759,7 +772,7 @@ declare module "translations/dictionaryHelper" {
|
|
|
759
772
|
}[];
|
|
760
773
|
export function clear(observable: any): void;
|
|
761
774
|
export function containsKey<Key, Value>(dictionary: Dictionary<Key, Value>, identifier: Key): boolean;
|
|
762
|
-
export function getItem<Key, Value>(dictionary: Dictionary<Key, Value>, identifier: Key, defaultValue?: Value): Value;
|
|
775
|
+
export function getItem<Key, Value>(dictionary: Dictionary<Key, Value>, identifier: Key, defaultValue?: Value): Value | undefined;
|
|
763
776
|
export function remove<Key, Value>(observable: any, identifier: Key): boolean;
|
|
764
777
|
export function setItem<Key, Value>(observable: any, identifier: Key, value: Value): void;
|
|
765
778
|
}
|
|
@@ -801,7 +814,7 @@ declare module "dotvvm-root" {
|
|
|
801
814
|
import * as validation from "validation/validation";
|
|
802
815
|
import { postBack } from "postback/postback";
|
|
803
816
|
import { serialize } from "serialization/serialize";
|
|
804
|
-
import { serializeDate, parseDate } from "serialization/date";
|
|
817
|
+
import { serializeDate, parseDate, parseDateOnly, parseTimeOnly } from "serialization/date";
|
|
805
818
|
import { deserialize } from "serialization/deserialize";
|
|
806
819
|
import * as evaluator from "utils/evaluator";
|
|
807
820
|
import * as globalize from "DotVVM.Globalize";
|
|
@@ -816,7 +829,7 @@ declare module "dotvvm-root" {
|
|
|
816
829
|
import * as eventHub from "api/eventHub";
|
|
817
830
|
import * as viewModuleManager from "viewModules/viewModuleManager";
|
|
818
831
|
import { notifyModuleLoaded } from "postback/resourceLoader";
|
|
819
|
-
import { logError, logWarning, logInfo, logInfoVerbose, logPostBackScriptError } from "utils/logging";
|
|
832
|
+
import { logError, logWarning, logInfo, logInfoVerbose, logPostBackScriptError, setLogger } from "utils/logging";
|
|
820
833
|
import * as metadataHelper from "metadata/metadataHelper";
|
|
821
834
|
import { StateManager } from "state-manager";
|
|
822
835
|
function init(culture: string): void;
|
|
@@ -880,6 +893,8 @@ declare module "dotvvm-root" {
|
|
|
880
893
|
serialize: typeof serialize;
|
|
881
894
|
serializeDate: typeof serializeDate;
|
|
882
895
|
parseDate: typeof parseDate;
|
|
896
|
+
parseDateOnly: typeof parseDateOnly;
|
|
897
|
+
parseTimeOnly: typeof parseTimeOnly;
|
|
883
898
|
deserialize: typeof deserialize;
|
|
884
899
|
};
|
|
885
900
|
metadata: {
|
|
@@ -903,6 +918,7 @@ declare module "dotvvm-root" {
|
|
|
903
918
|
logInfoVerbose: typeof logInfoVerbose;
|
|
904
919
|
logPostBackScriptError: typeof logPostBackScriptError;
|
|
905
920
|
level: "normal" | "verbose";
|
|
921
|
+
setLogger: typeof setLogger;
|
|
906
922
|
};
|
|
907
923
|
options: {
|
|
908
924
|
compressPOST: boolean;
|
|
@@ -1207,20 +1223,30 @@ type DotvvmFileSize = {
|
|
|
1207
1223
|
FormattedText: KnockoutObservable<string>;
|
|
1208
1224
|
};
|
|
1209
1225
|
type DotvvmJsComponent = {
|
|
1210
|
-
|
|
1226
|
+
/** Called after each update of dotvvm.state which changes any of the bound properties. Only the changed properties are listed in the `updatedProps` argument. */
|
|
1227
|
+
updateProps(updatedProps: {
|
|
1211
1228
|
[key: string]: any;
|
|
1212
1229
|
}): void;
|
|
1213
|
-
|
|
1230
|
+
/** Called after the HTMLElement is removed from DOM.
|
|
1231
|
+
* The component does not need to remove any child elements, but should clean any external data, such as subscription to dotvvm events */
|
|
1232
|
+
dispose?(): void;
|
|
1214
1233
|
};
|
|
1215
1234
|
type DotvvmJsComponentFactory = {
|
|
1235
|
+
/** Initializes the component on the specified HTMLElement.
|
|
1236
|
+
* @param element The root HTMLElement of this component
|
|
1237
|
+
* @param props An object listing all constants and `value` bindings from the `dot:JsComponent` instance
|
|
1238
|
+
* @param commands An object listing all `command` and `staticCommand` bindings from the `dot:JsComponent` instance
|
|
1239
|
+
* @param templates An object listing all content properties of the `dot:JsComponent`. The template is identified using its HTML id attribute, it can be rendered using ko.renderTemplate, KnockoutTemplateReactComponent or KnockoutTemplateSvelteComponent
|
|
1240
|
+
* @param setProps A function which will attempt to write a value back into the bound property. Only certain `value` bindings can be updated, an exception is thown if it isn't possible
|
|
1241
|
+
* @returns An object which will be notified about subsequent changes to the bound properties and when the component
|
|
1242
|
+
*/
|
|
1216
1243
|
create(element: HTMLElement, props: {
|
|
1217
1244
|
[key: string]: any;
|
|
1218
1245
|
}, commands: {
|
|
1219
1246
|
[key: string]: (args: any[]) => Promise<any>;
|
|
1220
1247
|
}, templates: {
|
|
1221
1248
|
[key: string]: string;
|
|
1222
|
-
},
|
|
1223
|
-
setProps: (p: {
|
|
1249
|
+
}, setProps: (p: {
|
|
1224
1250
|
[key: string]: any;
|
|
1225
1251
|
}) => void): DotvvmJsComponent;
|
|
1226
1252
|
};
|