@os-design/form 1.0.7 → 1.0.9
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/README.md +70 -36
- package/dist/cjs/BroadcastObserverManager.js +41 -0
- package/dist/cjs/BroadcastObserverManager.js.map +1 -0
- package/dist/cjs/{SubscribableData.js → ErrorData.js} +17 -17
- package/dist/cjs/ErrorData.js.map +1 -0
- package/dist/cjs/ErrorObserverManager.js +62 -0
- package/dist/cjs/ErrorObserverManager.js.map +1 -0
- package/dist/cjs/Form.js +43 -0
- package/dist/cjs/Form.js.map +1 -0
- package/dist/cjs/Node.js +57 -0
- package/dist/cjs/Node.js.map +1 -0
- package/dist/cjs/ValueData.js +53 -0
- package/dist/cjs/ValueData.js.map +1 -0
- package/dist/cjs/ValueObserverManager.js +122 -0
- package/dist/cjs/ValueObserverManager.js.map +1 -0
- package/dist/cjs/index.js +114 -105
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types.js +6 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/useFormContext.js +27 -0
- package/dist/cjs/useFormContext.js.map +1 -0
- package/dist/cjs/utils/deleteFromArray.js +17 -0
- package/dist/cjs/utils/deleteFromArray.js.map +1 -0
- package/dist/cjs/utils/path.js +53 -0
- package/dist/cjs/utils/path.js.map +1 -0
- package/dist/esm/BroadcastObserverManager.js +18 -0
- package/dist/esm/BroadcastObserverManager.js.map +1 -0
- package/dist/esm/ErrorData.js +20 -0
- package/dist/esm/ErrorData.js.map +1 -0
- package/dist/esm/ErrorObserverManager.js +26 -0
- package/dist/esm/ErrorObserverManager.js.map +1 -0
- package/dist/esm/Form.js +26 -0
- package/dist/esm/Form.js.map +1 -0
- package/dist/esm/Node.js +31 -0
- package/dist/esm/Node.js.map +1 -0
- package/dist/esm/ValueData.js +21 -0
- package/dist/esm/ValueData.js.map +1 -0
- package/dist/esm/ValueObserverManager.js +67 -0
- package/dist/esm/ValueObserverManager.js.map +1 -0
- package/dist/esm/index.js +44 -66
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/useFormContext.js +17 -0
- package/dist/esm/useFormContext.js.map +1 -0
- package/dist/esm/utils/deleteFromArray.js +8 -0
- package/dist/esm/utils/deleteFromArray.js.map +1 -0
- package/dist/esm/utils/path.js +31 -0
- package/dist/esm/utils/path.js.map +1 -0
- package/dist/types/BroadcastObserverManager.d.ts +10 -0
- package/dist/types/BroadcastObserverManager.d.ts.map +1 -0
- package/dist/types/ErrorData.d.ts +11 -0
- package/dist/types/ErrorData.d.ts.map +1 -0
- package/dist/types/ErrorObserverManager.d.ts +12 -0
- package/dist/types/ErrorObserverManager.d.ts.map +1 -0
- package/dist/types/Form.d.ts +12 -0
- package/dist/types/Form.d.ts.map +1 -0
- package/dist/types/Node.d.ts +15 -0
- package/dist/types/Node.d.ts.map +1 -0
- package/dist/types/ValueData.d.ts +11 -0
- package/dist/types/ValueData.d.ts.map +1 -0
- package/dist/types/ValueObserverManager.d.ts +13 -0
- package/dist/types/ValueObserverManager.d.ts.map +1 -0
- package/dist/types/index.d.ts +32 -46
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +15 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/useFormContext.d.ts +11 -0
- package/dist/types/useFormContext.d.ts.map +1 -0
- package/dist/types/utils/deleteFromArray.d.ts +3 -0
- package/dist/types/utils/deleteFromArray.d.ts.map +1 -0
- package/dist/types/utils/path.d.ts +5 -0
- package/dist/types/utils/path.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/cjs/SubscribableData.js.map +0 -1
- package/dist/cjs/SubscriptionManager.js +0 -83
- package/dist/cjs/SubscriptionManager.js.map +0 -1
- package/dist/esm/SubscribableData.js +0 -23
- package/dist/esm/SubscribableData.js.map +0 -1
- package/dist/esm/SubscriptionManager.js +0 -46
- package/dist/esm/SubscriptionManager.js.map +0 -1
- package/dist/types/SubscribableData.d.ts +0 -11
- package/dist/types/SubscribableData.d.ts.map +0 -1
- package/dist/types/SubscriptionManager.d.ts +0 -19
- package/dist/types/SubscriptionManager.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFormContext.js","names":["React","createContext","useContext","FormContext","FormProvider","form","children","useFormContext"],"sources":["../../src/useFormContext.tsx"],"sourcesContent":["import React, { createContext, ReactNode, useContext } from 'react';\nimport Form from './Form';\nimport { StringMap } from './types';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst FormContext = createContext<any>(null);\n\nexport interface FormProviderProps<TValues extends StringMap> {\n form: Form<TValues>;\n children?: ReactNode;\n}\n\n// eslint-disable-next-line react/function-component-definition\nexport function FormProvider<TValues extends StringMap>({\n form,\n children,\n}: FormProviderProps<TValues>) {\n return <FormContext.Provider value={form}>{children}</FormContext.Provider>;\n}\n\nfunction useFormContext<T>() {\n return useContext<T>(FormContext);\n}\n\nexport default useFormContext;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAaC,UAAU,QAAQ,OAAO;AAInE;AACA,MAAMC,WAAW,gBAAGF,aAAa,CAAM,IAAI,CAAC;AAO5C;AACA,OAAO,SAASG,YAAY,CAA4B;EACtDC,IAAI;EACJC;AAC0B,CAAC,EAAE;EAC7B,oBAAO,oBAAC,WAAW,CAAC,QAAQ;IAAC,KAAK,EAAED;EAAK,GAAEC,QAAQ,CAAwB;AAC7E;AAEA,SAASC,cAAc,GAAM;EAC3B,OAAOL,UAAU,CAAIC,WAAW,CAAC;AACnC;AAEA,eAAeI,cAAc"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2
|
+
const deleteFromArray = (arr, item) => {
|
|
3
|
+
const index = arr.findIndex(i => i === item);
|
|
4
|
+
if (index === -1) return;
|
|
5
|
+
arr.splice(index, 1);
|
|
6
|
+
};
|
|
7
|
+
export default deleteFromArray;
|
|
8
|
+
//# sourceMappingURL=deleteFromArray.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteFromArray.js","names":["deleteFromArray","arr","item","index","findIndex","i","splice"],"sources":["../../../src/utils/deleteFromArray.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst deleteFromArray = (arr: any[], item: any) => {\n const index = arr.findIndex((i) => i === item);\n if (index === -1) return;\n arr.splice(index, 1);\n};\n\nexport default deleteFromArray;\n"],"mappings":"AAAA;AACA,MAAMA,eAAe,GAAG,CAACC,GAAU,EAAEC,IAAS,KAAK;EACjD,MAAMC,KAAK,GAAGF,GAAG,CAACG,SAAS,CAAEC,CAAC,IAAKA,CAAC,KAAKH,IAAI,CAAC;EAC9C,IAAIC,KAAK,KAAK,CAAC,CAAC,EAAE;EAClBF,GAAG,CAACK,MAAM,CAACH,KAAK,EAAE,CAAC,CAAC;AACtB,CAAC;AAED,eAAeH,eAAe"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any,no-param-reassign */
|
|
2
|
+
|
|
3
|
+
export const isObjectOrArray = value => typeof value === 'object' && value !== null;
|
|
4
|
+
const split = path => {
|
|
5
|
+
const groups = path.match(/^([^.]*)\.(.*)$/);
|
|
6
|
+
return groups ? [groups[1], groups[2]] : null;
|
|
7
|
+
};
|
|
8
|
+
export const get = (data, path) => {
|
|
9
|
+
if (Object.hasOwn(data, path)) {
|
|
10
|
+
return data[path];
|
|
11
|
+
}
|
|
12
|
+
const groups = split(path);
|
|
13
|
+
if (!groups) return undefined;
|
|
14
|
+
const [key, nextPath] = groups;
|
|
15
|
+
if (!Object.hasOwn(data, key)) return undefined;
|
|
16
|
+
if (!isObjectOrArray(data[key])) return undefined;
|
|
17
|
+
return get(data[key], nextPath);
|
|
18
|
+
};
|
|
19
|
+
export const set = (data, path, value) => {
|
|
20
|
+
if (Object.hasOwn(data, path)) {
|
|
21
|
+
data[path] = value;
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
const groups = split(path);
|
|
25
|
+
if (!groups) return false;
|
|
26
|
+
const [key, nextPath] = groups;
|
|
27
|
+
if (!Object.hasOwn(data, key)) return false;
|
|
28
|
+
if (!isObjectOrArray(data[key])) return false;
|
|
29
|
+
return set(data[key], nextPath, value);
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.js","names":["isObjectOrArray","value","split","path","groups","match","get","data","Object","hasOwn","undefined","key","nextPath","set"],"sources":["../../../src/utils/path.ts"],"sourcesContent":["import { StringMap } from '../types';\n\n/* eslint-disable @typescript-eslint/no-explicit-any,no-param-reassign */\n\nexport const isObjectOrArray = (value: any): value is object =>\n typeof value === 'object' && value !== null;\n\nconst split = (path: string) => {\n const groups = path.match(/^([^.]*)\\.(.*)$/);\n return groups ? [groups[1], groups[2]] : null;\n};\n\nexport const get = (data: StringMap, path: string): any => {\n if (Object.hasOwn(data, path)) {\n return data[path];\n }\n\n const groups = split(path);\n if (!groups) return undefined;\n\n const [key, nextPath] = groups;\n if (!Object.hasOwn(data, key)) return undefined;\n if (!isObjectOrArray(data[key])) return undefined;\n\n return get(data[key], nextPath);\n};\n\nexport const set = (data: StringMap, path: string, value: any): boolean => {\n if (Object.hasOwn(data, path)) {\n data[path] = value;\n return true;\n }\n\n const groups = split(path);\n if (!groups) return false;\n\n const [key, nextPath] = groups;\n if (!Object.hasOwn(data, key)) return false;\n if (!isObjectOrArray(data[key])) return false;\n\n return set(data[key], nextPath, value);\n};\n"],"mappings":"AAEA;;AAEA,OAAO,MAAMA,eAAe,GAAIC,KAAU,IACxC,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI;AAE7C,MAAMC,KAAK,GAAIC,IAAY,IAAK;EAC9B,MAAMC,MAAM,GAAGD,IAAI,CAACE,KAAK,CAAC,iBAAiB,CAAC;E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AK;EAE7C,OAAOE,GAAG,CAACN,IAAI,CAACI,GAAG,CAAC,EAAEC,QAAQ,EAAEX,KAAK,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Subscription } from './types';
|
|
2
|
+
export type BroadcastObserver<TName, TValue> = (name: TName, value: TValue) => void;
|
|
3
|
+
declare class BroadcastObserverManager<TName, TValue> {
|
|
4
|
+
private readonly broadcastObservers;
|
|
5
|
+
constructor();
|
|
6
|
+
subscribeToAll(observer: BroadcastObserver<TName, TValue>): Subscription;
|
|
7
|
+
protected callBroadcastObservers<N extends TName, V extends TValue>(name: N, value: V): void;
|
|
8
|
+
}
|
|
9
|
+
export default BroadcastObserverManager;
|
|
10
|
+
//# sourceMappingURL=BroadcastObserverManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BroadcastObserverManager.d.ts","sourceRoot":"","sources":["../../src/BroadcastObserverManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,MAAM,MAAM,iBAAiB,CAAC,KAAK,EAAE,MAAM,IAAI,CAC7C,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,MAAM,KACV,IAAI,CAAC;AAEV,cAAM,wBAAwB,CAAC,KAAK,EAAE,MAAM;IAC1C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA0C;;IAMtE,cAAc,CACnB,QAAQ,EAAE,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,GACzC,YAAY;IAOf,SAAS,CAAC,sBAAsB,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC,SAAS,MAAM,EAChE,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,CAAC,GACP,IAAI;CAGR;AAED,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ErrorObserverManager from './ErrorObserverManager';
|
|
2
|
+
import { StringMap } from './types';
|
|
3
|
+
declare class ErrorData<TErrors extends StringMap<string | undefined>, TName extends keyof TErrors = keyof TErrors> extends ErrorObserverManager<TErrors> {
|
|
4
|
+
private readonly errors;
|
|
5
|
+
constructor(errors: TErrors);
|
|
6
|
+
get<T extends TName>(name: T): TErrors[T];
|
|
7
|
+
getAll(): TErrors;
|
|
8
|
+
set<T extends TName>(name: T, value: TErrors[T]): void;
|
|
9
|
+
}
|
|
10
|
+
export default ErrorData;
|
|
11
|
+
//# sourceMappingURL=ErrorData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorData.d.ts","sourceRoot":"","sources":["../../src/ErrorData.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,cAAM,SAAS,CACb,OAAO,SAAS,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,EAC7C,KAAK,SAAS,MAAM,OAAO,GAAG,MAAM,OAAO,CAC3C,SAAQ,oBAAoB,CAAC,OAAO,CAAC;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;gBAEd,MAAM,EAAE,OAAO;IAK3B,GAAG,CAAC,CAAC,SAAS,KAAK,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAIzC,MAAM,IAAI,OAAO;IAIjB,GAAG,CAAC,CAAC,SAAS,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI;CAI9D;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import BroadcastObserverManager from './BroadcastObserverManager';
|
|
2
|
+
import { Observer, StringMap, Subscription } from './types';
|
|
3
|
+
export type ErrorObserver = Observer<string | undefined>;
|
|
4
|
+
declare class ErrorObserverManager<TErrors extends StringMap<string | undefined>, TName extends keyof TErrors = keyof TErrors> extends BroadcastObserverManager<TName, string | undefined> {
|
|
5
|
+
private readonly observers;
|
|
6
|
+
constructor();
|
|
7
|
+
private getObservers;
|
|
8
|
+
subscribe<T extends TName>(name: T, observer: ErrorObserver): Subscription;
|
|
9
|
+
protected callObservers<T extends TName>(name: T, value: string | undefined): void;
|
|
10
|
+
}
|
|
11
|
+
export default ErrorObserverManager;
|
|
12
|
+
//# sourceMappingURL=ErrorObserverManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorObserverManager.d.ts","sourceRoot":"","sources":["../../src/ErrorObserverManager.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5D,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAEzD,cAAM,oBAAoB,CACxB,OAAO,SAAS,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,EAC7C,KAAK,SAAS,MAAM,OAAO,GAAG,MAAM,OAAO,CAC3C,SAAQ,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAExB;;IAOF,OAAO,CAAC,YAAY;IAKb,SAAS,CAAC,CAAC,SAAS,KAAK,EAC9B,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,aAAa,GACtB,YAAY;IAMf,SAAS,CAAC,aAAa,CAAC,CAAC,SAAS,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS;CAI5E;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ErrorData from './ErrorData';
|
|
2
|
+
import { Errors, StringMap } from './types';
|
|
3
|
+
import ValueData from './ValueData';
|
|
4
|
+
declare class Form<TValues extends StringMap = StringMap, TErrors extends Errors<TValues> = Errors<TValues>> {
|
|
5
|
+
initValues: TValues;
|
|
6
|
+
readonly values: ValueData<TValues>;
|
|
7
|
+
readonly errors: ErrorData<TErrors>;
|
|
8
|
+
constructor(initValues: TValues);
|
|
9
|
+
reset(): void;
|
|
10
|
+
}
|
|
11
|
+
export default Form;
|
|
12
|
+
//# sourceMappingURL=Form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../src/Form.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,MAAM,EAAiB,SAAS,EAAE,MAAM,SAAS,CAAC;AAE3D,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,cAAM,IAAI,CACR,OAAO,SAAS,SAAS,GAAG,SAAS,EACrC,OAAO,SAAS,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;IAE1C,UAAU,EAAE,OAAO,CAAC;IAE3B,SAAgB,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAE3C,SAAgB,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;gBAExB,UAAU,EAAE,OAAO;IAM/B,KAAK;CAiBb;AAED,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Observer } from './types';
|
|
2
|
+
declare class Node {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly parent: Node | null;
|
|
5
|
+
readonly nodes: Record<string, Node>;
|
|
6
|
+
readonly observers: Observer[];
|
|
7
|
+
constructor(parent?: Node | null, name?: string);
|
|
8
|
+
getNode(name: string): Node | undefined;
|
|
9
|
+
createNode(name: string): Node;
|
|
10
|
+
deleteNode(name: string): void;
|
|
11
|
+
addObserver(observer: Observer): void;
|
|
12
|
+
deleteObserver(observer: Observer): void;
|
|
13
|
+
}
|
|
14
|
+
export default Node;
|
|
15
|
+
//# sourceMappingURL=Node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Node.d.ts","sourceRoot":"","sources":["../../src/Node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGnC,cAAM,IAAI;IACR,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B,SAAgB,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;IAEpC,SAAgB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAE5C,SAAgB,SAAS,EAAE,QAAQ,EAAE,CAAC;gBAEnB,MAAM,GAAE,IAAI,GAAG,IAAW,EAAE,IAAI,SAAK;IAOjD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAIvC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK9B,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI9B,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAIrC,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAGhD;AAED,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PathReturn, RecursivePath, StringMap } from './types';
|
|
2
|
+
import ValueObserverManager from './ValueObserverManager';
|
|
3
|
+
declare class ValueData<TValues extends StringMap, TName extends RecursivePath<TValues> = RecursivePath<TValues>> extends ValueObserverManager<TValues> {
|
|
4
|
+
private readonly values;
|
|
5
|
+
constructor(values: TValues);
|
|
6
|
+
get<T extends TName>(name: T): PathReturn<TValues, T>;
|
|
7
|
+
getAll(): TValues;
|
|
8
|
+
set<T extends TName>(name: T, value: PathReturn<TValues, T>): void;
|
|
9
|
+
}
|
|
10
|
+
export default ValueData;
|
|
11
|
+
//# sourceMappingURL=ValueData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValueData.d.ts","sourceRoot":"","sources":["../../src/ValueData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAE/D,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D,cAAM,SAAS,CACb,OAAO,SAAS,SAAS,EACzB,KAAK,SAAS,aAAa,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,CAC7D,SAAQ,oBAAoB,CAAC,OAAO,CAAC;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;gBAEd,MAAM,EAAE,OAAO;IAK3B,GAAG,CAAC,CAAC,SAAS,KAAK,EAAE,IAAI,EAAE,CAAC,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;IAIrD,MAAM,IAAI,OAAO;IAIjB,GAAG,CAAC,CAAC,SAAS,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,IAAI;CAI1E;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BroadcastObserverManager from './BroadcastObserverManager';
|
|
2
|
+
import { Observer, PathReturn, RecursivePath, StringMap, Subscription } from './types';
|
|
3
|
+
declare class ValueObserverManager<TValues extends StringMap, TName extends RecursivePath<TValues> = RecursivePath<TValues>> extends BroadcastObserverManager<TName, TValues[TName]> {
|
|
4
|
+
private readonly root;
|
|
5
|
+
constructor();
|
|
6
|
+
private findNode;
|
|
7
|
+
subscribe<T extends TName>(name: T, observer: Observer<PathReturn<TValues, T>>): Subscription;
|
|
8
|
+
protected callObservers<T extends TName>(name: T, data: TValues): void;
|
|
9
|
+
private callNodeObservers;
|
|
10
|
+
private callChildObservers;
|
|
11
|
+
}
|
|
12
|
+
export default ValueObserverManager;
|
|
13
|
+
//# sourceMappingURL=ValueObserverManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValueObserverManager.d.ts","sourceRoot":"","sources":["../../src/ValueObserverManager.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAElE,OAAO,EACL,QAAQ,EACR,UAAU,EACV,aAAa,EACb,SAAS,EACT,YAAY,EACb,MAAM,SAAS,CAAC;AAKjB,cAAM,oBAAoB,CACxB,OAAO,SAAS,SAAS,EACzB,KAAK,SAAS,aAAa,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,CAC7D,SAAQ,wBAAwB,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACvD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAO;;IAO5B,OAAO,CAAC,QAAQ;IAST,SAAS,CAAC,CAAC,SAAS,KAAK,EAC9B,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,GACzC,YAAY;IAcf,SAAS,CAAC,aAAa,CAAC,CAAC,SAAS,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI;IAKtE,OAAO,CAAC,iBAAiB;IAuBzB,OAAO,CAAC,kBAAkB;CAQ3B;AAED,eAAe,oBAAoB,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,58 +1,44 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
children?: ReactNode;
|
|
16
|
-
}
|
|
17
|
-
export declare function FormProvider<TValues extends Values>({ form, children, }: FormProviderProps<TValues>): JSX.Element;
|
|
18
|
-
export declare const useError: <TValues extends Values = Values, TName extends keyof TValues = keyof TValues>(name: TName, form?: Form<TValues, Errors<TValues>> | undefined) => string | undefined;
|
|
19
|
-
export type Transformer<TValues extends Values, TName extends keyof TValues> = (value: TValues[TName]) => Partial<TValues>;
|
|
20
|
-
interface InputProps<T> {
|
|
21
|
-
value: T;
|
|
22
|
-
onChange: (value: T) => void;
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import Form from './Form';
|
|
3
|
+
import { PathReturn, RecursivePath, StringMap } from './types';
|
|
4
|
+
export * from './BroadcastObserverManager';
|
|
5
|
+
export * from './ErrorObserverManager';
|
|
6
|
+
export { default as Form } from './Form';
|
|
7
|
+
export * from './types';
|
|
8
|
+
export * from './useFormContext';
|
|
9
|
+
export type Transformer<TValues extends StringMap, TName extends RecursivePath<TValues>> = (value: PathReturn<TValues, TName>) => {
|
|
10
|
+
[K in RecursivePath<TValues>]?: PathReturn<TValues, K>;
|
|
11
|
+
};
|
|
12
|
+
interface InputProps<TValue> {
|
|
13
|
+
value: TValue;
|
|
14
|
+
onChange: (value: TValue) => void;
|
|
23
15
|
}
|
|
24
16
|
interface FieldState {
|
|
25
|
-
error
|
|
17
|
+
error?: string;
|
|
26
18
|
modified: boolean;
|
|
27
19
|
reset: () => void;
|
|
28
20
|
}
|
|
29
|
-
interface
|
|
30
|
-
name: TName;
|
|
31
|
-
toValue?: never;
|
|
32
|
-
fromValue?: never;
|
|
33
|
-
render: (inputProps: InputProps<TStateValue>, fieldState: FieldState) => ReactElement | null;
|
|
34
|
-
}
|
|
35
|
-
interface FieldPropsWithTransformers<TName, TStateValue, TInputValue> {
|
|
21
|
+
interface FieldProps<TName, TValue> {
|
|
36
22
|
name: TName;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
render: (inputProps: InputProps<TInputValue>, fieldState: FieldState) => ReactElement | null;
|
|
23
|
+
transformer?: (value: TValue) => TValue;
|
|
24
|
+
render: (inputProps: InputProps<TValue>, fieldState: FieldState) => ReactElement | null;
|
|
40
25
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
useTransformer: <
|
|
47
|
-
modifiedFields:
|
|
26
|
+
export declare const useForm: <TValues extends StringMap<any> = StringMap<any>>(initValues: TValues) => {
|
|
27
|
+
form: Form<TValues, import("./types").Errors<TValues>>;
|
|
28
|
+
Field: <TName extends RecursivePath<TValues>>(props: FieldProps<TName, PathReturn<TValues, TName>>) => ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
|
|
29
|
+
useValue: <TName_1 extends RecursivePath<TValues>>(name: TName_1) => PathReturn<TValues, TName_1>;
|
|
30
|
+
useError: <TName_2 extends RecursivePath<TValues>>(name: TName_2) => string | undefined;
|
|
31
|
+
useTransformer: <TName_3 extends RecursivePath<TValues>>(name: TName_3, transformer: Transformer<TValues, TName_3>) => void;
|
|
32
|
+
modifiedFields: RecursivePath<TValues>[];
|
|
48
33
|
modified: boolean;
|
|
49
34
|
};
|
|
50
|
-
export declare const useExistingForm: <TValues extends
|
|
51
|
-
form: Form<TValues, Errors<TValues>>;
|
|
52
|
-
Field: <TName extends
|
|
53
|
-
useValue: <TName_1 extends
|
|
54
|
-
|
|
55
|
-
|
|
35
|
+
export declare const useExistingForm: <TValues extends StringMap<any> = StringMap<any>>() => {
|
|
36
|
+
form: Form<TValues, import("./types").Errors<TValues>>;
|
|
37
|
+
Field: <TName extends RecursivePath<TValues>>(props: FieldProps<TName, PathReturn<TValues, TName>>) => ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
|
|
38
|
+
useValue: <TName_1 extends RecursivePath<TValues>>(name: TName_1) => PathReturn<TValues, TName_1>;
|
|
39
|
+
useError: <TName_2 extends RecursivePath<TValues>>(name: TName_2) => string | undefined;
|
|
40
|
+
useTransformer: <TName_3 extends RecursivePath<TValues>>(name: TName_3, transformer: Transformer<TValues, TName_3>) => void;
|
|
41
|
+
modifiedFields: RecursivePath<TValues>[];
|
|
56
42
|
modified: boolean;
|
|
57
43
|
};
|
|
58
44
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAMb,MAAM,OAAO,CAAC;AACf,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAM/D,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AACzC,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AAoCjC,MAAM,MAAM,WAAW,CACrB,OAAO,SAAS,SAAS,EACzB,KAAK,SAAS,aAAa,CAAC,OAAO,CAAC,IAClC,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK;KACxC,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;CACvD,CAAC;AA6BF,UAAU,UAAU,CAAC,MAAM;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AACD,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AACD,UAAU,UAAU,CAAC,KAAK,EAAE,MAAM;IAChC,IAAI,EAAE,KAAK,CAAC;IACZ,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACxC,MAAM,EAAE,CACN,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,EAC9B,UAAU,EAAE,UAAU,KACnB,YAAY,GAAG,IAAI,CAAC;CAC1B;AAoHD,eAAO,MAAM,OAAO;;;;;;;;CAenB,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;CAI3B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type StringMap<T = any> = Record<string, T>;
|
|
2
|
+
type Separator = '.';
|
|
3
|
+
type KeysWithSeparator<K1, K2> = `${K1 & string}${Separator}${K2 & string}`;
|
|
4
|
+
type KeyOf<T> = Exclude<keyof T, symbol | keyof any[]>;
|
|
5
|
+
export type Path<T, K = KeyOf<T>> = T extends StringMap ? K | (K extends keyof T ? T[K] extends StringMap ? KeysWithSeparator<K, Path<T[K]>> : never : never) : never;
|
|
6
|
+
export type PathReturn<T, K> = K extends keyof T ? T[K] : K extends `${infer U}${Separator}${infer R}` ? U extends keyof T ? PathReturn<T[U], R> : never : never;
|
|
7
|
+
type Cast<T1, T2> = T1 extends T2 ? T1 : T2;
|
|
8
|
+
export type RecursivePath<T> = Path<T> extends infer U ? Cast<U, string> : never;
|
|
9
|
+
export type Errors<T> = Record<RecursivePath<T>, string | undefined>;
|
|
10
|
+
export type Observer<V = any> = (value: V) => void;
|
|
11
|
+
export interface Subscription {
|
|
12
|
+
unsubscribe: () => void;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAEnD,KAAK,SAAS,GAAG,GAAG,CAAC;AACrB,KAAK,iBAAiB,CAAC,EAAE,EAAE,EAAE,IAAI,GAAG,EAAE,GAAG,MAAM,GAAG,SAAS,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;AAC5E,KAAK,KAAK,CAAC,CAA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0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import Form from './Form';
|
|
3
|
+
import { StringMap } from './types';
|
|
4
|
+
export interface FormProviderProps<TValues extends StringMap> {
|
|
5
|
+
form: Form<TValues>;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare function FormProvider<TValues extends StringMap>({ form, children, }: FormProviderProps<TValues>): JSX.Element;
|
|
9
|
+
declare function useFormContext<T>(): T;
|
|
10
|
+
export default useFormContext;
|
|
11
|
+
//# sourceMappingURL=useFormContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFormContext.d.ts","sourceRoot":"","sources":["../../src/useFormContext.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAiB,SAAS,EAAc,MAAM,OAAO,CAAC;AACpE,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKpC,MAAM,WAAW,iBAAiB,CAAC,OAAO,SAAS,SAAS;IAC1D,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAGD,wBAAgB,YAAY,CAAC,OAAO,SAAS,SAAS,EAAE,EACtD,IAAI,EACJ,QAAQ,GACT,EAAE,iBAAiB,CAAC,OAAO,CAAC,eAE5B;AAED,iBAAS,cAAc,CAAC,CAAC,OAExB;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteFromArray.d.ts","sourceRoot":"","sources":["../../../src/utils/deleteFromArray.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,eAAe,QAAS,GAAG,EAAE,QAAQ,GAAG,SAI7C,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { StringMap } from '../types';
|
|
2
|
+
export declare const isObjectOrArray: (value: any) => value is object;
|
|
3
|
+
export declare const get: (data: StringMap, path: string) => any;
|
|
4
|
+
export declare const set: (data: StringMap, path: string, value: any) => boolean;
|
|
5
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/utils/path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAIrC,eAAO,MAAM,eAAe,UAAW,GAAG,oBACG,CAAC;AAO9C,eAAO,MAAM,GAAG,SAAU,SAAS,QAAQ,MAAM,KAAG,GAanD,CAAC;AAEF,eAAO,MAAM,GAAG,SAAU,SAAS,QAAQ,MAAM,SAAS,GAAG,KAAG,OAc/D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@os-design/form",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"repository": "git@gitlab.com:os-team/libs/os-design.git",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@os-design/core": "^1.0.
|
|
31
|
+
"@os-design/core": "^1.0.187",
|
|
32
32
|
"@os-design/icons": "^1.0.44"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": ">=18"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "5a682a07301c596be544275f4ce4864e02e08010"
|
|
38
38
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SubscribableData.js","names":["SubscribableData","data","name","value","call","SubscriptionManager"],"sources":["../../src/SubscribableData.ts"],"sourcesContent":["import SubscriptionManager from './SubscriptionManager';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Data = Record<string, any>;\n\nclass SubscribableData<\n TData extends Data,\n TDataName extends keyof TData = keyof TData\n> extends SubscriptionManager<TData> {\n private data: TData;\n\n public constructor(data: TData) {\n super();\n this.data = data;\n }\n\n public get<TName extends TDataName>(name: TName): TData[TName] {\n return this.data[name];\n }\n\n public getAll(): TData {\n return this.data;\n }\n\n public set<TName extends TDataName>(name: TName, value: TData[TName]): void {\n this.data[name] = value;\n this.call(name, value);\n }\n}\n\nexport default SubscribableData;\n"],"mappings":";;;;;;;AAAA;AAAwD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKlDA,gBAAgB;EAAA;EAAA;EAMpB,0BAAmBC,IAAW,EAAE;IAAA;IAAA;IAC9B;IAAQ,MAHFA,IAAI;IAIV,MAAKA,IAAI,GAAGA,IAAI;IAAC;EACnB;EAAC;IAAA;IAAA,OAED,aAAoCC,IAAW,EAAgB;MAC7D,OAAO,IAAI,CAACD,IAAI,CAACC,IAAI,CAAC;IACxB;EAAC;IAAA;IAAA,OAED,kBAAuB;MACrB,OAAO,IAAI,CAACD,IAAI;IAClB;EAAC;IAAA;IAAA,OAED,aAAoCC,IAAW,EAAEC,KAAmB,EAAQ;MAC1E,IAAI,CAACF,IAAI,CAACC,IAAI,CAAC,GAAGC,KAAK;MACvB,IAAI,CAACC,IAAI,CAACF,IAAI,EAAEC,KAAK,CAAC;IACxB;EAAC;EAAA;AAAA,EAnBOE,gCAAmB;AAAA,eAsBdL,gBAAgB;AAAA"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
9
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
-
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
-
var deleteFromArray = function deleteFromArray(arr, item) {
|
|
14
|
-
var index = arr.findIndex(function (i) {
|
|
15
|
-
return i === item;
|
|
16
|
-
});
|
|
17
|
-
if (index === -1) return;
|
|
18
|
-
arr.splice(index, 1);
|
|
19
|
-
};
|
|
20
|
-
var SubscriptionManager = /*#__PURE__*/function () {
|
|
21
|
-
function SubscriptionManager() {
|
|
22
|
-
_classCallCheck(this, SubscriptionManager);
|
|
23
|
-
this.observers = void 0;
|
|
24
|
-
this.fieldObservers = void 0;
|
|
25
|
-
this.observers = [];
|
|
26
|
-
this.fieldObservers = {};
|
|
27
|
-
}
|
|
28
|
-
_createClass(SubscriptionManager, [{
|
|
29
|
-
key: "getFieldObservers",
|
|
30
|
-
value: function getFieldObservers(name) {
|
|
31
|
-
if (!this.fieldObservers[name]) {
|
|
32
|
-
this.fieldObservers[name] = [];
|
|
33
|
-
}
|
|
34
|
-
return this.fieldObservers[name];
|
|
35
|
-
}
|
|
36
|
-
}, {
|
|
37
|
-
key: "subscribeToAllFields",
|
|
38
|
-
value: function subscribeToAllFields(observer) {
|
|
39
|
-
var _this = this;
|
|
40
|
-
this.observers.push(observer);
|
|
41
|
-
return {
|
|
42
|
-
unsubscribe: function unsubscribe() {
|
|
43
|
-
return _this.unsubscribeFromAllFields(observer);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
}, {
|
|
48
|
-
key: "unsubscribeFromAllFields",
|
|
49
|
-
value: function unsubscribeFromAllFields(observer) {
|
|
50
|
-
deleteFromArray(this.observers, observer);
|
|
51
|
-
}
|
|
52
|
-
}, {
|
|
53
|
-
key: "subscribeToField",
|
|
54
|
-
value: function subscribeToField(name, observer) {
|
|
55
|
-
var _this2 = this;
|
|
56
|
-
this.getFieldObservers(name).push(observer);
|
|
57
|
-
return {
|
|
58
|
-
unsubscribe: function unsubscribe() {
|
|
59
|
-
return _this2.unsubscribeFromField(name, observer);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}, {
|
|
64
|
-
key: "unsubscribeFromField",
|
|
65
|
-
value: function unsubscribeFromField(name, observer) {
|
|
66
|
-
deleteFromArray(this.getFieldObservers(name), observer);
|
|
67
|
-
}
|
|
68
|
-
}, {
|
|
69
|
-
key: "call",
|
|
70
|
-
value: function call(name, value) {
|
|
71
|
-
this.observers.forEach(function (observer) {
|
|
72
|
-
return observer(name, value);
|
|
73
|
-
});
|
|
74
|
-
this.getFieldObservers(name).forEach(function (observer) {
|
|
75
|
-
return observer(value);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}]);
|
|
79
|
-
return SubscriptionManager;
|
|
80
|
-
}();
|
|
81
|
-
var _default = SubscriptionManager;
|
|
82
|
-
exports["default"] = _default;
|
|
83
|
-
//# sourceMappingURL=SubscriptionManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionManager.js","names":["deleteFromArray","arr","item","index","findIndex","i","splice","SubscriptionManager","observers","fieldObservers","name","observer","push","unsubscribe","unsubscribeFromAllFields","getFieldObservers","unsubscribeFromField","value","forEach"],"sources":["../../src/SubscriptionManager.ts"],"sourcesContent":["export type Observer<K, V> = (name: K, value: V) => void;\nexport type FieldObserver<V> = (value: V) => void;\n\nexport interface Subscription {\n unsubscribe: () => void;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Data = Record<string, any>;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst deleteFromArray = (arr: any[], item: any) => {\n const index = arr.findIndex((i) => i === item);\n if (index === -1) return;\n arr.splice(index, 1);\n};\n\nclass SubscriptionManager<\n TData extends Data,\n TDataName extends keyof TData = keyof TData\n> {\n private observers: Array<Observer<TDataName, TData[TDataName]>>;\n\n private fieldObservers: {\n [TName in TDataName]?: Array<FieldObserver<TData[TName]>>;\n };\n\n public constructor() {\n this.observers = [];\n this.fieldObservers = {};\n }\n\n private getFieldObservers<TName extends TDataName>(\n name: TName\n ): Array<FieldObserver<TData[TName]>> {\n if (!this.fieldObservers[name]) {\n this.fieldObservers[name] = [];\n }\n return this.fieldObservers[name] as Array<FieldObserver<TData[TName]>>;\n }\n\n public subscribeToAllFields(\n observer: Observer<TDataName, TData[TDataName]>\n ): Subscription {\n this.observers.push(observer);\n return { unsubscribe: () => this.unsubscribeFromAllFields(observer) };\n }\n\n private unsubscribeFromAllFields(\n observer: Observer<TDataName, TData[TDataName]>\n ): void {\n deleteFromArray(this.observers, observer);\n }\n\n public subscribeToField<TName extends TDataName>(\n name: TName,\n observer: FieldObserver<TData[TName]>\n ): Subscription {\n this.getFieldObservers(name).push(observer);\n return { unsubscribe: () => this.unsubscribeFromField(name, observer) };\n }\n\n private unsubscribeFromField<TName extends TDataName>(\n name: TName,\n observer: FieldObserver<TData[TName]>\n ): void {\n deleteFromArray(this.getFieldObservers(name), observer);\n }\n\n protected call<TName extends TDataName>(\n name: TName,\n value: TData[TName]\n ): void {\n this.observers.forEach((observer) => observer(name, value));\n this.getFieldObservers(name).forEach((observer) => observer(value));\n }\n}\n\nexport default SubscriptionManager;\n"],"mappings":";;;;;;;;;AAOA;;AAGA;AACA,IAAMA,eAAe,GAAG,SAAlBA,eAAe,CAAIC,GAAU,EAAEC,IAAS,EAAK;EACjD,IAAMC,KAAK,GAAGF,GAAG,CAACG,SAAS,CAAC,UAACC,CAAC;IAAA,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,CAAC;IACzD;EAAC;IAAA;IAAA,OAED,cACED,IAAW,EACXO,KAAmB,EACb;MACN,IAAI,CAACT,SAAS,CAACU,OAAO,CAAC,UAACP,QAAQ;QAAA,OAAKA,QAAQ,CAACD,IAAI,EAAEO,KAAK,CAAC;MAAA,EAAC;MAC3D,IAAI,CAACF,iBAAiB,CAACL,IAAI,CAAC,CAACQ,OAAO,CAAC,UAACP,QAAQ;QAAA,OAAKA,QAAQ,CAACM,KAAK,CAAC;MAAA,EAAC;IACrE;EAAC;EAAA;AAAA;AAAA,eAGYV,mBAAmB;AAAA"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import SubscriptionManager from './SubscriptionManager';
|
|
2
|
-
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
-
|
|
5
|
-
class SubscribableData extends SubscriptionManager {
|
|
6
|
-
constructor(data) {
|
|
7
|
-
super();
|
|
8
|
-
this.data = void 0;
|
|
9
|
-
this.data = data;
|
|
10
|
-
}
|
|
11
|
-
get(name) {
|
|
12
|
-
return this.data[name];
|
|
13
|
-
}
|
|
14
|
-
getAll() {
|
|
15
|
-
return this.data;
|
|
16
|
-
}
|
|
17
|
-
set(name, value) {
|
|
18
|
-
this.data[name] = value;
|
|
19
|
-
this.call(name, value);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export default SubscribableData;
|
|
23
|
-
//# sourceMappingURL=SubscribableData.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SubscribableData.js","names":["SubscriptionManager","SubscribableData","constructor","data","get","name","getAll","set","value","call"],"sources":["../../src/SubscribableData.ts"],"sourcesContent":["import SubscriptionManager from './SubscriptionManager';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Data = Record<string, any>;\n\nclass SubscribableData<\n TData extends Data,\n TDataName extends keyof TData = keyof TData\n> extends SubscriptionManager<TData> {\n private data: TData;\n\n public constructor(data: TData) {\n super();\n this.data = data;\n }\n\n public get<TName extends TDataName>(name: TName): TData[TName] {\n return this.data[name];\n }\n\n public getAll(): TData {\n return this.data;\n }\n\n public set<TName extends TDataName>(name: TName, value: TData[TName]): void {\n this.data[name] = value;\n this.call(name, value);\n }\n}\n\nexport default SubscribableData;\n"],"mappings":"AAAA,OAAOA,mBAAmB,MAAM,uBAAuB;;AAEvD;;AAGA,MAAMC,gBAAgB,SAGZD,mBAAmB,CAAQ;EAG5BE,WAAW,CAACC,IAAW,EAAE;IAC9B,KAAK,EAAE;IAAC,KAHFA,IAAI;IAIV,IAAI,CAACA,IAAI,GAAGA,IAAI;EAClB;EAEOC,GAAG,CAA0BC,IAAW,EAAgB;IAC7D,OAAO,IAAI,CAACF,IAAI,CAACE,IAAI,CAAC;EACxB;EAEOC,MAAM,GAAU;IACrB,OAAO,IAAI,CAACH,IAAI;EAClB;EAEOI,GAAG,CAA0BF,IAAW,EAAEG,KAAmB,EAAQ;IAC1E,IAAI,CAACL,IAAI,CAACE,IAAI,CAAC,GAAGG,KAAK;IACvB,IAAI,CAACC,IAAI,CAACJ,IAAI,EAAEG,KAAK,CAAC;EACxB;AACF;AAEA,eAAeP,gBAAgB"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2
|
-
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
-
const deleteFromArray = (arr, item) => {
|
|
5
|
-
const index = arr.findIndex(i => i === item);
|
|
6
|
-
if (index === -1) return;
|
|
7
|
-
arr.splice(index, 1);
|
|
8
|
-
};
|
|
9
|
-
class SubscriptionManager {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.observers = void 0;
|
|
12
|
-
this.fieldObservers = void 0;
|
|
13
|
-
this.observers = [];
|
|
14
|
-
this.fieldObservers = {};
|
|
15
|
-
}
|
|
16
|
-
getFieldObservers(name) {
|
|
17
|
-
if (!this.fieldObservers[name]) {
|
|
18
|
-
this.fieldObservers[name] = [];
|
|
19
|
-
}
|
|
20
|
-
return this.fieldObservers[name];
|
|
21
|
-
}
|
|
22
|
-
subscribeToAllFields(observer) {
|
|
23
|
-
this.observers.push(observer);
|
|
24
|
-
return {
|
|
25
|
-
unsubscribe: () => this.unsubscribeFromAllFields(observer)
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
unsubscribeFromAllFields(observer) {
|
|
29
|
-
deleteFromArray(this.observers, observer);
|
|
30
|
-
}
|
|
31
|
-
subscribeToField(name, observer) {
|
|
32
|
-
this.getFieldObservers(name).push(observer);
|
|
33
|
-
return {
|
|
34
|
-
unsubscribe: () => this.unsubscribeFromField(name, observer)
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
unsubscribeFromField(name, observer) {
|
|
38
|
-
deleteFromArray(this.getFieldObservers(name), observer);
|
|
39
|
-
}
|
|
40
|
-
call(name, value) {
|
|
41
|
-
this.observers.forEach(observer => observer(name, value));
|
|
42
|
-
this.getFieldObservers(name).forEach(observer => observer(value));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export default SubscriptionManager;
|
|
46
|
-
//# sourceMappingURL=SubscriptionManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionManager.js","names":["deleteFromArray","arr","item","index","findIndex","i","splice","SubscriptionManager","constructor","observers","fieldObservers","getFieldObservers","name","subscribeToAllFields","observer","push","unsubscribe","unsubscribeFromAllFields","subscribeToField","unsubscribeFromField","call","value","forEach"],"sources":["../../src/SubscriptionManager.ts"],"sourcesContent":["export type Observer<K, V> = (name: K, value: V) => void;\nexport type FieldObserver<V> = (value: V) => void;\n\nexport interface Subscription {\n unsubscribe: () => void;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Data = Record<string, any>;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst deleteFromArray = (arr: any[], item: any) => {\n const index = arr.findIndex((i) => i === item);\n if (index === -1) return;\n arr.splice(index, 1);\n};\n\nclass SubscriptionManager<\n TData extends Data,\n TDataName extends keyof TData = keyof TData\n> {\n private observers: Array<Observer<TDataName, TData[TDataName]>>;\n\n private fieldObservers: {\n [TName in TDataName]?: Array<FieldObserver<TData[TName]>>;\n };\n\n public constructor() {\n this.observers = [];\n this.fieldObservers = {};\n }\n\n private getFieldObservers<TName extends TDataName>(\n name: TName\n ): Array<FieldObserver<TData[TName]>> {\n if (!this.fieldObservers[name]) {\n this.fieldObservers[name] = [];\n }\n return this.fieldObservers[name] as Array<FieldObserver<TData[TName]>>;\n }\n\n public subscribeToAllFields(\n observer: Observer<TDataName, TData[TDataName]>\n ): Subscription {\n this.observers.push(observer);\n return { unsubscribe: () => this.unsubscribeFromAllFields(observer) };\n }\n\n private unsubscribeFromAllFields(\n observer: Observer<TDataName, TData[TDataName]>\n ): void {\n deleteFromArray(this.observers, observer);\n }\n\n public subscribeToField<TName extends TDataName>(\n name: TName,\n observer: FieldObserver<TData[TName]>\n ): Subscription {\n this.getFieldObservers(name).push(observer);\n return { unsubscribe: () => this.unsubscribeFromField(name, observer) };\n }\n\n private unsubscribeFromField<TName extends TDataName>(\n name: TName,\n observer: FieldObserver<TData[TName]>\n ): void {\n deleteFromArray(this.getFieldObservers(name), observer);\n }\n\n protected call<TName extends TDataName>(\n name: TName,\n value: TData[TName]\n ): void {\n this.observers.forEach((observer) => observer(name, value));\n this.getFieldObservers(name).forEach((observer) => observer(value));\n }\n}\n\nexport default SubscriptionManager;\n"],"mappings":"AAOA;;AAGA;AACA,MAAMA,eAAe,GAAG,CAACC,GAAU,EAAEC,IAAS,KAAK;EACjD,MAAMC,KAAK,GAAGF,GAAG,CAACG,SAAS,CAAEC,CAAC,IAAKA,CAAC,KAAKH,IAAI,CAAC;EAC9C,IAAIC,KAAK,KAAK,CAAC,CAAC,EAAE;EAClBF,GAAG,CAACK,MAAM,CAACH,KAAK,EAAE,CAAC,CAAC;AACtB,CAAC;AAED,MAAMI,mBAAmB,CAGvB;EAO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AC,CAAC;EACrE;AACF;AAEA,eAAed,mBAAmB"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import SubscriptionManager from './SubscriptionManager';
|
|
2
|
-
type Data = Record<string, any>;
|
|
3
|
-
declare class SubscribableData<TData extends Data, TDataName extends keyof TData = keyof TData> extends SubscriptionManager<TData> {
|
|
4
|
-
private data;
|
|
5
|
-
constructor(data: TData);
|
|
6
|
-
get<TName extends TDataName>(name: TName): TData[TName];
|
|
7
|
-
getAll(): TData;
|
|
8
|
-
set<TName extends TDataName>(name: TName, value: TData[TName]): void;
|
|
9
|
-
}
|
|
10
|
-
export default SubscribableData;
|
|
11
|
-
//# sourceMappingURL=SubscribableData.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SubscribableData.d.ts","sourceRoot":"","sources":["../../src/SubscribableData.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAGxD,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEhC,cAAM,gBAAgB,CACpB,KAAK,SAAS,IAAI,EAClB,SAAS,SAAS,MAAM,KAAK,GAAG,MAAM,KAAK,CAC3C,SAAQ,mBAAmB,CAAC,KAAK,CAAC;IAClC,OAAO,CAAC,IAAI,CAAQ;gBAED,IAAI,EAAE,KAAK;IAKvB,GAAG,CAAC,KAAK,SAAS,SAAS,EAAE,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAIvD,MAAM,IAAI,KAAK;IAIf,GAAG,CAAC,KAAK,SAAS,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI;CAI5E;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type Observer<K, V> = (name: K, value: V) => void;
|
|
2
|
-
export type FieldObserver<V> = (value: V) => void;
|
|
3
|
-
export interface Subscription {
|
|
4
|
-
unsubscribe: () => void;
|
|
5
|
-
}
|
|
6
|
-
type Data = Record<string, any>;
|
|
7
|
-
declare class SubscriptionManager<TData extends Data, TDataName extends keyof TData = keyof TData> {
|
|
8
|
-
private observers;
|
|
9
|
-
private fieldObservers;
|
|
10
|
-
constructor();
|
|
11
|
-
private getFieldObservers;
|
|
12
|
-
subscribeToAllFields(observer: Observer<TDataName, TData[TDataName]>): Subscription;
|
|
13
|
-
private unsubscribeFromAllFields;
|
|
14
|
-
subscribeToField<TName extends TDataName>(name: TName, observer: FieldObserver<TData[TName]>): Subscription;
|
|
15
|
-
private unsubscribeFromField;
|
|
16
|
-
protected call<TName extends TDataName>(name: TName, value: TData[TName]): void;
|
|
17
|
-
}
|
|
18
|
-
export default SubscriptionManager;
|
|
19
|
-
//# sourceMappingURL=SubscriptionManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionManager.d.ts","sourceRoot":"","sources":["../../src/SubscriptionManager.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AACzD,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAElD,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAGD,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAShC,cAAM,mBAAmB,CACvB,KAAK,SAAS,IAAI,EAClB,SAAS,SAAS,MAAM,KAAK,GAAG,MAAM,KAAK;IAE3C,OAAO,CAAC,SAAS,CAA+C;IAEhE,OAAO,CAAC,cAAc,CAEpB;;IAOF,OAAO,CAAC,iBAAiB;IASlB,oBAAoB,CACzB,QAAQ,EAAE,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,GAC9C,YAAY;IAKf,OAAO,CAAC,wBAAwB;IAMzB,gBAAgB,CAAC,KAAK,SAAS,SAAS,EAC7C,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GACpC,YAAY;IAKf,OAAO,CAAC,oBAAoB;IAO5B,SAAS,CAAC,IAAI,CAAC,KAAK,SAAS,SAAS,EACpC,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAClB,IAAI;CAIR;AAED,eAAe,mBAAmB,CAAC"}
|