arrmatura 5.2.0 → 6.2.1
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/index.ts +20 -0
- package/package.json +14 -44
- package/src/core/composition.ts +71 -0
- package/src/core/conditionals.ts +80 -0
- package/src/core/elementary.ts +40 -0
- package/src/core/fragment.ts +21 -0
- package/src/core/index.ts +19 -0
- package/src/core/iterations.ts +121 -0
- package/src/core/root.ts +46 -0
- package/src/core/routing.ts +37 -0
- package/src/core/selection.ts +57 -0
- package/src/core/slot.ts +36 -0
- package/src/ctx/Ctx.ts +424 -0
- package/src/ctx/CtxNode.ts +159 -0
- package/src/utils/compileExpression.ts +126 -0
- package/src/utils/stringify.ts +39 -0
- package/LICENSE +0 -21
- package/README.md +0 -54
- package/commons/auth/AuthService.ts +0 -111
- package/commons/auth/UserService.ts +0 -57
- package/commons/auth/index.ts +0 -5
- package/commons/auth/user.xml +0 -64
- package/commons/components/buttons.xml +0 -25
- package/commons/components/index.ts +0 -13
- package/commons/components/inputs.xml +0 -33
- package/commons/components/layouts.xml +0 -77
- package/commons/components/media.xml +0 -21
- package/commons/components/modal.xml +0 -37
- package/commons/components/navigation.xml +0 -73
- package/commons/components/popups.xml +0 -12
- package/commons/components/searchbar.xml +0 -54
- package/commons/components/table.xml +0 -140
- package/commons/components/toasts.xml +0 -18
- package/commons/components/viewport.xml +0 -48
- package/commons/forms/FieldItem.xml +0 -20
- package/commons/forms/FormController.ts +0 -87
- package/commons/forms/Item.ts +0 -132
- package/commons/forms/ItemCollectionController.ts +0 -113
- package/commons/forms/ItemController.ts +0 -91
- package/commons/forms/MultiEnumField.xml +0 -44
- package/commons/forms/MultivalueController.ts +0 -49
- package/commons/forms/NewItemController.ts +0 -46
- package/commons/forms/SmartareaField.xml +0 -51
- package/commons/forms/SuggestionController.ts +0 -80
- package/commons/forms/SuggestionField.xml +0 -28
- package/commons/forms/fields.xml +0 -151
- package/commons/forms/form.xml +0 -37
- package/commons/forms/index.ts +0 -29
- package/commons/index.ts +0 -6
- package/commons/services/ApiClientService.ts +0 -32
- package/commons/services/ErrorHandlingService.ts +0 -11
- package/commons/services/FirebaseService.ts +0 -185
- package/commons/services/GSheetsService.ts +0 -120
- package/commons/services/HeartbeatService.ts +0 -35
- package/commons/services/Invoke.ts +0 -29
- package/commons/services/JsonpService.ts +0 -18
- package/commons/services/Loader.ts +0 -17
- package/commons/services/MetadataService.ts +0 -50
- package/commons/services/NavigationService.ts +0 -74
- package/commons/services/Service.ts +0 -62
- package/commons/services/ServiceWorker.ts +0 -111
- package/commons/services/Storage.ts +0 -55
- package/commons/services/ToastService.ts +0 -61
- package/commons/services/index.ts +0 -13
- package/core/Arrmatura.ts +0 -79
- package/core/CNode.ts +0 -111
- package/core/Component.ts +0 -424
- package/core/cnodes/composition.ts +0 -100
- package/core/cnodes/conditionals.ts +0 -52
- package/core/cnodes/elementary.ts +0 -44
- package/core/cnodes/iterations.ts +0 -92
- package/core/cnodes/routing.ts +0 -25
- package/core/compileNode.ts +0 -39
- package/core/expression.ts +0 -73
- package/core/index.ts +0 -1
- package/core/register.ts +0 -43
- package/core/utils.ts +0 -23
- package/core-web/WebPlatform.ts +0 -25
- package/core-web/attributes.ts +0 -218
- package/core-web/elements.ts +0 -81
- package/core-web/index.ts +0 -28
- package/core-web/reflow.ts +0 -30
- package/core-web/support.ts +0 -27
- package/core-web/type.ts +0 -18
- package/docs/index.js +0 -485
- package/lib/array/arrayGroupBy.ts +0 -19
- package/lib/array/arraySortBy.ts +0 -49
- package/lib/array/arrayToObject.ts +0 -18
- package/lib/array/arrayish.ts +0 -7
- package/lib/array/index.ts +0 -4
- package/lib/crypto/index.ts +0 -25
- package/lib/date/index.ts +0 -127
- package/lib/func/curry.ts +0 -11
- package/lib/func/fx.ts +0 -56
- package/lib/func/identity.ts +0 -6
- package/lib/func/nextId.ts +0 -9
- package/lib/func/noop.ts +0 -6
- package/lib/geo/index.js +0 -22
- package/lib/index.ts +0 -17
- package/lib/object/index.ts +0 -69
- package/lib/parsing/codus.ts +0 -25
- package/lib/parsing/compiler.ts +0 -26
- package/lib/parsing/scalarParse.ts +0 -25
- package/lib/parsing/urls.ts +0 -91
- package/lib/parsing/xml.ts +0 -117
- package/lib/resources/l10n.ts +0 -40
- package/lib/resources/resources.ru.ts +0 -20
- package/lib/resources/resources.ts +0 -20
- package/lib/string/index.ts +0 -58
- package/lib/support/createListeners.ts +0 -12
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const parse = (s: string | null) => (s ? JSON.parse(s) : undefined);
|
|
2
|
-
|
|
3
|
-
class MemoryStore {
|
|
4
|
-
#map = new Map<string, string>();
|
|
5
|
-
|
|
6
|
-
clear() {
|
|
7
|
-
return this.#map.clear();
|
|
8
|
-
}
|
|
9
|
-
getItem(key: string) {
|
|
10
|
-
return this.#map.get(key) || null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
setItem(key: string, value: string): void {
|
|
14
|
-
this.#map.set(key, value);
|
|
15
|
-
}
|
|
16
|
-
removeItem(key: string): void {
|
|
17
|
-
this.#map.delete(key);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export class Storage {
|
|
22
|
-
cache: Hash = {};
|
|
23
|
-
storage: Omit<MemoryStore, 'prototype'>;
|
|
24
|
-
|
|
25
|
-
constructor(mode?: 'local' | 'transient' | 'session', readonly ns = '') {
|
|
26
|
-
this.storage =
|
|
27
|
-
mode === 'local' ? window.localStorage : mode === 'session' ? window.sessionStorage : new MemoryStore();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
clear() {
|
|
31
|
-
this.cache = {};
|
|
32
|
-
return this.storage.clear();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
get(key: string) {
|
|
36
|
-
return this.cache[key] || (this.cache[key] = parse(this.storage.getItem(key + this.ns)));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
set(key: string, val: unknown) {
|
|
40
|
-
this.cache[key] = val;
|
|
41
|
-
if (val) {
|
|
42
|
-
this.storage.setItem(key + this.ns, JSON.stringify(val));
|
|
43
|
-
} else {
|
|
44
|
-
this.storage.removeItem(key + this.ns);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
assign(delta: Delta) {
|
|
49
|
-
Object.entries(delta).forEach(([key, val = null]) => this.set(key, val));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
transform(key: string, fn: Pipe) {
|
|
53
|
-
return this.set(key, fn(this.get(key)));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { HeartbeatService } from './HeartbeatService';
|
|
2
|
-
import { Service } from './Service';
|
|
3
|
-
|
|
4
|
-
export type Toast = {
|
|
5
|
-
message: string;
|
|
6
|
-
link?: string;
|
|
7
|
-
mode: 'error' | 'warning' | 'info' | '';
|
|
8
|
-
id: string;
|
|
9
|
-
ttl: number;
|
|
10
|
-
timeout?: number;
|
|
11
|
-
counter?: number;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export class ToastSender extends Service {
|
|
15
|
-
onData(data: Delta) {
|
|
16
|
-
this.emit('toaster.send', data);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export class ToastService extends Service {
|
|
21
|
-
items: Toast[] = [];
|
|
22
|
-
|
|
23
|
-
heartbeat = new HeartbeatService(() => this.emit('this.tick', {}));
|
|
24
|
-
|
|
25
|
-
setItems(items: Toast[]) {
|
|
26
|
-
this.heartbeat.setActive(!!items.length);
|
|
27
|
-
this.items = items;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
onSend(data: Toast, { items }: this) {
|
|
31
|
-
const now = Date.now();
|
|
32
|
-
const id = String(data.id || now);
|
|
33
|
-
const close = () => this.emit('this.close', { id });
|
|
34
|
-
const toast = {
|
|
35
|
-
...data,
|
|
36
|
-
mode: data?.message?.startsWith('error') ? 'error' : data.mode,
|
|
37
|
-
id,
|
|
38
|
-
close,
|
|
39
|
-
ttl: now + (data.timeout || 6000),
|
|
40
|
-
};
|
|
41
|
-
const prev = items.find((e) => e.id === id);
|
|
42
|
-
if (prev) {
|
|
43
|
-
toast.counter = 1 + (prev.counter || 1);
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
items: [toast, ...items.filter((e) => e !== prev)],
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
onTick(_: unknown, { items }: this) {
|
|
51
|
-
const now = Date.now();
|
|
52
|
-
|
|
53
|
-
return { items: items.filter((e: Toast) => e.ttl > now) };
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
onClose({ id }: Datum, { items }: this) {
|
|
57
|
-
return {
|
|
58
|
-
items: items.filter((e) => e.id !== id),
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export { NavigationService } from './NavigationService';
|
|
2
|
-
export { ServiceWorker } from './ServiceWorker';
|
|
3
|
-
export { Service } from './Service';
|
|
4
|
-
export { ToastService } from './ToastService';
|
|
5
|
-
export { Loader } from './Loader';
|
|
6
|
-
export { Invoke } from './Invoke';
|
|
7
|
-
export { ErrorHandlingService } from './ErrorHandlingService';
|
|
8
|
-
export { FormController } from '../forms/FormController';
|
|
9
|
-
export * from './MetadataService';
|
|
10
|
-
export * from './GSheetsService';
|
|
11
|
-
export * from './ApiClientService';
|
|
12
|
-
export * from './FirebaseService';
|
|
13
|
-
export * from './MetadataService';
|
package/core/Arrmatura.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { CNode } from './CNode';
|
|
2
|
-
import { compileNodes } from './compileNode';
|
|
3
|
-
import { Component } from './Component';
|
|
4
|
-
import { xmlParse } from '../lib/parsing/xml';
|
|
5
|
-
import { registerTypes } from './register';
|
|
6
|
-
|
|
7
|
-
export class Arrmatura extends Component<CArrmaturaNode> implements IArrmatura {
|
|
8
|
-
rootElement: any;
|
|
9
|
-
reflowId?: unknown;
|
|
10
|
-
|
|
11
|
-
get displayName(): string {
|
|
12
|
-
return 'Arrmatura';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
get platform(): IPlatform {
|
|
16
|
-
return this.node.platform;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
requestReflow() {
|
|
20
|
-
if (this.reflowId) return;
|
|
21
|
-
this.reflowId = setTimeout(() => {
|
|
22
|
-
this.platform.reflow(this);
|
|
23
|
-
this.reflowId = undefined;
|
|
24
|
-
}, 10);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
res(key: string): any {
|
|
28
|
-
const [id, ...deep] = key.split('.');
|
|
29
|
-
const { resources = {} } = this.node;
|
|
30
|
-
const target = id ? resources?.[id] : resources;
|
|
31
|
-
if (!target || deep.length === 0) {
|
|
32
|
-
return target;
|
|
33
|
-
}
|
|
34
|
-
if (deep.length === 1) {
|
|
35
|
-
return target[deep[0]];
|
|
36
|
-
}
|
|
37
|
-
return deep.reduce((r, k) => (r ? r[k] : null), target);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
pipe(key: string) {
|
|
41
|
-
const [id, ...deep] = key.split('.');
|
|
42
|
-
const target = this.node.functions?.[id];
|
|
43
|
-
if (!target || deep.length === 0) {
|
|
44
|
-
return target;
|
|
45
|
-
}
|
|
46
|
-
if (deep.length === 1) {
|
|
47
|
-
return (target as Hash)[deep[0]];
|
|
48
|
-
}
|
|
49
|
-
return deep.reduce((r, k) => (r ? (r as Hash)[k] : null), target);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export class CArrmaturaNode extends CNode<Arrmatura> {
|
|
54
|
-
functions?: Hash;
|
|
55
|
-
resources: Hash<any> | undefined;
|
|
56
|
-
platform: IPlatform;
|
|
57
|
-
|
|
58
|
-
constructor(template: string, { types, functions, resources }: ArrmaturaOptions, platform: IPlatform) {
|
|
59
|
-
super();
|
|
60
|
-
|
|
61
|
-
registerTypes(types);
|
|
62
|
-
|
|
63
|
-
this.functions = functions;
|
|
64
|
-
this.resources = resources;
|
|
65
|
-
this.platform = platform;
|
|
66
|
-
|
|
67
|
-
this.content = compileNodes(xmlParse(template));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
get ComponentConstructor() {
|
|
71
|
-
return Arrmatura;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
launch(config = {}) {
|
|
75
|
-
const arrmatura = this.createComponent();
|
|
76
|
-
|
|
77
|
-
arrmatura.up(config, true);
|
|
78
|
-
}
|
|
79
|
-
}
|
package/core/CNode.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { nextId, identity } from '../lib';
|
|
2
|
-
import { Component } from './Component';
|
|
3
|
-
import { compileExpression, compilePipeExpression } from './expression';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Design-time Component class.
|
|
7
|
-
*/
|
|
8
|
-
export abstract class CNode<T extends Component = Component> implements INode<T> {
|
|
9
|
-
content?: ComponentContent;
|
|
10
|
-
uid: Uid = nextId('N');
|
|
11
|
-
refId?: string;
|
|
12
|
-
private propertyResolvers: Array<PropertyResolver> = [];
|
|
13
|
-
private initialState?: Hash;
|
|
14
|
-
initializers: Array<(c: IComponent) => undefined | ComponentSubsription> = [];
|
|
15
|
-
tag: any;
|
|
16
|
-
|
|
17
|
-
abstract get ComponentConstructor(): new (node: INode<T>, parent?: IComponent, scope?: IScope) => T;
|
|
18
|
-
|
|
19
|
-
createComponent(parent?: IComponent, scope?: Component): T {
|
|
20
|
-
return new this.ComponentConstructor(this as INode<T>, parent, scope);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
addInitialState(values: Hash) {
|
|
24
|
-
this.initialState = Object.entries(values).reduce((acc, [key, val]) => {
|
|
25
|
-
acc[key] = val;
|
|
26
|
-
return acc;
|
|
27
|
-
}, this.initialState || {});
|
|
28
|
-
return this;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
addPropertyResolver(getter: PropertyGetter, propKey: string) {
|
|
32
|
-
this.propertyResolvers.push((c: IComponent, delta: Delta) => {
|
|
33
|
-
delta[propKey] = getter(c);
|
|
34
|
-
return delta;
|
|
35
|
-
});
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
addPropertiesResolver(getter: PropertyGetter) {
|
|
40
|
-
this.propertyResolvers.push((c: IComponent, delta: Delta) => {
|
|
41
|
-
const value = getter(c);
|
|
42
|
-
if (value && typeof value === 'object') {
|
|
43
|
-
Object.entries(value).forEach(([key, val]) => {
|
|
44
|
-
delta[key] = val;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
return delta;
|
|
48
|
-
});
|
|
49
|
-
return this;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
addPropertyConnector(expr: Expression, getter: (x: unknown) => unknown) {
|
|
53
|
-
const { key, pipec } = compilePipeExpression(expr);
|
|
54
|
-
this.initializers.push((c: IComponent) => c.connect(key, (rr: unknown) => getter(pipec(c, rr))));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
addEmitter(expr: Expression, k: PropertyKey) {
|
|
58
|
-
const { key, pipec } = compilePipeExpression(expr);
|
|
59
|
-
this.initializers.push((c) => ({
|
|
60
|
-
payload: { [k]: (data: unknown) => c.$scope?.emit(key, pipec(c, data) as Delta) },
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
resolveInitialProps(c: IComponent) {
|
|
65
|
-
return this.resolveProps(c, { ...this.initialState });
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
resolveProps(c: IComponent, props: Delta = {}) {
|
|
69
|
-
return this.propertyResolvers.reduce((delta, resolver) => resolver(c, delta), props);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
compileAttribute(k: string, v: unknown) {
|
|
73
|
-
if (k === 'id') {
|
|
74
|
-
this.addInitialState({ [k]: v });
|
|
75
|
-
} else if (k.startsWith('ui:')) {
|
|
76
|
-
const sv = String(v);
|
|
77
|
-
if (k === 'ui:ref') {
|
|
78
|
-
this.refId = sv;
|
|
79
|
-
} else if (k === 'ui:props') {
|
|
80
|
-
if (sv[0] === '<' && sv[1] === '-') {
|
|
81
|
-
this.addPropertyConnector(sv.slice(2), identity);
|
|
82
|
-
} else {
|
|
83
|
-
this.addPropertiesResolver(compileExpression(v));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
if (typeof v !== 'string') {
|
|
88
|
-
this.addInitialState({ [k]: v });
|
|
89
|
-
} else {
|
|
90
|
-
if (v[0] === '<' && v[1] === '-') {
|
|
91
|
-
this.addPropertyConnector(v.slice(2), (rr) => ({ [k]: rr }));
|
|
92
|
-
} else if (v[0] === '-' && v[1] === '>') {
|
|
93
|
-
this.addEmitter(v.slice(2), k);
|
|
94
|
-
} else {
|
|
95
|
-
if (!v.includes('{') && v[0] !== ':') {
|
|
96
|
-
this.addInitialState({ [k]: v });
|
|
97
|
-
} else {
|
|
98
|
-
this.addPropertyResolver(compileExpression(v), k);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return this;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
compileAttributes(attrs?: Hash) {
|
|
107
|
-
if (attrs) {
|
|
108
|
-
Object.entries(attrs).forEach((keyValue) => this.compileAttribute(...keyValue));
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|