arrmatura 5.0.4 → 5.2.0

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.
Files changed (81) hide show
  1. package/commons/auth/AuthService.ts +111 -0
  2. package/commons/auth/UserService.ts +28 -78
  3. package/commons/auth/index.ts +4 -3
  4. package/commons/auth/user.xml +18 -20
  5. package/commons/components/buttons.xml +6 -4
  6. package/commons/components/layouts.xml +8 -8
  7. package/commons/components/modal.xml +4 -4
  8. package/commons/components/navigation.xml +21 -7
  9. package/commons/components/searchbar.xml +36 -22
  10. package/commons/components/table.xml +25 -5
  11. package/commons/components/toasts.xml +10 -5
  12. package/commons/forms/FormController.ts +48 -34
  13. package/commons/forms/Item.ts +93 -29
  14. package/commons/forms/ItemCollectionController.ts +113 -0
  15. package/commons/forms/ItemController.ts +50 -21
  16. package/commons/forms/NewItemController.ts +46 -0
  17. package/commons/forms/SmartareaField.xml +3 -3
  18. package/commons/forms/SuggestionField.xml +3 -3
  19. package/commons/forms/fields.xml +28 -15
  20. package/commons/forms/form.xml +3 -3
  21. package/commons/forms/index.ts +4 -4
  22. package/commons/index.ts +2 -2
  23. package/commons/services/ApiClientService.ts +32 -0
  24. package/commons/services/GSheetsService.ts +92 -64
  25. package/commons/services/Invoke.ts +24 -8
  26. package/commons/services/JsonpService.ts +1 -1
  27. package/commons/services/MetadataService.ts +50 -0
  28. package/commons/services/NavigationService.ts +20 -1
  29. package/commons/services/Service.ts +22 -28
  30. package/commons/services/Storage.ts +55 -0
  31. package/commons/services/ToastService.ts +16 -4
  32. package/commons/services/index.ts +3 -4
  33. package/core/Arrmatura.ts +4 -9
  34. package/core/CNode.ts +1 -2
  35. package/core/Component.ts +29 -31
  36. package/core/cnodes/conditionals.ts +3 -2
  37. package/core/expression.ts +1 -1
  38. package/core/register.ts +1 -1
  39. package/core/utils.ts +1 -3
  40. package/core-web/attributes.ts +38 -10
  41. package/core-web/elements.ts +22 -4
  42. package/core-web/index.ts +14 -2
  43. package/core-web/reflow.ts +3 -1
  44. package/core-web/support.ts +27 -0
  45. package/docs/index.js +350 -66
  46. package/lib/{arrayGroupBy.ts → array/arrayGroupBy.ts} +1 -1
  47. package/lib/{arraySortBy.ts → array/arraySortBy.ts} +5 -5
  48. package/lib/{arrayToObject.ts → array/arrayToObject.ts} +0 -0
  49. package/lib/array/arrayish.ts +7 -0
  50. package/lib/array/index.ts +4 -0
  51. package/lib/crypto/index.ts +25 -0
  52. package/lib/{dateFormat.ts → date/index.ts} +61 -3
  53. package/lib/func/curry.ts +11 -0
  54. package/lib/{fx.ts → func/fx.ts} +32 -38
  55. package/lib/{noop.ts → func/identity.ts} +1 -3
  56. package/lib/{nextId.ts → func/nextId.ts} +0 -0
  57. package/lib/func/noop.ts +6 -0
  58. package/lib/geo/index.js +22 -0
  59. package/lib/index.ts +17 -19
  60. package/lib/{obj.ts → object/index.ts} +8 -3
  61. package/lib/{codus.ts → parsing/codus.ts} +1 -1
  62. package/lib/{predicat.ts → parsing/compiler.ts} +0 -0
  63. package/lib/{scalar.ts → parsing/scalarParse.ts} +0 -0
  64. package/lib/{urls.ts → parsing/urls.ts} +0 -0
  65. package/lib/{xml.ts → parsing/xml.ts} +3 -3
  66. package/lib/{l10n.ts → resources/l10n.ts} +2 -2
  67. package/lib/{resources.ru.ts → resources/resources.ru.ts} +0 -0
  68. package/lib/{resources.ts → resources/resources.ts} +0 -0
  69. package/lib/{str.ts → string/index.ts} +2 -20
  70. package/lib/{createListeners.ts → support/createListeners.ts} +0 -0
  71. package/package.json +7 -6
  72. package/commons/forms/ItemCollection.ts +0 -152
  73. package/commons/forms/MetadataService.ts +0 -45
  74. package/commons/pipes/index.ts +0 -21
  75. package/commons/pipes/showCounts.ts +0 -16
  76. package/commons/services/LocalStorage.ts +0 -46
  77. package/lib/consts.ts +0 -3
  78. package/lib/curry.ts +0 -8
  79. package/lib/dateOf.ts +0 -31
  80. package/lib/dateParseISO8601.ts +0 -27
  81. package/lib/guid.ts +0 -7
@@ -1,45 +0,0 @@
1
- import { JsonpService } from '../services/JsonpService';
2
- import { LocalStorage } from '../services/LocalStorage';
3
- import { Service } from '../services/Service';
4
-
5
- export class MetadataService extends Service {
6
- local = new LocalStorage('local');
7
- url: string = '';
8
- remote = new JsonpService();
9
- version: any;
10
- resources = {};
11
- meta = { fields: [] };
12
- kind: string = '';
13
-
14
- init() {
15
- return this.syncAll();
16
- }
17
-
18
- syncAll() {
19
- const now = Date.now();
20
- const skey = '$meta_' + (this.kind || encodeURIComponent(this.url));
21
- const { version, ...meta } = this.local.get(skey) || {};
22
- if (this.version && version >= this.version) {
23
- Object.assign(this.resources, meta, { strings: { ...this.resources.strings, ...meta.strings } });
24
- return { ready: true, meta };
25
- }
26
- return {
27
- ready: false,
28
- '*': fetch(this.url, { redirect: 'follow' })
29
- .then((res) => res.json())
30
- .then(
31
- (meta) => {
32
- this.log('metadata ', now, meta);
33
- // this.toast('metadata loaded');
34
- Object.assign(this.resources, meta, { strings: { ...this.resources.strings, ...meta.strings } });
35
- this.local.set(skey, meta);
36
- return { ready: true, meta };
37
- },
38
- (err) => {
39
- this.toast('error: metadata ' + JSON.stringify(err?.message || err || 'unknown'));
40
- return { ready: true, meta: {} };
41
- }
42
- ),
43
- };
44
- }
45
- }
@@ -1,21 +0,0 @@
1
- import * as libs from '../../lib';
2
- import { dateFormat, dateOf, urlParse } from '../../lib';
3
- import { showCounts } from './showCounts';
4
-
5
- // useful pipes
6
- export const pipes: Hash<Pipe> = {
7
- ...libs,
8
-
9
- queryParam: (_, key: string) => urlParse(window.location.search).params[key],
10
- queryParams: (_) => urlParse(window.location.search).params,
11
- date: (x) => dateFormat(dateOf(x)),
12
- rest: (x, pos = 1) => (x ? x.slice(pos) : []),
13
- findByKey: (x, key, val) => x?.find?.((e: Hash) => e[key] == val),
14
- filterByKey: (x, key, val) => x?.filter?.((e: Hash) => !e[key] || e[key] == val),
15
- resolve: (x, id, key) => x?.find?.((e: Hash) => e.id == id)?.[key],
16
- limit: (x, size = 50) => (x ? x.slice(0, size) : []),
17
- ifAbove: (x, limit = 0) => (+x > +limit ? x : ''),
18
- showCounts,
19
- };
20
-
21
- export default pipes;
@@ -1,16 +0,0 @@
1
- export const showCounts = (counts: Obj, nicNema = '⭕', neZnojdzeno = '⭕') => {
2
- if (!counts) {
3
- return '…';
4
- }
5
- const { total, actual } = counts;
6
- if (!total) {
7
- return nicNema;
8
- }
9
- if (!actual) {
10
- return neZnojdzeno;
11
- }
12
- if (actual === total) {
13
- return total;
14
- }
15
- return actual + ' / ' + total;
16
- };
@@ -1,46 +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
- getItem(key: string) {
7
- return this.map.get(key) || null;
8
- }
9
-
10
- setItem(key: string, value: string): void {
11
- this.map.set(key, value);
12
- }
13
- removeItem(key: string): void {
14
- this.map.delete(key);
15
- }
16
- }
17
-
18
- export class LocalStorage {
19
- cache: Hash = {};
20
- storage: MemoryStore | Storage;
21
-
22
- constructor(mode?: 'local' | 'transient') {
23
- this.storage = mode === 'local' ? window.localStorage : new MemoryStore();
24
- }
25
-
26
- get(key: string) {
27
- return this.cache[key] || (this.cache[key] = parse(this.storage.getItem(key)));
28
- }
29
-
30
- set(key: string, val: unknown) {
31
- this.cache[key] = val;
32
- if (val) {
33
- this.storage.setItem(key, JSON.stringify(val));
34
- } else {
35
- this.storage.removeItem(key);
36
- }
37
- }
38
-
39
- assign(delta: Delta) {
40
- Object.entries(delta).forEach(([key, val = null]) => this.set(key, val));
41
- }
42
-
43
- transform(key: string, fn: Pipe) {
44
- return this.set(key, fn(this.get(key)));
45
- }
46
- }
package/lib/consts.ts DELETED
@@ -1,3 +0,0 @@
1
- export const EMPTY_OBJECT = Object.freeze({});
2
-
3
- export const ARRAY_EMPTY = Object.freeze([]);
package/lib/curry.ts DELETED
@@ -1,8 +0,0 @@
1
- const _curry = <S>(fn: (...args: unknown[]) => S, args0: unknown[], lengthLimit: number): (() => S) => {
2
- const fx = (args: unknown[]) =>
3
- args.length >= lengthLimit ? fn(...args) : _curry(fn, args, lengthLimit - args.length);
4
-
5
- return (...args: unknown[]) => fx([...args0, ...args]);
6
- };
7
-
8
- export const curry = <S>(fn: () => S, ...args: S[]): S | (() => S) => _curry<S>(fn, args, fn.length);
package/lib/dateOf.ts DELETED
@@ -1,31 +0,0 @@
1
- import { dateParseISO8601 } from 'dateParseISO8601';
2
-
3
- /**
4
- * Universal converter to Date.
5
- *
6
- * @returns Date instance or null
7
- */
8
- export function dateOf(x: Dateable | null): Date | null {
9
- if (x == null) {
10
- return null;
11
- }
12
- if (typeof x === 'number') {
13
- return new Date(x);
14
- }
15
- if (typeof x === 'object') {
16
- // Date or has time
17
- const dx = x as { getTime?: () => number };
18
- if (dx.getTime) {
19
- return new Date(dx.getTime());
20
- }
21
- // having a date representation
22
- const ddx = x as { toDate?: () => Date };
23
- if (ddx.toDate) {
24
- return ddx.toDate();
25
- }
26
- }
27
- if (typeof x === 'string') {
28
- return dateParseISO8601(x);
29
- }
30
- return null;
31
- }
@@ -1,27 +0,0 @@
1
- export const dateParseISO8601 = function (x: string, TZ = new Date().getTimezoneOffset()) {
2
- if (!x) {
3
- return null;
4
- }
5
- if (x.length === 10) {
6
- x += 'T12:00';
7
- }
8
- const timebits =
9
- /^([0-9]{4})-([0-9]{2})-([0-9]{2})[ T]([0-9]{2}):([0-9]{2})(?::([0-9]*)(\.[0-9]*)?)?(Z?)(([+-])([0-9]{2})([0-9]{2}))?/;
10
- const m = timebits.exec(x);
11
- if (!m) {
12
- return null;
13
- }
14
- const tz = m[8] ? (!m[9] ? 0 : (m[10] === '+' ? -1 : +1) * (parseInt(m[11]) * 60 + parseInt(m[12]))) : TZ;
15
- // utcdate is milliseconds since the epoch
16
- const utcdate = Date.UTC(
17
- parseInt(m[1]),
18
- parseInt(m[2]) - 1, // months are zero-offset (!)
19
- parseInt(m[3]),
20
- parseInt(m[4]),
21
- parseInt(m[5]), // hh:mm
22
- (m[6] && parseInt(m[6])) || 0, // optional seconds
23
- (m[7] && parseFloat(m[7])) || 0
24
- );
25
-
26
- return new Date(utcdate + tz * 60000);
27
- };
package/lib/guid.ts DELETED
@@ -1,7 +0,0 @@
1
- /* Simple GUID generator. */
2
- const s4 = (): string =>
3
- Math.floor((1 + Math.random()) * 0x10000)
4
- .toString(16)
5
- .substring(1);
6
-
7
- export const guid = (): string => `${s4()}${s4()}-${s4()}-${s4()}-${s4()}-${s4()}${s4()}${s4()}`;